From 512a8c61212582e4f9a4802b5b54ff177c3749b6 Mon Sep 17 00:00:00 2001 From: Mikola Date: Mon, 30 Oct 2023 01:35:28 +0300 Subject: [PATCH] create task with tags --- .../Tracker/TrackerModal/TrackerModal.jsx | 107 ++++++++++++------ 1 file changed, 70 insertions(+), 37 deletions(-) diff --git a/src/components/Modal/Tracker/TrackerModal/TrackerModal.jsx b/src/components/Modal/Tracker/TrackerModal/TrackerModal.jsx index 160f104d..0b893a2f 100644 --- a/src/components/Modal/Tracker/TrackerModal/TrackerModal.jsx +++ b/src/components/Modal/Tracker/TrackerModal/TrackerModal.jsx @@ -35,11 +35,11 @@ import ModalLayout from "@components/Common/ModalLayout/ModalLayout"; import arrowCreateTask from "assets/icons/arrows/arrowCreateTask.svg"; import arrowRight from "assets/icons/arrows/arrowRightCreateTask.svg"; import arrowDown from "assets/icons/arrows/selectArrow.png"; +import close from "assets/icons/close.png"; import calendarImg from "assets/icons/createTaskCalendar.svg"; import avatarMok from "assets/images/avatarMok.png"; import "./trackerModal.scss"; -import close from "assets/icons/close.png"; registerLocale("ru", ru); @@ -52,7 +52,7 @@ export const TrackerModal = ({ projectId, priorityTask, projectUsers, - projectMarks + projectMarks, }) => { const dispatch = useDispatch(); const projectBoard = useSelector(getProjectBoard); @@ -80,7 +80,7 @@ export const TrackerModal = ({ const [correctProjectUsers, setCorrectProjectUsers] = useState([]); const [correctProjectTags, setCorrectProjectTags] = useState([]); const [taskTags, setTaskTags] = useState([]); - const [selectTagsOpen, setSelectTagsOpen] = useState(false) + const [selectTagsOpen, setSelectTagsOpen] = useState(false); const [selectColumnPriorityOpen, setSelectColumnPriorityOpen] = useState(false); const { showNotification } = useNotification(); @@ -146,10 +146,10 @@ export const TrackerModal = ({ data: { mark_id: taskTags[i].id, entity_type: 2, - entity_id: res.id + entity_id: res.id, }, }).then(() => { - setTaskTags([]) + setTaskTags([]); }); } if (selectedExecutorTask.user_id) { @@ -327,10 +327,10 @@ export const TrackerModal = ({ let tagIds = taskTags.map((tag) => tag.id); if (projectMarks) { setCorrectProjectTags( - projectMarks.reduce((acc, cur) => { - if (!tagIds.includes(cur.id)) acc.push(cur); - return acc; - }, []) + projectMarks.reduce((acc, cur) => { + if (!tagIds.includes(cur.id)) acc.push(cur); + return acc; + }, []) ); } }, [taskTags, projectMarks]); @@ -436,12 +436,12 @@ export const TrackerModal = ({

Создатель : {profileInfo?.fio}

avatar
{/*Этап*/} @@ -486,39 +486,72 @@ export const TrackerModal = ({
-
-
+
+
{taskTags.map((tag) => { - return
-

{tag.slug}

- +

{tag.slug}

+ delete setTaskTags((prevState) => prevState.filter((prevTag) => prevTag.id !== tag.id))} - /> -
- }) - } + onClick={() => + setTaskTags((prevState) => + prevState.filter( + (prevTag) => prevTag.id !== tag.id + ) + ) + } + /> +
+ ); + })}
-
setSelectTagsOpen(!selectTagsOpen)}> +
setSelectTagsOpen(!selectTagsOpen)} + > Выберете тег - arrow + arrow
- {selectTagsOpen && -
- setSelectTagsOpen(false)}/> - {correctProjectTags.map((tag) => { - return
setTaskTags((prevState) => ([...prevState, tag]))}> + {selectTagsOpen && ( +
+ setSelectTagsOpen(false)} + /> + {correctProjectTags.map((tag) => { + return ( +
+ setTaskTags((prevState) => [...prevState, tag]) + } + >

{tag.slug}

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

Нет тегов

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

Нет тегов

+ )} +
+ )}