From d45e600c93b0edeab465cfd8ab48550e59eb3596 Mon Sep 17 00:00:00 2001 From: Gubar Nikita Date: Thu, 4 Jul 2024 18:04:28 +0300 Subject: [PATCH] fix url Tracker/tickets --- .../ModalTicketToReport.jsx | 11 +- .../TicketFullScreen/TicketFullScreen.jsx | 2200 ++++++++--------- src/pages/ProjectTracker/ProjectTracker.jsx | 30 +- src/pages/Tracker/Tracker.jsx | 1 - src/pages/roles/DeveloperPage.jsx | 1 - src/pages/roles/PartnerPage.jsx | 5 + 6 files changed, 1119 insertions(+), 1129 deletions(-) diff --git a/src/components/Modal/Tracker/ModalTicketToReport/ModalTicketToReport.jsx b/src/components/Modal/Tracker/ModalTicketToReport/ModalTicketToReport.jsx index 857dd55d..0f1f282b 100644 --- a/src/components/Modal/Tracker/ModalTicketToReport/ModalTicketToReport.jsx +++ b/src/components/Modal/Tracker/ModalTicketToReport/ModalTicketToReport.jsx @@ -3,6 +3,8 @@ import React, { useState } from "react"; import DatePicker from "react-datepicker"; import "react-datepicker/dist/react-datepicker.css"; +import { apiRequest } from "@api/request"; + import BaseButton from "@components/Common/BaseButton/BaseButton"; import "./modalTicketToReport.scss"; @@ -17,9 +19,12 @@ const ModalTicketToReport = ({ show, onClose, additionalData }) => { }; try { - await axios.post( - "https://itguild.info/profile/calendar/reports/create", - data + await apiRequest( + "https://back.itguild.info/profile/calendar/reports/create", + { + method: "POST", + data: data + } ); } catch (error) { console.error("Error:", error); diff --git a/src/components/Modal/Tracker/TicketFullScreen/TicketFullScreen.jsx b/src/components/Modal/Tracker/TicketFullScreen/TicketFullScreen.jsx index c8b189d5..b2ce7a11 100644 --- a/src/components/Modal/Tracker/TicketFullScreen/TicketFullScreen.jsx +++ b/src/components/Modal/Tracker/TicketFullScreen/TicketFullScreen.jsx @@ -1,1157 +1,1157 @@ -// import ClassicEditor from "@ckeditor/ckeditor5-build-classic"; -// import { CKEditor } from "@ckeditor/ckeditor5-react"; -// import ru from "date-fns/locale/ru"; -// import React, { useEffect, useState } from "react"; -// import DatePicker, { registerLocale } from "react-datepicker"; -// import { useDispatch, useSelector } from "react-redux"; -// import { Link, useNavigate, useParams } from "react-router-dom"; +import ClassicEditor from "@ckeditor/ckeditor5-build-classic"; +import { CKEditor } from "@ckeditor/ckeditor5-react"; +import ru from "date-fns/locale/ru"; +import React, { useEffect, useState } from "react"; +import DatePicker, { registerLocale } from "react-datepicker"; +import { useDispatch, useSelector } from "react-redux"; +import { Link, useNavigate, useParams } from "react-router-dom"; -// import { getProfileInfo } from "@redux/outstaffingSlice"; -// import { getBoarderLoader, setToggleTab } from "@redux/projectsTrackerSlice"; +import { getProfileInfo } from "@redux/outstaffingSlice"; +import { getBoarderLoader, setToggleTab } from "@redux/projectsTrackerSlice"; -// import { getCorrectDate } from "@utils/calendarHelper"; -// import { -// backendImg, -// caseOfNum, -// getCorrectRequestDate, -// getToken, -// removeLast, -// urlForLocal -// } from "@utils/helper"; +import { getCorrectDate } from "@utils/calendarHelper"; +import { + backendImg, + caseOfNum, + getCorrectRequestDate, + getToken, + removeLast, + urlForLocal +} from "@utils/helper"; -// import { apiRequest } from "@api/request"; +import { apiRequest } from "@api/request"; -// import { useNotification } from "@hooks/useNotification"; +import { useNotification } from "@hooks/useNotification"; -// import { Footer } from "@components/Common/Footer/Footer"; -// import { Loader } from "@components/Common/Loader/Loader"; -// import FileTracker from "@components/FileTracker/FileTracker"; -// import AcceptModal from "@components/Modal/AcceptModal/AcceptModal"; -// import { Navigation } from "@components/Navigation/Navigation"; -// import { ProfileBreadcrumbs } from "@components/ProfileBreadcrumbs/ProfileBreadcrumbs"; -// import { ProfileHeader } from "@components/ProfileHeader/ProfileHeader"; -// import TrackerTaskComment from "@components/TrackerTaskComment/TrackerTaskComment"; +import { Footer } from "@components/Common/Footer/Footer"; +import { Loader } from "@components/Common/Loader/Loader"; +import FileTracker from "@components/FileTracker/FileTracker"; +import AcceptModal from "@components/Modal/AcceptModal/AcceptModal"; +import { Navigation } from "@components/Navigation/Navigation"; +import { ProfileBreadcrumbs } from "@components/ProfileBreadcrumbs/ProfileBreadcrumbs"; +import { ProfileHeader } from "@components/ProfileHeader/ProfileHeader"; +import TrackerTaskComment from "@components/TrackerTaskComment/TrackerTaskComment"; -// import arrow from "assets/icons/arrows/arrowRight.png"; -// import arrowStart from "assets/icons/arrows/arrowStart.png"; -// import arrowDown from "assets/icons/arrows/selectArrow.png"; -// import calendarIcon from "assets/icons/calendar.svg"; -// import fileDelete from "assets/icons/closeProjectPersons.svg"; -// import close from "assets/icons/crossWhite.svg"; -// import del from "assets/icons/delete.svg"; -// import edit from "assets/icons/edit.svg"; -// import file from "assets/icons/fileModal.svg"; -// import link from "assets/icons/link.svg"; -// import send from "assets/icons/send.svg"; -// import project from "assets/icons/trackerProject.svg"; -// import tasks from "assets/icons/trackerTasks.svg"; -// import watch from "assets/icons/watch.svg"; -// import archive from "assets/images/archiveIcon.webp"; -// import avatarMok from "assets/images/avatarMok.webp"; +import arrow from "assets/icons/arrows/arrowRight.png"; +import arrowStart from "assets/icons/arrows/arrowStart.png"; +import arrowDown from "assets/icons/arrows/selectArrow.png"; +import calendarIcon from "assets/icons/calendar.svg"; +import fileDelete from "assets/icons/closeProjectPersons.svg"; +import close from "assets/icons/crossWhite.svg"; +import del from "assets/icons/delete.svg"; +import edit from "assets/icons/edit.svg"; +import file from "assets/icons/fileModal.svg"; +import link from "assets/icons/link.svg"; +import send from "assets/icons/send.svg"; +import project from "assets/icons/trackerProject.svg"; +import tasks from "assets/icons/trackerTasks.svg"; +import watch from "assets/icons/watch.svg"; +import archive from "assets/images/archiveIcon.webp"; +import avatarMok from "assets/images/avatarMok.webp"; -// import "./ticketFullScreen.scss"; +import "./ticketFullScreen.scss"; -// registerLocale("ru", ru); +registerLocale("ru", ru); -// export const TicketFullScreen = () => { -// const ticketId = useParams(); -// const dispatch = useDispatch(); -// const navigate = useNavigate(); -// const boardLoader = useSelector(getBoarderLoader); -// const [projectInfo, setProjectInfo] = useState({}); -// const [taskInfo, setTaskInfo] = useState({}); -// const [editOpen, setEditOpen] = useState(false); -// const [inputsValue, setInputsValue] = useState({}); -// const [loader, setLoader] = useState(true); -// const [comments, setComments] = useState([]); -// const [timerStart, setTimerStart] = useState(false); -// const [timerInfo, setTimerInfo] = useState({}); -// const [currentTimerCount, setCurrentTimerCount] = useState({ -// hours: 0, -// minute: 0, -// seconds: 0 -// }); -// const profileInfo = useSelector(getProfileInfo); -// const [timerId, setTimerId] = useState(null); -// const [dropListOpen, setDropListOpen] = useState(false); -// const [correctProjectUsers, setCorrectProjectUsers] = useState([]); -// const [dropListMembersOpen, setDropListMembersOpen] = useState(false); -// const [users, setUsers] = useState([]); -// const [deadLine, setDeadLine] = useState(""); -// const [datePickerOpen, setDatePickerOpen] = useState(false); -// const [startDate, setStartDate] = useState(null); -// const [uploadedFile, setUploadedFile] = useState(null); -// const [taskFiles, setTaskFiles] = useState([]); -// const [taskPriority, setTaskPriority] = useState(""); -// const [acceptModalOpen, setAcceptModalOpen] = useState(false); -// const [taskTags, setTaskTags] = useState([]); -// const [selectTagsOpen, setSelectTagsOpen] = useState(false); -// const [selectPriorityOpen, setSelectPriorityOpen] = useState(false); -// const [correctProjectTags, setCorrectProjectTags] = useState([]); -// const { showNotification } = useNotification(); -// const [commentSendDisable, setCommentSendDisable] = useState(false); +export const TicketFullScreen = () => { + const ticketId = useParams(); + const dispatch = useDispatch(); + const navigate = useNavigate(); + const boardLoader = useSelector(getBoarderLoader); + const [projectInfo, setProjectInfo] = useState({}); + const [taskInfo, setTaskInfo] = useState({}); + const [editOpen, setEditOpen] = useState(false); + const [inputsValue, setInputsValue] = useState({}); + const [loader, setLoader] = useState(true); + const [comments, setComments] = useState([]); + const [timerStart, setTimerStart] = useState(false); + const [timerInfo, setTimerInfo] = useState({}); + const [currentTimerCount, setCurrentTimerCount] = useState({ + hours: 0, + minute: 0, + seconds: 0 + }); + const profileInfo = useSelector(getProfileInfo); + const [timerId, setTimerId] = useState(null); + const [dropListOpen, setDropListOpen] = useState(false); + const [correctProjectUsers, setCorrectProjectUsers] = useState([]); + const [dropListMembersOpen, setDropListMembersOpen] = useState(false); + const [users, setUsers] = useState([]); + const [deadLine, setDeadLine] = useState(""); + const [datePickerOpen, setDatePickerOpen] = useState(false); + const [startDate, setStartDate] = useState(null); + const [uploadedFile, setUploadedFile] = useState(null); + const [taskFiles, setTaskFiles] = useState([]); + const [taskPriority, setTaskPriority] = useState(""); + const [acceptModalOpen, setAcceptModalOpen] = useState(false); + const [taskTags, setTaskTags] = useState([]); + const [selectTagsOpen, setSelectTagsOpen] = useState(false); + const [selectPriorityOpen, setSelectPriorityOpen] = useState(false); + const [correctProjectTags, setCorrectProjectTags] = useState([]); + const { showNotification } = useNotification(); + const [commentSendDisable, setCommentSendDisable] = useState(false); -// const priority = { -// 2: "Высокий", -// 1: "Средний", -// 0: "Низкий" -// }; + const priority = { + 2: "Высокий", + 1: "Средний", + 0: "Низкий" + }; -// const priorityTypes = [ -// { -// name: "Высокий", -// key: 2 -// }, -// { -// name: "Средний", -// key: 1 -// }, -// { -// name: "Низкий", -// key: 0 -// } -// ]; + const priorityTypes = [ + { + name: "Высокий", + key: 2 + }, + { + name: "Средний", + key: 1 + }, + { + name: "Низкий", + key: 0 + } + ]; -// useEffect(() => { -// initListeners(); -// apiRequest(`/task/get-task?task_id=${ticketId.id}&expand=mark`).then( -// (taskInfo) => { -// setTaskInfo(taskInfo); -// setDeadLine(taskInfo.dead_line); -// setTaskPriority(taskInfo.execution_priority); -// setStartDate( -// taskInfo.dead_line ? new Date(taskInfo.dead_line) : new Date() -// ); -// setInputsValue({ -// title: taskInfo.title, -// description: taskInfo.description, -// comment: "" -// }); -// setTaskTags(taskInfo.mark); -// apiRequest( -// `/comment/get-by-entity?entity_type=2&entity_id=${taskInfo.id}` -// ).then((res) => { -// const comments = res.reduce((acc, cur) => { -// if (!cur.parent_id) { -// acc.push({ ...cur, subComments: [] }); -// } else { -// 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); -// } -// }); -// }); -// apiRequest( -// `/project/get-project?project_id=${taskInfo.project_id}&expand=columns,mark` -// ).then((res) => { -// setProjectInfo(res); -// setCorrectProjectUsers(res.projectUsers); -// }); -// setLoader(boardLoader); -// } -// ); -// }, []); + useEffect(() => { + initListeners(); + apiRequest(`/task/get-task?task_id=${ticketId.id}&expand=mark`).then( + (taskInfo) => { + setTaskInfo(taskInfo); + setDeadLine(taskInfo.dead_line); + setTaskPriority(taskInfo.execution_priority); + setStartDate( + taskInfo.dead_line ? new Date(taskInfo.dead_line) : new Date() + ); + setInputsValue({ + title: taskInfo.title, + description: taskInfo.description, + comment: "" + }); + setTaskTags(taskInfo.mark); + apiRequest( + `/comment/get-by-entity?entity_type=2&entity_id=${taskInfo.id}` + ).then((res) => { + const comments = res.reduce((acc, cur) => { + if (!cur.parent_id) { + acc.push({ ...cur, subComments: [] }); + } else { + 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); + } + }); + }); + apiRequest( + `/project/get-project?project_id=${taskInfo.project_id}&expand=columns,mark` + ).then((res) => { + setProjectInfo(res); + setCorrectProjectUsers(res.projectUsers); + }); + setLoader(boardLoader); + } + ); + }, []); -// useEffect(() => { -// let tagIds = taskTags.map((tag) => tag.id); -// if (projectInfo.mark) { -// setCorrectProjectTags( -// projectInfo.mark.reduce((acc, cur) => { -// if (!tagIds.includes(cur.id)) acc.push(cur); -// return acc; -// }, []) -// ); -// } -// }, [taskTags, projectInfo]); + useEffect(() => { + let tagIds = taskTags.map((tag) => tag.id); + if (projectInfo.mark) { + setCorrectProjectTags( + projectInfo.mark.reduce((acc, cur) => { + if (!tagIds.includes(cur.id)) acc.push(cur); + return acc; + }, []) + ); + } + }, [taskTags, projectInfo]); -// function deleteTask() { -// apiRequest("/task/update-task", { -// method: "PUT", -// data: { -// task_id: ticketId.id, -// status: 0 -// } -// }).then(() => { -// navigate(`/tracker/project/${taskInfo.project_id}`); -// }); -// } + function deleteTask() { + apiRequest("/task/update-task", { + method: "PUT", + data: { + task_id: ticketId.id, + status: 0 + } + }).then(() => { + navigate(`/tracker/project/${taskInfo.project_id}`); + }); + } -// function archiveTask() { -// setAcceptModalOpen(true); -// } + function archiveTask() { + setAcceptModalOpen(true); + } -// function editTask() { -// if (!inputsValue.title || !inputsValue.description) { -// return showNotification({ -// show: true, -// text: "Заполните поля", -// type: "error" -// }); -// } -// apiRequest("/task/update-task", { -// method: "PUT", -// data: { -// task_id: taskInfo.id, -// title: inputsValue.title, -// description: inputsValue.description -// } -// }).then(() => { -// showNotification({ -// show: true, -// text: "Изменения сохранены", -// type: "success" -// }); -// setEditOpen(!editOpen); -// }); -// } + function editTask() { + if (!inputsValue.title || !inputsValue.description) { + return showNotification({ + show: true, + text: "Заполните поля", + type: "error" + }); + } + apiRequest("/task/update-task", { + method: "PUT", + data: { + task_id: taskInfo.id, + title: inputsValue.title, + description: inputsValue.description + } + }).then(() => { + showNotification({ + show: true, + text: "Изменения сохранены", + type: "success" + }); + setEditOpen(!editOpen); + }); + } -// function createComment() { -// if (!inputsValue.comment) return; -// setCommentSendDisable(true); -// apiRequest("/comment/create", { -// method: "POST", -// data: { -// text: inputsValue.comment, -// entity_type: 2, -// entity_id: taskInfo.id -// } -// }).then((res) => { -// let newComment = res; -// setCommentSendDisable(false); -// newComment.created_at = new Date(); -// newComment.subComments = []; -// setInputsValue((prevValue) => ({ ...prevValue, comment: "" })); -// setComments((prevValue) => [...prevValue, newComment]); -// }); -// } + function createComment() { + if (!inputsValue.comment) return; + setCommentSendDisable(true); + apiRequest("/comment/create", { + method: "POST", + data: { + text: inputsValue.comment, + entity_type: 2, + entity_id: taskInfo.id + } + }).then((res) => { + let newComment = res; + setCommentSendDisable(false); + newComment.created_at = new Date(); + newComment.subComments = []; + setInputsValue((prevValue) => ({ ...prevValue, comment: "" })); + setComments((prevValue) => [...prevValue, newComment]); + }); + } -// function startTaskTimer() { -// apiRequest("/timer/create", { -// method: "POST", -// data: { -// entity_type: 2, -// entity_id: taskInfo.id, -// created_at: getCorrectRequestDate(new Date()) -// } -// }).then((res) => { -// setTimerStart(true); -// setTimerInfo(res); -// startTimer(); -// }); -// } + function startTaskTimer() { + apiRequest("/timer/create", { + method: "POST", + data: { + entity_type: 2, + entity_id: taskInfo.id, + created_at: getCorrectRequestDate(new Date()) + } + }).then((res) => { + setTimerStart(true); + setTimerInfo(res); + startTimer(); + }); + } -// function stopTaskTimer() { -// apiRequest("/timer/update", { -// method: "PUT", -// data: { -// timer_id: timerInfo.id, -// stopped_at: getCorrectRequestDate(new Date()) -// } -// }).then(() => { -// setTimerStart(false); -// clearInterval(timerId); -// }); -// } + function stopTaskTimer() { + apiRequest("/timer/update", { + method: "PUT", + data: { + timer_id: timerInfo.id, + stopped_at: getCorrectRequestDate(new Date()) + } + }).then(() => { + setTimerStart(false); + clearInterval(timerId); + }); + } -// function commentDelete(comment) { -// setComments((prevValue) => -// prevValue.filter((item) => item.id !== comment.id) -// ); -// if (comment.subComments.length) { -// comment.subComments.forEach((subComment) => { -// apiRequest("/comment/update", { -// method: "PUT", -// data: { -// comment_id: subComment.id, -// status: 0 -// } -// }).then(() => {}); -// }); -// } -// } + function commentDelete(comment) { + setComments((prevValue) => + prevValue.filter((item) => item.id !== comment.id) + ); + if (comment.subComments.length) { + comment.subComments.forEach((subComment) => { + apiRequest("/comment/update", { + method: "PUT", + data: { + comment_id: subComment.id, + status: 0 + } + }).then(() => {}); + }); + } + } -// function addSubComment(commentId, subComment) { -// const addSubComment = comments; -// addSubComment.forEach((comment) => { -// if (comment.id === commentId) { -// comment.subComments.push(subComment); -// } -// }); -// setComments(addSubComment); -// } + function addSubComment(commentId, subComment) { + const addSubComment = comments; + addSubComment.forEach((comment) => { + if (comment.id === commentId) { + comment.subComments.push(subComment); + } + }); + setComments(addSubComment); + } -// function subCommentDelete(subComment) { -// const deleteSubComment = comments; -// deleteSubComment.forEach((comment, index) => { -// if (comment.id === subComment.parent_id) { -// deleteSubComment[index].subComments = comment.subComments.filter( -// (item) => item.id !== subComment.id -// ); -// } -// }); -// setComments([...deleteSubComment]); -// } + function subCommentDelete(subComment) { + const deleteSubComment = comments; + deleteSubComment.forEach((comment, index) => { + if (comment.id === subComment.parent_id) { + deleteSubComment[index].subComments = comment.subComments.filter( + (item) => item.id !== subComment.id + ); + } + }); + setComments([...deleteSubComment]); + } -// const toggleTabs = (index) => { -// dispatch(setToggleTab(index)); -// }; + const toggleTabs = (index) => { + dispatch(setToggleTab(index)); + }; -// function copyTicketLink() { -// navigator.clipboard.writeText( -// `https://itguild.info/tracker/task/${taskInfo.id}` -// ); -// } + function copyTicketLink() { + navigator.clipboard.writeText( + `https://itguild.info/tracker/task/${taskInfo.id}` + ); + } -// function startTimer() { -// setTimerId( -// setInterval(() => { -// run(); -// }, 1000) -// ); -// } + function startTimer() { + setTimerId( + setInterval(() => { + run(); + }, 1000) + ); + } -// useEffect(() => { -// if (taskInfo.taskUsers && projectInfo.projectUsers) { -// let ids = taskInfo.taskUsers.map((user) => user.user_id); -// setUsers( -// projectInfo.projectUsers.reduce((acc, cur) => { -// if (!ids.includes(cur.user_id)) acc.push(cur); -// return acc; -// }, []) -// ); -// } -// }, [taskInfo.taskUsers, projectInfo]); + useEffect(() => { + if (taskInfo.taskUsers && projectInfo.projectUsers) { + let ids = taskInfo.taskUsers.map((user) => user.user_id); + setUsers( + projectInfo.projectUsers.reduce((acc, cur) => { + if (!ids.includes(cur.user_id)) acc.push(cur); + return acc; + }, []) + ); + } + }, [taskInfo.taskUsers, projectInfo]); -// let updateTimerSec = currentTimerCount.seconds, -// updateTimerMinute = currentTimerCount.minute, -// updateTimerHours = currentTimerCount.hours; + let updateTimerSec = currentTimerCount.seconds, + updateTimerMinute = currentTimerCount.minute, + updateTimerHours = currentTimerCount.hours; -// function run() { -// updateTimerSec++; -// if (updateTimerSec > 60) { -// updateTimerMinute++; -// updateTimerSec = 0; -// } -// if (updateTimerMinute === 60) { -// updateTimerMinute = 0; -// updateTimerHours++; -// } + function run() { + updateTimerSec++; + if (updateTimerSec > 60) { + updateTimerMinute++; + updateTimerSec = 0; + } + if (updateTimerMinute === 60) { + updateTimerMinute = 0; + updateTimerHours++; + } -// return setCurrentTimerCount({ -// hours: updateTimerHours, -// minute: updateTimerMinute, -// seconds: updateTimerSec -// }); -// } + return setCurrentTimerCount({ + hours: updateTimerHours, + minute: updateTimerMinute, + seconds: updateTimerSec + }); + } -// function correctTimerTime(time) { -// if (time < 10) return `0${time}`; -// if (time > 10) return time; -// } + function correctTimerTime(time) { + if (time < 10) return `0${time}`; + if (time > 10) return time; + } -// function deleteTaskExecutor() { -// apiRequest("/task/update-task", { -// method: "PUT", -// data: { -// task_id: taskInfo.id, -// executor_id: 0 -// } -// }).then(() => { -// setTaskInfo((prevState) => ({ -// ...prevState, -// executor_id: null, -// executor: null -// })); -// }); -// } + function deleteTaskExecutor() { + apiRequest("/task/update-task", { + method: "PUT", + data: { + task_id: taskInfo.id, + executor_id: 0 + } + }).then(() => { + setTaskInfo((prevState) => ({ + ...prevState, + executor_id: null, + executor: null + })); + }); + } -// function taskExecutor(person) { -// apiRequest("/task/update-task", { -// method: "PUT", -// data: { -// task_id: taskInfo.id, -// executor_id: person.user_id -// } -// }).then((res) => { -// setDropListOpen(false); -// setTaskInfo((prevState) => ({ -// ...prevState, -// executor_id: res.executor_id, -// executor: res.executor -// })); -// }); -// } + function taskExecutor(person) { + apiRequest("/task/update-task", { + method: "PUT", + data: { + task_id: taskInfo.id, + executor_id: person.user_id + } + }).then((res) => { + setDropListOpen(false); + setTaskInfo((prevState) => ({ + ...prevState, + executor_id: res.executor_id, + executor: res.executor + })); + }); + } -// function deleteMember(person) { -// apiRequest("/task/del-user", { -// method: "DELETE", -// data: { -// task_id: taskInfo.id, -// user_id: person.user_id -// } -// }).then(() => { -// setTaskInfo((prevState) => ({ -// ...prevState, -// taskUsers: taskInfo.taskUsers.filter( -// (item) => item.user_id !== person.user_id -// ) -// })); -// }); -// } + function deleteMember(person) { + apiRequest("/task/del-user", { + method: "DELETE", + data: { + task_id: taskInfo.id, + user_id: person.user_id + } + }).then(() => { + setTaskInfo((prevState) => ({ + ...prevState, + taskUsers: taskInfo.taskUsers.filter( + (item) => item.user_id !== person.user_id + ) + })); + }); + } -// function addMember(person) { -// apiRequest("/task/add-user-to-task", { -// method: "POST", -// data: { -// task_id: taskInfo.id, -// user_id: person.user_id -// } -// }).then((res) => { -// setDropListMembersOpen(false); -// setTaskInfo((prevValue) => ({ -// ...prevValue, -// taskUsers: [...prevValue.taskUsers, res] -// })); -// }); -// } + function addMember(person) { + apiRequest("/task/add-user-to-task", { + method: "POST", + data: { + task_id: taskInfo.id, + user_id: person.user_id + } + }).then((res) => { + setDropListMembersOpen(false); + setTaskInfo((prevValue) => ({ + ...prevValue, + taskUsers: [...prevValue.taskUsers, res] + })); + }); + } -// function selectDeadLine(date) { -// apiRequest("/task/update-task", { -// method: "PUT", -// data: { -// task_id: taskInfo.id, -// dead_line: getCorrectRequestDate(date) -// } -// }).then(() => {}); -// } + function selectDeadLine(date) { + apiRequest("/task/update-task", { + method: "PUT", + data: { + task_id: taskInfo.id, + dead_line: getCorrectRequestDate(date) + } + }).then(() => {}); + } -// async function handleUpload(event) { -// const formData = new FormData(); -// formData.append("uploadFile", event.target.files[0]); -// const res = await fetch("https://itguild.info/api/file/upload", { -// method: "POST", -// body: formData, -// headers: { ...getToken() } -// }); + async function handleUpload(event) { + const formData = new FormData(); + formData.append("uploadFile", event.target.files[0]); + const res = await fetch("https://itguild.info/api/file/upload", { + method: "POST", + body: formData, + headers: { ...getToken() } + }); -// const data = await res.json(); + const data = await res.json(); -// setUploadedFile(data); -// } + setUploadedFile(data); + } -// function attachFile() { -// apiRequest("/file/attach", { -// method: "POST", -// data: { -// file_id: uploadedFile[0].id, -// entity_type: 2, -// entity_id: taskInfo.id, -// status: 1 -// } -// }).then((res) => { -// setTaskFiles((prevValue) => [...prevValue, res]); -// setUploadedFile(null); -// }); -// } + function attachFile() { + apiRequest("/file/attach", { + method: "POST", + data: { + file_id: uploadedFile[0].id, + entity_type: 2, + entity_id: taskInfo.id, + status: 1 + } + }).then((res) => { + setTaskFiles((prevValue) => [...prevValue, res]); + setUploadedFile(null); + }); + } -// function deleteLoadedFile() { -// setUploadedFile(null); -// } + function deleteLoadedFile() { + setUploadedFile(null); + } -// function updateTaskPriority(key) { -// setSelectPriorityOpen(false); -// apiRequest("/task/update-task", { -// method: "PUT", -// data: { -// task_id: taskInfo.id, -// execution_priority: key -// } -// }).then(() => {}); -// } + function updateTaskPriority(key) { + setSelectPriorityOpen(false); + apiRequest("/task/update-task", { + method: "PUT", + data: { + task_id: taskInfo.id, + execution_priority: key + } + }).then(() => {}); + } -// // 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) => + // prevValue.filter((item) => item.id !== file.id) + // ); + // }); + // } -// function deleteFile(file) { -// setTaskFiles((prevValue) => -// prevValue.filter((item) => item.id !== file.id) -// ); -// } + function deleteFile(file) { + setTaskFiles((prevValue) => + prevValue.filter((item) => item.id !== file.id) + ); + } -// function closeAcceptModal() { -// setAcceptModalOpen(false); -// } + function closeAcceptModal() { + setAcceptModalOpen(false); + } -// function deleteTagFromTask(tagId) { -// apiRequest("/mark/detach", { -// method: "DELETE", -// data: { -// mark_id: tagId, -// entity_type: 2, -// entity_id: taskInfo.id -// } -// }).then(() => { -// setTaskTags((prevValue) => prevValue.filter((tag) => tag.id !== tagId)); -// }); -// } + function deleteTagFromTask(tagId) { + apiRequest("/mark/detach", { + method: "DELETE", + data: { + mark_id: tagId, + entity_type: 2, + entity_id: taskInfo.id + } + }).then(() => { + setTaskTags((prevValue) => prevValue.filter((tag) => tag.id !== tagId)); + }); + } -// function addTagToTask(tagId) { -// apiRequest("/mark/attach", { -// method: "POST", -// data: { -// mark_id: tagId, -// entity_type: 2, -// entity_id: taskInfo.id -// } -// }).then((data) => { -// setSelectTagsOpen(false); -// setTaskTags((prevValue) => [...prevValue, data.mark]); -// }); -// } + function addTagToTask(tagId) { + apiRequest("/mark/attach", { + method: "POST", + data: { + mark_id: tagId, + entity_type: 2, + entity_id: taskInfo.id + } + }).then((data) => { + setSelectTagsOpen(false); + setTaskTags((prevValue) => [...prevValue, data.mark]); + }); + } -// const initListeners = () => { -// document.addEventListener("click", closeByClickingOut); -// }; + const initListeners = () => { + document.addEventListener("click", closeByClickingOut); + }; -// const closeByClickingOut = (event) => { -// const path = event.path || (event.composedPath && event.composedPath()); + const closeByClickingOut = (event) => { + const path = event.path || (event.composedPath && event.composedPath()); -// if ( -// event && -// !path.find( -// (div) => -// div.classList && -// (div.classList.contains("button-add-worker") || -// div.classList.contains("dropdown-list")) -// ) -// ) { -// setDropListOpen(false); -// setDropListMembersOpen(false); -// } + if ( + event && + !path.find( + (div) => + div.classList && + (div.classList.contains("button-add-worker") || + div.classList.contains("dropdown-list")) + ) + ) { + setDropListOpen(false); + setDropListMembersOpen(false); + } -// if ( -// event && -// !path.find( -// (div) => -// div.classList && -// (div.classList.contains("dead-line") || -// div.classList.contains("react-datepicker-popper")) -// ) -// ) { -// setDatePickerOpen(false); -// } + if ( + event && + !path.find( + (div) => + div.classList && + (div.classList.contains("dead-line") || + div.classList.contains("react-datepicker-popper")) + ) + ) { + setDatePickerOpen(false); + } -// if ( -// event && -// !path.find( -// (div) => -// div.classList && -// (div.classList.contains("tags") || -// div.classList.contains("tags__dropDown")) -// ) -// ) { -// setSelectTagsOpen(false); -// } -// }; + if ( + event && + !path.find( + (div) => + div.classList && + (div.classList.contains("tags") || + div.classList.contains("tags__dropDown")) + ) + ) { + setSelectTagsOpen(false); + } + }; -// return ( -//
-// -// -//
-//
-// -//

Управление проектами с трекером

-//
-//
-//
-//
-// toggleTabs(1)} -// > -// img -//

Проекты

-// -// toggleTabs(2)} -// > -// img -//

Все мои задачи

-// -//
-// {loader ? ( -// -// ) : ( -// <> -//
-//
-//
-//
{projectInfo.name}
-// -//
-//

К списку задач

-// arrow -//
-// -//
-//
-//
-//
-//
-//
-// {editOpen ? ( -// { -// setInputsValue((prevValue) => ({ -// ...prevValue, -// title: e.target.value -// })); -// }} -// /> -// ) : ( -//
-// {inputsValue.title} -//
-// )} -//
-// {editOpen ? ( -// { -// const data = editor.getData(); -// setInputsValue((prevValue) => ({ -// ...prevValue, -// description: data -// })); -// }} -// /> -// ) : ( -//
-//
-//
-// )} -//
-// {Boolean(taskFiles.length) && ( -//
-// {taskFiles.map((file) => { -// return ( -// -// ); -// })} -//
-// )} -// {uploadedFile && ( -//
-// {uploadedFile.map((file) => { -// return ( -//
-// img -//
deleteLoadedFile(file)} -// > -// delete -//
-//
-// ); -// })} -// -//
-// )} -//
-//
-//
-// -// -//
-// {taskFiles.length ? taskFiles.length : 0} -// {caseOfNum(taskFiles.length, "files")} -//
-//
-//
-// { -// setInputsValue((prevValue) => ({ -// ...prevValue, -// comment: e.target.value -// })); -// }} -// /> -// send -//
-//
-// {comments.map((comment) => { -// return ( -// -// ); -// })} -//
-//
-//
-//
-//
-//
-// Создатель:

{removeLast(taskInfo.user?.fio)}

-//
+ return ( +
+ + +
+
+ +

Управление проектами с трекером

+
+
+
+
+ toggleTabs(1)} + > + img +

Проекты

+ + toggleTabs(2)} + > + img +

Все мои задачи

+ +
+ {loader ? ( + + ) : ( + <> +
+
+
+
{projectInfo.name}
+ +
+

К списку задач

+ arrow +
+ +
+
+
+
+
+
+ {editOpen ? ( + { + setInputsValue((prevValue) => ({ + ...prevValue, + title: e.target.value + })); + }} + /> + ) : ( +
+ {inputsValue.title} +
+ )} +
+ {editOpen ? ( + { + const data = editor.getData(); + setInputsValue((prevValue) => ({ + ...prevValue, + description: data + })); + }} + /> + ) : ( +
+
+
+ )} +
+ {Boolean(taskFiles.length) && ( +
+ {taskFiles.map((file) => { + return ( + + ); + })} +
+ )} + {uploadedFile && ( +
+ {uploadedFile.map((file) => { + return ( +
+ img +
deleteLoadedFile(file)} + > + delete +
+
+ ); + })} + +
+ )} +
+
+
+ + +
+ {taskFiles.length ? taskFiles.length : 0} + {caseOfNum(taskFiles.length, "files")} +
+
+
+ { + setInputsValue((prevValue) => ({ + ...prevValue, + comment: e.target.value + })); + }} + /> + send +
+
+ {comments.map((comment) => { + return ( + + ); + })} +
+
+
+
+
+
+ Создатель:

