From 9152aa1adc245b2a89d3faa6db2012f208a20fad Mon Sep 17 00:00:00 2001 From: M1kola Date: Fri, 28 Apr 2023 18:29:13 +0300 Subject: [PATCH] tracker-connect --- src/components/ProjectTiket/ProjectTiket.js | 21 ++++++++-- src/components/UI/ModalTicket/ModalTicket.js | 41 +++++++++++++------ .../UI/ModalTicket/ModalTicket.scss | 5 ++- src/pages/Tracker/Tracker.js | 12 +++--- src/redux/projectsTrackerSlice.js | 14 ++++++- 5 files changed, 69 insertions(+), 24 deletions(-) diff --git a/src/components/ProjectTiket/ProjectTiket.js b/src/components/ProjectTiket/ProjectTiket.js index 9d11c406..53df6e24 100644 --- a/src/components/ProjectTiket/ProjectTiket.js +++ b/src/components/ProjectTiket/ProjectTiket.js @@ -6,9 +6,9 @@ import archiveSet from "../../images/archive.svg"; import del from "../../images/delete.svg"; import edit from "../../images/edit.svg"; -// import {apiRequest} from "../../api/request"; +import {apiRequest} from "../../api/request"; import {useDispatch} from "react-redux"; -import { setProjectBoardFetch } from "../../redux/projectsTrackerSlice"; +import { deleteProject, setProjectBoardFetch } from "../../redux/projectsTrackerSlice"; import "./projectTiket.scss"; @@ -35,6 +35,18 @@ export const ProjectTiket = ({ project, index, setOpenProject }) => { } } + function removeProject() { + apiRequest('/project/update', { + method: 'PUT', + data: { + project_id: project.id, + status: 0 + } + }).then((res) => { + dispatch(deleteProject(project)) + }) + } + return (

