import React, {useEffect, useRef, useState} from "react"; import {Link} from "react-router-dom"; import { ProfileHeader } from "../../components/ProfileHeader/ProfileHeader"; import { ProfileBreadcrumbs } from "../../components/ProfileBreadcrumbs/ProfileBreadcrumbs"; import { Footer } from "../../components/Footer/Footer"; import { useDispatch, useSelector } from "react-redux"; import {getProjectBoard, moveProjectTask, setProjectBoardFetch, setToggleTab} from "../../redux/projectsTrackerSlice"; import ModalTicket from "../../components/UI/ModalTicket/ModalTicket"; import ModalAdd from "../../components/UI/ModalAdd/ModalAdd"; 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 {apiRequest} from "../../api/request"; import { Navigation } from "../../components/Navigation/Navigation"; export const ProjectTracker = () => { const dispatch = useDispatch(); const currentUrl = useState(window.location.pathname) const projectId = currentUrl[0].split('/').at(-1) useEffect(() => { dispatch(setProjectBoardFetch(projectId)) }, []) // Modal State const [modalActiveTicket, setModalActiveTicket] = useState(false); const [selectedTicket, setSelectedTicket] = useState({}); const [modalAddWorker, setModalAddWorker] = useState(false); const [modalCreateColl, setModalCreateColl] = useState(false); const [modalCreateTiket, setModalCreateTiket] = useState(false); const [valueTiket, setValueTiket] = useState(""); const [descriptionTicket, setDescriptionTicket] = useState("") const [valueColl, setValueColl] = useState(""); // const [selectedTab, setSelectedTab] = useState(0); const startWrapperIndexTest = useRef({}) const [wrapperHover, setWrapperHover] = useState([ false, false, false, false, ]); const projectBoard = useSelector(getProjectBoard); // 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((prevArray) => prevArray.map((elem) => { return false; }) ); e.target.classList.remove("tasks__board__item__hide"); } function dragOverHandler(e) { e.preventDefault(); } function dragEnterHandler(columnId) { if (columnId === startWrapperIndexTest.current.index) { return; } setWrapperHover((prevArray) => prevArray.map((elem, index) => { if (index === columnId) { return true; } else { return false; } }) ); } function dragDropHandler(e, columnId) { e.preventDefault(); if (startWrapperIndexTest.current.index === columnId) { return; } setWrapperHover((prevArray) => prevArray.map((elem) => { return false; }) ); if (columnId !== startWrapperIndexTest.current.index) { dispatch(moveProjectTask({startWrapperIndex: startWrapperIndexTest.current, columnId})) } } function selectedTabTask(columnId) { setSelectedTab(columnId); setModalCreateTiket(true); } function openTicket(e, task) { setSelectedTicket(task); setModalActiveTicket(true); } function createTiket() { if (!valueTiket || !descriptionTicket) { return } apiRequest('/task/create-task', { method: 'POST', data: { project_id: projectBoard.id, title: valueTiket, description: descriptionTicket, status: 1, user_id: localStorage.getItem('id'), column_id: selectedTab } }).then((res) => { dispatch(setProjectBoardFetch(projectBoard.id)) }) setModalCreateTiket(false); setValueTiket(""); setDescriptionTicket("") } function createTab() { if (!valueColl) { return } apiRequest('/project-column/create-column', { method: 'POST', data: { project_id: projectBoard.id, title: valueColl } }).then((res) => { dispatch(setProjectBoardFetch(projectBoard.id)) }) setValueColl(""); setModalCreateColl(false); } return (
Проекты
dispatch(setToggleTab(2))} >Все мои задачи
dispatch(setToggleTab(3))} >Архив
Введите имя или e-mail{" "}
добавить колонку
добавить участника
Вернуться на проекты
{task.title}
{task.description}