diff --git a/src/components/Common/BaseButton/BaseButton.jsx b/src/components/Common/BaseButton/BaseButton.jsx index 9f9c5e5a..d659b3e8 100644 --- a/src/components/Common/BaseButton/BaseButton.jsx +++ b/src/components/Common/BaseButton/BaseButton.jsx @@ -1,13 +1,10 @@ import React from "react"; -import "./basebutton.scss" +import "./basebutton.scss"; export const BaseButton = ({ children, styles, ...props }) => { return ( - ); diff --git a/src/components/Modal/ModalSelect/modalSelect.scss b/src/components/Modal/ModalSelect/modalSelect.scss index 07844484..156d37ee 100644 --- a/src/components/Modal/ModalSelect/modalSelect.scss +++ b/src/components/Modal/ModalSelect/modalSelect.scss @@ -19,6 +19,10 @@ img { margin-right: 12px; } + + p:hover { + text-decoration: underline; + } } } diff --git a/src/components/Modal/Tracker/ModalTicket/ModalTicket.jsx b/src/components/Modal/Tracker/ModalTicket/ModalTicket.jsx index 1b5da0b5..1b3ec8c7 100644 --- a/src/components/Modal/Tracker/ModalTicket/ModalTicket.jsx +++ b/src/components/Modal/Tracker/ModalTicket/ModalTicket.jsx @@ -4,14 +4,13 @@ import { Link } from "react-router-dom"; import { modalToggle, setProjectBoardFetch } from "@redux/projectsTrackerSlice"; -import { urlForLocal } from "@utils/helper"; +import { getCorrectRequestDate, urlForLocal } from "@utils/helper"; import { apiRequest } from "@api/request"; -import { getCorrectDate } from "@components/Calendar/calendarHelper"; import BaseButton from "@components/Common/BaseButton/BaseButton"; -import ModalLayout from "@components/Common/ModalLayout/ModalLayout"; -import TrackerModal from "@components/Modal/TrackerModal/TrackerModal"; +import TrackerModal from "@components/Modal/Tracker/TrackerModal/TrackerModal"; +import TrackerTaskComment from "@components/TrackerTaskComment/TrackerTaskComment"; import archive from "assets/icons/archive.svg"; import arrow from "assets/icons/arrows/arrowStart.png"; @@ -26,7 +25,7 @@ import plus from "assets/icons/plus.svg"; import send from "assets/icons/send.svg"; import watch from "assets/icons/watch.svg"; -import "./ModalTicket.scss"; +import "./modalTicket.scss"; export const ModalTiсket = ({ active, @@ -45,13 +44,19 @@ export const ModalTiсket = ({ comment: "", }); const [comments, setComments] = useState([]); - const [commentsEditOpen, setCommentsEditOpen] = useState({}); - const [commentsEditText, setCommentsEditText] = useState({}); const [dropListOpen, setDropListOpen] = useState(false); const [dropListMembersOpen, setDropListMembersOpen] = useState(false); const [executor, setExecutor] = useState(task.executor); const [members, setMembers] = useState(task.taskUsers); const [users, setUsers] = useState([]); + const [timerStart, setTimerStart] = useState(false); + const [timerInfo, setTimerInfo] = useState({}); + const [currentTimerCount, setCurrentTimerCount] = useState({ + hours: 0, + minute: 0, + seconds: 0, + }); + const [timerId, setTimerId] = useState(null); function deleteTask() { apiRequest("/task/update-task", { @@ -90,37 +95,78 @@ export const ModalTiсket = ({ }).then((res) => { let newComment = res; newComment.created_at = new Date(); + newComment.subComments = []; setInputsValue((prevValue) => ({ ...prevValue, comment: "" })); setComments((prevValue) => [...prevValue, newComment]); - setCommentsEditOpen((prevValue) => ({ ...prevValue, [res.id]: false })); - setCommentsEditText((prevValue) => ({ - ...prevValue, - [res.id]: res.text, - })); - }); - } - function deleteComment(commentId) { - apiRequest("/comment/update", { - method: "PUT", - data: { - comment_id: commentId, - status: 0, - }, - }).then(() => { - setComments((prevValue) => - prevValue.filter((item) => item.id !== commentId) - ); }); } - function editComment(commentId) { - apiRequest("/comment/update", { + function commentDelete(comment) { + setComments((prevValue) => + prevValue.filter((item) => item.id !== comment.id) + ); + if (comment.subComments.length) { + // promiseAll + comment.subComments.forEach((subComment) => { + apiRequest("/comment/update", { + method: "PUT", + data: { + comment_id: subComment.id, + status: 0, + }, + }).then(() => {}); + }); + } + } + + function addSubComment(commentId, subComment) { + const addSubComment = comments; + addSubComment.forEach((comment) => { + if (comment.id === commentId) { + comment.subComments.push(subComment); + } + }); + setComments(addSubComment); + } + + function subCommentDelete(subComment) { + const deleteSubComment = comments; + deleteSubComment.forEach((comment, index) => { + if (comment.id === subComment.parent_id) { + deleteSubComment[index].subComments = comment.subComments.filter( + (item) => item.id !== subComment.id + ); + } + }); + setComments([...deleteSubComment]); + } + + function startTaskTimer() { + apiRequest("/timer/create", { + method: "POST", + data: { + entity_type: 2, + entity_id: task.id, + created_at: getCorrectRequestDate(new Date()), + }, + }).then((res) => { + setTimerStart(true); + setTimerInfo(res); + startTimer(); + }); + } + + function stopTaskTimer() { + apiRequest("/timer/update", { method: "PUT", data: { - comment_id: commentId, - text: commentsEditText[commentId], + timer_id: timerInfo.id, + stopped_at: getCorrectRequestDate(new Date()), }, - }).then(() => {}); + }).then(() => { + setTimerStart(false); + clearInterval(timerId); + }); } function taskExecutor(person) { @@ -177,20 +223,77 @@ export const ModalTiсket = ({ apiRequest( `/comment/get-by-entity?entity_type=2&entity_id=${task.id}` ).then((res) => { - setComments(res); - res.forEach((item) => { - setCommentsEditOpen((prevValue) => ({ - ...prevValue, - [item.id]: false, - })); - setCommentsEditText((prevValue) => ({ - ...prevValue, - [item.id]: item.text, - })); - }); + const comments = res.reduce((acc, cur) => { + if (!cur.parent_id) { + acc.push({ ...cur, subComments: [] }); + } else { + acc.forEach((item) => { + if (item.id === cur.parent_id) item.subComments.push(cur); + }); + } + return acc; + }, []); + setComments(comments); }); + apiRequest(`/timer/get-by-entity?entity_type=2&entity_id=${task.id}`).then( + (res) => { + let timerSeconds = 0; + res.length && + res.forEach((time) => { + timerSeconds += time.deltaSeconds; + setCurrentTimerCount({ + hours: Math.floor(timerSeconds / 60 / 60), + minute: Math.floor((timerSeconds / 60) % 60), + seconds: timerSeconds % 60, + }); + updateTimerHours = Math.floor(timerSeconds / 60 / 60); + updateTimerMinute = Math.floor((timerSeconds / 60) % 60); + updateTimerSec = timerSeconds % 60; + if (!time.stopped_at) { + setTimerStart(true); + startTimer(); + setTimerInfo(time); + } + }); + } + ); }, []); + function startTimer() { + setTimerId( + setInterval(() => { + run(); + }, 1000) + ); + } + + let updateTimerSec = currentTimerCount.seconds, + updateTimerMinute = currentTimerCount.minute, + updateTimerHours = currentTimerCount.hours; + + function run() { + updateTimerSec++; + if (updateTimerSec > 60) { + updateTimerMinute++; + updateTimerSec = 0; + } + if (updateTimerMinute === 60) { + updateTimerMinute = 0; + updateTimerHours++; + } + + return setCurrentTimerCount({ + hours: updateTimerHours, + minute: updateTimerMinute, + seconds: updateTimerSec, + }); + } + + function correctTimerTime(time) { + if (time < 10) return `0${time}`; + if (time > 10) return time; + } + useEffect(() => { let ids = members.map((user) => user.user_id); setUsers( @@ -202,23 +305,26 @@ export const ModalTiсket = ({ }, [members]); return ( - <> - setActive(false)} + > +
e.stopPropagation()} >
-

+ + + + +
- Проект: {projectName} - - - -

+

+ Проект: +

{projectName}

+ +
Задача @@ -237,7 +343,7 @@ export const ModalTiсket = ({ )}
{editOpen ? ( - { setInputsValue((prevValue) => ({ @@ -258,14 +364,14 @@ export const ModalTiсket = ({ dispatch(modalToggle("addSubtask")); setAddSubtask(true); }} - styles={"tasks__button"} + styles={"button-green-add"} > Добавить под задачу

- + Загрузить файл @@ -289,50 +395,14 @@ export const ModalTiсket = ({

{comments.map((comment) => { return ( -
-
- {getCorrectDate(comment.created_at)} -
- edit { - if (commentsEditOpen[comment.id]) { - editComment(comment.id); - } - setCommentsEditOpen((prevValue) => ({ - ...prevValue, - [comment.id]: !prevValue[comment.id], - })); - }} - /> -
- delete deleteComment(comment.id)} - /> -
- {commentsEditOpen[comment.id] ? ( - { - setCommentsEditText((prevValue) => ({ - ...prevValue, - [comment.id]: e.target.value, - })); - }} - /> - ) : ( -

{commentsEditText[comment.id]}

- )} -
+ ); })}
@@ -356,7 +426,12 @@ export const ModalTiсket = ({
) : (
- + setDropListOpen(true)} + styles={"button-add-worker"} + > + + + Добавить исполнителя {dropListOpen && (
@@ -404,7 +479,12 @@ export const ModalTiсket = ({ )}
- + setDropListMembersOpen(true)} + styles={"button-add-worker"} + > + + + Добавить участников {dropListMembersOpen && (
@@ -438,12 +518,29 @@ export const ModalTiсket = ({
Длительность : -

{"0:00:00"}

+

+ {correctTimerTime(currentTimerCount.hours)}: + {correctTimerTime(currentTimerCount.minute)}: + {correctTimerTime(currentTimerCount.seconds)} +

- + {timerStart ? ( + + ) : ( + + )}
@@ -475,14 +572,14 @@ export const ModalTiсket = ({
- +
- +
); }; diff --git a/src/components/Modal/Tracker/ModalTicket/ModalTicket.scss b/src/components/Modal/Tracker/ModalTicket/ModalTicket.scss deleted file mode 100644 index ce06851a..00000000 --- a/src/components/Modal/Tracker/ModalTicket/ModalTicket.scss +++ /dev/null @@ -1,594 +0,0 @@ -.tracker-ticket { - background: #ffffff; - padding: 0; - border-radius: 8px; - align-items: initial; - display: flex; - flex-direction: row; - - .content { - display: flex; - flex-direction: column; - width: 600px; - margin: 26px 0 0 21px; - - .title-project { - color: #1458dd; - font-family: "LabGrotesque", sans-serif; - display: flex; - align-items: center; - font-weight: 700; - font-size: 22px; - line-height: 32px; - - &__category { - margin-right: 17px; - } - - &__full { - margin-left: 35%; - } - } - - &__task { - margin-top: -5px; - padding: 18px; - display: flex; - flex-direction: column; - - input { - font-style: normal; - font-size: 16px; - line-height: 24px; - max-width: 340px; - outline: none; - } - - button { - img { - margin-right: 5px; - } - } - - h5 { - font-family: "Inter", sans-serif; - font-weight: 500; - font-style: normal; - font-size: 16px; - line-height: 24px; - color: #1a1919; - margin-bottom: 0; - } - - .comments__list { - display: flex; - flex-direction: column; - max-height: 420px; - overflow: auto; - - &::-webkit-scrollbar { - width: 4px; - border-radius: 10px; - } - - &::-webkit-scrollbar-thumb { - background: #cbd9f9; - border-radius: 10px; - } - - &::-webkit-scrollbar-track { - background: #c5c0c6; - border-radius: 10px; - } - - &__item { - padding: 10px 20px; - display: flex; - flex-direction: column; - max-width: 438px; - border-radius: 44px; - font-size: 14px; - width: 100%; - position: relative; - - &__subComment { - &:before { - content: ''; - background: #E4E4E6; - height: 1px; - width: 7px; - position: absolute; - top: 36%; - left: 2.5%; - } - } - - &__main { - &:after { - content: ''; - position: absolute; - background-image: url("../../../images/mainTaskCommentImg.png"); - width: 10px; - height: 8px; - top: 50px; - left: 25px; - } - - &:before { - content: ''; - position: absolute; - background: #E4E4E6; - width: 1px; - height: calc(100% - 120px); - left: 29px; - top: 65px; - } - } - - &__fio { - display: flex; - align-items: center; - - p { - font-size: 12px; - color: #000000; - line-height: 32px; - max-width: 150px; - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; - margin-left: 10px; - } - - img { - width: 24px; - height: 24px; - } - } - - &__date { - display: flex; - align-items: center; - column-gap: 5px; - - img { - cursor: pointer; - width: 15px; - } - - span { - font-size: 12px; - } - } - - &__text { - margin-left: 34px; - } - - &__info { - display: flex; - justify-content: space-between; - - .edit { - width: 25px; - display: flex; - align-items: center; - justify-content: center; - border-radius: 5px; - } - - .edit__open { - background: green; - } - } - - &__answer { - margin-left: 34px; - text-decoration-line: underline; - font-weight: 400; - font-size: 10px; - line-height: 32px; - cursor: pointer; - - &__new { - margin-left: 34px; - font-size: 14px; - border-radius: 5px; - border: 1px solid gainsboro; - padding: 3px 5px; - display: flex; - align-items: center; - margin-top: 5px; - - img { - width: 20px; - height: 20px; - cursor: pointer; - } - - input { - width: 90%; - border: none; - } - } - } - } - } - } - - &__description { - display: flex; - flex-direction: column; - margin-top: 10px; - - p { - font-weight: 400; - font-size: 14px; - line-height: 140%; - color: #252c32; - text-align: justify; - } - - .image-task { - margin: 10px 0 20px 0; - max-width: 330px; - } - } - - &__communication { - display: flex; - flex-direction: row; - margin: 29px 0 0 -5px; - - .tasks { - justify-content: space-evenly; - - &__button { - width: 180px; - height: 40px; - font-size: 12px; - } - } - - .tasks, - .file { - display: flex; - align-items: center; - } - - .file { - justify-content: space-between; - margin-left: 20px; - - &__button { - background: white; - width: 166px; - height: 40px; - border: 0.5px solid #1458dd; - font-weight: 400; - font-size: 12px; - color: #1458dd; - - img { - margin-right: 9px; - } - } - - span { - margin: 0 3px 0 11px; - font-weight: 500; - font-size: 12px; - line-height: 15px; - color: #6e7c87; - } - } - } - - &__input { - margin: 20px 0 20px 0; - display: flex; - align-items: center; - justify-content: space-between; - width: 438px; - height: 40px; - background: #f1f1f1; - border-radius: 44px; - - input { - width: 80%; - background: inherit; - border: none; - outline: none; - padding-left: 30px; - font-weight: 400; - font-size: 12px; - line-height: 32px; - border-radius: 44px; - } - - img { - cursor: pointer; - margin-right: 18px; - } - } - } - - .members { - display: flex; - flex-direction: column; - font-size: 14px; - - &__list { - display: flex; - flex-direction: column; - row-gap: 8px; - } - } - - .workers { - position: relative; - border-left: 1px solid #f1f1f1; - - .exit { - cursor: pointer; - position: absolute; - top: 35px; - right: 40px; - - &:before, - &:after { - content: ""; - position: absolute; - width: 16px; - height: 2px; - background: #263238; - } - - &:before { - transform: rotate(45deg); - } - &:after { - transform: rotate(-45deg); - } - } - - span { - font-family: "Inter", sans-serif; - font-weight: 500; - font-size: 11px; - color: #807777; - } - - .nameProject { - max-width: 200px; - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; - } - - .add-worker { - display: flex; - align-items: center; - position: relative; - - span { - color: #000000; - font-size: 12px; - line-height: 32px; - margin-left: 17px; - font-style: normal; - font-weight: 400; - } - - button { - cursor: pointer; - background: #8bcc60; - border-radius: 44px; - width: 33px; - height: 33px; - display: flex; - justify-content: center; - align-items: center; - border: none; - color: white; - font-size: 17px; - } - } - - .start { - font-size: 12px; - margin-top: 25px; - width: 151px; - height: 40px; - border: none; - color: white; - background: #1458dd; - border-radius: 44px; - - img { - margin-left: 10px; - } - } - - .disable { - opacity: 0.5; - pointer-events: none; - } - - .stop { - font-size: 12px; - margin-top: 25px; - width: 151px; - height: 40px; - border: none; - color: white; - background: red; - border-radius: 44px; - } - - .time { - display: flex; - align-items: center; - justify-content: space-between; - font-size: 12px; - margin-top: 20px; - width: 160px; - - p { - color: #000000; - margin: 0; - } - } - - &__creator { - font-size: 14px; - line-height: 32px; - font-weight: 500; - color: #2d4a17; - max-width: 200px; - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; - - span { - margin-left: 5px; - font-size: 14px; - line-height: 32px; - font-weight: 500; - display: flex; - } - } - - .worker { - display: flex; - flex-direction: row; - align-items: center; - - p { - max-width: 170px; - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; - font-size: 14px; - } - - img { - max-width: 25px; - max-height: 25px; - margin-left: 5px; - } - } - - .task__info { - display: flex; - flex-direction: column; - row-gap: 5px; - - .delete { - cursor: pointer; - } - - .executor { - display: flex; - font-size: 14px; - align-items: center; - - p { - max-width: 170px; - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; - } - - img { - margin-left: 5px; - max-width: 25px; - max-height: 25px; - } - } - - .dropdownList { - position: absolute; - background: white; - padding: 10px; - border-radius: 10px; - top: 0; - z-index: 10; - border: 1px solid gray; - width: 260px; - display: flex; - flex-direction: column; - row-gap: 8px; - - .noUsers { - font-size: 14px; - text-align: center; - } - - &__close { - cursor: pointer; - margin-left: auto; - width: 12px; - margin-right: 5px; - } - - &__person { - display: flex; - justify-content: space-between; - cursor: pointer; - - img { - max-width: 30px; - max-height: 30px; - } - } - } - } - - &_box { - padding: 25px 85px 40px 40px; - border-bottom: 1px solid #f1f1f1; - - &-middle { - padding: 0px 40px 25px 40px; - border-bottom: 1px solid #f1f1f1; - } - - &-bottom { - padding: 40px 110px 75px 56px; - font-weight: 400; - font-size: 14px; - line-height: 38px; - - div { - display: flex; - cursor: pointer; - align-items: center; - padding-left: 10px; - - p { - margin: 0 0 0 12px; - } - } - - .edit { - background: #52b709; - border-radius: 50px; - - p { - font-weight: 700; - } - } - } - } - } -} - -.subtask { - h4 { - width: 90%; - p { - color: #1458dd; - } - } -} diff --git a/src/components/UI/ModalTicket/modalTicket.scss b/src/components/Modal/Tracker/ModalTicket/modalTicket.scss similarity index 90% rename from src/components/UI/ModalTicket/modalTicket.scss rename to src/components/Modal/Tracker/ModalTicket/modalTicket.scss index 5912f569..60936eeb 100644 --- a/src/components/UI/ModalTicket/modalTicket.scss +++ b/src/components/Modal/Tracker/ModalTicket/modalTicket.scss @@ -17,32 +17,54 @@ .modal-tiket__content { background: #ffffff; - //border: 1px solid #dde2e4; border-radius: 8px; display: flex; flex-direction: row; .content { + position: relative; display: flex; flex-direction: column; width: 600px; margin: 26px 0 0 21px; .title-project { - color: #1458dd; - font-family: "LabGrotesque", sans-serif; + max-width: 85%; display: flex; align-items: center; - font-weight: 700; - font-size: 22px; - line-height: 32px; + flex-direction: row; &__category { margin-right: 17px; } + h2, + h3 { + font-weight: 700; + font-size: 22px; + line-height: 32px; + color: #1458dd; + margin: 0; + font-family: "LabGrotesque", sans-serif; + } + + h2 { + display: flex; + align-items: center; + flex-wrap: wrap; + flex-direction: row; + + h3 { + margin-left: 5px; + word-break: break-all; + } + } + &__full { - margin-left: 35%; + position: absolute; + position: absolute; + right: 28px; + top: 0; } } @@ -79,7 +101,7 @@ .comments__list { display: flex; flex-direction: column; - max-height: 420px; + max-height: 300px; overflow: auto; &::-webkit-scrollbar { @@ -109,8 +131,8 @@ &__subComment { &:before { - content: ''; - background: #E4E4E6; + content: ""; + background: #e4e4e6; height: 1px; width: 7px; position: absolute; @@ -121,9 +143,9 @@ &__main { &:after { - content: ''; + content: ""; position: absolute; - background-image: url("../../../assets/images/mainTaskCommentImg.png"); + background-image: url("assets/images/mainTaskCommentImg.png"); width: 10px; height: 8px; top: 50px; @@ -131,9 +153,9 @@ } &:before { - content: ''; + content: ""; position: absolute; - background: #E4E4E6; + background: #e4e4e6; width: 1px; height: calc(100% - 120px); left: 29px; @@ -236,6 +258,13 @@ display: flex; flex-direction: column; margin-top: 10px; + + textarea { + min-height: 120px; + max-height: 450px; + font-size: 14px; + } + p { font-weight: 400; font-size: 14px; @@ -258,16 +287,12 @@ .tasks { justify-content: space-evenly; - button { + .button-green-add { width: 180px; height: 40px; - background: #52b709; - border-radius: 44px; font-weight: 400; font-size: 12px; line-height: 32px; - border: none; - color: #ffffff; } } @@ -281,7 +306,7 @@ justify-content: space-between; margin-left: 20px; - button { + .button-add-file { display: flex; align-items: center; justify-content: center; @@ -336,6 +361,10 @@ cursor: pointer; margin-right: 18px; } + + &:focus-within { + border: 1px solid #0000004d; + } } } @@ -396,6 +425,7 @@ display: flex; align-items: center; position: relative; + margin-bottom: 5px; span { color: #000000; @@ -406,17 +436,12 @@ font-weight: 400; } - button { - cursor: pointer; - background: #8bcc60; - border-radius: 44px; + .button-add-worker { width: 33px; height: 33px; display: flex; justify-content: center; align-items: center; - border: none; - color: white; font-size: 17px; } } @@ -605,6 +630,10 @@ font-weight: 700; } } + + p:hover { + text-decoration: underline; + } } } } diff --git a/src/components/Modal/Tracker/TicketFullScreen/TicketFullScreen.jsx b/src/components/Modal/Tracker/TicketFullScreen/TicketFullScreen.jsx index 6c845bab..5338a2f1 100644 --- a/src/components/Modal/Tracker/TicketFullScreen/TicketFullScreen.jsx +++ b/src/components/Modal/Tracker/TicketFullScreen/TicketFullScreen.jsx @@ -1,45 +1,47 @@ import React, { useEffect, useState } from "react"; +import { useDispatch, useSelector } from "react-redux"; +import { Link, useNavigate, useParams } from "react-router-dom"; -import { ProfileHeader } from "../../../ProfileHeader/ProfileHeader"; -import { ProfileBreadcrumbs } from "../../../ProfileBreadcrumbs/ProfileBreadcrumbs"; -import { Footer } from "@components/Common/Footer/Footer"; -import { Link, useParams, useNavigate } from "react-router-dom"; -import TrackerModal from "../../../Modal/TrackerModal/TrackerModal"; -import TrackerTaskComment from "../../../TrackerTaskComment/TrackerTaskComment"; -import { Navigation } from "../../../Navigation/Navigation"; -import {Loader} from "@components/Common/Loader/Loader"; - -import {useDispatch, useSelector} from "react-redux"; import { deletePersonOnProject, + getBoarderLoader, + getProjectBoard, modalToggle, setProjectBoardFetch, setToggleTab, - getProjectBoard, - getBoarderLoader, -} from "../../../../redux/projectsTrackerSlice"; -import { apiRequest } from "../../../../api/request"; +} from "@redux/projectsTrackerSlice"; -import project from "../../../../assets/icons/trackerProject.svg"; -import watch from "../../../../assets/icons/watch.svg"; -import file from "../../../../assets/icons/fileModal.svg"; -import send from "../../../../assets/icons/send.svg"; -import arrow2 from "../../../../assets/icons/arrows/arrowStart.png"; -import plus from "../../../../assets/icons/plus.svg"; -import tasks from "../../../../assets/icons/trackerTasks.svg"; -import archive from "../../../../assets/icons/archive.svg"; -import arrow from "../../../../assets/icons/arrows/arrowCalendar.png"; -import link from "../../../../assets/icons/link.svg"; -import archive2 from "../../../../assets/icons/archive.svg"; -import del from "../../../../assets/icons/delete.svg"; -import edit from "../../../../assets/icons/edit.svg"; -import close from "../../../../assets/icons/close.png"; +import { getCorrectRequestDate, urlForLocal } from "@utils/helper"; + +import { apiRequest } from "@api/request"; + +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 TrackerTaskComment from "@components/TrackerTaskComment/TrackerTaskComment"; + +import archive from "assets/icons/archive.svg"; +import archive2 from "assets/icons/archive.svg"; +import arrow from "assets/icons/arrows/arrowCalendar.png"; +import arrow2 from "assets/icons/arrows/arrowStart.png"; +import close from "assets/icons/close.png"; +import del from "assets/icons/delete.svg"; +import edit from "assets/icons/edit.svg"; +import file from "assets/icons/fileModal.svg"; +import link from "assets/icons/link.svg"; +import plus from "assets/icons/plus.svg"; +import send from "assets/icons/send.svg"; +import project from "assets/icons/trackerProject.svg"; +import tasks from "assets/icons/trackerTasks.svg"; +import watch from "assets/icons/watch.svg"; import "./ticketFullScreen.scss"; -import {getCorrectRequestDate, urlForLocal} from "../../../../utils/helper"; - -export const TicketFullScreen = ({}) => { +export const TicketFullScreen = () => { const [modalAddWorker, setModalAddWorker] = useState(false); const ticketId = useParams(); const dispatch = useDispatch(); @@ -51,35 +53,41 @@ export const TicketFullScreen = ({}) => { const [inputsValue, setInputsValue] = useState({}); const [loader, setLoader] = useState(true); const [comments, setComments] = useState([]); - const [personListOpen, setPersonListOpen] = useState(false) - const [timerStart, setTimerStart] = useState(false) - const [timerInfo, setTimerInfo] = useState({}) + const [personListOpen, setPersonListOpen] = useState(false); + const [timerStart, setTimerStart] = useState(false); + const [timerInfo, setTimerInfo] = useState({}); useEffect(() => { apiRequest(`/task/get-task?task_id=${ticketId.id}`).then((taskInfo) => { setTaskInfo(taskInfo); - setInputsValue({title: taskInfo.title, description: taskInfo.description, comment: ''}) - apiRequest(`/comment/get-by-entity?entity_type=2&entity_id=${taskInfo.id}`).then((res) => { + setInputsValue({ + title: taskInfo.title, + description: taskInfo.description, + comment: "", + }); + apiRequest( + `/comment/get-by-entity?entity_type=2&entity_id=${taskInfo.id}` + ).then((res) => { const comments = res.reduce((acc, cur) => { if (!cur.parent_id) { - acc.push({...cur, subComments: []}) + acc.push({ ...cur, subComments: [] }); } else { acc.forEach((item) => { - if (item.id === cur.parent_id) item.subComments.push(cur) - }) + if (item.id === cur.parent_id) item.subComments.push(cur); + }); } - return acc - }, []) - setComments(comments) - }) + return acc; + }, []); + setComments(comments); + }); taskInfo.timers.forEach((time) => { if (!time.stopped_at) { - setTimerStart(true) - setTimerInfo(time) + setTimerStart(true); + setTimerInfo(time); } - }) + }); dispatch(setProjectBoardFetch(taskInfo.project_id)); - setLoader(boardLoader) + setLoader(boardLoader); }); }, []); @@ -101,10 +109,9 @@ export const TicketFullScreen = ({}) => { data: { task_id: taskInfo.id, title: inputsValue.title, - description: inputsValue.description + description: inputsValue.description, }, - }).then(() => { - }); + }).then(() => {}); } function createComment() { @@ -113,15 +120,15 @@ export const TicketFullScreen = ({}) => { data: { text: inputsValue.comment, entity_type: 2, - entity_id: taskInfo.id - } + entity_id: taskInfo.id, + }, }).then((res) => { - let newComment = res - newComment.created_at = new Date() - newComment.subComments = [] - setInputsValue((prevValue) => ({...prevValue, comment: ''})) - setComments((prevValue) => ([...prevValue, newComment])) - }) + let newComment = res; + newComment.created_at = new Date(); + newComment.subComments = []; + setInputsValue((prevValue) => ({ ...prevValue, comment: "" })); + setComments((prevValue) => [...prevValue, newComment]); + }); } function startTaskTimer() { @@ -130,12 +137,12 @@ export const TicketFullScreen = ({}) => { data: { entity_type: 2, entity_id: taskInfo.id, - created_at: getCorrectRequestDate(new Date()) - } + created_at: getCorrectRequestDate(new Date()), + }, }).then((res) => { - setTimerStart(true) - setTimerInfo(res) - }) + setTimerStart(true); + setTimerInfo(res); + }); } function stopTaskTimer() { @@ -143,9 +150,9 @@ export const TicketFullScreen = ({}) => { method: "PUT", data: { timer_id: timerInfo.id, - stopped_at: getCorrectRequestDate(new Date()) - } - }).then(() => setTimerStart(false)) + stopped_at: getCorrectRequestDate(new Date()), + }, + }).then(() => setTimerStart(false)); } function deletePerson(userId) { @@ -153,47 +160,50 @@ export const TicketFullScreen = ({}) => { method: "DELETE", data: { project_id: projectBoard.id, - user_id: userId + user_id: userId, }, }).then(() => { - dispatch(deletePersonOnProject(userId)) + dispatch(deletePersonOnProject(userId)); }); } function commentDelete(comment) { - setComments((prevValue) => prevValue.filter((item) => item.id !== comment.id)) + setComments((prevValue) => + prevValue.filter((item) => item.id !== comment.id) + ); if (comment.subComments.length) { comment.subComments.forEach((subComment) => { apiRequest("/comment/update", { method: "PUT", data: { comment_id: subComment.id, - status: 0 - } - }).then(() => { - }) - }) + status: 0, + }, + }).then(() => {}); + }); } } function addSubComment(commentId, subComment) { - const addSubComment = comments + const addSubComment = comments; addSubComment.forEach((comment) => { if (comment.id === commentId) { - comment.subComments.push(subComment) + comment.subComments.push(subComment); } - }) - setComments(addSubComment) + }); + setComments(addSubComment); } function subCommentDelete(subComment) { - const deleteSubComment = comments + const deleteSubComment = comments; deleteSubComment.forEach((comment, index) => { if (comment.id === subComment.parent_id) { - deleteSubComment[index].subComments = comment.subComments.filter((item) => item.id !== subComment.id) + deleteSubComment[index].subComments = comment.subComments.filter( + (item) => item.id !== subComment.id + ); } - }) - setComments([...deleteSubComment]) + }); + setComments([...deleteSubComment]); } const toggleTabs = (index) => { @@ -201,256 +211,323 @@ export const TicketFullScreen = ({}) => { }; return ( -
- - -
-
- -

Управление проектами с трекером

-
+
+ + +
+
+ +

Управление проектами с трекером

-
-
- toggleTabs(1)} - > - img -

Проекты

- - toggleTabs(2)} - > - img -

Все мои задачи

- - toggleTabs(3)} - > - img -

Архив

- -
- {loader ? : - <> -
-
-
-

Проект : {projectBoard.name}

+
+
+
+ toggleTabs(1)} + > + img +

Проекты

+ + toggleTabs(2)} + > + img +

Все мои задачи

+ + toggleTabs(3)} + > + img +

Архив

+ +
+ {loader ? ( + + ) : ( + <> +
+
+
+

Проект : {projectBoard.name}

- + -
- {/*avatar*/} - {/*avatar*/} - {projectBoard.projectUsers?.length} - { - setPersonListOpen(true) - }} - > - + - -

добавить участника

- {personListOpen && -
- close setPersonListOpen(false)} /> -
{projectBoard.projectUsers?.length}участник
-
В проекте - “{projectBoard.name}”
-
- {projectBoard.projectUsers?.map((person) => { - return
- avatar - {person.user.fio} - delete deletePerson(person.user_id)}/> -
- }) - } -
-
{ - dispatch(modalToggle("addWorker")); - setModalAddWorker(true); - setPersonListOpen(false) - }} - > - + -

Добавить участников

-
-
- } -
- -
-

Вернуться на проекты

- arrow +
+ + {projectBoard.projectUsers?.length} + + { + setPersonListOpen(true); + }} + > + + + +

добавить участника

+ {personListOpen && ( +
+ close setPersonListOpen(false)} + /> +
+ {projectBoard.projectUsers?.length} + участник
- +
+ В проекте - “{projectBoard.name}” +
+
+ {projectBoard.projectUsers?.map((person) => { + return ( +
+ avatar + {person.user.fio} + delete deletePerson(person.user_id)} + /> +
+ ); + })} +
+
{ + dispatch(modalToggle("addWorker")); + setModalAddWorker(true); + setPersonListOpen(false); + }} + > + + +

Добавить участников

+
+
+ )} +
+ +
+

Вернуться на проекты

+ arrow
+ +
+
+
+
+
+
+ Задача + {editOpen ? ( + { + setInputsValue((prevValue) => ({ + ...prevValue, + title: e.target.value, + })); + }} + /> + ) : ( +
{inputsValue.title}
+ )} +
+ {editOpen ? ( + { + setInputsValue((prevValue) => ({ + ...prevValue, + description: e.target.value, + })); + }} + /> + ) : ( +

{inputsValue.description}

+ )} +
+
+

+ { + dispatch(modalToggle("addSubtask")); + setModalAddWorker(true); + }} + styles={"button-green-add"} + > + + Добавить под задачу + +

+

+ + + Загрузить файл + + {0} + Файлов +

+
+
+ { + setInputsValue((prevValue) => ({ + ...prevValue, + comment: e.target.value, + })); + }} + /> + send +
+
+ {comments.map((comment) => { + return ( + + ); + })}
-
-
-
- Задача - {editOpen ? { - setInputsValue((prevValue) => ({...prevValue, title: e.target.value})) - }} /> :
{inputsValue.title}
} -
- {editOpen ? { - setInputsValue((prevValue) => ({...prevValue, description: e.target.value})) - }}/> :

{inputsValue.description}

} - {/**/} -
-
-

- -

-

- - {0} - Файлов -

-
-
- { - setInputsValue((prevValue) => ({...prevValue, comment: e.target.value})) - }} /> - send -
-
- {comments.map((comment) => { - return - }) - - } -
-
+
+
+
+

+ Создатель : {taskInfo.user?.fio} +

+
+ {Boolean(taskInfo.taskUsers?.length) && + taskInfo.taskUsers.map((worker, index) => { + return ( +
+ worket +

{worker.name}

+
+ ); + })}
-
-
-

- Создатель : {taskInfo.user?.fio} -

-
- {Boolean(taskInfo.taskUsers?.length) && - taskInfo.taskUsers.map((worker, index) => { - return ( -
- worket -

{worker.name}

-
- ); - })} -
-
- - Добавить исполнителя -
-
- - Добавить участников -
-
+
+ { + dispatch(modalToggle("addWorker")); + setModalAddWorker(true); + }} + styles={"button-add-worker"} + > + + + + Добавить исполнителя +
+
+ { + dispatch(modalToggle("addWorker")); + setModalAddWorker(true); + }} + styles={"button-add-worker"} + > + + + -
-
- watch - Длительность : -

{"0:00:00"}

-
+ Добавить участников +
+
- {timerStart ? - - : - +
+
+ watch + Длительность : +

{"0:00:00"}

+
+ + {timerStart ? ( + + ) : ( + + )} +
-
-
{ - if(editOpen) { - setEditOpen(!editOpen) - editTask() - } else { - setEditOpen(!editOpen) - } - }}> - edit -

{editOpen ? 'сохранить' : 'редактировать'}

-
-
- link -

ссылка на проект

-
-
- arch -

в архив

-
-
- delete -

удалить

-
-
+
+
{ + if (editOpen) { + setEditOpen(!editOpen); + editTask(); + } else { + setEditOpen(!editOpen); + } + }} + > + edit +

{editOpen ? "сохранить" : "редактировать"}

+
+
+ link +

ссылка на проект

+
+
+ arch +

в архив

+
+
+ delete +

удалить

- - } -
-
-
+
+
+ + )} + +