{ @@ -52,7 +64,7 @@ export const ProjectTiket = ({ project, index, setOpenProject }) => {
-
+
console.log(project)}>

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

@@ -64,7 +76,8 @@ export const ProjectTiket = ({ project, index, setOpenProject }) => {

в архив

-
+

удалить

diff --git a/src/components/UI/ModalTicket/ModalTicket.js b/src/components/UI/ModalTicket/ModalTicket.js index 89933e43..f1bbef71 100644 --- a/src/components/UI/ModalTicket/ModalTicket.js +++ b/src/components/UI/ModalTicket/ModalTicket.js @@ -1,11 +1,16 @@ import React, { useState } from "react"; +import { Link } from "react-router-dom"; +import ModalAdd from "../ModalAdd/ModalAdd"; +import {apiRequest} from "../../../api/request"; +import {useDispatch} from "react-redux"; +import { setProjectBoardFetch } from "../../../redux/projectsTrackerSlice"; import avatarMock1 from "../../../images/avatarMoсk1.png"; import avatarMock2 from "../../../images/avatarMoсk2.png"; import category from "../../../images/category.png"; import watch from "../../../images/watch.png"; import file from "../../../images/fileModal.svg"; -import task from "../../../images/tasksMock.png"; +import taskImg from "../../../images/tasksMock.png"; import arrow from "../../../images/arrowStart.png"; import link from "../../../images/link.svg"; import archive from "../../../images/archive.svg"; @@ -15,11 +20,10 @@ import send from "../../../images/send.svg"; import plus from "../../../images/plus.svg"; import fullScreen from "../../../images/inFullScreen.svg"; -import ModalAdd from "../ModalAdd/ModalAdd"; import "./ModalTicket.scss"; -import { Link } from "react-router-dom"; -export const ModalTiсket = ({ active, setActive, index }) => { +export const ModalTiсket = ({ active, setActive, task, projectId, projectName }) => { + const dispatch = useDispatch(); const [tiket] = useState({ name: "Разработка трекера", code: "PR - 2245", @@ -39,6 +43,19 @@ export const ModalTiсket = ({ active, setActive, index }) => { ]); const [addSubtask, setAddSubtask] = useState(false); + function deleteTask() { + apiRequest('/task/update-task', { + method: 'PUT', + data: { + task_id : task.id, + status: 0 + } + }).then((res) => { + setActive(false) + dispatch(setProjectBoardFetch(projectId)) + }) + } + return (
{

- Проект: {tiket.name} - + Проект: {projectName} +

Задача -
{tiket.code}
+
{task.title}
-

{tiket.descriptions}

- +

{task.description}

+

{tiket.descriptions}

@@ -90,8 +107,8 @@ export const ModalTiсket = ({ active, setActive, index }) => {
setActive(false)}> - {tiket.code} -

Создатель : {tiket.creator}

+ {task.title} +

Создатель : {task.user?.fio}

{workers.map((worker, index) => { return ( @@ -134,7 +151,7 @@ export const ModalTiсket = ({ active, setActive, index }) => {

в архив

-
+

удалить

diff --git a/src/components/UI/ModalTicket/ModalTicket.scss b/src/components/UI/ModalTicket/ModalTicket.scss index f1983bd1..f1a7132f 100644 --- a/src/components/UI/ModalTicket/ModalTicket.scss +++ b/src/components/UI/ModalTicket/ModalTicket.scss @@ -18,7 +18,7 @@ .modal-tiket__content { background: #ffffff; - border: 1px solid #dde2e4; + //border: 1px solid #dde2e4; border-radius: 8px; display: flex; flex-direction: row; @@ -291,13 +291,14 @@ } &-bottom { - padding: 40px 0 75px 56px; + padding: 40px 110px 75px 56px; font-weight: 400; font-size: 14px; line-height: 38px; div { display: flex; + cursor: pointer; align-items: center; p { diff --git a/src/pages/Tracker/Tracker.js b/src/pages/Tracker/Tracker.js index 2227bb5c..d44d98b3 100644 --- a/src/pages/Tracker/Tracker.js +++ b/src/pages/Tracker/Tracker.js @@ -255,7 +255,7 @@ export const Tracker = () => { // Modal State const [modalActiveTicket, setModalActiveTicket] = useState(false); - const [indexTicket, setIndexTicket] = useState(0); + const [selectedTicket, setSelectedTicket] = useState({}); const [modalAddWorker, setModalAddWorker] = useState(false); const [modalCreateProject, setModalCreateProject] = useState(false); const [modalCreateColl, setModalCreateColl] = useState(false); @@ -378,8 +378,8 @@ export const Tracker = () => { setModalCreateTiket(true); } - function openTicket(e, iTicket) { - setIndexTicket(iTicket); + function openTicket(e, task) { + setSelectedTicket(task); setModalActiveTicket(true); } @@ -610,7 +610,9 @@ export const Tracker = () => { @@ -682,7 +684,7 @@ export const Tracker = () => { dragStartHandler(e, task, column.id) } onDragEnd={(e) => dragEndHandler(e)} - onClick={(e) => openTicket(e, task.id)} + onClick={(e) => openTicket(e, task)} >

{task.title}

diff --git a/src/redux/projectsTrackerSlice.js b/src/redux/projectsTrackerSlice.js index 779ea66c..544dea1c 100644 --- a/src/redux/projectsTrackerSlice.js +++ b/src/redux/projectsTrackerSlice.js @@ -22,10 +22,22 @@ export const projectsTrackerSlice = createSlice({ setProject: (state, action) => { state.projects.push(action.payload); }, + deleteProject: (state, action) => { + console.log(action.payload) + state.projects = state.projects.filter((project) => project.id !== action.payload.id) + }, moveProjectTask: (state, action) => { state.projectBoard.columns.forEach((column, index) => { if (column.id === action.payload.columnId) { column.tasks.push(action.payload.startWrapperIndex.task) + apiRequest(`/task/update-task`, { + method: 'PUT', + data: { + task_id: action.payload.startWrapperIndex.task.id, + column_id: column.id + } + }).then((res) => { + }) } if (column.id === action.payload.startWrapperIndex.index) { state.projectBoard.columns[index].tasks = column.tasks.filter((task)=> task.id !== action.payload.startWrapperIndex.task.id); @@ -40,7 +52,7 @@ export const projectsTrackerSlice = createSlice({ } }); -export const { setProject, setAllProjects, moveProjectTask } = projectsTrackerSlice.actions; +export const { setProject, deleteProject, setAllProjects, moveProjectTask } = projectsTrackerSlice.actions; export const getProjects = (state) => state.tracker.projects; export const getProjectBoard = (state) => state.tracker.projectBoard;