From 33b70c7fbdd95c8e3fc945a2a33ef392de69a913 Mon Sep 17 00:00:00 2001 From: Mikola Date: Tue, 24 Oct 2023 22:58:45 +0300 Subject: [PATCH] marks --- src/pages/ProjectTracker/ProjectTracker.js | 203 ++++++++++++--------- src/redux/projectsTrackerSlice.js | 2 +- 2 files changed, 117 insertions(+), 88 deletions(-) diff --git a/src/pages/ProjectTracker/ProjectTracker.js b/src/pages/ProjectTracker/ProjectTracker.js index d0c82de6..4816d468 100644 --- a/src/pages/ProjectTracker/ProjectTracker.js +++ b/src/pages/ProjectTracker/ProjectTracker.js @@ -1,14 +1,12 @@ import React, { useEffect, useRef, useState } from "react"; +import { HexColorPicker } from "react-colorful"; import { useDispatch, useSelector } from "react-redux"; import { Link, useParams } from "react-router-dom"; -import { - HexColorPicker -} from "react-colorful"; import { activeLoader, - deletePersonOnProject, addNewTagToProject, + deletePersonOnProject, filterCreatedByMe, filteredExecutorTasks, filteredParticipateTasks, @@ -55,7 +53,6 @@ import accept from "assets/images/accept.png"; import archive from "assets/images/archiveIcon.png"; import avatarMok from "assets/images/avatarMok.png"; - import { getCorrectDate } from "../../components/Calendar/calendarHelper"; export const ProjectTracker = () => { @@ -73,10 +70,10 @@ export const ProjectTracker = () => { const [personListOpen, setPersonListOpen] = useState(false); const [tags, setTags] = useState({ open: false, - add: false - }) + add: false, + }); const [color, setColor] = useState("#aabbcc"); - const [tagInfo, setTagInfo] = useState({description: '', name: ''}) + const [tagInfo, setTagInfo] = useState({ description: "", name: "" }); const [checkBoxParticipateTasks, setCheckBoxParticipateTasks] = useState(false); const [filteredNoTasks, setFilteredNoTasks] = useState(false); @@ -294,14 +291,14 @@ export const ProjectTracker = () => { dispatch(setProjectBoardFetch(projectId.id)); } - function addNewTag () { + function addNewTag() { apiRequest("/mark/create", { method: "POST", data: { title: tagInfo.description, slug: tagInfo.name, color: color, - status: 1 + status: 1, }, }).then((data) => { apiRequest("/mark/attach", { @@ -309,16 +306,16 @@ export const ProjectTracker = () => { data: { mark_id: data.id, entity_type: 1, - entity_id: projectId.id - } + entity_id: projectId.id, + }, }).then((data) => { - dispatch(addNewTagToProject(data.mark)) + dispatch(addNewTagToProject(data.mark)); setTags((prevState) => ({ ...prevState, - add: false - })) - }) - }) + add: false, + })); + }); + }); } return ( @@ -570,85 +567,117 @@ export const ProjectTracker = () => { )}
-
{ - setTags((prevState) => ({ - ...prevState, - open: !tags.open - })) - }}> +
{ + setTags((prevState) => ({ + ...prevState, + open: !tags.open, + })); + }} + >

Список тегов

+
- {tags.open && -
- close { - setTags((prevState) => ({ - ...prevState, - open: false - })) - }} /> - {!tags.add && -
- {projectBoard.mark.map((tag) => { - return
-

- {tag.title} -

-
- {tag.slug} - + {tags.open && ( +
+ close { + setTags((prevState) => ({ + ...prevState, + open: false, + })); + }} + /> + {!tags.add && ( +
+ {projectBoard.mark.map((tag) => { + return ( +
+

+ {tag.title} +

+
+ + {tag.slug} + +
-
- }) - } -
setTags((prevState) => ({...prevState, add: true}))}> -

- Добавить новый тег -

- - + - -
-
- } - {tags.add && -
- arrow { +
+ ); + })} +
setTags((prevState) => ({ ...prevState, - add: false + add: true, })) - }}/> - setTagInfo(prevState => ({ - ...prevState, - description: e.target.value - }))} - /> - setTagInfo(prevState => ({ - ...prevState, - name: e.target.value - }))} - /> - - + } + > +

Добавить новый тег

+ +
- } +
+ )} + {tags.add && ( +
+ arrow { + setTags((prevState) => ({ + ...prevState, + add: false, + })); + }} + /> + + setTagInfo((prevState) => ({ + ...prevState, + description: e.target.value, + })) + } + /> + + setTagInfo((prevState) => ({ + ...prevState, + name: e.target.value, + })) + } + /> + + +
+ )}
- } + )}

Вернуться на проекты

diff --git a/src/redux/projectsTrackerSlice.js b/src/redux/projectsTrackerSlice.js index 94ed6399..5e984c59 100644 --- a/src/redux/projectsTrackerSlice.js +++ b/src/redux/projectsTrackerSlice.js @@ -46,7 +46,7 @@ export const projectsTrackerSlice = createSlice({ state.projectBoard.projectUsers.push(action.payload); }, addNewTagToProject: (state, action) => { - state.projectBoard.mark.push(action.payload) + state.projectBoard.mark.push(action.payload); }, activeLoader: (state) => { state.boardLoader = true;