diff --git a/src/components/ProfileCalendar/ProfileCalendarComponent.jsx b/src/components/ProfileCalendar/ProfileCalendarComponent.jsx index 0e076717..8e24284c 100644 --- a/src/components/ProfileCalendar/ProfileCalendarComponent.jsx +++ b/src/components/ProfileCalendar/ProfileCalendarComponent.jsx @@ -289,16 +289,16 @@ export const ProfileCalendarComponent = React.memo( ? `${getCorrectDate(startDate)} - ${getCorrectDate(endDate)}` : `${getCorrectDate(endDate)} - ${getCorrectDate(startDate)}` : activePeriod - ? "Выберите диапазон на календаре" - : "Выбрать диапазон"} + ? "Выберите диапазон на календаре" + : "Выбрать диапазон"} {totalRangeHours ? `${totalRangeHours} ${hourOfNum(totalRangeHours)}` : endDate - ? "0 часов" - : ""} + ? "0 часов" + : ""} {endDate && ( { + const [selectExecutorOpen, setSelectedExecutorOpen] = useState(false); + const dispatch = useDispatch(); + + const initListeners = () => { + document.addEventListener("click", closeByClickingOut); + }; + + const closeByClickingOut = (event) => { + const path = event.path || (event.composedPath && event.composedPath()); + + if ( + event && + !path.find( + (div) => + div.classList && + (div.classList.contains("tasks__head__executor") || + div.classList.contains("tasks__head__executor-dropdown")) + ) + ) { + setSelectedExecutorOpen(false); + } + }; + + function executorFilter(user) { + dispatch(filteredExecutorTasks(user.user_id)); + setSelectedExecutor(user); + } + + useEffect(() => { + initListeners(); + }, []); + + if (selectedExecutor) { + return ( +
+

{removeLast(selectedExecutor.user.fio)}

+ avatar + delete +
+ ); + } else { + return ( +
setSelectedExecutorOpen(!selectExecutorOpen)} + > +

Выберите исполнителя

+ arrow + {selectExecutorOpen && ( +
+ {projectBoard.projectUsers.map((user) => { + return ( +
executorFilter(user)} + > +

{removeLast(user.user?.fio)}

+ avatar +
+ ); + })} +
+ )} +
+ ); + } +}; + +export default TrackerSelectExecutor; diff --git a/src/components/TrackerSelectExecutor/trackerSelectExecutor.scss b/src/components/TrackerSelectExecutor/trackerSelectExecutor.scss new file mode 100644 index 00000000..e69de29b diff --git a/src/pages/ProjectTracker/ProjectTracker.jsx b/src/pages/ProjectTracker/ProjectTracker.jsx index 5494adea..07cee39b 100644 --- a/src/pages/ProjectTracker/ProjectTracker.jsx +++ b/src/pages/ProjectTracker/ProjectTracker.jsx @@ -40,6 +40,7 @@ import { Navigation } from "@components/Navigation/Navigation"; import { ProfileBreadcrumbs } from "@components/ProfileBreadcrumbs/ProfileBreadcrumbs"; import { ProfileHeader } from "@components/ProfileHeader/ProfileHeader"; import TrackerSelectColumn from "@components/TrackerSelectColumn/TrackerSelectColumn"; +import TrackerSelectExecutor from "@components/TrackerSelectExecutor/TrackerSelectExecutor"; import arrow from "assets/icons/arrows/arrowRight.png"; import arrowDown from "assets/icons/arrows/selectArrow.png"; @@ -53,7 +54,6 @@ import trackerNoTasks from "assets/icons/trackerNoTasks.svg"; import project from "assets/icons/trackerProject.svg"; import tasks from "assets/icons/trackerTasks.svg"; import accept from "assets/images/accept.png"; -import archive from "assets/images/archiveIcon.png"; import avatarMok from "assets/images/avatarMok.png"; import { getCorrectDate } from "../../utils/calendarHelper"; @@ -85,7 +85,6 @@ export const ProjectTracker = () => { const [filteredNoTasks, setFilteredNoTasks] = useState(false); const [checkBoxMyTasks, setCheckBoxMyTasks] = useState(false); const [selectedExecutor, setSelectedExecutor] = useState(null); - const [selectExecutorOpen, setSelectedExecutorOpen] = useState(false); const startWrapperIndexTest = useRef({}); const projectBoard = useSelector(getProjectBoard); const loader = useSelector(getBoarderLoader); @@ -288,11 +287,6 @@ export const ProjectTracker = () => { setCheckBoxMyTasks(!checkBoxMyTasks); } - function executorFilter(user) { - dispatch(filteredExecutorTasks(user.user_id)); - setSelectedExecutor(user); - } - function deleteSelectedExecutorFilter() { setSelectedExecutor(null); setCheckBoxParticipateTasks(false); @@ -394,18 +388,6 @@ export const ProjectTracker = () => { setPersonListOpen(false); } - if ( - event && - !path.find( - (div) => - div.classList && - (div.classList.contains("tasks__head__executor") || - div.classList.contains("tasks__head__executor-dropdown")) - ) - ) { - setSelectedExecutorOpen(false); - } - if ( event && !path.find( @@ -577,63 +559,14 @@ export const ProjectTracker = () => { {checkBoxMyTasks && accept} - {selectedExecutor ? ( -
-

{removeLast(selectedExecutor.user.fio)}

- avatar - delete -
- ) : ( -
- setSelectedExecutorOpen(!selectExecutorOpen) - } - > -

Выберите исполнителя

- arrow - {selectExecutorOpen && ( -
- {projectBoard.projectUsers.map((user) => { - return ( -
executorFilter(user)} - > -

{removeLast(user.user?.fio)}

- avatar -
- ); - })} -
- )} -
- )} + + +