{removeLast(taskInfo.user?.fio)}

+
-// {taskInfo.executor ? ( -// <> -//
Исполнитель:
-//
-//

{removeLast(taskInfo.executor.fio)}

-// avatar -// deleteTaskExecutor()} -// /> -//
-// -// ) : ( -//
-// -// Добавить исполнителя -// {dropListOpen && ( -//
-// setDropListOpen(false)} -// /> -// {correctProjectUsers.map((person) => { -// return ( -//
taskExecutor(person)} -// > -// {removeLast(person.user.fio)} -// avatar -//
-// ); -// })} -//
-// )} -//
-// )} -// {Boolean(taskInfo.taskUsers.length) && ( -//
-//

Участники:

-//
-// {taskInfo.taskUsers.map((member) => { -// return ( -//
-//

{removeLast(member.fio)}

-// avatar -// deleteMember(member)} -// /> -//
-// ); -// })} -//
-//
-// )} -//
-// -// Добавить участника -// {dropListMembersOpen && ( -//
-// setDropListMembersOpen(false)} -// /> -// {users.length ? ( -// users.map((person) => { -// return ( -//
addMember(person)} -// > -// {removeLast(person.user.fio)} -// avatar -//
-// ); -// }) -// ) : ( -//

Нет пользователей

-// )} -//
-// )} -//
-//
+ {taskInfo.executor ? ( + <> +
Исполнитель:
+
+

{removeLast(taskInfo.executor.fio)}

+ avatar + deleteTaskExecutor()} + /> +
+ + ) : ( +
+ + Добавить исполнителя + {dropListOpen && ( +
+ setDropListOpen(false)} + /> + {correctProjectUsers.map((person) => { + return ( +
taskExecutor(person)} + > + {removeLast(person.user.fio)} + avatar +
+ ); + })} +
+ )} +
+ )} + {Boolean(taskInfo.taskUsers.length) && ( +
+

Участники:

+
+ {taskInfo.taskUsers.map((member) => { + return ( +
+

{removeLast(member.fio)}

+ avatar + deleteMember(member)} + /> +
+ ); + })} +
+
+ )} +
+ + Добавить участника + {dropListMembersOpen && ( +
+ setDropListMembersOpen(false)} + /> + {users.length ? ( + users.map((person) => { + return ( +
addMember(person)} + > + {removeLast(person.user.fio)} + avatar +
+ ); + }) + ) : ( +

Нет пользователей

+ )} +
+ )} +
+
-//
-//
-//
setDatePickerOpen(!datePickerOpen)} -// > -//

