diff --git a/src/components/Modal/Tracker/ModalTicket/ModalTicket.jsx b/src/components/Modal/Tracker/ModalTicket/ModalTicket.jsx index 205c157b..88977841 100644 --- a/src/components/Modal/Tracker/ModalTicket/ModalTicket.jsx +++ b/src/components/Modal/Tracker/ModalTicket/ModalTicket.jsx @@ -79,7 +79,7 @@ export const ModalTiсket = ({ const [users, setUsers] = useState([]); const [timerStart, setTimerStart] = useState(false); const [timerInfo, setTimerInfo] = useState({}); - const [uploadedFile, setUploadedFile] = useState(null); + // const [uploadedFile, setUploadedFile] = useState(null); const [currentTimerCount, setCurrentTimerCount] = useState({ hours: 0, minute: 0, @@ -378,25 +378,26 @@ export const ModalTiсket = ({ const data = await res.json(); - setUploadedFile(data); + // setUploadedFile(data); + attachFile(data[0].id) } - function deleteLoadedFile() { - setUploadedFile(null); - } + // function deleteLoadedFile() { + // setUploadedFile(null); + // } - function attachFile() { + function attachFile(id) { apiRequest("/file/attach", { method: "POST", data: { - file_id: uploadedFile[0].id, + file_id: id, entity_type: 2, entity_id: task.id, status: 1, }, }).then((res) => { setTaskFiles((prevValue) => [...prevValue, res]); - setUploadedFile(null); + // setUploadedFile(null); }); } @@ -635,24 +636,24 @@ export const ModalTiсket = ({ })} )} - {uploadedFile && ( -
- {uploadedFile.map((file) => { - return ( -
- img -
deleteLoadedFile(file)} - > - delete -
-
- ); - })} - -
- )} + {/*{uploadedFile && (*/} + {/*
*/} + {/* {uploadedFile.map((file) => {*/} + {/* return (*/} + {/*
*/} + {/* img*/} + {/* deleteLoadedFile(file)}*/} + {/* >*/} + {/* delete*/} + {/*
*/} + {/*
*/} + {/* );*/} + {/* })}*/} + {/* */} + {/* */} + {/*)}*/}
{/*

*/} {/* { setUploadedFile(null); } + // function deleteFile(file) { + // apiRequest("/file/detach", { + // method: "DELETE", + // data: { + // file_id: file.id, + // entity_type: 2, + // entity_id: taskInfo.id, + // status: 0, + // }, + // }).then(() => { + // setTaskFiles((prevValue) => + // prevValue.filter((item) => item.id !== file.id) + // ); + // }); + // } + function deleteFile(file) { - apiRequest("/file/detach", { - method: "DELETE", - data: { - file_id: file.id, - entity_type: 2, - entity_id: taskInfo.id, - status: 0, - }, - }).then(() => { - setTaskFiles((prevValue) => + setTaskFiles((prevValue) => prevValue.filter((item) => item.id !== file.id) - ); - }); + ); } function closeAcceptModal() { @@ -800,19 +807,12 @@ export const TicketFullScreen = () => {

{taskFiles.map((file) => { return ( -
- img -
deleteFile(file)} - > - delete -
-
); })}