From 44725b014ba989d6648139205765e0eb59147170 Mon Sep 17 00:00:00 2001 From: Mikola Date: Sun, 19 Nov 2023 19:04:42 +0300 Subject: [PATCH] task files --- .../Modal/Tracker/ModalTicket/ModalTicket.jsx | 53 ++++++++++--------- .../Tracker/ModalTicket/modalTicket.scss | 16 ------ .../TicketFullScreen/TicketFullScreen.jsx | 48 ++++++++--------- 3 files changed, 51 insertions(+), 66 deletions(-) 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 -
-
); })}