From 8c440ce7c7472b101c991f94d64692f7665ed5a7 Mon Sep 17 00:00:00 2001 From: Mikola Date: Tue, 21 Nov 2023 16:41:18 +0300 Subject: [PATCH] task priority --- .../Modal/Tracker/ModalTicket/ModalTicket.jsx | 84 +++++---- .../TicketFullScreen/TicketFullScreen.jsx | 171 ++++++++++-------- .../Tracker/TrackerModal/TrackerModal.jsx | 77 ++++---- src/pages/ProjectTracker/ProjectTracker.js | 40 ++-- 4 files changed, 202 insertions(+), 170 deletions(-) diff --git a/src/components/Modal/Tracker/ModalTicket/ModalTicket.jsx b/src/components/Modal/Tracker/ModalTicket/ModalTicket.jsx index f076e7e6..a8f1885b 100644 --- a/src/components/Modal/Tracker/ModalTicket/ModalTicket.jsx +++ b/src/components/Modal/Tracker/ModalTicket/ModalTicket.jsx @@ -75,7 +75,7 @@ export const ModalTiсket = ({ const [dropListOpen, setDropListOpen] = useState(false); const [dropListMembersOpen, setDropListMembersOpen] = useState(false); const [executor, setExecutor] = useState(task.executor); - const [taskPriority, setTaskPriority] = useState(task.execution_priority) + const [taskPriority, setTaskPriority] = useState(task.execution_priority); const [members, setMembers] = useState(task.taskUsers); const [taskTags, setTaskTags] = useState(task.mark); const [users, setUsers] = useState([]); @@ -95,7 +95,7 @@ export const ModalTiсket = ({ const profileInfo = useSelector(getProfileInfo); const [acceptModalOpen, setAcceptModalOpen] = useState(false); const [selectTagsOpen, setSelectTagsOpen] = useState(false); - const [selectPriorityOpen, setSelectPriorityOpen] = useState(false) + const [selectPriorityOpen, setSelectPriorityOpen] = useState(false); const { showNotification } = useNotification(); const [commentSendDisable, setCommentSendDisable] = useState(false); @@ -117,27 +117,26 @@ export const ModalTiсket = ({ }); } - const priority = - { - 2: 'Высокий', - 1: 'Средний', - 0: 'Низкий' - } + const priority = { + 2: "Высокий", + 1: "Средний", + 0: "Низкий", + }; const priorityTypes = [ { - name: 'Высокий', - key: 2 + name: "Высокий", + key: 2, }, { - name: 'Средний', - key: 1 + name: "Средний", + key: 1, }, { - name: 'Низкий', - key: 0 + name: "Низкий", + key: 0, }, - ] + ]; function archiveTask() { setAcceptModalOpen(true); @@ -287,12 +286,12 @@ export const ModalTiсket = ({ } function updateTaskPriority(key) { - setSelectPriorityOpen(false) + setSelectPriorityOpen(false); apiRequest("/task/update-task", { method: "PUT", data: { task_id: task.id, - execution_priority: key + execution_priority: key, }, }).then(() => { dispatch(setProjectBoardFetch(projectId)); @@ -1006,29 +1005,40 @@ export const ModalTiсket = ({ )} -
-
setSelectPriorityOpen(!selectPriorityOpen)}> - {typeof taskPriority === "number" ? priority[taskPriority] : 'Выберете приоритет'} +
+
setSelectPriorityOpen(!selectPriorityOpen)} + > + + {typeof taskPriority === "number" + ? priority[taskPriority] + : "Выберете приоритет"} + arrow
- {selectPriorityOpen && -
- {priorityTypes.map((item) => { - return
{ - setTaskPriority(item.key) - updateTaskPriority(item.key) - }} - >{item.name}
- })} -
- } + {selectPriorityOpen && ( +
+ {priorityTypes.map((item) => { + return ( +
{ + setTaskPriority(item.key); + updateTaskPriority(item.key); + }} + > + {item.name} +
+ ); + })} +
+ )}
{ const [startDate, setStartDate] = useState(null); const [uploadedFile, setUploadedFile] = useState(null); const [taskFiles, setTaskFiles] = useState([]); - const [taskPriority, setTaskPriority] = 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 [selectPriorityOpen, setSelectPriorityOpen] = useState(false); const [correctProjectTags, setCorrectProjectTags] = useState([]); const { showNotification } = useNotification(); const [commentSendDisable, setCommentSendDisable] = useState(false); const priority = { - 2: 'Высокий', - 1: 'Средний', - 0: 'Низкий' - } + 2: "Высокий", + 1: "Средний", + 0: "Низкий", + }; const priorityTypes = [ { - name: 'Высокий', - key: 2 + name: "Высокий", + key: 2, }, { - name: 'Средний', - key: 1 + name: "Средний", + key: 1, }, { - name: 'Низкий', - key: 0 + name: "Низкий", + key: 0, }, - ] + ]; useEffect(() => { initListeners(); @@ -125,7 +126,7 @@ export const TicketFullScreen = () => { (taskInfo) => { setTaskInfo(taskInfo); setDeadLine(taskInfo.dead_line); - setTaskPriority(taskInfo.execution_priority) + setTaskPriority(taskInfo.execution_priority); setStartDate( taskInfo.dead_line ? new Date(taskInfo.dead_line) : new Date() ); @@ -509,15 +510,14 @@ export const TicketFullScreen = () => { } function updateTaskPriority(key) { - setSelectPriorityOpen(false) + setSelectPriorityOpen(false); apiRequest("/task/update-task", { method: "PUT", data: { task_id: taskInfo.id, - execution_priority: key + execution_priority: key, }, - }).then(() => { - }); + }).then(() => {}); } // function deleteFile(file) { @@ -1144,84 +1144,95 @@ export const TicketFullScreen = () => {
{taskTags.map((tag) => { return ( -
-

{tag.slug}

- delete deleteTagFromTask(tag.id)} - /> -
+
+

{tag.slug}

+ delete deleteTagFromTask(tag.id)} + /> +
); })}
setSelectTagsOpen(!selectTagsOpen)} + className="tags__select" + onClick={() => 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) && ( -

Нет тегов

- )} -
+
+ 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] : 'Выберете приоритет'} +
+
setSelectPriorityOpen(!selectPriorityOpen)} + > + + {typeof taskPriority === "number" + ? priority[taskPriority] + : "Выберете приоритет"} + arrow
- {selectPriorityOpen && -
- {priorityTypes.map((item) => { - return
{ - setTaskPriority(item.key) - updateTaskPriority(item.key) - }} - >{item.name}
- })} -
- } + {selectPriorityOpen && ( +
+ {priorityTypes.map((item) => { + return ( +
{ + setTaskPriority(item.key); + updateTaskPriority(item.key); + }} + > + {item.name} +
+ ); + })} +
+ )}
)}
-
-
setSelectPriority(!selectPriority)} +
+
setSelectPriority(!selectPriority)} > - {selectedPriority ? `Приоритет: ${selectedPriority.name}` : 'Выберети приоритет'} + {selectedPriority + ? `Приоритет: ${selectedPriority.name}` + : "Выберети приоритет"} arrow
- {selectPriority && -
- {priority.map((item) => { - return
{ - setSelectPriority(false) - setSelectedPriority(item) - }} - >{item.name}
- })} -
- } + {selectPriority && ( +
+ {priority.map((item) => { + return ( +
{ + setSelectPriority(false); + setSelectedPriority(item); + }} + > + {item.name} +
+ ); + })} +
+ )}
diff --git a/src/pages/ProjectTracker/ProjectTracker.js b/src/pages/ProjectTracker/ProjectTracker.js index 4552b6c9..c0ddc4d7 100644 --- a/src/pages/ProjectTracker/ProjectTracker.js +++ b/src/pages/ProjectTracker/ProjectTracker.js @@ -90,18 +90,17 @@ export const ProjectTracker = () => { const loader = useSelector(getBoarderLoader); const { showNotification } = useNotification(); - const priority = - { - 2: 'Высокий', - 1: 'Средний', - 0: 'Низкий' - } + const priority = { + 2: "Высокий", + 1: "Средний", + 0: "Низкий", + }; - const priorityClass = { - 2: 'high', - 1: 'middle', - 0: 'low' - } + const priorityClass = { + 2: "high", + 1: "middle", + 0: "low", + }; useEffect(() => { dispatch(activeLoader()); @@ -1011,12 +1010,19 @@ export const ProjectTracker = () => { })}
)} - {typeof task.execution_priority === "number" && -
-

Приоритет:

- {priority[task.execution_priority]} -
- } + {typeof task.execution_priority === + "number" && ( +
+

Приоритет:

+ + {priority[task.execution_priority]} + +
+ )} {task.dead_line && (

Срок исполнения: