From bb027d003f8be3f2eacb595ca68ab843457b721b Mon Sep 17 00:00:00 2001 From: MaxOvs19 Date: Wed, 3 May 2023 22:06:19 +0300 Subject: [PATCH] Added modal in project tiket --- src/components/ProjectTiket/ProjectTiket.js | 61 ++++++++++++------- src/components/UI/ModalAdd/ModalAdd.jsx | 26 +++++++- src/components/UI/ModalAdd/modalAdd.scss | 2 +- .../ModalSelect.jsx} | 6 +- .../modalSelect.scss} | 0 5 files changed, 67 insertions(+), 28 deletions(-) rename src/components/UI/{ModalSettings/ModalSettings.jsx => ModalSelect/ModalSelect.jsx} (57%) rename src/components/UI/{ModalSettings/modalSettings.scss => ModalSelect/modalSelect.scss} (100%) diff --git a/src/components/ProjectTiket/ProjectTiket.js b/src/components/ProjectTiket/ProjectTiket.js index e223dd6d..ecb947ad 100644 --- a/src/components/ProjectTiket/ProjectTiket.js +++ b/src/components/ProjectTiket/ProjectTiket.js @@ -1,20 +1,22 @@ import React, { useEffect, useState } from "react"; -import {Link} from "react-router-dom"; -import ModalSettings from "../UI/ModalSettings/ModalSettings"; +import { useDispatch } from "react-redux"; +import { Link } from "react-router-dom"; +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 archiveSet from "../../images/archive.svg"; import del from "../../images/delete.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"; export const ProjectTiket = ({ project, index }) => { - const [modalSettings, setModalSettings] = useState(false); + const [modalSelect, setModalSelect] = useState(false); + const [modalAdd, setModalAdd] = useState(false); const dispatch = useDispatch(); useEffect(() => { @@ -32,20 +34,20 @@ export const ProjectTiket = ({ project, index }) => { event && !path.find((item) => item.classList && item.classList.contains("project")) ) { - setModalSettings(false); + setModalSelect(false); } } function removeProject() { - apiRequest('/project/update', { - method: 'PUT', + apiRequest("/project/update", { + method: "PUT", data: { project_id: project.id, - status: 0 - } + status: 0, + }, }).then((res) => { - dispatch(deleteProject(project)) - }) + dispatch(deleteProject(project)); + }); } return ( @@ -53,16 +55,34 @@ export const ProjectTiket = ({ project, index }) => { {project.name}

Открытые задачи

- {project.columns.reduce((accumulator, currentValue) => accumulator + currentValue.tasks.length, 0)} + + {project.columns.reduce( + (accumulator, currentValue) => + accumulator + currentValue.tasks.length, + 0 + )} + {/*{project.columns.length ? '+' : ''}*/} - setModalSettings(true)}> + setModalSelect(true)}> ...
- + + +
-
+
{ + dispatch(modalToggle("editProject")); + setModalAdd(true); + setModalSelect(false); + }} + >

редактировать

@@ -74,13 +94,12 @@ export const ProjectTiket = ({ project, index }) => {

в архив

-
+

удалить

- +
); }; diff --git a/src/components/UI/ModalAdd/ModalAdd.jsx b/src/components/UI/ModalAdd/ModalAdd.jsx index 8a5e828e..0b06696a 100644 --- a/src/components/UI/ModalAdd/ModalAdd.jsx +++ b/src/components/UI/ModalAdd/ModalAdd.jsx @@ -10,9 +10,7 @@ import { import "./modalAdd.scss"; -// НУЖНО ДОБАВИТЬ ВАРИАЦИИ ОТРИСОВКИ И ПЕРЕНЕТИ ЛОГИКУ В МОДАЛКУ - -export const ModalAdd = ({ active, setActive, selectedTab }) => { +export const ModalAdd = ({ active, setActive, selectedTab, defautlInput }) => { const dispatch = useDispatch(); const projectBoard = useSelector(getProjectBoard); @@ -142,6 +140,28 @@ export const ModalAdd = ({ active, setActive, selectedTab }) => { setActive(false)}> ); + case "editProject": + return ( +
e.stopPropagation()} + > +
+

Введите новое название

+
+ setValueTiket(e.target.value)} + > +
+
+ + setActive(false)}> +
+ ); default: return null; } diff --git a/src/components/UI/ModalAdd/modalAdd.scss b/src/components/UI/ModalAdd/modalAdd.scss index 8f60c092..9e54d8b4 100644 --- a/src/components/UI/ModalAdd/modalAdd.scss +++ b/src/components/UI/ModalAdd/modalAdd.scss @@ -48,7 +48,7 @@ font-weight: 300; font-size: 12px; line-height: 14px; - margin: -13px 0 16px 0; + margin: 12px 0 16px 0; } &__textarea { diff --git a/src/components/UI/ModalSettings/ModalSettings.jsx b/src/components/UI/ModalSelect/ModalSelect.jsx similarity index 57% rename from src/components/UI/ModalSettings/ModalSettings.jsx rename to src/components/UI/ModalSelect/ModalSelect.jsx index e3ffb5d5..4aae3e92 100644 --- a/src/components/UI/ModalSettings/ModalSettings.jsx +++ b/src/components/UI/ModalSelect/ModalSelect.jsx @@ -1,8 +1,8 @@ import React from "react"; -import "./modalSettings.scss"; +import "./modalSelect.scss"; -export const ModalSettings = ({ active, children }) => { +export const ModalSelect = ({ active, children }) => { return (
{children} @@ -10,4 +10,4 @@ export const ModalSettings = ({ active, children }) => { ); }; -export default ModalSettings; +export default ModalSelect; diff --git a/src/components/UI/ModalSettings/modalSettings.scss b/src/components/UI/ModalSelect/modalSelect.scss similarity index 100% rename from src/components/UI/ModalSettings/modalSettings.scss rename to src/components/UI/ModalSelect/modalSelect.scss