From 35f76abe60b08a715f61c19f21f808bf41254a90 Mon Sep 17 00:00:00 2001 From: Mikola Date: Sun, 31 Mar 2024 20:38:16 +0300 Subject: [PATCH] all tasks table --- src/pages/Tracker/Tracker.jsx | 90 ++++++++++++++++++++++++----------- 1 file changed, 62 insertions(+), 28 deletions(-) diff --git a/src/pages/Tracker/Tracker.jsx b/src/pages/Tracker/Tracker.jsx index a245f124..7f74b6bb 100644 --- a/src/pages/Tracker/Tracker.jsx +++ b/src/pages/Tracker/Tracker.jsx @@ -1,11 +1,11 @@ -import React, { useEffect, useState } from "react"; -import { useDispatch, useSelector } from "react-redux"; import { getTheme } from "@table-library/react-table-library/baseline"; import { CompactTable } from "@table-library/react-table-library/compact"; import { usePagination } from "@table-library/react-table-library/pagination"; import { useSort } from "@table-library/react-table-library/sort"; import { useTheme } from "@table-library/react-table-library/theme"; -import { getCorrectDate } from "@utils/calendarHelper"; +import React, { useEffect, useState } from "react"; +import { useDispatch, useSelector } from "react-redux"; +import { Link } from "react-router-dom"; import { getProjects, @@ -15,6 +15,7 @@ import { setToggleTab } from "@redux/projectsTrackerSlice"; +import { getCorrectDate } from "@utils/calendarHelper"; import { caseOfNum, urlForLocal } from "@utils/helper"; import { apiRequest } from "@api/request"; @@ -32,6 +33,7 @@ import ProjectTicket from "@components/ProjectTicket/ProjectTicket"; import addProjectImg from "assets/icons/addProjectImg.svg"; import archiveTrackerProjects from "assets/icons/archiveTrackerProjects.svg"; +import rightArrow from "assets/icons/arrows/arrowRight.svg"; import arrowViewReport from "assets/icons/arrows/arrowViewReport.svg"; import filterIcon from "assets/icons/filterIcon.svg"; import searchImg from "assets/icons/serchIcon.png"; @@ -44,8 +46,6 @@ import noProjects from "assets/images/noProjects.png"; import statusTimeTask from "assets/images/statusTimeTask.svg"; import "./tracker.scss"; -import { Link } from "react-router-dom"; -import rightArrow from "assets/icons/arrows/arrowRight.svg"; export const Tracker = () => { const dispatch = useDispatch(); @@ -67,22 +67,34 @@ export const Tracker = () => { const COLUMNS = [ { label: "Задача", - renderCell: (item) =>

, + renderCell: (item) => ( +

+ ), sort: { sortKey: "NAME" } }, { label: "Создано", renderCell: (item) => {getCorrectDate(item.created_at)}, - sort: { sortKey: "CREATE" }, + sort: { sortKey: "CREATE" } }, { label: "Дедлайн", - renderCell: (item) => {item.dead_line ? getCorrectDate(item.dead_line) : 'Без дедлайна'}, + renderCell: (item) => ( + + {item.dead_line ? getCorrectDate(item.dead_line) : "Без дедлайна"} + + ), sort: { sortKey: "DEADLINE" } }, { label: "Потраченное время", - renderCell: (item) => {item.timers.length ? getSpendTime(item.timers) : 'Трекер не был включен'}, + renderCell: (item) => ( + + {item.timers.length + ? getSpendTime(item.timers) + : "Трекер не был включен"} + + ), sort: { sortKey: "SPEND" } } ]; @@ -97,9 +109,15 @@ export const Tracker = () => { { sortFns: { NAME: (array) => array.sort((a, b) => a.title.localeCompare(b.title)), - CREATE: (array) => array.sort((a, b) => new Date(a.created_at) - new Date(b.created_at)), - DEADLINE: (array) => array.sort((a, b) => new Date(a.dead_line) - new Date(b.dead_line)), - SPEND: (array) => array.sort((a, b) => getSpendTime(a.timers, true) - getSpendTime(b.timers, true)), + CREATE: (array) => + array.sort((a, b) => new Date(a.created_at) - new Date(b.created_at)), + DEADLINE: (array) => + array.sort((a, b) => new Date(a.dead_line) - new Date(b.dead_line)), + SPEND: (array) => + array.sort( + (a, b) => + getSpendTime(a.timers, true) - getSpendTime(b.timers, true) + ) } } ); @@ -115,11 +133,13 @@ export const Tracker = () => { let timerSeconds = 0; times.forEach((time) => { timerSeconds += time.deltaSeconds; - }) + }); if (seconds) { - return timerSeconds + return timerSeconds; } - return `${Math.floor(timerSeconds / 60 / 60)}:${Math.floor((timerSeconds / 60) % 60)}:${timerSeconds % 60}` + return `${Math.floor(timerSeconds / 60 / 60)}:${Math.floor( + (timerSeconds / 60) % 60 + )}:${timerSeconds % 60}`; } function onSortChange(action, state) { @@ -130,9 +150,7 @@ export const Tracker = () => { setSearch(event.target.value); setNodes( initialNodes.filter((item) => - item.title - .toLowerCase() - .includes(event.target.value.toLowerCase()) + item.title.toLowerCase().includes(event.target.value.toLowerCase()) ) ); }; @@ -169,8 +187,8 @@ export const Tracker = () => { : []; setAllTasks(allTasks); setFilteredAllTasks(allTasks); - setNodes(allTasks) - setInitialNodes(allTasks) + setNodes(allTasks); + setInitialNodes(allTasks); setAllCompletedTasks(completedTasks); setFilterCompleteTasks(completedTasks); }) @@ -365,10 +383,12 @@ export const Tracker = () => { {/* */} {/**/} - {loader ? : + {loader ? ( + + ) : ( <> -
- search +
+ search { />
- } + )} {/*