tracker tasks

This commit is contained in:
Николай Полтщук 2023-08-31 01:58:48 +03:00
parent a66bea4462
commit 45438da61c
3 changed files with 88 additions and 58 deletions

View File

@ -1,47 +1,50 @@
import React, {useState} from "react"; import React, { useState } from "react";
import { backendImg } from "@utils/helper"; import { backendImg } from "@utils/helper";
import { apiRequest } from "@api/request";
import close from "assets/icons/closeProjectPersons.svg"; import close from "assets/icons/closeProjectPersons.svg";
import {apiRequest} from "@api/request";
const FileTracker = ({ file, setDeletedTask, taskId }) => { const FileTracker = ({ file, setDeletedTask, taskId }) => {
const [openImg, setOpenImg] = useState(false) const [openImg, setOpenImg] = useState(false);
function deleteFile(file) { function deleteFile(file) {
apiRequest("/file/detach", { apiRequest("/file/detach", {
method: "DELETE", method: "DELETE",
data: { data: {
file_id: file.id, file_id: file.id,
entity_type: 2, entity_type: 2,
entity_id: taskId, entity_id: taskId,
status: 0, status: 0,
}, },
}).then(() => { }).then(() => {
setDeletedTask(file); setDeletedTask(file);
}); });
} }
return ( return (
<div className={openImg ? "taskFile ImgOpened" : "taskFile"} key={file.id} <div
onClick={() => className={openImg ? "taskFile ImgOpened" : "taskFile"}
{if(openImg) setOpenImg(!openImg)}} key={file.id}
> onClick={() => {
<img if (openImg) setOpenImg(!openImg);
className="imgFile" }}
src={backendImg(file.file?.url)} >
alt="img" <img
onClick={() => className="imgFile"
{if(!openImg) setOpenImg(!openImg)}} src={backendImg(file.file?.url)}
/> alt="img"
{!openImg && onClick={() => {
<div if (!openImg) setOpenImg(!openImg);
className="deleteFile" }}
onClick={() => deleteFile(file)} />
> {!openImg && (
<img src={close} alt="delete" /> <div className="deleteFile" onClick={() => deleteFile(file)}>
</div> <img src={close} alt="delete" />
}
</div> </div>
); )}
</div>
);
}; };
export default FileTracker; export default FileTracker;

View File

