task files

This commit is contained in:
Mikola 2023-11-19 19:04:42 +03:00
parent 3f5f221702
commit 44725b014b
3 changed files with 51 additions and 66 deletions

View File

@ -79,7 +79,7 @@ export const ModalTiсket = ({
const [users, setUsers] = useState([]); const [users, setUsers] = 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 [uploadedFile, setUploadedFile] = useState(null);
const [currentTimerCount, setCurrentTimerCount] = useState({ const [currentTimerCount, setCurrentTimerCount] = useState({
hours: 0, hours: 0,
minute: 0, minute: 0,
@ -378,25 +378,26 @@ export const ModalTiсket = ({
const data = await res.json(); const data = await res.json();
setUploadedFile(data); // setUploadedFile(data);
attachFile(data[0].id)
} }
function deleteLoadedFile() { // function deleteLoadedFile() {
setUploadedFile(null); // setUploadedFile(null);
} // }
function attachFile() { function attachFile(id) {
apiRequest("/file/attach", { apiRequest("/file/attach", {
method: "POST", method: "POST",
data: { data: {
file_id: uploadedFile[0].id, file_id: id,
entity_type: 2, entity_type: 2,
entity_id: task.id, entity_id: task.id,
status: 1, status: 1,
}, },
}).then((res) => { }).then((res) => {
setTaskFiles((prevValue) => [...prevValue, res]); setTaskFiles((prevValue) => [...prevValue, res]);
setUploadedFile(null); // setUploadedFile(null);
}); });
} }
@ -635,24 +636,24 @@ export const ModalTiсket = ({
})} })}
</div> </div>
)} )}
{uploadedFile && ( {/*{uploadedFile && (*/}
<div className="fileLoaded"> {/* <div className="fileLoaded">*/}
{uploadedFile.map((file) => { {/* {uploadedFile.map((file) => {*/}
return ( {/* return (*/}
<div className="loadedFile" key={file.id}> {/* <div className="loadedFile" key={file.id}>*/}
<img src={backendImg(file.url)} alt="img" key={file.id} /> {/* <img src={backendImg(file.url)} alt="img" key={file.id} />*/}
<div {/* <div*/}
className="deleteFile" {/* className="deleteFile"*/}
onClick={() => deleteLoadedFile(file)} {/* onClick={() => deleteLoadedFile(file)}*/}
> {/* >*/}
<img src={close} alt="delete" /> {/* <img src={close} alt="delete" />*/}
</div> {/* </div>*/}
</div> {/* </div>*/}
); {/* );*/}
})} {/* })}*/}
<button onClick={attachFile}>Загрузить</button> {/* <button onClick={attachFile}>Загрузить</button>*/}
</div> {/* </div>*/}
)} {/*)}*/}
<div className="content__communication"> <div className="content__communication">
{/*<p className="tasks">*/} {/*<p className="tasks">*/}
{/* <button*/} {/* <button*/}

View File

@ -359,24 +359,8 @@
column-gap: 25px; column-gap: 25px;
row-gap: 20px; row-gap: 20px;
margin-top: 33px; margin-top: 33px;
max-height: 170px;
overflow-y: auto; overflow-y: auto;
&::-webkit-scrollbar {
width: 5px;
border-radius: 10px;
}
&::-webkit-scrollbar-thumb {
background: #cbd9f9;
border-radius: 20px;
}
&::-webkit-scrollbar-track {
background: #c5c0c6;
border-radius: 20px;
}
.taskFile { .taskFile {
cursor: pointer; cursor: pointer;
position: relative; position: relative;

View File

@ -35,6 +35,7 @@ import { Navigation } from "@components/Navigation/Navigation";
import { ProfileBreadcrumbs } from "@components/ProfileBreadcrumbs/ProfileBreadcrumbs"; import { ProfileBreadcrumbs } from "@components/ProfileBreadcrumbs/ProfileBreadcrumbs";
import { ProfileHeader } from "@components/ProfileHeader/ProfileHeader"; import { ProfileHeader } from "@components/ProfileHeader/ProfileHeader";
import TrackerTaskComment from "@components/TrackerTaskComment/TrackerTaskComment"; import TrackerTaskComment from "@components/TrackerTaskComment/TrackerTaskComment";
import FileTracker from "@components/FileTracker/FileTracker";
import arrow from "assets/icons/arrows/arrowCalendar.png"; import arrow from "assets/icons/arrows/arrowCalendar.png";
import arrowStart from "assets/icons/arrows/arrowStart.png"; import arrowStart from "assets/icons/arrows/arrowStart.png";
@ -483,20 +484,26 @@ export const TicketFullScreen = () => {
setUploadedFile(null); 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) { function deleteFile(file) {
apiRequest("/file/detach", { setTaskFiles((prevValue) =>
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) prevValue.filter((item) => item.id !== file.id)
); );
});
} }
function closeAcceptModal() { function closeAcceptModal() {
@ -800,19 +807,12 @@ export const TicketFullScreen = () => {
<div className="task__files filesFullScreen"> <div className="task__files filesFullScreen">
{taskFiles.map((file) => { {taskFiles.map((file) => {
return ( return (
<div className="taskFile" key={file.id}> <FileTracker
<img key={file.id}
className="imgFile" file={file}
src={backendImg(file.file?.url)} setDeletedTask={deleteFile}
alt="img" taskId={taskInfo.id}
/> />
<div
className="deleteFile"
onClick={() => deleteFile(file)}
>
<img src={fileDelete} alt="delete" />
</div>
</div>
); );
})} })}
</div> </div>