import React, { useEffect, useState } from "react"; import { useDispatch, useSelector } from "react-redux"; import { setAllProjects, getProjects, setToggleTab, getToggleTab, modalToggle, } from "../../redux/projectsTrackerSlice"; import { ProfileHeader } from "../../components/ProfileHeader/ProfileHeader"; import { ProfileBreadcrumbs } from "../../components/ProfileBreadcrumbs/ProfileBreadcrumbs"; import { Footer } from "../../components/Footer/Footer"; import { apiRequest } from "../../api/request"; import { Navigation } from "../../components/Navigation/Navigation"; import TrackerModal from "../../components/UI/TrackerModal/TrackerModal"; import ProjectTiket from "../../components/ProjectTiket/ProjectTiket"; import { urlForLocal } from "../../helper"; import { getCorrectDate } from "../../components/Calendar/calendarHelper"; import { Loader } from "../../components/Loader/Loader"; import project from "../../assets/icons/trackerProject.svg"; import tasks from "../../assets/icons/trackerTasks.svg"; import archive from "../../assets/icons/archiveTracker.svg"; import search from "../../assets/icons/serchIcon.png"; import noProjects from "../../assets/images/noProjects.png"; import "./tracker.scss"; export const Tracker = () => { const dispatch = useDispatch(); const projects = useSelector(getProjects); const tab = useSelector(getToggleTab); const [allTasks, setAllTasks] = useState([]); const [filteredAllTasks, setFilteredAllTasks] = useState([]); const [loader, setLoader] = useState(false); const [filterCompleteTasks, setFilterCompleteTasks] = useState([]); const [allCompletedTasks, setAllCompletedTasks] = useState([]); const [modalCreateProject, setModalCreateProject] = useState(false); useEffect(() => { setLoader(true); apiRequest( `/project/project-list?user_id=${localStorage.getItem( "id" )}&expand=columns` ).then((el) => { dispatch(setAllProjects(el.projects)); setLoader(false); // setAllCompletedTasks(el.projects.filter((project) => { // if (project.status === 10 && project.columns.length) { // return project // } // }).map((project) => { return project.columns}).reduce((acu, curr) => { // curr.forEach((item) => { // acu.push(...item.tasks) // }) // return acu // }, [])) }); apiRequest( `/task/get-user-tasks?user_id=${localStorage.getItem("id")}` ).then((el) => { const allTasks = el.filter((item) => item.status !== 0); const completedTasks = el.filter((item) => item.status === 0); setAllTasks(allTasks); setFilteredAllTasks(allTasks); setAllCompletedTasks(completedTasks); setFilterCompleteTasks(completedTasks); }); }, []); const toggleTabs = (index) => { dispatch(setToggleTab(index)); }; function filterAllTask(e) { setFilteredAllTasks( allTasks.filter((item) => { if (!e.target.value) { return item; } if ( item.title.toLowerCase().startsWith(e.target.value.toLowerCase()) || item.description .toLowerCase() .startsWith(e.target.value.toLowerCase()) ) { return item; } }) ); } function filterArchiveTasks(e) { setFilterCompleteTasks( allCompletedTasks.filter((item) => { if (!e.target.value) { return item; } if ( item.title.toLowerCase().startsWith(e.target.value.toLowerCase()) || item.description .toLowerCase() .startsWith(e.target.value.toLowerCase()) ) { return item; } }) ); } return (
Проекты
Все мои задачи
Архив
Создайте свой первый проект
Ставьте задачи, следите за прогрессом, ведите учёт рабочего времени
Ставьте задачи, следите за прогрессом, ведите учёт рабочего времени
{task.description}
{task.user.fio}
{getCorrectDate(task.created_at)}{filterCompleteTasks.length} задач(а)
{task.title}
{task.description}
{getCorrectDate(task.updated_at)}
В архиве задач нет
{projects.filter((project) => project.status === 10).length}{" "} проект(ов)
{project.name}
{project.date}
В архиве проектов нет