import React, { useEffect, useState } from "react"; import { Link, useParams, useNavigate } from "react-router-dom"; import { useDispatch, useSelector } from "react-redux"; import { ProfileHeader } from "@components/ProfileHeader/ProfileHeader"; import { ProfileBreadcrumbs } from "@components/ProfileBreadcrumbs/ProfileBreadcrumbs"; import { Footer } from "@components/Common/Footer/Footer"; import { getCorrectDate } from "@components/Calendar/calendarHelper"; import BaseButton from "@components/Common/BaseButton/BaseButton"; import TrackerModal from "@components/Modal/TrackerModal/TrackerModal"; import { Navigation } from "@components/Navigation/Navigation"; import { Loader } from "@components/Common/Loader/Loader"; import { deletePersonOnProject, modalToggle, setProjectBoardFetch, setToggleTab, getProjectBoard, getBoarderLoader, } from "@redux/projectsTrackerSlice"; import { apiRequest } from "@api/request"; import { urlForLocal } from "@utils/helper"; 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/archiveTracker.svg"; import selectArrow from "assets/icons/arrows/select.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/closeProjectPersons.svg"; import "./ticketFullScreen.scss"; export const TicketFullScreen = ({}) => { const [modalAddWorker, setModalAddWorker] = useState(false); const ticketId = useParams(); const dispatch = useDispatch(); const navigate = useNavigate(); const projectBoard = useSelector(getProjectBoard); const boardLoader = useSelector(getBoarderLoader); const [taskInfo, setTaskInfo] = useState({}); const [editOpen, setEditOpen] = useState(false); const [inputsValue, setInputsValue] = useState({}); const [loader, setLoader] = useState(true); const [comments, setComments] = useState([]); const [commentsEditOpen, setCommentsEditOpen] = useState({}); const [commentsEditText, setCommentsEditText] = useState({}); const [personListOpen, setPersonListOpen] = useState(false); 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) => { setComments(res); res.forEach((item) => { setCommentsEditOpen((prevValue) => ({ ...prevValue, [item.id]: false, })); setCommentsEditText((prevValue) => ({ ...prevValue, [item.id]: item.text, })); }); }); dispatch(setProjectBoardFetch(taskInfo.project_id)); setLoader(boardLoader); }); }, []); function deleteTask() { apiRequest("/task/update-task", { method: "PUT", data: { task_id: ticketId.id, status: 0, }, }).then((res) => { navigate(`/tracker/project/${taskInfo.project_id}`); }); } function editTask() { apiRequest("/task/update-task", { method: "PUT", data: { task_id: taskInfo.id, title: inputsValue.title, description: inputsValue.description, }, }).then((res) => {}); } function createComment() { apiRequest("/comment/create", { method: "POST", data: { text: inputsValue.comment, entity_type: 2, entity_id: taskInfo.id, }, }).then((res) => { let newComment = res; newComment.created_at = new Date(); 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((res) => { setComments((prevValue) => prevValue.filter((item) => item.id !== commentId) ); }); } function editComment(commentId) { apiRequest("/comment/update", { method: "PUT", data: { comment_id: commentId, text: commentsEditText[commentId], }, }).then((res) => {}); } function deletePerson(userId) { apiRequest("/project/del-user", { method: "DELETE", data: { project_id: projectBoard.id, user_id: userId, }, }).then((res) => { dispatch(deletePersonOnProject(userId)); }); } const toggleTabs = (index) => { dispatch(setToggleTab(index)); }; return (

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

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
Мои arrow

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

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

{inputsValue.description}

)}

{ dispatch(modalToggle("addSubtask")); setAddSubtask(true); }} styles={"tasks__button"} > Добавить под задачу

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

{ setInputsValue((prevValue) => ({ ...prevValue, comment: e.target.value, })); }} />
{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]}

)}
); })}

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

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

{worker.name}

); })}
Добавить исполнителя
Добавить участников
Длительность :

{"0:00:00"}

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

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

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

в архив

удалить

)}
); }; export default TicketFullScreen;