guild_front/src/components/ProjectTiket/ProjectTiket.js

78 lines
2.2 KiB
JavaScript
Raw Normal View History

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 14:56:59 +03:00
// import {apiRequest} from "../../api/request";
import {useDispatch} from "react-redux";
import { setProjectBoardFetch } from "../../redux/projectsTrackerSlice";
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);
}
}
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">
<div>
<img src={edit}></img>
<p>редактировать</p>
</div>
<div>
<img src={link}></img>
<p>ссылка на проект</p>
</div>
<div>
<img src={archiveSet}></img>
<p>в архив</p>
</div>
<div>
<img src={del}></img>
<p>удалить</p>
</div>
</div>
</ModalSettings>
</div>
);
};
export default ProjectTiket;