import React, { useEffect, useState } from "react"; import { useDispatch, useSelector } from "react-redux"; import { getProjects, getToggleTab, modalToggle, setAllProjects, setToggleTab, } from "@redux/projectsTrackerSlice"; import { urlForLocal } from "@utils/helper"; import { apiRequest } from "@api/request"; import { getCorrectDate } from "@components/Calendar/calendarHelper"; import BaseButton from "@components/Common/BaseButton/BaseButton"; import { Footer } from "@components/Common/Footer/Footer"; import { Loader } from "@components/Common/Loader/Loader"; import TrackerModal from "@components/Modal/Tracker/TrackerModal/TrackerModal"; import { Navigation } from "@components/Navigation/Navigation"; import { ProfileBreadcrumbs } from "@components/ProfileBreadcrumbs/ProfileBreadcrumbs"; import { ProfileHeader } from "@components/ProfileHeader/ProfileHeader"; import ProjectTiket from "@components/ProjectTiket/ProjectTiket"; import search from "assets/icons/serchIcon.png"; import project from "assets/icons/trackerProject.svg"; import tasks from "assets/icons/trackerTasks.svg"; import archive from "assets/images/archiveIcon.png"; import avatarMok from "assets/images/avatarMok.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.user.fio}
{getCorrectDate(task.created_at)}{filterCompleteTasks.length} задач(а)
{task.title}
{getCorrectDate(task.updated_at)}
В архиве задач нет
{projects.filter((project) => project.status === 10).length}{" "} проект(ов)
{project.name}
{project.date}
В архиве проектов нет