Merge pull request #134 from apuc/tracker-fix

Tracker fix
This commit is contained in:
NikoM1k 2023-10-13 14:41:42 +03:00 committed by GitHub
commit 01f6dfbc6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 65 additions and 63 deletions

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}`).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() {

View File

@ -14,7 +14,7 @@ const initialState = {
}; };
export const setProjectBoardFetch = createAsyncThunk("userInfo", (id) => export const setProjectBoardFetch = createAsyncThunk("userInfo", (id) =>
apiRequest(`/project/get-project?project_id=${id}&expand=columns`) apiRequest(`/project/get-project?project_id=${id}&expand=columns,mark`)
); );
export const projectsTrackerSlice = createSlice({ export const projectsTrackerSlice = createSlice({