-// -// {deadLine -// ? getCorrectDate(deadLine) -// : "Срок исполнения:"} -// -//
-// { -// setDatePickerOpen(false); -// setStartDate(date); -// setDeadLine(date); -// selectDeadLine(date); -// }} -// /> -//
-//
-//

-//

-// {correctTimerTime(currentTimerCount.hours)}: -// {correctTimerTime(currentTimerCount.minute)}: -// {correctTimerTime(currentTimerCount.seconds)} -//

-//
+
+
+
setDatePickerOpen(!datePickerOpen)} + > +

+ + {deadLine + ? getCorrectDate(deadLine) + : "Срок исполнения:"} + +
+ { + setDatePickerOpen(false); + setStartDate(date); + setDeadLine(date); + selectDeadLine(date); + }} + /> +
+
+

+

+ {correctTimerTime(currentTimerCount.hours)}: + {correctTimerTime(currentTimerCount.minute)}: + {correctTimerTime(currentTimerCount.seconds)} +

+
-// {timerStart ? ( -// -// ) : ( -// -// )} -//
-//
-//
-//
-// {taskTags.map((tag) => { -// return ( -//
-//

{tag.slug}

-// delete deleteTagFromTask(tag.id)} -// /> -//
-// ); -// })} -//
-//
setSelectTagsOpen(!selectTagsOpen)} -// > -// Выберите тег -// arrow -//
-// {selectTagsOpen && ( -//
-// setSelectTagsOpen(false)} -// className="tags__dropDown__close" -// src={close} -// alt="close" -// /> -// {correctProjectTags.map((tag) => { -// return ( -//
addTagToTask(tag.id)} -// > -//

{tag.slug}

-// -//
-// ); -// })} -// {!Boolean(correctProjectTags.length) && ( -//

Нет тегов

-// )} -//
-// )} -//
-//
+ {timerStart ? ( + + ) : ( + + )} +
+
+
+
+ {taskTags.map((tag) => { + return ( +
+

{tag.slug}

+ delete deleteTagFromTask(tag.id)} + /> +
+ ); + })} +
+
setSelectTagsOpen(!selectTagsOpen)} + > + Выберите тег + arrow +
+ {selectTagsOpen && ( +
+ setSelectTagsOpen(false)} + className="tags__dropDown__close" + src={close} + alt="close" + /> + {correctProjectTags.map((tag) => { + return ( +
addTagToTask(tag.id)} + > +

{tag.slug}

+ +
+ ); + })} + {!Boolean(correctProjectTags.length) && ( +

Нет тегов

+ )} +
+ )} +
+
-//
-//
setSelectPriorityOpen(!selectPriorityOpen)} -// > -// -// {typeof taskPriority === "number" -// ? `Приоритет: ${priority[taskPriority]}` -// : "Выберите приоритет"} -// -// arrow -//
-// {selectPriorityOpen && ( -//
-// {priorityTypes.map((item) => { -// return ( -//
{ -// setTaskPriority(item.key); -// updateTaskPriority(item.key); -// }} -// > -// {item.name} -//
-// ); -// })} -//
-// )} -//
-//
-//
{ -// if (editOpen) { -// editTask(); -// } else { -// setEditOpen(!editOpen); -// } -// }} -// > -// edit -//

{editOpen ? "сохранить" : "редактировать"}

-//
-//
-// link -//

ссылка на задачу

-//
-//
-// arch -//

в архив

-//
-//
-// delete -//

удалить

-//
-//
-//
-//
-// -// )} -//
-// {acceptModalOpen && ( -// -// )} -//
-//
-// ); -// }; +
+
setSelectPriorityOpen(!selectPriorityOpen)} + > + + {typeof taskPriority === "number" + ? `Приоритет: ${priority[taskPriority]}` + : "Выберите приоритет"} + + arrow +
+ {selectPriorityOpen && ( +
+ {priorityTypes.map((item) => { + return ( +
{ + setTaskPriority(item.key); + updateTaskPriority(item.key); + }} + > + {item.name} +
+ ); + })} +
+ )} +
+
+
{ + if (editOpen) { + editTask(); + } else { + setEditOpen(!editOpen); + } + }} + > + edit +

