2023-05-02 18:51:19 +03:00
|
|
|
|
import React, {useEffect, useState} from "react";
|
2023-02-17 15:19:49 +03:00
|
|
|
|
|
2023-03-07 19:40:52 +03:00
|
|
|
|
import { ProfileHeader } from "../../components/ProfileHeader/ProfileHeader";
|
2023-04-10 21:22:22 +03:00
|
|
|
|
import { ProfileBreadcrumbs } from "../../components/ProfileBreadcrumbs/ProfileBreadcrumbs";
|
2023-03-07 19:40:52 +03:00
|
|
|
|
import { Footer } from "../../components/Footer/Footer";
|
2023-05-02 19:41:51 +03:00
|
|
|
|
import {apiRequest} from "../../api/request";
|
|
|
|
|
import { Navigation } from "../../components/Navigation/Navigation";
|
2023-03-03 18:49:02 +03:00
|
|
|
|
|
2023-03-23 21:18:48 +03:00
|
|
|
|
import { useDispatch, useSelector } from "react-redux";
|
2023-05-02 18:51:19 +03:00
|
|
|
|
import { setAllProjects, getProjects, setToggleTab, getToggleTab } from "../../redux/projectsTrackerSlice";
|
2023-03-23 21:18:48 +03:00
|
|
|
|
|
2023-03-22 21:48:06 +03:00
|
|
|
|
import ModalCreate from "../../components/UI/ModalCreate/ModalCreate";
|
2023-04-14 15:52:21 +03:00
|
|
|
|
import ProjectTiket from "../../components/ProjectTiket/ProjectTiket";
|
2023-05-02 19:41:51 +03:00
|
|
|
|
import { urlForLocal } from '../../helper'
|
|
|
|
|
import { getCorrectDate} from "../../components/Calendar/calendarHelper";
|
2023-03-08 11:36:34 +03:00
|
|
|
|
|
2023-03-07 19:40:52 +03:00
|
|
|
|
import project from "../../images/trackerProject.svg";
|
|
|
|
|
import tasks from "../../images/trackerTasks.svg";
|
|
|
|
|
import archive from "../../images/archiveTracker.svg";
|
|
|
|
|
import avatarTest from "../../images/AvatarTest .png";
|
2023-03-30 15:07:05 +03:00
|
|
|
|
import search from "../../images/serchIcon.png";
|
2023-04-10 21:22:22 +03:00
|
|
|
|
import noProjects from "../../images/noProjects.png";
|
2023-03-03 18:49:02 +03:00
|
|
|
|
|
2023-04-27 14:51:01 +03:00
|
|
|
|
import "./tracker.scss";
|
|
|
|
|
|
2023-02-17 15:19:49 +03:00
|
|
|
|
export const Tracker = () => {
|
2023-04-28 14:56:59 +03:00
|
|
|
|
const dispatch = useDispatch();
|
2023-05-02 18:51:19 +03:00
|
|
|
|
const projects = useSelector(getProjects);
|
|
|
|
|
const tab = useSelector(getToggleTab)
|
2023-05-02 19:41:51 +03:00
|
|
|
|
const [allTasks, setAllTasks] = useState([])
|
|
|
|
|
const [filteredAllTasks, setFilteredAllTasks] = useState([]);
|
2023-03-30 15:07:05 +03:00
|
|
|
|
|
|
|
|
|
const [archiveProjects] = useState([
|
2023-04-10 21:22:22 +03:00
|
|
|
|
{
|
|
|
|
|
name: "Будущее России",
|
|
|
|
|
date: "7 марта 2023 г",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "Будущее России",
|
|
|
|
|
date: "7 марта 2023 г",
|
2023-05-02 19:41:51 +03:00
|
|
|
|
}
|
2023-04-10 21:22:22 +03:00
|
|
|
|
]);
|
2023-03-30 15:07:05 +03:00
|
|
|
|
|
2023-03-13 23:33:12 +03:00
|
|
|
|
const [completeTasks] = useState([
|
|
|
|
|
{
|
|
|
|
|
name: "PR - 2245",
|
|
|
|
|
description: "Сверстать часть таблицы. Сверстать часть таблицы",
|
2023-03-30 15:07:05 +03:00
|
|
|
|
dateComplete: "7 марта 2023 г",
|
2023-03-13 23:33:12 +03:00
|
|
|
|
avatarDo: avatarTest,
|
2023-04-10 21:22:22 +03:00
|
|
|
|
project: "Будущее России",
|
2023-03-13 23:33:12 +03:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "PR - 2245",
|
|
|
|
|
description: "Сверстать часть таблицы. Сверстать часть таблицы",
|
2023-03-30 15:07:05 +03:00
|
|
|
|
dateComplete: "7 марта 2023 г",
|
2023-03-13 23:33:12 +03:00
|
|
|
|
avatarDo: avatarTest,
|
2023-04-10 21:22:22 +03:00
|
|
|
|
project: "Будущее России",
|
2023-03-13 23:33:12 +03:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "PR - 2245",
|
|
|
|
|
description: "Сверстать часть таблицы. Сверстать часть таблицы",
|
2023-03-30 15:07:05 +03:00
|
|
|
|
dateComplete: "7 марта 2023 г",
|
2023-03-13 23:33:12 +03:00
|
|
|
|
avatarDo: avatarTest,
|
2023-04-10 21:22:22 +03:00
|
|
|
|
project: "Будущее России",
|
2023-05-02 19:41:51 +03:00
|
|
|
|
}
|
2023-03-22 21:48:06 +03:00
|
|
|
|
]);
|
2023-03-13 23:33:12 +03:00
|
|
|
|
|
2023-03-22 21:48:06 +03:00
|
|
|
|
const [filterCompleteTasks, setFilterCompleteTasks] = useState(completeTasks);
|
2023-03-13 23:33:12 +03:00
|
|
|
|
|
2023-03-24 19:26:27 +03:00
|
|
|
|
// Modal State
|
2023-03-22 21:48:06 +03:00
|
|
|
|
const [modalCreateProject, setModalCreateProject] = useState(false);
|
|
|
|
|
|
2023-04-27 14:51:01 +03:00
|
|
|
|
useEffect(() => {
|
|
|
|
|
apiRequest(`/project/project-list?user_id=${localStorage.getItem('id')}&expand=columns`).then((el) => {
|
2023-04-28 14:56:59 +03:00
|
|
|
|
dispatch(setAllProjects(el.projects))
|
2023-04-27 14:51:01 +03:00
|
|
|
|
})
|
2023-05-02 19:41:51 +03:00
|
|
|
|
apiRequest(`/task/get-user-tasks?user_id=${localStorage.getItem('id')}`).then((el) => {
|
|
|
|
|
setAllTasks(el)
|
|
|
|
|
setFilteredAllTasks(el)
|
|
|
|
|
})
|
2023-04-27 14:51:01 +03:00
|
|
|
|
}, [])
|
|
|
|
|
|
2023-03-07 19:40:52 +03:00
|
|
|
|
const toggleTabs = (index) => {
|
2023-05-02 18:51:19 +03:00
|
|
|
|
dispatch(setToggleTab(index))
|
2023-03-07 19:40:52 +03:00
|
|
|
|
};
|
2023-03-10 01:20:15 +03:00
|
|
|
|
|
2023-05-02 19:41:51 +03:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-13 23:33:12 +03:00
|
|
|
|
function filterArchiveTasks(e) {
|
2023-03-22 21:48:06 +03:00
|
|
|
|
setFilterCompleteTasks(
|
|
|
|
|
completeTasks.filter((item) => {
|
|
|
|
|
if (!e.target.value) {
|
|
|
|
|
return item;
|
|
|
|
|
}
|
|
|
|
|
if (
|
|
|
|
|
item.name.toLowerCase().startsWith(e.target.value.toLowerCase()) ||
|
|
|
|
|
item.description
|
|
|
|
|
.toLowerCase()
|
|
|
|
|
.startsWith(e.target.value.toLowerCase())
|
|
|
|
|
) {
|
|
|
|
|
return item;
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-07 19:40:52 +03:00
|
|
|
|
return (
|
|
|
|
|
<div className="tracker">
|
|
|
|
|
<ProfileHeader />
|
2023-04-19 20:22:06 +03:00
|
|
|
|
<Navigation />
|
2023-03-07 19:40:52 +03:00
|
|
|
|
<div className="container">
|
|
|
|
|
<div className="tracker__content">
|
2023-04-10 21:22:22 +03:00
|
|
|
|
<ProfileBreadcrumbs
|
|
|
|
|
links={[
|
|
|
|
|
{ name: "Главная", link: "/profile" },
|
|
|
|
|
{ name: "Трекер", link: "/profile/tracker" },
|
|
|
|
|
]}
|
2023-03-23 16:18:57 +03:00
|
|
|
|
/>
|
2023-03-30 15:07:05 +03:00
|
|
|
|
<h2 className="tracker__title">Управление проектами с трекером</h2>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="tracker__tabs">
|
|
|
|
|
<div className="tracker__tabs__head">
|
|
|
|
|
<div
|
2023-05-02 18:51:19 +03:00
|
|
|
|
className={tab === 1 ? "tab active-tab" : "tab"}
|
2023-04-10 21:22:22 +03:00
|
|
|
|
onClick={() => toggleTabs(1)}
|
2023-03-30 15:07:05 +03:00
|
|
|
|
>
|
|
|
|
|
<img src={project} alt="img" />
|
|
|
|
|
<p>Проекты </p>
|
|
|
|
|
</div>
|
|
|
|
|
<div
|
2023-05-02 18:51:19 +03:00
|
|
|
|
className={tab === 2 ? "tab active-tab" : "tab"}
|
2023-04-10 21:22:22 +03:00
|
|
|
|
onClick={() => toggleTabs(2)}
|
2023-03-30 15:07:05 +03:00
|
|
|
|
>
|
|
|
|
|
<img src={tasks} alt="img" />
|
|
|
|
|
<p>Все мои задачи</p>
|
|
|
|
|
</div>
|
|
|
|
|
<div
|
2023-05-02 18:51:19 +03:00
|
|
|
|
className={tab === 3 ? "tab active-tab" : "tab"}
|
2023-04-10 21:22:22 +03:00
|
|
|
|
onClick={() => toggleTabs(3)}
|
2023-03-30 15:07:05 +03:00
|
|
|
|
>
|
|
|
|
|
<img src={archive} alt="img" />
|
|
|
|
|
<p>Архив</p>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="tracker__tabs__content">
|
|
|
|
|
<div
|
2023-04-10 21:22:22 +03:00
|
|
|
|
className={
|
2023-05-02 18:51:19 +03:00
|
|
|
|
tab === 1
|
2023-04-10 21:22:22 +03:00
|
|
|
|
? "tracker__tabs__content__projects active__content tracker__tabs__content__wrapper"
|
|
|
|
|
: "tracker__tabs__content__projects tracker__tabs__content__wrapper"
|
|
|
|
|
}
|
2023-03-30 15:07:05 +03:00
|
|
|
|
>
|
|
|
|
|
<ModalCreate
|
2023-04-10 21:22:22 +03:00
|
|
|
|
active={modalCreateProject}
|
|
|
|
|
setActive={setModalCreateProject}
|
|
|
|
|
title={"Укажите название проекта:"}
|
2023-03-30 15:07:05 +03:00
|
|
|
|
/>
|
2023-04-13 22:10:20 +03:00
|
|
|
|
|
2023-04-10 21:22:22 +03:00
|
|
|
|
{Boolean(projects.length) &&
|
2023-03-30 15:07:05 +03:00
|
|
|
|
projects.map((project, index) => {
|
|
|
|
|
return (
|
2023-04-14 15:52:21 +03:00
|
|
|
|
<ProjectTiket
|
|
|
|
|
key={index}
|
|
|
|
|
project={project}
|
|
|
|
|
></ProjectTiket>
|
2023-03-30 15:07:05 +03:00
|
|
|
|
);
|
|
|
|
|
})}
|
2023-05-02 18:51:19 +03:00
|
|
|
|
{!Boolean(projects.length) && (
|
2023-04-10 21:22:22 +03:00
|
|
|
|
<div className="no-projects">
|
|
|
|
|
<div className="no-projects__createNew">
|
|
|
|
|
<div>
|
|
|
|
|
<img src={noProjects} alt="noProjectImg" />
|
|
|
|
|
<p>Создайте свой первый проект</p>
|
2023-03-30 15:07:05 +03:00
|
|
|
|
</div>
|
2023-04-10 21:22:22 +03:00
|
|
|
|
<button
|
|
|
|
|
className="createProjectBtn"
|
|
|
|
|
onClick={() => setModalCreateProject(true)}
|
|
|
|
|
>
|
|
|
|
|
<span>+</span>Создать проект
|
|
|
|
|
</button>
|
2023-03-30 15:07:05 +03:00
|
|
|
|
</div>
|
2023-04-10 21:22:22 +03:00
|
|
|
|
<p className="no-projects__info">
|
|
|
|
|
Ставьте задачи, следите за прогрессом, ведите учёт рабочего
|
|
|
|
|
времени
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
2023-05-02 18:51:19 +03:00
|
|
|
|
{Boolean(projects.length) && (
|
2023-03-30 15:07:05 +03:00
|
|
|
|
<div className="create-newProject">
|
2023-04-10 21:22:22 +03:00
|
|
|
|
<button
|
|
|
|
|
className="createProjectBtn"
|
|
|
|
|
onClick={() => setModalCreateProject(true)}
|
|
|
|
|
>
|
2023-03-07 19:40:52 +03:00
|
|
|
|
<span>+</span>Создать проект
|
|
|
|
|
</button>
|
2023-04-10 21:22:22 +03:00
|
|
|
|
<p>
|
|
|
|
|
Ставьте задачи, следите за прогрессом, ведите учёт рабочего
|
|
|
|
|
времени
|
|
|
|
|
</p>
|
2023-03-07 19:40:52 +03:00
|
|
|
|
</div>
|
2023-04-10 21:22:22 +03:00
|
|
|
|
)}
|
2023-03-30 15:07:05 +03:00
|
|
|
|
</div>
|
|
|
|
|
<div
|
2023-04-10 21:22:22 +03:00
|
|
|
|
className={
|
2023-05-02 18:51:19 +03:00
|
|
|
|
tab === 2
|
2023-04-10 21:22:22 +03:00
|
|
|
|
? "tracker__tabs__content__allTasks taskList tasks active__content"
|
|
|
|
|
: "tracker__tabs__content__projects"
|
|
|
|
|
}
|
2023-03-30 15:07:05 +03:00
|
|
|
|
>
|
|
|
|
|
<div className="taskList__head">
|
|
|
|
|
<h3>Список всех задач</h3>
|
|
|
|
|
<div className="taskList__head__search">
|
|
|
|
|
<img src={search} alt="search" />
|
|
|
|
|
<input
|
2023-04-10 21:22:22 +03:00
|
|
|
|
type="text"
|
|
|
|
|
placeholder="Найти задачу"
|
2023-05-02 19:41:51 +03:00
|
|
|
|
onChange={(event) => filterAllTask(event)}
|
2023-03-30 15:07:05 +03:00
|
|
|
|
/>
|
2023-03-07 19:40:52 +03:00
|
|
|
|
</div>
|
2023-03-30 15:07:05 +03:00
|
|
|
|
</div>
|
|
|
|
|
<div className="taskList__wrapper">
|
2023-05-02 19:41:51 +03:00
|
|
|
|
{filteredAllTasks.map((task) => {
|
2023-04-10 21:22:22 +03:00
|
|
|
|
return (
|
2023-05-02 19:41:51 +03:00
|
|
|
|
<div className="task" key={task.id}>
|
2023-04-10 21:22:22 +03:00
|
|
|
|
<div className="task__info">
|
2023-05-02 19:41:51 +03:00
|
|
|
|
<h5>{task.title}</h5>
|
2023-04-10 21:22:22 +03:00
|
|
|
|
<p>{task.description}</p>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="task__person">
|
2023-05-02 19:41:51 +03:00
|
|
|
|
<img src={urlForLocal(task.user.avatar)} alt="avatar" />
|
2023-04-10 21:22:22 +03:00
|
|
|
|
<div className="task__project">
|
2023-05-02 19:41:51 +03:00
|
|
|
|
<p>{task.user.fio}</p>
|
|
|
|
|
<span>{getCorrectDate(task.created_at)}</span>
|
2023-03-30 15:07:05 +03:00
|
|
|
|
</div>
|
2023-04-10 21:22:22 +03:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
})}
|
2023-03-30 15:07:05 +03:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div
|
2023-04-10 21:22:22 +03:00
|
|
|
|
className={
|
2023-05-02 18:51:19 +03:00
|
|
|
|
tab === 3
|
2023-04-10 21:22:22 +03:00
|
|
|
|
? "tracker__tabs__content__archive active__content"
|
|
|
|
|
: "tracker__tabs__content__projects"
|
|
|
|
|
}
|
2023-03-30 15:07:05 +03:00
|
|
|
|
>
|
|
|
|
|
<div className="archive__tasks">
|
|
|
|
|
<div className="archive__title">
|
|
|
|
|
<h3>Архив задач:</h3>
|
|
|
|
|
<p>{filterCompleteTasks.length} задач(а)</p>
|
|
|
|
|
<div className="archive__tasks__search">
|
|
|
|
|
<img src={search} alt="search" />
|
|
|
|
|
<input
|
2023-04-10 21:22:22 +03:00
|
|
|
|
type="text"
|
|
|
|
|
placeholder="Найти задачу"
|
|
|
|
|
onChange={(event) => filterArchiveTasks(event)}
|
2023-03-30 15:07:05 +03:00
|
|
|
|
/>
|
2023-03-13 23:33:12 +03:00
|
|
|
|
</div>
|
2023-03-30 15:07:05 +03:00
|
|
|
|
</div>
|
|
|
|
|
<div className="archive__tasksWrapper">
|
2023-04-10 21:22:22 +03:00
|
|
|
|
{Boolean(filterCompleteTasks.length) ? (
|
2023-03-30 15:07:05 +03:00
|
|
|
|
filterCompleteTasks.map((task, index) => {
|
2023-03-22 21:48:06 +03:00
|
|
|
|
return (
|
2023-04-10 21:22:22 +03:00
|
|
|
|
<div className="archive__completeTask" key={index}>
|
|
|
|
|
<div className="archive__completeTask__description">
|
|
|
|
|
<p>{task.description}</p>
|
|
|
|
|
<p className="date">{task.dateComplete}</p>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="archive__completeTask__info">
|
|
|
|
|
<img src={task.avatarDo} alt="avatar" />
|
|
|
|
|
<div className="archive__completeTask__info__project">
|
|
|
|
|
<span>Проект</span>
|
|
|
|
|
<p>{task.project}</p>
|
2023-03-30 15:07:05 +03:00
|
|
|
|
</div>
|
2023-03-22 21:48:06 +03:00
|
|
|
|
</div>
|
2023-04-10 21:22:22 +03:00
|
|
|
|
</div>
|
2023-03-22 21:48:06 +03:00
|
|
|
|
);
|
2023-03-30 15:07:05 +03:00
|
|
|
|
})
|
2023-04-10 21:22:22 +03:00
|
|
|
|
) : (
|
2023-03-30 15:07:05 +03:00
|
|
|
|
<div className="archive__noItem">
|
|
|
|
|
<p>В архиве задач нет</p>
|
|
|
|
|
</div>
|
2023-04-10 21:22:22 +03:00
|
|
|
|
)}
|
2023-03-30 15:07:05 +03:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="archive__projects">
|
|
|
|
|
<div className="archive__title">
|
|
|
|
|
<h3>Архив проектов:</h3>
|
|
|
|
|
<p>{archiveProjects.length} проект(ов)</p>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="archive__tasksWrapper">
|
2023-04-10 21:22:22 +03:00
|
|
|
|
{Boolean(archiveProjects) ? (
|
2023-03-30 15:07:05 +03:00
|
|
|
|
archiveProjects.map((project, index) => {
|
2023-04-10 21:22:22 +03:00
|
|
|
|
return (
|
|
|
|
|
<div className="archive__completeTask" key={index}>
|
|
|
|
|
<div className="archive__completeTask__description">
|
|
|
|
|
<p>{project.name}</p>
|
|
|
|
|
<p className="date">{project.date}</p>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
})
|
|
|
|
|
) : (
|
2023-03-30 15:07:05 +03:00
|
|
|
|
<div className="archive__noItem">
|
|
|
|
|
<p>В архиве проектов нет</p>
|
|
|
|
|
</div>
|
2023-04-10 21:22:22 +03:00
|
|
|
|
)}
|
2023-03-13 23:33:12 +03:00
|
|
|
|
</div>
|
2023-03-03 18:49:02 +03:00
|
|
|
|
</div>
|
2023-03-07 19:40:52 +03:00
|
|
|
|
</div>
|
2023-02-17 15:19:49 +03:00
|
|
|
|
</div>
|
2023-03-07 19:40:52 +03:00
|
|
|
|
</div>
|
|
|
|
|
<Footer />
|
|
|
|
|
</div>
|
|
|
|
|
);
|
2023-02-17 15:19:49 +03:00
|
|
|
|
};
|