From bd3e2288edacc133fa8f3ceeb20b2ddc675a3749 Mon Sep 17 00:00:00 2001 From: M1kola Date: Tue, 27 Jun 2023 18:35:59 +0300 Subject: [PATCH] select executor on create task --- .../Tracker/TrackerModal/TrackerModal.jsx | 101 +++++++++++------- src/components/ProjectTiket/ProjectTiket.jsx | 1 - 2 files changed, 65 insertions(+), 37 deletions(-) diff --git a/src/components/Modal/Tracker/TrackerModal/TrackerModal.jsx b/src/components/Modal/Tracker/TrackerModal/TrackerModal.jsx index 35d55407..99475330 100644 --- a/src/components/Modal/Tracker/TrackerModal/TrackerModal.jsx +++ b/src/components/Modal/Tracker/TrackerModal/TrackerModal.jsx @@ -1,6 +1,7 @@ import React, { useEffect, useState } from "react"; import { useDispatch, useSelector } from "react-redux"; +import { getProfileInfo } from "@redux/outstaffingSlice"; import { addPersonToProject, editColumnName, @@ -16,8 +17,6 @@ import { setProjectBoardFetch, } from "@redux/projectsTrackerSlice"; -import {getProfileInfo} from "@redux/outstaffingSlice"; - import { urlForLocal } from "@utils/helper"; import { apiRequest } from "@api/request"; @@ -37,7 +36,7 @@ export const TrackerModal = ({ titleProject, projectId, priorityTask, - projectUsers + projectUsers, }) => { const dispatch = useDispatch(); const projectBoard = useSelector(getProjectBoard); @@ -58,8 +57,10 @@ export const TrackerModal = ({ const [selectColumnPriority, setSelectColumnPriority] = useState( "Выберите приоритет колонки" ); - const [selectedExecutorTask, setSelectedExecutorTask] = useState('Выберите исполнителя задачи') - const [selectExecutorTaskOpen, setSelectExecutorTaskOpen] = useState(false) + const [selectedExecutorTask, setSelectedExecutorTask] = useState( + "Выберите исполнителя задачи" + ); + const [selectExecutorTaskOpen, setSelectExecutorTaskOpen] = useState(false); const [correctProjectUsers, setCorrectProjectUsers] = useState([]); const [selectColumnPriorityOpen, setSelectColumnPriorityOpen] = useState(false); @@ -114,8 +115,8 @@ export const TrackerModal = ({ setActive(false); setValueTiket(""); setDescriptionTicket(""); - setSelectedExecutorTask('Выберите исполнителя задачи') - }) + setSelectedExecutorTask("Выберите исполнителя задачи"); + }); } else { setActive(false); setValueTiket(""); @@ -237,9 +238,13 @@ export const TrackerModal = ({ }) : ""; if ( - localStorage.getItem("role_status") !== "18" && projectUsers && Boolean(!projectUsers.find((item) => item.user_id === profileInfo.id_user)) + localStorage.getItem("role_status") !== "18" && + projectUsers && + Boolean( + !projectUsers.find((item) => item.user_id === profileInfo.id_user) + ) ) { - setCorrectProjectUsers( [ + setCorrectProjectUsers([ ...projectUsers, { user: { @@ -250,7 +255,7 @@ export const TrackerModal = ({ }, ]); } else { - setCorrectProjectUsers(projectUsers) + setCorrectProjectUsers(projectUsers); } }, [active]); @@ -341,32 +346,52 @@ export const TrackerModal = ({ />
setSelectExecutorTaskOpen(!selectExecutorTaskOpen)} - className={selectExecutorTaskOpen ? 'select__executor select__executor--open' : 'select__executor'}> -
- {selectedExecutorTask.user_id ? - <> - {selectedExecutorTask.user.fio} - avatar - - : {selectedExecutorTask} - } -
- arrow - {selectExecutorTaskOpen && -
- {correctProjectUsers.length ? - correctProjectUsers.map((person) => { - return
setSelectedExecutorTask(person)} className='executor' key={person.user_id}> - {person.user.fio} - avatar -
- }) - : Нет пользователей - - } -
+ onClick={() => setSelectExecutorTaskOpen(!selectExecutorTaskOpen)} + className={ + selectExecutorTaskOpen + ? "select__executor select__executor--open" + : "select__executor" } + > +
+ {selectedExecutorTask.user_id ? ( + <> + {selectedExecutorTask.user.fio} + avatar + + ) : ( + {selectedExecutorTask} + )} +
+ arrow + {selectExecutorTaskOpen && ( +
+ {correctProjectUsers.length ? ( + correctProjectUsers.map((person) => { + return ( +
setSelectedExecutorTask(person)} + className="executor" + key={person.user_id} + > + {person.user.fio} + avatar +
+ ); + }) + ) : ( + Нет пользователей + )} +
+ )}
@@ -456,7 +481,11 @@ export const TrackerModal = ({

Приоритет колонки

setSelectColumnPriorityOpen(!selectColumnPriorityOpen) } diff --git a/src/components/ProjectTiket/ProjectTiket.jsx b/src/components/ProjectTiket/ProjectTiket.jsx index 98a28635..cefb1f1e 100644 --- a/src/components/ProjectTiket/ProjectTiket.jsx +++ b/src/components/ProjectTiket/ProjectTiket.jsx @@ -25,7 +25,6 @@ export const ProjectTiket = ({ project, index }) => { initListeners(); }, []); - function initListeners() { document.addEventListener("click", closeByClickingOut); }