{editOpen ? "сохранить" : "редактировать"}

+
+
+ link +

ссылка на задачу

+
+
+ arch +

в архив

+
+
+ delete +

удалить

+
+
+
+
+ + )} +
+ {acceptModalOpen && ( + + )} +
+
+ ); +}; -// export default TicketFullScreen; +export default TicketFullScreen; diff --git a/src/pages/ProjectTracker/ProjectTracker.jsx b/src/pages/ProjectTracker/ProjectTracker.jsx index 1bee26dc..85ed1653 100644 --- a/src/pages/ProjectTracker/ProjectTracker.jsx +++ b/src/pages/ProjectTracker/ProjectTracker.jsx @@ -1,7 +1,7 @@ import moment from "moment"; import React, { useEffect, useRef, useState } from "react"; import { useDispatch, useSelector } from "react-redux"; -import { Link, useLocation, useNavigate, useParams } from "react-router-dom"; +import { Link, useParams } from "react-router-dom"; import { activeLoader, @@ -51,8 +51,6 @@ import avatarMok from "assets/images/avatarMok.webp"; export const ProjectTracker = () => { const dispatch = useDispatch(); const projectId = useParams(); - const location = useLocation(); - const navigate = useNavigate(); const [openColumnSelect, setOpenColumnSelect] = useState({}); const [selectedTab, setSelectedTab] = useState(0); @@ -99,24 +97,6 @@ export const ProjectTracker = () => { } else { setFilteredNoTasks(false); } - - const path = location.pathname; - const match = path.match(/\/task\/(\d+)/); - console.log(match); - if (match) { - const extractedTaskId = match[1]; - - console.log(extractedTaskId); - // Убираем /task/id из URL - const newUrl = path.replace(/\/task\/\d+/, ""); - navigate(newUrl, { replace: true }); - - // Открываем тикет - console.log("asd", projectBoard); - const Dtask = tasks.find((task) => task.id === extractedTaskId); - console.log("asd", Dtask); - // openTicket(extractedTaskId); - } }, [projectBoard]); function dragOverHandler(e) { @@ -174,9 +154,11 @@ export const ProjectTracker = () => { document.body.style.overflow = "hidden"; } - // useEffect(() => { - - // }, [location]); + useEffect(() => { + const currentUrl = window.location.pathname; + const newUrl = currentUrl.replace(/\/task\/\d+$/, ""); + window.history.replaceState({}, "", newUrl); + }, []); function deleteColumn(column) { const priorityColumns = []; diff --git a/src/pages/Tracker/Tracker.jsx b/src/pages/Tracker/Tracker.jsx index 04c9693e..81645746 100644 --- a/src/pages/Tracker/Tracker.jsx +++ b/src/pages/Tracker/Tracker.jsx @@ -5,7 +5,6 @@ import { useSort } from "@table-library/react-table-library/sort"; import { useTheme } from "@table-library/react-table-library/theme"; import React, { useEffect, useState } from "react"; import { useDispatch, useSelector } from "react-redux"; -import { Link } from "react-router-dom"; import { getProjects, diff --git a/src/pages/roles/DeveloperPage.jsx b/src/pages/roles/DeveloperPage.jsx index 7f325c40..14704e4d 100644 --- a/src/pages/roles/DeveloperPage.jsx +++ b/src/pages/roles/DeveloperPage.jsx @@ -26,7 +26,6 @@ export const DeveloperPage = () => { path="/tracker/project/:id/task/:taskId" element={} /> - } /> diff --git a/src/pages/roles/PartnerPage.jsx b/src/pages/roles/PartnerPage.jsx index de52b5d5..6aba1b72 100644 --- a/src/pages/roles/PartnerPage.jsx +++ b/src/pages/roles/PartnerPage.jsx @@ -27,6 +27,11 @@ export const PartnerPage = () => { } /> } /> + } + /> } />