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/Common/Footer/Footer"; import { Navigation } from "../../components/Navigation/Navigation"; import { Loader } from "@components/Common/Loader/Loader"; import { urlForLocal } from '../../utils/helper' import { useDispatch, useSelector } from "react-redux"; import { apiRequest } from "../../api/request"; import { getProjectBoard, getBoarderLoader, modalToggle, moveProjectTask, setProjectBoardFetch, setToggleTab, activeLoader, setColumnName, setColumnId, setColumnPriority, deletePersonOnProject, filterCreatedByMe, filteredParticipateTasks } from "../../redux/projectsTrackerSlice"; import ModalTicket from "../../components/UI/ModalTicket/ModalTicket"; import TrackerModal from "../../components/Modal/TrackerModal/TrackerModal"; import project from "../../assets/icons/trackerProject.svg"; import tasks from "../../assets/icons/trackerTasks.svg"; import archive from "../../assets/icons/archiveTracker.svg"; import commentsBoard from "../../assets/icons/commentsBoard.svg"; import filesBoard from "../../assets/icons/filesBoard.svg"; import arrow from "../../assets/icons/arrows/arrowCalendar.png"; import del from "../../assets/icons/delete.svg"; import edit from "../../assets/icons/edit.svg"; import close from "../../assets/icons/close.png" import accept from "../../assets/images/accept.png"; export const ProjectTracker = () => { const dispatch = useDispatch(); const projectId = useParams(); const [openColumnSelect, setOpenColumnSelect] = useState({}); const [selectedTab, setSelectedTab] = useState(0); const [priorityTask, setPriorityTask] = useState(0); const [wrapperHover, setWrapperHover] = useState({}); const [modalAdd, setModalAdd] = useState(false); const [modalActiveTicket, setModalActiveTicket] = useState(false); const [selectedTicket, setSelectedTicket] = useState({}); const [personListOpen, setPersonListOpen] = useState(false) const [checkBoxParticipateTasks, setCheckBoxParticipateTasks] = useState(false) const [checkBoxMyTasks, setCheckBoxMyTasks] = useState(false) 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 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, length) { setSelectedTab(columnId); dispatch(modalToggle("createTiketProject")); setModalAdd(true); setPriorityTask(length + 1) } function openTicket(e, task) { setSelectedTicket(task); setModalActiveTicket(true); } function deleteColumn(column) { const priorityColumns = [] apiRequest("/project-column/update-column", { method: "PUT", data: { column_id: column.id, project_id: projectBoard.id, status: 0, }, }).then(() => { if (column.priority < projectBoard.columns.length) { for (let i = column.priority; i < projectBoard.columns.length; i++) { const currentColumn = { column_id: projectBoard.columns[i].id, priority: i } priorityColumns.push(currentColumn) } apiRequest("/project-column/set-priority", { method: "POST", data: { project_id: projectBoard.id, data: JSON.stringify(priorityColumns) } }).then(() => { dispatch(setProjectBoardFetch(projectBoard.id)); }) } else { dispatch(setProjectBoardFetch(projectBoard.id)); } }); } function deletePerson(userId) { apiRequest("/project/del-user", { method: "DELETE", data: { project_id: projectBoard.id, user_id: userId }, }).then(() => { dispatch(deletePersonOnProject(userId)) }); } function filterParticipateTasks() { if (!checkBoxParticipateTasks) { dispatch(filteredParticipateTasks(Number(localStorage.getItem('id')))) } else { dispatch(setProjectBoardFetch(projectId.id)) setCheckBoxParticipateTasks(false) setCheckBoxMyTasks(false) } setCheckBoxParticipateTasks(!checkBoxParticipateTasks) } function filterMyTask() { if (!checkBoxMyTasks) { dispatch(filterCreatedByMe(Number(localStorage.getItem('id')))) } else { dispatch(setProjectBoardFetch(projectId.id)) setCheckBoxParticipateTasks(false) setCheckBoxMyTasks(false) } setCheckBoxMyTasks(!checkBoxMyTasks) } return (
Проекты
dispatch(setToggleTab(2))} >Все мои задачи
dispatch(setToggleTab(3))} >Архив
добавить колонку
добавить участника
{personListOpen &&Добавить участников
Вернуться на проекты
{task.title}
{task.description}