import React, { useEffect, useState } from "react"; 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, modalToggle, setProjectBoardFetch, setToggleTab, getProjectBoard, getBoarderLoader, } from "../../../../redux/projectsTrackerSlice"; import { apiRequest } from "../../../../api/request"; 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 "./ticketFullScreen.scss"; import {getCorrectRequestDate, urlForLocal} from "../../../../utils/helper"; 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 [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) => { 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) }) taskInfo.timers.forEach((time) => { if (!time.stopped_at) { setTimerStart(true) setTimerInfo(time) } }) dispatch(setProjectBoardFetch(taskInfo.project_id)); setLoader(boardLoader) }); }, []); function deleteTask() { apiRequest("/task/update-task", { method: "PUT", data: { task_id: ticketId.id, status: 0, }, }).then(() => { 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(() => { }); } 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() newComment.subComments = [] setInputsValue((prevValue) => ({...prevValue, comment: ''})) setComments((prevValue) => ([...prevValue, newComment])) }) } function startTaskTimer() { apiRequest("/timer/create", { method: "POST", data: { entity_type: 2, entity_id: taskInfo.id, created_at: getCorrectRequestDate(new Date()) } }).then((res) => { setTimerStart(true) setTimerInfo(res) }) } function stopTaskTimer() { apiRequest("/timer/update", { method: "PUT", data: { timer_id: timerInfo.id, stopped_at: getCorrectRequestDate(new Date()) } }).then(() => setTimerStart(false)) } function deletePerson(userId) { apiRequest("/project/del-user", { method: "DELETE", data: { project_id: projectBoard.id, user_id: userId }, }).then(() => { dispatch(deletePersonOnProject(userId)) }); } function commentDelete(comment) { 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(() => { }) }) } } 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]) } 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
Задача {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}

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

{"0:00:00"}

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

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

link

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

arch

в архив

delete

удалить

}
); }; export default TicketFullScreen;