file
This commit is contained in:
parent
2090677b3d
commit
c308e0fd58
@ -68,9 +68,9 @@ export const ModalTiсket = ({
|
|||||||
const [executor, setExecutor] = useState(task.executor);
|
const [executor, setExecutor] = useState(task.executor);
|
||||||
const [members, setMembers] = useState(task.taskUsers);
|
const [members, setMembers] = useState(task.taskUsers);
|
||||||
const [users, setUsers] = useState([]);
|
const [users, setUsers] = useState([]);
|
||||||
const [selectedFile, setSelectedFile] = useState("");
|
|
||||||
const [timerStart, setTimerStart] = useState(false);
|
const [timerStart, setTimerStart] = useState(false);
|
||||||
const [timerInfo, setTimerInfo] = useState({});
|
const [timerInfo, setTimerInfo] = useState({});
|
||||||
|
const [uploadedFile, setUploadedFile] = useState(null)
|
||||||
const [currentTimerCount, setCurrentTimerCount] = useState({
|
const [currentTimerCount, setCurrentTimerCount] = useState({
|
||||||
hours: 0,
|
hours: 0,
|
||||||
minute: 0,
|
minute: 0,
|
||||||
@ -308,31 +308,18 @@ export const ModalTiсket = ({
|
|||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
function handleChange(event) {
|
async function handleUpload(event) {
|
||||||
setSelectedFile(event.target.files[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function handleUpload() {
|
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append("uploadFile", selectedFile);
|
formData.append("uploadFile", event.target.files[0]);
|
||||||
const headers = {
|
|
||||||
"Access-Control-Allow-Origin": "*",
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
};
|
|
||||||
const fullHeaders = { ...headers, ...getToken() };
|
|
||||||
const res = await fetch("https://itguild.info/api/file/upload", {
|
const res = await fetch("https://itguild.info/api/file/upload", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: formData,
|
body: formData,
|
||||||
headers: { ...fullHeaders },
|
headers: { ...getToken() },
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(fullHeaders);
|
const data = await res.json()
|
||||||
console.log(res);
|
|
||||||
// apiRequest('/file/upload', {
|
setUploadedFile(data)
|
||||||
// method: 'POST',
|
|
||||||
// body: formData
|
|
||||||
// }).then((res) => {
|
|
||||||
// })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function startTimer() {
|
function startTimer() {
|
||||||
@ -468,6 +455,14 @@ export const ModalTiсket = ({
|
|||||||
)}
|
)}
|
||||||
{/*<img src={taskImg} className="image-task"></img>*/}
|
{/*<img src={taskImg} className="image-task"></img>*/}
|
||||||
</div>
|
</div>
|
||||||
|
{uploadedFile &&
|
||||||
|
<div className='fileLoaded'>
|
||||||
|
{uploadedFile.map((file) => {
|
||||||
|
return <img src={urlForLocal(file.url)} alt='img' key={file.id}/>
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
<div className="content__communication">
|
<div className="content__communication">
|
||||||
{/*<p className="tasks">*/}
|
{/*<p className="tasks">*/}
|
||||||
{/* <button*/}
|
{/* <button*/}
|
||||||
@ -488,14 +483,13 @@ export const ModalTiсket = ({
|
|||||||
type="file"
|
type="file"
|
||||||
accept="image/*,.png,.jpg,.svg,.jpeg"
|
accept="image/*,.png,.jpg,.svg,.jpeg"
|
||||||
className="input__file"
|
className="input__file"
|
||||||
onChange={handleChange}
|
onChange={handleUpload}
|
||||||
/>
|
/>
|
||||||
<label htmlFor="input__file" className="button-add-file">
|
<label htmlFor="input__file" className="button-add-file">
|
||||||
<img src={file}></img>
|
<img src={file}></img>
|
||||||
Загрузить файл
|
Загрузить файл
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<p onClick={handleUpload}>Отправить</p>
|
|
||||||
<span>{0}</span>
|
<span>{0}</span>
|
||||||
{caseOfNum(0, "files")}
|
{caseOfNum(0, "files")}
|
||||||
</div>
|
</div>
|
||||||
|
@ -315,6 +315,16 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.fileLoaded {
|
||||||
|
display: flex;
|
||||||
|
margin: 10px 0 0;
|
||||||
|
|
||||||
|
img {
|
||||||
|
max-width: 250px;
|
||||||
|
object-fit: contain;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&__communication {
|
&__communication {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
|
Loading…
Reference in New Issue
Block a user