import React, { useState } from "react"; import { ProfileHeader } from "../../components/ProfileHeader/ProfileHeader"; import { Footer } from "../../components/Footer/Footer"; import ModalTiket from "../../components/UI/ModalTiket/ModalTiket"; import ModalProject from "../../components/UI/ModalProject/ModalProject"; 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 "./tracker.scss"; export const Tracker = () => { const [toggleTab, setToggleTab] = useState(1); const [projects] = useState([ { name: "Разработка трекера", count: 4, }, { name: "Кинотеатр", count: 4, }, { name: "Проект страхование", count: 4, }, ]); const [tabTaskMok, setTabTaskMok] = useState([ { name: "Открытые", tasks: [ { task: "PR - 2245", description: "Сверстать часть таблицы. Сверстать часть таблицы", comments: 12, files: 0, avatarCreated: avatarTest, avatarDo: avatarTest, id: 1 }, { task: "PR - 2245", description: "Сверстать часть таблицы. Сверстать часть таблицы", comments: 12, files: 0, avatarCreated: avatarTest, avatarDo: avatarTest, id: 2 }, ], }, { name: "В процессе", tasks: [ { task: "PR - 2245", description: "Сверстать часть таблицы. Сверстать часть таблицы", comments: 12, files: 0, avatarCreated: avatarTest, avatarDo: avatarTest, id: 3 }, ], }, { name: "На проверке", tasks: [ { task: "PR - 2245", description: "Сверстать часть таблицы. Сверстать часть таблицы", comments: 12, files: 0, avatarCreated: avatarTest, avatarDo: avatarTest, id: 4 }, { task: "PR - 2245", description: "Сверстать часть таблицы. Сверстать часть таблицы", comments: 12, files: 0, avatarCreated: avatarTest, avatarDo: avatarTest, id: 5 }, { task: "PR - 2245", description: "Сверстать часть таблицы. Сверстать часть таблицы", comments: 12, files: 0, avatarCreated: avatarTest, avatarDo: avatarTest, id: 6 }, ], }, { name: "Готово", tasks: [ { task: "PR - 2245", description: "Сверстать часть таблицы. Сверстать часть таблицы", comments: 12, files: 0, avatarCreated: avatarTest, avatarDo: avatarTest, id: 7 }, { task: "PR - 2245", description: "Сверстать часть таблицы. Сверстать часть таблицы", comments: 12, files: 0, avatarCreated: avatarTest, avatarDo: avatarTest, id: 8 }, ], }, ]); const [modalActiveTicket, setModalActiveTicket] = useState(false); const [modalActiveProject, setModalActiveProject] = useState(false); const [startWrapperIndex, setStartWrapperIndex] = useState(null) const [wrapperHover, setWrapperHover] = useState([false, false, false, false]) const toggleTabs = (index) => { setToggleTab(index); }; function dragStartHandler(e, task, wrapperIndex) { setStartWrapperIndex({task: task, index: wrapperIndex}) 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(wrapperIndex) { if (wrapperIndex === startWrapperIndex.index) { return } setWrapperHover(prevArray => prevArray.map((elem, index) => { if (index === wrapperIndex) { return true } else { return false } })) } function dragDropHandler(e, wrapperIndex) { e.preventDefault() if (startWrapperIndex.index === wrapperIndex) { return } setWrapperHover(prevArray => prevArray.map((elem) => { return false })) setTabTaskMok(prevArray => prevArray.map((elem, index) => { if (index === wrapperIndex) { return {...elem, tasks: [...elem.tasks, startWrapperIndex.task]} } else if (index === startWrapperIndex.index) { return {...elem, tasks: elem.tasks.filter((item) => { return item.id !== startWrapperIndex.task.id } )} } else { return elem } })) } return (

Трекер

toggleTabs(1)} > img

Проекты

toggleTabs(2)} > img

Задачи

toggleTabs(3)} > img

Архив

{projects.map((project, index) => { return (

{project.name}

Открытые задачи

{project.count} +
); })}

Проект : Разработка трекера

+
avatar avatar avatar avatar +9
Учавствую arrow
Мои arrow
{tabTaskMok.map((section, wrapperIndex) => { return (
dragOverHandler(e)} onDragEnter={(e) => dragEnterHandler(wrapperIndex)} onDrop={(e) => dragDropHandler(e, wrapperIndex)} className={`tasks__board ${section.tasks.length >= 3 ? 'tasks__board__more' : ''} ${wrapperHover[wrapperIndex] ? 'tasks__board__hover' : ''}`} >
{section.name}
+ ...
{section.tasks.map((task, index) => { return (
dragStartHandler(e, task, wrapperIndex)} onDragEnd={(e) => dragEndHandler(e)} onClick={() => setModalActiveTicket(true)} >

{task.task}

...

{task.description}

commentsImg {task.comments} коментариев
filesImg {task.files} файлов
avatar avatar
); })} {section.tasks.length >= 3 && ( + )}
); })}
); };