import React, { useEffect, useRef, useState } from "react"; import { Link, useParams } from "react-router-dom"; import { ProfileHeader } from "../../components/ProfileHeader/ProfileHeader"; import { ProfileBreadcrumbs } from "../../components/ProfileBreadcrumbs/ProfileBreadcrumbs"; import { Footer } from "../../components/Footer/Footer"; import { Navigation } from "../../components/Navigation/Navigation"; import { Loader } from "../../components/Loader/Loader"; import { useDispatch, useSelector } from "react-redux"; import { apiRequest } from "../../api/request"; import { getProjectBoard, getBoarderLoader, modalToggle, moveProjectTask, setProjectBoardFetch, setToggleTab, activeLoader, setColumnName, setColumnId, } from "../../redux/projectsTrackerSlice"; import ModalTicket from "../../components/UI/ModalTicket/ModalTicket"; import TrackerModal from "../../components/UI/TrackerModal/TrackerModal"; import project from "../../images/trackerProject.svg"; import tasks from "../../images/trackerTasks.svg"; import archive from "../../images/archiveTracker.svg"; import avatarTest from "../../images/AvatarTest .png"; import selectArrow from "../../images/select.svg"; import commentsBoard from "../../images/commentsBoard.svg"; import filesBoard from "../../images/filesBoard.svg"; import arrow from "../../images/arrowCalendar.png"; import del from "../../images/delete.svg"; import edit from "../../images/edit.svg"; export const ProjectTracker = () => { const dispatch = useDispatch(); const projectId = useParams(); const [openColumnSelect, setOpenColumnSelect] = useState({}); const [selectedTab, setSelectedTab] = useState(0); const [wrapperHover, setWrapperHover] = useState({}); const [modalAdd, setModalAdd] = useState(false); const [modalActiveTicket, setModalActiveTicket] = useState(false); const [selectedTicket, setSelectedTicket] = useState({}); const startWrapperIndexTest = useRef({}); const projectBoard = useSelector(getProjectBoard); const loader = useSelector(getBoarderLoader); useEffect(() => { dispatch(activeLoader()); dispatch(setProjectBoardFetch(projectId.id)); }, []); useEffect(() => { if (Object.keys(projectBoard).length) { projectBoard.columns.forEach((column) => { setOpenColumnSelect((prevState) => ({ ...prevState, [column.id]: false, })); setWrapperHover((prevState) => ({ ...prevState, [column.id]: false })); }); } }, [projectBoard]); // function toggleMoreTasks(columnId) { // setTabTaskMok((prevArray) => // prevArray.map((elem, index) => { // if (columnId === index) { // return { ...elem, open: !elem.open }; // } else { // return elem; // } // }) // ); // } function dragStartHandler(e, task, columnId) { startWrapperIndexTest.current = { task: task, index: columnId }; setTimeout(() => { e.target.classList.add("tasks__board__item__hide"); }, 0); } function dragEndHandler(e) { setWrapperHover((prevState) => ({ [prevState]: false, })); e.target.classList.remove("tasks__board__item__hide"); } function dragOverHandler(e) { e.preventDefault(); } function dragEnterHandler(columnId) { if (columnId === startWrapperIndexTest.current.index) { return; } setWrapperHover((prevState) => ({ [prevState]: false, [columnId]: true, })); } function dragDropHandler(e, columnId) { e.preventDefault(); if (startWrapperIndexTest.current.index === columnId) { return; } setWrapperHover((prevState) => ({ [prevState]: false, })); if (columnId !== startWrapperIndexTest.current.index) { dispatch( moveProjectTask({ startWrapperIndex: startWrapperIndexTest.current, columnId, }) ); } } function selectedTabTask(columnId) { setSelectedTab(columnId); dispatch(modalToggle("createTiketProject")); setModalAdd(true); } function openTicket(e, task) { setSelectedTicket(task); setModalActiveTicket(true); } function deleteColumn(id) { apiRequest("/project-column/update-column", { method: "PUT", data: { column_id: id, project_id: projectBoard.id, status: 0, }, }).then((res) => { dispatch(setProjectBoardFetch(projectBoard.id)); }); } return (

Управление проектами с трекером

dispatch(setToggleTab(1))} > img

Проекты

dispatch(setToggleTab(2))} > img

Все мои задачи

dispatch(setToggleTab(3))} > img

Архив

{loader && } {!loader && (

Проект : {projectBoard.name}

{ dispatch(modalToggle("createColumn")); setModalAdd(true); }} > +

добавить колонку

{/*avatar*/} {/*avatar*/} {projectBoard.projectUsers?.length} { dispatch(modalToggle("addWorker")); setModalAdd(true); }} > +

добавить участника

Участвую arrow
Мои arrow

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

arrow
{Boolean(modalActiveTicket) && }
{Boolean(projectBoard?.columns) && Boolean(projectBoard.columns.length) && projectBoard.columns.map((column) => { return (
dragOverHandler(e)} onDragEnter={(e) => dragEnterHandler(column.id)} onDrop={(e) => dragDropHandler(e, column.id)} className={`tasks__board ${ column.tasks.length >= 3 ? "tasks__board__more" : "" } ${ wrapperHover[column.id] ? "tasks__board__hover" : "" }`} >
{/**/} {column.title}
selectedTabTask(column.id)} > + { setOpenColumnSelect((prevState) => ({ ...prevState, [column.id]: true, })); }} className="more" > ...
{openColumnSelect[column.id] && (
{ setOpenColumnSelect((prevState) => ({ ...prevState, [column.id]: false, })); dispatch(modalToggle("editColumn")); dispatch(setColumnName(column.title)) dispatch(setColumnId(column.id)) setModalAdd(true); }} > edit Изменить
deleteColumn(column.id)} > delete Удалить
)} {column.tasks.map((task, index) => { if (index > 2) { if (!column.open) { return; } } return (
dragStartHandler(e, task, column.id) } onDragEnd={(e) => dragEndHandler(e)} onClick={(e) => openTicket(e, task)} >

{task.title}

{task.description}

commentsImg {task.comments} коментариев
filesImg {task.files} файлов
{/*
*/} {/* avatar*/} {/* avatar*/} {/*
*/}
); })} {column.tasks.length > 3 && ( toggleMoreTasks(column.id)} > {column.open ? "-" : "+"} )}
); })} {Boolean(projectBoard?.columns) && !Boolean(projectBoard.columns.length) && (
В проекте нет задач.
)}
)}
); };