2023-04-14 15:52:21 +03:00
|
|
|
import React, { useEffect, useState } from "react";
|
|
|
|
import ModalSettings from "../UI/ModalSettings/ModalSettings";
|
|
|
|
|
|
|
|
import link from "../../images/link.svg";
|
|
|
|
import archiveSet from "../../images/archive.svg";
|
|
|
|
import del from "../../images/delete.svg";
|
|
|
|
import edit from "../../images/edit.svg";
|
|
|
|
|
2023-04-28 18:29:13 +03:00
|
|
|
import {apiRequest} from "../../api/request";
|
2023-04-28 14:56:59 +03:00
|
|
|
import {useDispatch} from "react-redux";
|
2023-04-28 18:29:13 +03:00
|
|
|
import { deleteProject, setProjectBoardFetch } from "../../redux/projectsTrackerSlice";
|
2023-04-28 14:56:59 +03:00
|
|
|
|
2023-04-14 15:52:21 +03:00
|
|
|
import "./projectTiket.scss";
|
|
|
|
|
|
|
|
export const ProjectTiket = ({ project, index, setOpenProject }) => {
|
|
|
|
const [modalSettings, setModalSettings] = useState(false);
|
2023-04-28 14:56:59 +03:00
|
|
|
const dispatch = useDispatch();
|
2023-04-14 15:52:21 +03:00
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
initListeners();
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
function initListeners() {
|
|
|
|
document.addEventListener("click", closeByClickingOut);
|
|
|
|
}
|
|
|
|
|
|
|
|
function closeByClickingOut(event) {
|
|
|
|
const path = event.path || (event.composedPath && event.composedPath());
|
|
|
|
|
|
|
|
if (
|
|
|
|
event &&
|
|
|
|
!path.find((item) => item.classList && item.classList.contains("project"))
|
|
|
|
) {
|
|
|
|
setModalSettings(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-28 18:29:13 +03:00
|
|
|
function removeProject() {
|
|
|
|
apiRequest('/project/update', {
|
|
|
|
method: 'PUT',
|
|
|
|
data: {
|
|
|
|
project_id: project.id,
|
|
|
|
status: 0
|
|
|
|
}
|
|
|
|
}).then((res) => {
|
|
|
|
dispatch(deleteProject(project))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2023-04-14 15:52:21 +03:00
|
|
|
return (
|
|
|
|
<div className="project" key={index}>
|
2023-04-28 14:56:59 +03:00
|
|
|
<h3 onClick={() =>{
|
|
|
|
setOpenProject(true)
|
|
|
|
dispatch(setProjectBoardFetch(project.id))
|
|
|
|
}}>{project.name}</h3>
|
2023-04-14 15:52:21 +03:00
|
|
|
<div className="project__info">
|
|
|
|
<p>Открытые задачи</p>
|
2023-04-28 14:56:59 +03:00
|
|
|
<span className="count">-</span>
|
|
|
|
{/*<span className="add">{project.columns.length ? '+' : ''}</span>*/}
|
2023-04-14 15:52:21 +03:00
|
|
|
<span className="menu-settings" onClick={() => setModalSettings(true)}>
|
|
|
|
...
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<ModalSettings active={modalSettings}>
|
|
|
|
<div className="project__settings-menu">
|
2023-04-28 18:29:13 +03:00
|
|
|
<div onClick={() => console.log(project)}>
|
2023-04-14 15:52:21 +03:00
|
|
|
<img src={edit}></img>
|
|
|
|
<p>редактировать</p>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<img src={link}></img>
|
|
|
|
<p>ссылка на проект</p>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<img src={archiveSet}></img>
|
|
|
|
<p>в архив</p>
|
|
|
|
</div>
|
2023-04-28 18:29:13 +03:00
|
|
|
<div
|
|
|
|
onClick={removeProject}>
|
2023-04-14 15:52:21 +03:00
|
|
|
<img src={del}></img>
|
|
|
|
<p>удалить</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</ModalSettings>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default ProjectTiket;
|