diff --git a/src/components/Modal/Tracker/ModalTicket/ModalTicket.jsx b/src/components/Modal/Tracker/ModalTicket/ModalTicket.jsx index e165bd0d..d00d5883 100644 --- a/src/components/Modal/Tracker/ModalTicket/ModalTicket.jsx +++ b/src/components/Modal/Tracker/ModalTicket/ModalTicket.jsx @@ -27,6 +27,7 @@ import send from "assets/icons/send.svg"; import watch from "assets/icons/watch.svg"; import "./modalTicket.scss"; +import avatarMok from "assets/images/avatarMok.png"; export const ModalTiсket = ({ active, @@ -469,7 +470,13 @@ export const ModalTiсket = ({ {executor ? (

Исполнитель: {executor.fio}

- avatar + avatar taskExecutor(person)} > {person.user.fio} - + avatar
); })} @@ -517,7 +531,14 @@ export const ModalTiсket = ({ return (

{member.fio}

- + avatar addMember(person)} > {person.user.fio} - + avatar
); }) diff --git a/src/components/Modal/Tracker/TicketFullScreen/TicketFullScreen.jsx b/src/components/Modal/Tracker/TicketFullScreen/TicketFullScreen.jsx index 87853a3d..0c93c5e7 100644 --- a/src/components/Modal/Tracker/TicketFullScreen/TicketFullScreen.jsx +++ b/src/components/Modal/Tracker/TicketFullScreen/TicketFullScreen.jsx @@ -7,10 +7,8 @@ import { Link, useNavigate, useParams } from "react-router-dom"; import { deletePersonOnProject, getBoarderLoader, - getProjectBoard, - modalToggle, - setProjectBoardFetch, - setToggleTab, + modalToggle, setProjectBoardFetch, + setToggleTab } from "@redux/projectsTrackerSlice"; import { getCorrectRequestDate, urlForLocal } from "@utils/helper"; @@ -35,7 +33,6 @@ 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 plus from "assets/icons/plus.svg"; import send from "assets/icons/send.svg"; import project from "assets/icons/trackerProject.svg"; import tasks from "assets/icons/trackerTasks.svg"; @@ -49,8 +46,8 @@ export const TicketFullScreen = () => { const ticketId = useParams(); const dispatch = useDispatch(); const navigate = useNavigate(); - const projectBoard = useSelector(getProjectBoard); const boardLoader = useSelector(getBoarderLoader); + const [projectInfo, setProjectInfo] = useState({}) const [taskInfo, setTaskInfo] = useState({}); const [editOpen, setEditOpen] = useState(false); const [inputsValue, setInputsValue] = useState({}); @@ -65,6 +62,10 @@ export const TicketFullScreen = () => { seconds: 0, }); const [timerId, setTimerId] = useState(null); + const [dropListOpen, setDropListOpen] = useState(false); + const [correctProjectUsers, setCorrectProjectUsers] = useState([]); + const [dropListMembersOpen, setDropListMembersOpen] = useState(false); + const [users, setUsers] = useState([]); useEffect(() => { apiRequest(`/task/get-task?task_id=${ticketId.id}`).then((taskInfo) => { @@ -111,7 +112,10 @@ export const TicketFullScreen = () => { } }); }); - dispatch(setProjectBoardFetch(taskInfo.project_id)); + apiRequest(`/project/get-project?project_id=${taskInfo.project_id}&expand=columns`).then((res) => { + setProjectInfo(res) + setCorrectProjectUsers(res.projectUsers) + }) setLoader(boardLoader); }); }, []); @@ -188,7 +192,7 @@ export const TicketFullScreen = () => { apiRequest("/project/del-user", { method: "DELETE", data: { - project_id: projectBoard.id, + project_id: projectInfo.id, user_id: userId, }, }).then(() => { @@ -253,6 +257,18 @@ export const TicketFullScreen = () => { ); } + 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; @@ -280,6 +296,70 @@ export const TicketFullScreen = () => { 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 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 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] + })); + }); + } + return (
@@ -329,7 +409,7 @@ export const TicketFullScreen = () => {
-
Проект : {projectBoard.name}
+
Проект : {projectInfo.name}
{ >
- {projectBoard.projectUsers?.length > 3 && ( + {projectInfo.projectUsers?.length > 3 && ( +1... )}
- {projectBoard.projectUsers?.length && - projectBoard.projectUsers + {projectInfo.projectUsers?.length && + projectInfo.projectUsers .slice( 0, - projectBoard.length > 3 ? 3 : projectBoard.length + 3 ) .map((person) => { return ( @@ -379,14 +459,14 @@ export const TicketFullScreen = () => { onClick={() => setPersonListOpen(false)} />
- {projectBoard.projectUsers?.length} + {projectInfo.projectUsers?.length} участник
- В проекте - “{projectBoard.name}” + В проекте - “{projectInfo.name}”
- {projectBoard.projectUsers?.map((person) => { + {projectInfo.projectUsers?.map((person) => { return (
{ > avatar {person.user.fio} @@ -484,18 +568,18 @@ export const TicketFullScreen = () => { )}
-

- { - dispatch(modalToggle("addSubtask")); - setModalAddWorker(true); - }} - styles={"button-green-add"} - > - - Добавить под задачу - -

+ {/*

*/} + {/* {*/} + {/* dispatch(modalToggle("addSubtask"));*/} + {/* setModalAddWorker(true);*/} + {/* }}*/} + {/* styles={"button-green-add"}*/} + {/* >*/} + {/* */} + {/* Добавить под задачу*/} + {/* */} + {/*

*/}

@@ -540,42 +624,129 @@ export const TicketFullScreen = () => { Создатель :
{taskInfo.user?.fio}

-
- {Boolean(taskInfo.taskUsers?.length) && - taskInfo.taskUsers.map((worker, index) => { - return ( -
- worket -

{worker.name}

-
- ); - })} -
+ {taskInfo.executor ? ( +
+

Исполнитель: {taskInfo.executor.fio}

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

Участники:

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

{member.fio}

+ avatar + deleteMember(member)} + /> +
+ ); + })} +
+
+ )}
- { - dispatch(modalToggle("addWorker")); - setModalAddWorker(true); - }} - styles={"button-add-worker"} +
-
- { - dispatch(modalToggle("addWorker")); - setModalAddWorker(true); - }} - styles={"button-add-worker"} - > - + - - + Добавить участников + {dropListMembersOpen && ( +
+ setDropListMembersOpen(false)} + /> + {users.length ? ( + users.map((person) => { + return ( +
addMember(person)} + > + {person.user.fio} + avatar +
+ ); + }) + ) : ( +

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

+ )} +
+ )}
diff --git a/src/pages/ProjectTracker/ProjectTracker.js b/src/pages/ProjectTracker/ProjectTracker.js index 627fc219..a912c7a0 100644 --- a/src/pages/ProjectTracker/ProjectTracker.js +++ b/src/pages/ProjectTracker/ProjectTracker.js @@ -330,7 +330,7 @@ export const ProjectTracker = () => { projectBoard.projectUsers .slice( 0, - projectBoard.length > 3 ? 3 : projectBoard.length + 3 ) .map((person) => { return (