@ -22,10 +22,10 @@ import { apiRequest } from "@api/request";
import { useNotification } from "@hooks/useNotification"; import { useNotification } from "@hooks/useNotification";
import FileTracker from "@components/FileTracker/FileTracker";
import AcceptModal from "@components/Modal/AcceptModal/AcceptModal"; import AcceptModal from "@components/Modal/AcceptModal/AcceptModal";
import TrackerModal from "@components/Modal/Tracker/TrackerModal/TrackerModal"; import TrackerModal from "@components/Modal/Tracker/TrackerModal/TrackerModal";
import TrackerTaskComment from "@components/TrackerTaskComment/TrackerTaskComment"; import TrackerTaskComment from "@components/TrackerTaskComment/TrackerTaskComment";
import FileTracker from "@components/FileTracker/FileTracker";
import archive from "assets/icons/archive.svg"; import archive from "assets/icons/archive.svg";
import arrow from "assets/icons/arrows/arrowStart.png"; import arrow from "assets/icons/arrows/arrowStart.png";
@ -53,7 +53,7 @@ export const ModalTiсket = ({
projectId, projectId,
projectName, projectName,
projectUsers, projectUsers,
projectOwnerId projectOwnerId,
}) => { }) => {
const dispatch = useDispatch(); const dispatch = useDispatch();
const [addSubtask, setAddSubtask] = useState(false); const [addSubtask, setAddSubtask] = useState(false);
@ -373,9 +373,9 @@ export const ModalTiсket = ({
} }
function deleteFile(file) { function deleteFile(file) {
setTaskFiles((prevValue) => setTaskFiles((prevValue) =>
prevValue.filter((item) => item.id !== file.id) prevValue.filter((item) => item.id !== file.id)
); );
} }
function startTimer() { function startTimer() {
@ -525,12 +525,12 @@ export const ModalTiсket = ({
<div className="task__files"> <div className="task__files">
{taskFiles.map((file) => { {taskFiles.map((file) => {
return ( return (
<FileTracker <FileTracker
key={file.id} key={file.id}
file={file} file={file}
setDeletedTask={deleteFile} setDeletedTask={deleteFile}
taskId={task.id} taskId={task.id}
/> />
); );
})} })}
</div> </div>
@ -823,12 +823,27 @@ export const ModalTiсket = ({
<img src={link}></img> <img src={link}></img>
<p onClick={copyTicketLink}>ссылка на задачу</p> <p onClick={copyTicketLink}>ссылка на задачу</p>
</div> </div>
<div onClick={archiveTask} className={(profileInfo.id_user === projectOwnerId) || (profileInfo.id_user === task.user_id) ? '' : 'disable'}> <div
onClick={archiveTask}
className={
profileInfo.id_user === projectOwnerId ||
profileInfo.id_user === task.user_id
? ""
: "disable"
}
>
<img src={archive}></img> <img src={archive}></img>
<p>в архив</p> <p>в архив</p>
</div> </div>
<div onClick={deleteTask} className={ <div
(profileInfo.id_user === projectOwnerId) || (profileInfo.id_user === task.user_id) ? '' : 'disable'}> onClick={deleteTask}
className={
profileInfo.id_user === projectOwnerId ||
profileInfo.id_user === task.user_id
? ""
: "disable"
}
>
<img src={del}></img> <img src={del}></img>
<p>удалить</p> <p>удалить</p>
</div> </div>

View File

@ -6,6 +6,7 @@ import DatePicker, { registerLocale } from "react-datepicker";
import { useDispatch, useSelector } from "react-redux"; import { useDispatch, useSelector } from "react-redux";
import { Link, useNavigate, useParams } from "react-router-dom"; import { Link, useNavigate, useParams } from "react-router-dom";
import { getProfileInfo } from "@redux/outstaffingSlice";
import { import {
deletePersonOnProject, deletePersonOnProject,
getBoarderLoader, getBoarderLoader,
@ -13,8 +14,6 @@ import {
setToggleTab, setToggleTab,
} from "@redux/projectsTrackerSlice"; } from "@redux/projectsTrackerSlice";
import { getProfileInfo } from "@redux/outstaffingSlice";
import { import {
backendImg, backendImg,
caseOfNum, caseOfNum,
@ -1000,13 +999,26 @@ export const TicketFullScreen = () => {
<img src={link} alt="link"></img> <img src={link} alt="link"></img>
<p onClick={copyTicketLink}>ссылка на задачу</p> <p onClick={copyTicketLink}>ссылка на задачу</p>
</div> </div>
<div onClick={archiveTask} <div
className={(profileInfo.id_user === projectInfo.owner_id) || (profileInfo.id_user === taskInfo.user_id) ? '' : 'disable'}> onClick={archiveTask}
className={
profileInfo.id_user === projectInfo.owner_id ||
profileInfo.id_user === taskInfo.user_id
? ""
: "disable"
}
>
<img src={archive} alt="arch"></img> <img src={archive} alt="arch"></img>
<p>в архив</p> <p>в архив</p>
</div> </div>
<div onClick={deleteTask} <div
className={(profileInfo.id_user === projectInfo.owner_id) || (profileInfo.id_user === taskInfo.user_id) ? '' : 'disable'} onClick={deleteTask}
className={
profileInfo.id_user === projectInfo.owner_id ||
profileInfo.id_user === taskInfo.user_id
? ""
: "disable"
}
> >
<img src={del} alt="delete"></img> <img src={del} alt="delete"></img>
<p>удалить</p> <p>удалить</p>