2023-05-04 18:38:56 +03:00
|
|
|
|
import React, { useEffect, useState } from "react";
|
2023-04-20 20:10:08 +03:00
|
|
|
|
|
|
|
|
|
import { ProfileHeader } from "../../ProfileHeader/ProfileHeader";
|
|
|
|
|
import { ProfileBreadcrumbs } from "../../ProfileBreadcrumbs/ProfileBreadcrumbs";
|
|
|
|
|
import { Footer } from "../../Footer/Footer";
|
2023-05-03 20:01:23 +03:00
|
|
|
|
import { Link, useParams, useNavigate } from "react-router-dom";
|
2023-05-05 16:10:25 +03:00
|
|
|
|
import TrackerModal from "../TrackerModal/TrackerModal";
|
2023-05-03 16:47:20 +03:00
|
|
|
|
import { Navigation } from "../../Navigation/Navigation";
|
2023-05-16 00:24:52 +03:00
|
|
|
|
import {Loader} from "../../Loader/Loader";
|
2023-05-03 16:47:20 +03:00
|
|
|
|
|
2023-05-02 18:51:19 +03:00
|
|
|
|
import { useDispatch } from "react-redux";
|
2023-05-16 00:24:52 +03:00
|
|
|
|
import {modalToggle, setToggleTab} from "../../../redux/projectsTrackerSlice";
|
2023-05-04 18:38:56 +03:00
|
|
|
|
import { apiRequest } from "../../../api/request";
|
2023-04-20 20:10:08 +03:00
|
|
|
|
|
|
|
|
|
import project from "../../../images/trackerProject.svg";
|
|
|
|
|
import watch from "../../../images/watch.png";
|
|
|
|
|
import file from "../../../images/fileModal.svg";
|
|
|
|
|
import task from "../../../images/tasksMock.png";
|
|
|
|
|
import send from "../../../images/send.svg";
|
|
|
|
|
import arrow2 from "../../../images/arrowStart.png";
|
|
|
|
|
import plus from "../../../images/plus.svg";
|
|
|
|
|
import tasks from "../../../images/trackerTasks.svg";
|
|
|
|
|
import archive from "../../../images/archiveTracker.svg";
|
|
|
|
|
import selectArrow from "../../../images/select.svg";
|
|
|
|
|
import avatarTest from "../../../images/AvatarTest .png";
|
|
|
|
|
import arrow from "../../../images/arrowCalendar.png";
|
|
|
|
|
import link from "../../../images/link.svg";
|
|
|
|
|
import archive2 from "../../../images/archive.svg";
|
|
|
|
|
import del from "../../../images/delete.svg";
|
|
|
|
|
import edit from "../../../images/edit.svg";
|
|
|
|
|
|
|
|
|
|
import "./ticketFullScreen.scss";
|
|
|
|
|
|
|
|
|
|
export const TicketFullScreen = ({}) => {
|
|
|
|
|
const [modalAddWorker, setModalAddWorker] = useState(false);
|
2023-05-04 18:38:56 +03:00
|
|
|
|
const ticketId = useParams();
|
2023-05-02 18:51:19 +03:00
|
|
|
|
const dispatch = useDispatch();
|
2023-05-03 20:01:23 +03:00
|
|
|
|
const navigate = useNavigate();
|
2023-05-04 18:38:56 +03:00
|
|
|
|
const [projectInfo, setProjectInfo] = useState({});
|
|
|
|
|
const [taskInfo, setTaskInfo] = useState({});
|
2023-05-16 00:24:52 +03:00
|
|
|
|
const [editOpen, setEditOpen] = useState(false);
|
2023-05-17 23:18:46 +03:00
|
|
|
|
const [inputsValue, setInputsValue] = useState({});
|
|
|
|
|
const [loader, setLoader] = useState(true);
|
|
|
|
|
const [comments, setComments] = useState([]);
|
2023-04-20 20:10:08 +03:00
|
|
|
|
|
2023-05-03 20:01:23 +03:00
|
|
|
|
useEffect(() => {
|
|
|
|
|
apiRequest(`/task/get-task?task_id=${ticketId.id}`).then((taskInfo) => {
|
2023-05-04 18:38:56 +03:00
|
|
|
|
setTaskInfo(taskInfo);
|
2023-05-17 23:18:46 +03:00
|
|
|
|
setInputsValue({title: taskInfo.title, description: taskInfo.description, comment: ''})
|
|
|
|
|
apiRequest(`/comment/get-by-entity?entity_type=2&entity_id=${taskInfo.id}`).then((res) => setComments(res))
|
2023-05-04 18:38:56 +03:00
|
|
|
|
apiRequest(`/project/get-project?project_id=${taskInfo.project_id}`).then(
|
|
|
|
|
(project) => {
|
|
|
|
|
setProjectInfo(project);
|
2023-05-16 00:24:52 +03:00
|
|
|
|
setLoader(false)
|
2023-05-04 18:38:56 +03:00
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
}, []);
|
2023-05-03 20:01:23 +03:00
|
|
|
|
|
|
|
|
|
function deleteTask() {
|
|
|
|
|
apiRequest("/task/update-task", {
|
|
|
|
|
method: "PUT",
|
|
|
|
|
data: {
|
|
|
|
|
task_id: ticketId.id,
|
|
|
|
|
status: 0,
|
|
|
|
|
},
|
|
|
|
|
}).then((res) => {
|
2023-05-04 18:38:56 +03:00
|
|
|
|
navigate(`/tracker/project/${taskInfo.project_id}`);
|
2023-05-03 20:01:23 +03:00
|
|
|
|
});
|
|
|
|
|
}
|
2023-04-20 20:10:08 +03:00
|
|
|
|
|
2023-05-16 00:24:52 +03:00
|
|
|
|
function editTask() {
|
|
|
|
|
apiRequest("/task/update-task", {
|
|
|
|
|
method: "PUT",
|
|
|
|
|
data: {
|
|
|
|
|
task_id: taskInfo.id,
|
|
|
|
|
title: inputsValue.title,
|
|
|
|
|
description: inputsValue.description
|
|
|
|
|
},
|
|
|
|
|
}).then((res) => {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-17 23:18:46 +03:00
|
|
|
|
function editComment() {
|
|
|
|
|
apiRequest("/comment/create", {
|
|
|
|
|
method: "POST",
|
|
|
|
|
data: {
|
|
|
|
|
text: inputsValue.comment,
|
|
|
|
|
entity_type: 2,
|
|
|
|
|
entity_id: taskInfo.id
|
|
|
|
|
}
|
|
|
|
|
}).then((res) => {
|
|
|
|
|
setInputsValue((prevValue) => ({...prevValue, comment: ''}))
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-20 20:10:08 +03:00
|
|
|
|
const toggleTabs = (index) => {
|
2023-05-02 18:51:19 +03:00
|
|
|
|
dispatch(setToggleTab(index));
|
2023-04-20 20:10:08 +03:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<section className="ticket-full-screen">
|
|
|
|
|
<ProfileHeader />
|
2023-05-03 16:47:20 +03:00
|
|
|
|
<Navigation />
|
2023-04-20 20:10:08 +03:00
|
|
|
|
<div className="container">
|
|
|
|
|
<div className="tracker__content">
|
|
|
|
|
<ProfileBreadcrumbs
|
|
|
|
|
links={[
|
|
|
|
|
{ name: "Главная", link: "/profile" },
|
|
|
|
|
{ name: "Трекер", link: "/profile/tracker" },
|
|
|
|
|
]}
|
|
|
|
|
/>
|
|
|
|
|
<h2 className="tracker__title">Управление проектами с трекером</h2>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="tracker__tabs">
|
|
|
|
|
<div className="tracker__tabs__head">
|
2023-05-02 18:51:19 +03:00
|
|
|
|
<Link
|
2023-05-03 16:47:20 +03:00
|
|
|
|
to="/profile/tracker"
|
2023-05-02 18:51:19 +03:00
|
|
|
|
className="tab active-tab"
|
2023-04-20 20:10:08 +03:00
|
|
|
|
onClick={() => toggleTabs(1)}
|
|
|
|
|
>
|
|
|
|
|
<img src={project} alt="img" />
|
|
|
|
|
<p>Проекты </p>
|
2023-05-02 18:51:19 +03:00
|
|
|
|
</Link>
|
|
|
|
|
<Link
|
2023-05-03 16:47:20 +03:00
|
|
|
|
to="/profile/tracker"
|
2023-05-02 18:51:19 +03:00
|
|
|
|
className="tab"
|
2023-04-20 20:10:08 +03:00
|
|
|
|
onClick={() => toggleTabs(2)}
|
|
|
|
|
>
|
|
|
|
|
<img src={tasks} alt="img" />
|
2023-05-02 18:51:19 +03:00
|
|
|
|
<p>Все мои задачи</p>
|
|
|
|
|
</Link>
|
|
|
|
|
<Link
|
2023-05-03 16:47:20 +03:00
|
|
|
|
to="/profile/tracker"
|
2023-05-02 18:51:19 +03:00
|
|
|
|
className="tab"
|
2023-04-20 20:10:08 +03:00
|
|
|
|
onClick={() => toggleTabs(3)}
|
|
|
|
|
>
|
|
|
|
|
<img src={archive} alt="img" />
|
2023-05-02 18:51:19 +03:00
|
|
|
|
<p>Архив</p>
|
|
|
|
|
</Link>
|
2023-04-20 20:10:08 +03:00
|
|
|
|
</div>
|
2023-05-16 00:24:52 +03:00
|
|
|
|
{loader ? <Loader /> :
|
|
|
|
|
<>
|
2023-04-20 20:10:08 +03:00
|
|
|
|
<div className="tracker__tabs__content content-tabs">
|
|
|
|
|
<div className="tasks__head">
|
|
|
|
|
<div className="tasks__head__wrapper">
|
2023-05-03 20:01:23 +03:00
|
|
|
|
<h4>Проект : {projectInfo.name}</h4>
|
2023-04-20 20:10:08 +03:00
|
|
|
|
|
2023-05-05 16:10:25 +03:00
|
|
|
|
<TrackerModal
|
|
|
|
|
active={modalAddWorker}
|
|
|
|
|
setActive={setModalAddWorker}
|
|
|
|
|
></TrackerModal>
|
2023-04-20 20:10:08 +03:00
|
|
|
|
|
|
|
|
|
<div className="tasks__head__persons">
|
|
|
|
|
<img src={avatarTest} alt="avatar" />
|
|
|
|
|
<img src={avatarTest} alt="avatar" />
|
|
|
|
|
<span className="countPersons">+9</span>
|
2023-05-05 16:10:25 +03:00
|
|
|
|
<span
|
|
|
|
|
className="addPerson"
|
|
|
|
|
onClick={() => {
|
|
|
|
|
dispatch(modalToggle("addWorker"));
|
|
|
|
|
setModalAddWorker(true);
|
|
|
|
|
}}
|
|
|
|
|
>
|
2023-04-20 20:10:08 +03:00
|
|
|
|
+
|
|
|
|
|
</span>
|
|
|
|
|
<p>добавить участника в проект</p>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="tasks__head__select">
|
|
|
|
|
<span>Учавствую</span>
|
|
|
|
|
<img src={selectArrow} alt="arrow" />
|
|
|
|
|
</div>
|
|
|
|
|
<div className="tasks__head__select">
|
|
|
|
|
<span>Мои</span>
|
|
|
|
|
<img src={selectArrow} alt="arrow" />
|
|
|
|
|
</div>
|
|
|
|
|
<Link to={`/profile/tracker`} className="link">
|
|
|
|
|
<div className="tasks__head__back">
|
|
|
|
|
<p>Вернуться на проекты</p>
|
|
|
|
|
<img src={arrow} alt="arrow" />
|
|
|
|
|
</div>
|
|
|
|
|
</Link>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="modal-tiket__content ticket">
|
|
|
|
|
<div className="content ticket-whith">
|
|
|
|
|
<div className="content__task">
|
|
|
|
|
<span>Задача</span>
|
2023-05-16 00:24:52 +03:00
|
|
|
|
{editOpen ? <input value={inputsValue.title} onChange={(e) => {
|
|
|
|
|
setInputsValue((prevValue) => ({...prevValue, title: e.target.value}))
|
|
|
|
|
}} /> :<h5>{inputsValue.title}</h5>}
|
2023-04-20 20:10:08 +03:00
|
|
|
|
<div className="content__description">
|
2023-05-16 00:24:52 +03:00
|
|
|
|
{editOpen ? <input value={inputsValue.description} onChange={(e) => {
|
|
|
|
|
setInputsValue((prevValue) => ({...prevValue, description: e.target.value}))
|
|
|
|
|
}}/> :<p>{inputsValue.description}</p>}
|
2023-04-20 20:10:08 +03:00
|
|
|
|
<img src={task} className="image-task"></img>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="content__communication">
|
|
|
|
|
<p className="tasks">
|
2023-05-05 16:10:25 +03:00
|
|
|
|
<button
|
|
|
|
|
onClick={() => {
|
|
|
|
|
dispatch(modalToggle("addSubtask"));
|
|
|
|
|
setModalAddWorker(true);
|
|
|
|
|
}}
|
|
|
|
|
>
|
2023-04-20 20:10:08 +03:00
|
|
|
|
<img src={plus}></img>
|
|
|
|
|
Добавить под задачу
|
|
|
|
|
</button>
|
|
|
|
|
</p>
|
|
|
|
|
<p className="file">
|
|
|
|
|
<button>
|
|
|
|
|
<img src={file}></img>
|
|
|
|
|
Загрузить файл
|
|
|
|
|
</button>
|
|
|
|
|
<span>{0}</span>
|
|
|
|
|
Файлов
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="content__input">
|
2023-05-17 23:18:46 +03:00
|
|
|
|
<input placeholder="Оставить комментарий" value={inputsValue.comment} onChange={(e) => {
|
|
|
|
|
setInputsValue((prevValue) => ({...prevValue, comment: e.target.value}))
|
|
|
|
|
}} />
|
|
|
|
|
<img src={send} onClick={editComment}></img>
|
2023-04-20 20:10:08 +03:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="workers">
|
|
|
|
|
<div className="workers_box">
|
2023-05-04 18:38:56 +03:00
|
|
|
|
<p className="workers__creator">
|
|
|
|
|
Создатель : <span>{taskInfo.user?.fio}</span>
|
|
|
|
|
</p>
|
2023-04-20 20:10:08 +03:00
|
|
|
|
<div>
|
2023-05-04 18:38:56 +03:00
|
|
|
|
{Boolean(taskInfo.taskUsers?.length) &&
|
|
|
|
|
taskInfo.taskUsers.map((worker, index) => {
|
|
|
|
|
return (
|
|
|
|
|
<div className="worker" key={index}>
|
|
|
|
|
<img src={worker.avatar}></img>
|
|
|
|
|
<p>{worker.name}</p>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
})}
|
2023-04-20 20:10:08 +03:00
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="add-worker moreItems">
|
2023-05-05 16:10:25 +03:00
|
|
|
|
<button
|
|
|
|
|
onClick={() => {
|
|
|
|
|
dispatch(modalToggle("addWorker"));
|
|
|
|
|
setModalAddWorker(true);
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
+
|
|
|
|
|
</button>
|
2023-04-20 20:10:08 +03:00
|
|
|
|
<span>Добавить участников</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="workers_box-middle">
|
|
|
|
|
<div className="time">
|
|
|
|
|
<img src={watch}></img>
|
|
|
|
|
<span>Длительность : </span>
|
|
|
|
|
<p>{"8:30:22"}</p>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<button className="start">
|
|
|
|
|
Начать делать <img src={arrow2}></img>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="workers_box-bottom">
|
2023-05-16 00:24:52 +03:00
|
|
|
|
<div className={editOpen ? 'edit' : ''} onClick={() => {
|
|
|
|
|
if(editOpen) {
|
|
|
|
|
setEditOpen(!editOpen)
|
|
|
|
|
editTask()
|
|
|
|
|
} else {
|
|
|
|
|
setEditOpen(!editOpen)
|
|
|
|
|
}
|
|
|
|
|
}}>
|
2023-04-20 20:10:08 +03:00
|
|
|
|
<img src={edit}></img>
|
2023-05-16 00:24:52 +03:00
|
|
|
|
<p>{editOpen ? 'сохранить' : 'редактировать'}</p>
|
2023-04-20 20:10:08 +03:00
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<img src={link}></img>
|
|
|
|
|
<p>ссылка на проект</p>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<img src={archive2}></img>
|
|
|
|
|
<p>в архив</p>
|
|
|
|
|
</div>
|
2023-05-03 20:01:23 +03:00
|
|
|
|
<div onClick={deleteTask}>
|
2023-04-20 20:10:08 +03:00
|
|
|
|
<img src={del}></img>
|
|
|
|
|
<p>удалить</p>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2023-05-16 00:24:52 +03:00
|
|
|
|
</>
|
|
|
|
|
}
|
2023-04-20 20:10:08 +03:00
|
|
|
|
</div>
|
|
|
|
|
<Footer />
|
|
|
|
|
</section>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default TicketFullScreen;
|