Added modal in project tiket

This commit is contained in:
MaxOvs19 2023-05-03 22:06:19 +03:00
parent 553ac3e75d
commit bb027d003f
5 changed files with 67 additions and 28 deletions

View File

@ -1,20 +1,22 @@
import React, { useEffect, useState } from "react"; import React, { useEffect, useState } from "react";
import { useDispatch } from "react-redux";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import ModalSettings from "../UI/ModalSettings/ModalSettings"; import { apiRequest } from "../../api/request";
import { deleteProject, modalToggle } from "../../redux/projectsTrackerSlice";
import { ModalSelect } from "../UI/ModalSelect/ModalSelect";
import ModalAdd from "../UI/ModalAdd/ModalAdd";
import link from "../../images/link.svg"; import link from "../../images/link.svg";
import archiveSet from "../../images/archive.svg"; import archiveSet from "../../images/archive.svg";
import del from "../../images/delete.svg"; import del from "../../images/delete.svg";
import edit from "../../images/edit.svg"; import edit from "../../images/edit.svg";
import {apiRequest} from "../../api/request";
import {useDispatch} from "react-redux";
import { deleteProject } from "../../redux/projectsTrackerSlice";
import "./projectTiket.scss"; import "./projectTiket.scss";
export const ProjectTiket = ({ project, index }) => { export const ProjectTiket = ({ project, index }) => {
const [modalSettings, setModalSettings] = useState(false); const [modalSelect, setModalSelect] = useState(false);
const [modalAdd, setModalAdd] = useState(false);
const dispatch = useDispatch(); const dispatch = useDispatch();
useEffect(() => { useEffect(() => {
@ -32,20 +34,20 @@ export const ProjectTiket = ({ project, index }) => {
event && event &&
!path.find((item) => item.classList && item.classList.contains("project")) !path.find((item) => item.classList && item.classList.contains("project"))
) { ) {
setModalSettings(false); setModalSelect(false);
} }
} }
function removeProject() { function removeProject() {
apiRequest('/project/update', { apiRequest("/project/update", {
method: 'PUT', method: "PUT",
data: { data: {
project_id: project.id, project_id: project.id,
status: 0 status: 0,
} },
}).then((res) => { }).then((res) => {
dispatch(deleteProject(project)) dispatch(deleteProject(project));
}) });
} }
return ( return (
@ -53,16 +55,34 @@ export const ProjectTiket = ({ project, index }) => {
<Link to={`/tracker/project/${project.id}`}>{project.name}</Link> <Link to={`/tracker/project/${project.id}`}>{project.name}</Link>
<div className="project__info"> <div className="project__info">
<p>Открытые задачи</p> <p>Открытые задачи</p>
<span className="count">{project.columns.reduce((accumulator, currentValue) => accumulator + currentValue.tasks.length, 0)}</span> <span className="count">
{project.columns.reduce(
(accumulator, currentValue) =>
accumulator + currentValue.tasks.length,
0
)}
</span>
{/*<span className="add">{project.columns.length ? '+' : ''}</span>*/} {/*<span className="add">{project.columns.length ? '+' : ''}</span>*/}
<span className="menu-settings" onClick={() => setModalSettings(true)}> <span className="menu-settings" onClick={() => setModalSelect(true)}>
... ...
</span> </span>
</div> </div>
<ModalSettings active={modalSettings}> <ModalAdd
active={modalAdd}
setActive={setModalAdd}
defautlInput={project.name}
></ModalAdd>
<ModalSelect active={modalSelect}>
<div className="project__settings-menu"> <div className="project__settings-menu">
<div> <div
onClick={() => {
dispatch(modalToggle("editProject"));
setModalAdd(true);
setModalSelect(false);
}}
>
<img src={edit}></img> <img src={edit}></img>
<p>редактировать</p> <p>редактировать</p>
</div> </div>
@ -74,13 +94,12 @@ export const ProjectTiket = ({ project, index }) => {
<img src={archiveSet}></img> <img src={archiveSet}></img>
<p>в архив</p> <p>в архив</p>
</div> </div>
<div <div onClick={removeProject}>
onClick={removeProject}>
<img src={del}></img> <img src={del}></img>
<p>удалить</p> <p>удалить</p>
</div> </div>
</div> </div>
</ModalSettings> </ModalSelect>
</div> </div>
); );
}; };

View File

@ -10,9 +10,7 @@ import {
import "./modalAdd.scss"; import "./modalAdd.scss";
// НУЖНО ДОБАВИТЬ ВАРИАЦИИ ОТРИСОВКИ И ПЕРЕНЕТИ ЛОГИКУ В МОДАЛКУ export const ModalAdd = ({ active, setActive, selectedTab, defautlInput }) => {
export const ModalAdd = ({ active, setActive, selectedTab }) => {
const dispatch = useDispatch(); const dispatch = useDispatch();
const projectBoard = useSelector(getProjectBoard); const projectBoard = useSelector(getProjectBoard);
@ -142,6 +140,28 @@ export const ModalAdd = ({ active, setActive, selectedTab }) => {
<span className="exit" onClick={() => setActive(false)}></span> <span className="exit" onClick={() => setActive(false)}></span>
</div> </div>
); );
case "editProject":
return (
<div
className="modal-add__content"
onClick={(e) => e.stopPropagation()}
>
<div className="title-project">
<h4>Введите новое название</h4>
<div className="input-container">
<input
className="name-project"
value={defautlInput}
onChange={(e) => setValueTiket(e.target.value)}
></input>
</div>
</div>
<button className="button-add" onClick={(e) => e.preventDefault()}>
Добавить
</button>
<span className="exit" onClick={() => setActive(false)}></span>
</div>
);
default: default:
return null; return null;
} }

View File

@ -48,7 +48,7 @@
font-weight: 300; font-weight: 300;
font-size: 12px; font-size: 12px;
line-height: 14px; line-height: 14px;
margin: -13px 0 16px 0; margin: 12px 0 16px 0;
} }
&__textarea { &__textarea {

View File

@ -1,8 +1,8 @@
import React from "react"; import React from "react";
import "./modalSettings.scss"; import "./modalSelect.scss";
export const ModalSettings = ({ active, children }) => { export const ModalSelect = ({ active, children }) => {
return ( return (
<div className={active ? "project__settings active" : "project__settings "}> <div className={active ? "project__settings active" : "project__settings "}>
{children} {children}
@ -10,4 +10,4 @@ export const ModalSettings = ({ active, children }) => {
); );
}; };
export default ModalSettings; export default ModalSelect;