From 879a42f3b4b59f03a73a45663eddbd0f2b020041 Mon Sep 17 00:00:00 2001 From: Z1chi Date: Fri, 28 Apr 2023 16:15:46 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D1=82=D0=B0=D1=81=D0=BA=D0=B8=20=D1=81=20=D0=BA=D0=BE?= =?UTF-8?q?=D0=BB=D0=BE=D0=BD=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Tracker/Tracker.js | 151 +----------------------------- src/redux/projectsTrackerSlice.js | 5 +- 2 files changed, 3 insertions(+), 153 deletions(-) diff --git a/src/pages/Tracker/Tracker.js b/src/pages/Tracker/Tracker.js index 08bbb2c7..2227bb5c 100644 --- a/src/pages/Tracker/Tracker.js +++ b/src/pages/Tracker/Tracker.js @@ -31,114 +31,6 @@ import "./tracker.scss"; export const Tracker = () => { const dispatch = useDispatch(); const [toggleTab, setToggleTab] = useState(1); - const [tabTaskMok, setTabTaskMok] = useState([ - { - name: "Открытые", - open: false, - tasks: [ - { - task: "PR - 2245", - description: "Сверстать часть таблицы. Сверстать часть таблицы", - comments: 12, - files: 0, - avatarCreated: avatarTest, - avatarDo: avatarTest, - id: 1, - }, - { - task: "PR - 2245", - description: "Сверстать часть таблицы. Сверстать часть таблицы", - comments: 12, - files: 0, - avatarCreated: avatarTest, - avatarDo: avatarTest, - id: 2, - }, - ], - }, - { - name: "В процессе", - open: false, - tasks: [ - { - task: "PR - 2245", - description: "Сверстать часть таблицы. Сверстать часть таблицы", - comments: 12, - files: 0, - avatarCreated: avatarTest, - avatarDo: avatarTest, - id: 3, - }, - ], - }, - { - name: "На проверке", - open: false, - tasks: [ - { - task: "PR - 2245", - description: "Сверстать часть таблицы. Сверстать часть таблицы", - comments: 12, - files: 0, - avatarCreated: avatarTest, - avatarDo: avatarTest, - id: 4, - }, - { - task: "PR - 2245", - description: "Сверстать часть таблицы. Сверстать часть таблицы", - comments: 12, - files: 0, - avatarCreated: avatarTest, - avatarDo: avatarTest, - id: 5, - }, - { - task: "PR - 2245", - description: "Сверстать часть таблицы. Сверстать часть таблицы", - comments: 12, - files: 0, - avatarCreated: avatarTest, - avatarDo: avatarTest, - id: 6, - }, - { - task: "PR - 2245", - description: "Сверстать часть таблицы. Сверстать часть таблицы", - comments: 12, - files: 0, - avatarCreated: avatarTest, - avatarDo: avatarTest, - id: 9, - }, - ], - }, - { - name: "Готово", - open: false, - tasks: [ - { - task: "PR - 2245", - description: "Сверстать часть таблицы. Сверстать часть таблицы", - comments: 12, - files: 0, - avatarCreated: avatarTest, - avatarDo: avatarTest, - id: 7, - }, - { - task: "PR - 2245", - description: "Сверстать часть таблицы. Сверстать часть таблицы", - comments: 12, - files: 0, - avatarCreated: avatarTest, - avatarDo: avatarTest, - id: 8, - }, - ], - }, - ]); - const [allTasks] = useState([ { name: "PR - 2245", @@ -377,7 +269,6 @@ export const Tracker = () => { const [selectedTab, setSelectedTab] = useState(0); - const [startWrapperIndex, setStartWrapperIndex] = useState(null); const startWrapperIndexTest = useRef({}) const [wrapperHover, setWrapperHover] = useState([ false, @@ -415,7 +306,6 @@ export const Tracker = () => { } function dragStartHandler(e, task, columnId) { - // setStartWrapperIndex({ task: task, index: columnId }); startWrapperIndexTest.current = { task: task, index: columnId }; setTimeout(() => { e.target.classList.add("tasks__board__item__hide"); @@ -449,7 +339,6 @@ export const Tracker = () => { }) ); } - function dragDropHandler(e, columnId) { e.preventDefault(); if (startWrapperIndexTest.current.index === columnId) { @@ -462,25 +351,8 @@ export const Tracker = () => { ); if (columnId !== startWrapperIndexTest.current.index) { - dispatch(moveProjectTask({startWrapperIndex:startWrapperIndexTest.current, columnId})) + dispatch(moveProjectTask({startWrapperIndex: startWrapperIndexTest.current, columnId})) } - - // setTabTaskMok((prevArray) => - // prevArray.map((elem, index) => { - // if (index === columnId) { - // return { ...elem, tasks: [...elem.tasks, startWrapperIndex.task] }; - // } else if (index === startWrapperIndex.index) { - // return { - // ...elem, - // tasks: elem.tasks.filter((item) => { - // return item.id !== startWrapperIndex.task.id; - // }), - // }; - // } else { - // return elem; - // } - // }) - // ); } function filterArchiveTasks(e) { @@ -533,27 +405,6 @@ export const Tracker = () => { setModalCreateTiket(false); setValueTiket(""); setDescriptionTicket("") - // tabTaskMok.filter((item) => { - // if (item.name == selectedTab.name) { - // let idItem = 0; - // - // item.tasks.forEach((item) => { - // idItem = item.id; - // }); - // - // let newTiket = { - // task: valueTiket, - // description: descriptionTicket, - // comments: 0, - // files: 0, - // avatarCreated: avatarTest, - // avatarDo: avatarTest, - // id: idItem + 1, - // }; - // - // item.tasks.push(newTiket); - // } - // }); } function createTab() { diff --git a/src/redux/projectsTrackerSlice.js b/src/redux/projectsTrackerSlice.js index 62465064..779ea66c 100644 --- a/src/redux/projectsTrackerSlice.js +++ b/src/redux/projectsTrackerSlice.js @@ -1,6 +1,5 @@ import { createAsyncThunk, createSlice } from "@reduxjs/toolkit"; import {apiRequest} from "../api/request"; -import {act} from "@testing-library/react"; const initialState = { projects: [], @@ -24,12 +23,12 @@ export const projectsTrackerSlice = createSlice({ state.projects.push(action.payload); }, moveProjectTask: (state, action) => { - state.projectBoard.columns.forEach((column) => { + state.projectBoard.columns.forEach((column, index) => { if (column.id === action.payload.columnId) { column.tasks.push(action.payload.startWrapperIndex.task) } if (column.id === action.payload.startWrapperIndex.index) { - column.tasks.splice(column.tasks.indexOf(action.payload.startWrapperIndex.task), 1) + state.projectBoard.columns[index].tasks = column.tasks.filter((task)=> task.id !== action.payload.startWrapperIndex.task.id); } }) }