This commit is contained in:
Mikola 2023-10-13 14:39:01 +03:00
parent 356104b475
commit 2af61e5a7a

View File

@ -91,69 +91,71 @@ export const TicketFullScreen = () => {
const { showNotification } = useNotification(); const { showNotification } = useNotification();
useEffect(() => { useEffect(() => {
apiRequest(`/task/get-task?task_id=${ticketId.id}&expand=mark`).then((taskInfo) => { apiRequest(`/task/get-task?task_id=${ticketId.id}&expand=mark`).then(
setTaskInfo(taskInfo); (taskInfo) => {
setDeadLine(taskInfo.dead_line); setTaskInfo(taskInfo);
setStartDate( setDeadLine(taskInfo.dead_line);
taskInfo.dead_line ? new Date(taskInfo.dead_line) : new Date() setStartDate(
); taskInfo.dead_line ? new Date(taskInfo.dead_line) : new Date()
setInputsValue({ );
title: taskInfo.title, setInputsValue({
description: taskInfo.description, title: taskInfo.title,
comment: "", description: taskInfo.description,
}); comment: "",
apiRequest( });
`/comment/get-by-entity?entity_type=2&entity_id=${taskInfo.id}` apiRequest(
).then((res) => { `/comment/get-by-entity?entity_type=2&entity_id=${taskInfo.id}`
const comments = res.reduce((acc, cur) => { ).then((res) => {
if (!cur.parent_id) { const comments = res.reduce((acc, cur) => {
acc.push({ ...cur, subComments: [] }); if (!cur.parent_id) {
} else { acc.push({ ...cur, subComments: [] });
acc.forEach((item) => { } else {
if (item.id === cur.parent_id) item.subComments.push(cur); acc.forEach((item) => {
}); if (item.id === cur.parent_id) item.subComments.push(cur);
} });
return acc;
}, []);
setComments(comments);
});
apiRequest(
`/file/get-by-entity?entity_type=2&entity_id=${taskInfo.id}`
).then((res) => {
if (Array.isArray(res)) {
setTaskFiles(res);
}
});
apiRequest(
`/timer/get-by-entity?entity_type=2&entity_id=${taskInfo.id}`
).then((res) => {
let timerSeconds = 0;
res.length &&
res.forEach((time) => {
timerSeconds += time.deltaSeconds;
setCurrentTimerCount({
hours: Math.floor(timerSeconds / 60 / 60),
minute: Math.floor((timerSeconds / 60) % 60),
seconds: timerSeconds % 60,
});
updateTimerHours = Math.floor(timerSeconds / 60 / 60);
updateTimerMinute = Math.floor((timerSeconds / 60) % 60);
updateTimerSec = timerSeconds % 60;
if (!time.stopped_at) {
setTimerStart(true);
startTimer();
setTimerInfo(time);
} }
}); return acc;
}); }, []);
apiRequest( setComments(comments);
`/project/get-project?project_id=${taskInfo.project_id}&expand=columns` });
).then((res) => { apiRequest(
setProjectInfo(res); `/file/get-by-entity?entity_type=2&entity_id=${taskInfo.id}`
setCorrectProjectUsers(res.projectUsers); ).then((res) => {
}); if (Array.isArray(res)) {
setLoader(boardLoader); setTaskFiles(res);
}); }
});
apiRequest(
`/timer/get-by-entity?entity_type=2&entity_id=${taskInfo.id}`
).then((res) => {
let timerSeconds = 0;
res.length &&
res.forEach((time) => {
timerSeconds += time.deltaSeconds;
setCurrentTimerCount({
hours: Math.floor(timerSeconds / 60 / 60),
minute: Math.floor((timerSeconds / 60) % 60),
seconds: timerSeconds % 60,
});
updateTimerHours = Math.floor(timerSeconds / 60 / 60);
updateTimerMinute = Math.floor((timerSeconds / 60) % 60);
updateTimerSec = timerSeconds % 60;
if (!time.stopped_at) {
setTimerStart(true);
startTimer();
setTimerInfo(time);
}
});
});
apiRequest(
`/project/get-project?project_id=${taskInfo.project_id}&expand=columns`
).then((res) => {
setProjectInfo(res);
setCorrectProjectUsers(res.projectUsers);
});
setLoader(boardLoader);
}
);
}, []); }, []);
function deleteTask() { function deleteTask() {