From fc6feca92dff6c0aa221a1258917c8edef7e813f Mon Sep 17 00:00:00 2001 From: M1kola Date: Thu, 22 Jun 2023 19:43:12 +0300 Subject: [PATCH 1/3] correctProjectUsers --- .../Modal/TrackerModal/trackerModal.scss | 1 + src/components/UI/ModalTicket/ModalTicket.jsx | 64 +++++++++++++------ .../UI/ModalTicket/modalTicket.scss | 12 +++- src/pages/Tracker/tracker.scss | 2 +- 4 files changed, 58 insertions(+), 21 deletions(-) diff --git a/src/components/Modal/TrackerModal/trackerModal.scss b/src/components/Modal/TrackerModal/trackerModal.scss index 8e73a9f1..5bba0676 100644 --- a/src/components/Modal/TrackerModal/trackerModal.scss +++ b/src/components/Modal/TrackerModal/trackerModal.scss @@ -76,6 +76,7 @@ cursor: pointer; width: 100%; position: relative; + margin-bottom: 10px; p { max-width: 150px; diff --git a/src/components/UI/ModalTicket/ModalTicket.jsx b/src/components/UI/ModalTicket/ModalTicket.jsx index ba3b2025..41627bdb 100644 --- a/src/components/UI/ModalTicket/ModalTicket.jsx +++ b/src/components/UI/ModalTicket/ModalTicket.jsx @@ -3,7 +3,7 @@ import { Link } from "react-router-dom"; import TrackerModal from "../../../components/Modal/TrackerModal/TrackerModal"; import TrackerTaskComment from "../../../components/TrackerTaskComment/TrackerTaskComment"; import { apiRequest } from "../../../api/request"; -import { useDispatch } from "react-redux"; +import {useDispatch, useSelector} from "react-redux"; import "./modalTicket.scss" import { modalToggle, @@ -24,6 +24,7 @@ import fullScreen from "../../../assets/icons/arrows/inFullScreen.svg"; import close from "../../../assets/icons/closeProjectPersons.svg"; import {urlForLocal, getCorrectRequestDate} from "../../../utils/helper"; +import {getProfileInfo} from "@redux/outstaffingSlice"; export const ModalTiсket = ({ active, @@ -51,6 +52,9 @@ export const ModalTiсket = ({ seconds: 0 }) const [timerId, setTimerId] = useState(null) + const [correctProjectUsers, setCorrectProjectUsers] = useState(projectUsers) + const [executorId, setExecutorId] = useState(task.executor_id) + const profileInfo = useSelector(getProfileInfo); function deleteTask() { apiRequest("/task/update-task", { @@ -168,8 +172,10 @@ export const ModalTiсket = ({ executor_id: person.user_id }, }).then((res) => { + setExecutorId(person.user_id) setDropListOpen(false) setExecutor(res.executor) + dispatch(setProjectBoardFetch(projectId)); }); } @@ -181,7 +187,9 @@ export const ModalTiсket = ({ executor_id: 0 }, }).then(() => { - setExecutor(null) + setExecutorId(null) + setExecutor(null); + dispatch(setProjectBoardFetch(projectId)); }); } @@ -195,6 +203,7 @@ export const ModalTiсket = ({ }).then((res) => { setDropListMembersOpen(false) setMembers((prevValue) => ([...prevValue, res])) + dispatch(setProjectBoardFetch(projectId)); }); } @@ -206,7 +215,8 @@ export const ModalTiсket = ({ user_id: person.user_id }, }).then(() => { - setMembers(members.filter((item) => item.user_id !== person.user_id)) + setMembers(members.filter((item) => item.user_id !== person.user_id)); + dispatch(setProjectBoardFetch(projectId)); }); } @@ -243,6 +253,16 @@ export const ModalTiсket = ({ } }) }) + + if (localStorage.getItem("role_status") !== "18" && Boolean(!correctProjectUsers.find((item) => item.user_id === profileInfo.id_user))) { + setCorrectProjectUsers((prevState) => [...prevState, { + user: { + avatar: profileInfo.photo, + fio: profileInfo.fio + }, + user_id: profileInfo.id_user + }]) + } }, []) function startTimer () { @@ -313,23 +333,24 @@ export const ModalTiсket = ({ setInputsValue((prevValue) => ({...prevValue, title: e.target.value})) }} /> :
{inputsValue.title}
}
- {editOpen ? { + {editOpen ? +