From 776c53cbbd12009aeed03a8879a2c6b07e8726cd Mon Sep 17 00:00:00 2001 From: MaxOvs19 Date: Mon, 8 May 2023 16:57:35 +0300 Subject: [PATCH 1/4] Fixed modal edit clumn --- .../UI/TrackerModal/TrackerModal.jsx | 18 ++++++++++-------- src/pages/ProjectTracker/ProjectTracker.js | 5 ++++- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/components/UI/TrackerModal/TrackerModal.jsx b/src/components/UI/TrackerModal/TrackerModal.jsx index 026d1093..71a85d35 100644 --- a/src/components/UI/TrackerModal/TrackerModal.jsx +++ b/src/components/UI/TrackerModal/TrackerModal.jsx @@ -7,7 +7,7 @@ import { getValueModalType, setProject, setProjectBoardFetch, - editProjectName + editProjectName, } from "../../../redux/projectsTrackerSlice"; import "./trackerModal.scss"; @@ -18,7 +18,8 @@ export const TrackerModal = ({ selectedTab, defautlInput, titleProject, - projectId + projectId, + titleColumn, }) => { const dispatch = useDispatch(); const projectBoard = useSelector(getProjectBoard); @@ -30,6 +31,8 @@ export const TrackerModal = ({ const [valueColumn, setValueColumn] = useState(""); const [nameProject, setNameProject] = useState(""); + // const [editTitleColumn, setEditTitleColumn] = useState(titleColumn); + const [valueTiket, setValueTiket] = useState(""); const [descriptionTicket, setDescriptionTicket] = useState(""); @@ -80,11 +83,11 @@ export const TrackerModal = ({ method: "PUT", data: { project_id: projectId, - name: projectName + name: projectName, }, }).then((res) => { - setActive(false) - dispatch(editProjectName({id: projectId, name: projectName})) + setActive(false); + dispatch(editProjectName({ id: projectId, name: projectName })); }); } @@ -232,7 +235,6 @@ export const TrackerModal = ({ )} - {/* TODO: fix state */} {modalType === "editColumn" && (
@@ -240,8 +242,8 @@ export const TrackerModal = ({
setValueTiket(e.target.value)} + value={titleColumn} + onChange={(e) => setEditTitleColumn(e.target.value)} />
diff --git a/src/pages/ProjectTracker/ProjectTracker.js b/src/pages/ProjectTracker/ProjectTracker.js index 59c3697d..584d42b2 100644 --- a/src/pages/ProjectTracker/ProjectTracker.js +++ b/src/pages/ProjectTracker/ProjectTracker.js @@ -42,6 +42,7 @@ export const ProjectTracker = () => { const [modalAdd, setModalAdd] = useState(false); const [modalActiveTicket, setModalActiveTicket] = useState(false); const [selectedTicket, setSelectedTicket] = useState({}); + const [titleEditColumn, setTitleEditColumn] = useState(""); const startWrapperIndexTest = useRef({}); const projectBoard = useSelector(getProjectBoard); @@ -202,7 +203,8 @@ export const ProjectTracker = () => { active={modalAdd} setActive={setModalAdd} selectedTab={selectedTab} - > + titleColumn={titleEditColumn} + />
{ [column.id]: false, })); dispatch(modalToggle("editColumn")); + setTitleEditColumn(column.title); setModalAdd(true); }} > From e1ac3bc70e8f202ccbe77f0a288d0c6902281fbd Mon Sep 17 00:00:00 2001 From: M1kola Date: Tue, 9 May 2023 01:13:55 +0300 Subject: [PATCH 2/4] fix --- src/components/UI/TrackerModal/TrackerModal.jsx | 5 ++--- src/pages/ProjectTracker/ProjectTracker.js | 15 ++++++--------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/components/UI/TrackerModal/TrackerModal.jsx b/src/components/UI/TrackerModal/TrackerModal.jsx index 71a85d35..1bc6535c 100644 --- a/src/components/UI/TrackerModal/TrackerModal.jsx +++ b/src/components/UI/TrackerModal/TrackerModal.jsx @@ -28,11 +28,10 @@ export const TrackerModal = ({ const [emailWorker, setEmailWorker] = useState(""); const [projectName, setProjectName] = useState(defautlInput); + const [editTitleColumn, setEditTitleColumn] = useState(titleColumn); const [valueColumn, setValueColumn] = useState(""); const [nameProject, setNameProject] = useState(""); - // const [editTitleColumn, setEditTitleColumn] = useState(titleColumn); - const [valueTiket, setValueTiket] = useState(""); const [descriptionTicket, setDescriptionTicket] = useState(""); @@ -242,7 +241,7 @@ export const TrackerModal = ({
setEditTitleColumn(e.target.value)} />
diff --git a/src/pages/ProjectTracker/ProjectTracker.js b/src/pages/ProjectTracker/ProjectTracker.js index 584d42b2..47a402ee 100644 --- a/src/pages/ProjectTracker/ProjectTracker.js +++ b/src/pages/ProjectTracker/ProjectTracker.js @@ -42,7 +42,6 @@ export const ProjectTracker = () => { const [modalAdd, setModalAdd] = useState(false); const [modalActiveTicket, setModalActiveTicket] = useState(false); const [selectedTicket, setSelectedTicket] = useState({}); - const [titleEditColumn, setTitleEditColumn] = useState(""); const startWrapperIndexTest = useRef({}); const projectBoard = useSelector(getProjectBoard); @@ -199,13 +198,6 @@ export const ProjectTracker = () => {

Проект : {projectBoard.name}

- -
{ @@ -271,6 +263,12 @@ export const ProjectTracker = () => { wrapperHover[column.id] ? "tasks__board__hover" : "" }`} > +
{/**/} {column.title} @@ -304,7 +302,6 @@ export const ProjectTracker = () => { [column.id]: false, })); dispatch(modalToggle("editColumn")); - setTitleEditColumn(column.title); setModalAdd(true); }} > From 83f0c670176a0cb62ae54f75fe82574a6ef54da5 Mon Sep 17 00:00:00 2001 From: MaxOvs19 Date: Wed, 10 May 2023 12:23:35 +0300 Subject: [PATCH 3/4] added store modal tracker --- .../UI/TrackerModal/TrackerModal.jsx | 18 ++++++++++++-- src/pages/ProjectTracker/ProjectTracker.js | 14 ++++++----- src/redux/projectsTrackerSlice.js | 24 ++++++++++++------- 3 files changed, 39 insertions(+), 17 deletions(-) diff --git a/src/components/UI/TrackerModal/TrackerModal.jsx b/src/components/UI/TrackerModal/TrackerModal.jsx index 1bc6535c..75a96866 100644 --- a/src/components/UI/TrackerModal/TrackerModal.jsx +++ b/src/components/UI/TrackerModal/TrackerModal.jsx @@ -8,6 +8,7 @@ import { setProject, setProjectBoardFetch, editProjectName, + getColumnTitle, } from "../../../redux/projectsTrackerSlice"; import "./trackerModal.scss"; @@ -19,16 +20,18 @@ export const TrackerModal = ({ defautlInput, titleProject, projectId, - titleColumn, }) => { const dispatch = useDispatch(); const projectBoard = useSelector(getProjectBoard); const modalType = useSelector(getValueModalType); + const titleColumn = useSelector(getColumnTitle); + const [emailWorker, setEmailWorker] = useState(""); const [projectName, setProjectName] = useState(defautlInput); - const [editTitleColumn, setEditTitleColumn] = useState(titleColumn); + const [editTitleColumn, setEditTitleColumn] = useState(""); + const [valueColumn, setValueColumn] = useState(""); const [nameProject, setNameProject] = useState(""); @@ -239,8 +242,19 @@ export const TrackerModal = ({

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

+ {/* {Boolean(projectBoard?.columns) && + Boolean(projectBoard.columns.length) && + projectBoard.columns.map((column) => { + // console.log(column.title); + // console.log("Lol" + titleColumn.title); + if (column.title === titleColumn) { + console.log(column.title); + + } + })} */} setEditTitleColumn(e.target.value)} /> diff --git a/src/pages/ProjectTracker/ProjectTracker.js b/src/pages/ProjectTracker/ProjectTracker.js index 47a402ee..6c78f0c9 100644 --- a/src/pages/ProjectTracker/ProjectTracker.js +++ b/src/pages/ProjectTracker/ProjectTracker.js @@ -16,6 +16,7 @@ import { setProjectBoardFetch, setToggleTab, activeLoader, + setColumnTitle, } from "../../redux/projectsTrackerSlice"; import ModalTicket from "../../components/UI/ModalTicket/ModalTicket"; @@ -191,6 +192,12 @@ export const ProjectTracker = () => {
+ + {loader && } {!loader && (
@@ -263,12 +270,6 @@ export const ProjectTracker = () => { wrapperHover[column.id] ? "tasks__board__hover" : "" }`} > -
{/**/} {column.title} @@ -302,6 +303,7 @@ export const ProjectTracker = () => { [column.id]: false, })); dispatch(modalToggle("editColumn")); + dispatch(setColumnTitle(column.title)); setModalAdd(true); }} > diff --git a/src/redux/projectsTrackerSlice.js b/src/redux/projectsTrackerSlice.js index 754adcc1..0ee4459e 100644 --- a/src/redux/projectsTrackerSlice.js +++ b/src/redux/projectsTrackerSlice.js @@ -6,7 +6,8 @@ const initialState = { projectBoard: {}, toggleTab: 1, modalType: "", - boardLoader: false + titleColumn: "", + boardLoader: false, }; export const setProjectBoardFetch = createAsyncThunk("userInfo", (id) => @@ -29,12 +30,12 @@ export const projectsTrackerSlice = createSlice({ deleteProject: (state, action) => { state.projects.forEach((project) => { if (project.id === action.payload.id) { - project.status = 10 + project.status = 10; } - }) + }); }, activeLoader: (state) => { - state.boardLoader = true + state.boardLoader = true; }, moveProjectTask: (state, action) => { state.projectBoard.columns.forEach((column, index) => { @@ -58,18 +59,21 @@ export const projectsTrackerSlice = createSlice({ editProjectName: (state, action) => { state.projects.forEach((project) => { if (project.id === action.payload.id) { - project.name = action.payload.name + project.name = action.payload.name; } - }) + }); }, modalToggle: (state, action) => { state.modalType = action.payload; }, + setColumnTitle: (state, action) => { + state.titleColumn = action.payload; + }, }, extraReducers: { [setProjectBoardFetch.fulfilled]: (state, action) => { state.projectBoard = action.payload; - state.boardLoader = false + state.boardLoader = false; }, }, }); @@ -82,13 +86,15 @@ export const { setToggleTab, modalToggle, activeLoader, - editProjectName + editProjectName, + setColumnTitle, } = projectsTrackerSlice.actions; export const getProjects = (state) => state.tracker.projects; export const getProjectBoard = (state) => state.tracker.projectBoard; export const getToggleTab = (state) => state.tracker.toggleTab; export const getValueModalType = (state) => state.tracker.modalType; -export const getBoarderLoader = (state) => state.tracker.boardLoader +export const getColumnTitle = (state) => state.tracker.titleColumn; +export const getBoarderLoader = (state) => state.tracker.boardLoader; export default projectsTrackerSlice.reducer; From 906dd0ec907b6912248c5199e8addcf8e3e23ffd Mon Sep 17 00:00:00 2001 From: M1kola Date: Mon, 15 May 2023 21:23:42 +0300 Subject: [PATCH 4/4] fix --- src/components/UI/TrackerModal/TrackerModal.jsx | 16 ++-------------- src/pages/ProjectTracker/ProjectTracker.js | 7 ++++++- src/redux/projectsTrackerSlice.js | 5 ----- 3 files changed, 8 insertions(+), 20 deletions(-) diff --git a/src/components/UI/TrackerModal/TrackerModal.jsx b/src/components/UI/TrackerModal/TrackerModal.jsx index 75a96866..9951b10b 100644 --- a/src/components/UI/TrackerModal/TrackerModal.jsx +++ b/src/components/UI/TrackerModal/TrackerModal.jsx @@ -20,17 +20,16 @@ export const TrackerModal = ({ defautlInput, titleProject, projectId, + titleColumn }) => { const dispatch = useDispatch(); const projectBoard = useSelector(getProjectBoard); const modalType = useSelector(getValueModalType); - const titleColumn = useSelector(getColumnTitle); - const [emailWorker, setEmailWorker] = useState(""); const [projectName, setProjectName] = useState(defautlInput); - const [editTitleColumn, setEditTitleColumn] = useState(""); + const [editTitleColumn, setEditTitleColumn] = useState(titleColumn); const [valueColumn, setValueColumn] = useState(""); const [nameProject, setNameProject] = useState(""); @@ -242,19 +241,8 @@ export const TrackerModal = ({

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

- {/* {Boolean(projectBoard?.columns) && - Boolean(projectBoard.columns.length) && - projectBoard.columns.map((column) => { - // console.log(column.title); - // console.log("Lol" + titleColumn.title); - if (column.title === titleColumn) { - console.log(column.title); - - } - })} */} setEditTitleColumn(e.target.value)} /> diff --git a/src/pages/ProjectTracker/ProjectTracker.js b/src/pages/ProjectTracker/ProjectTracker.js index 6c78f0c9..842f85a0 100644 --- a/src/pages/ProjectTracker/ProjectTracker.js +++ b/src/pages/ProjectTracker/ProjectTracker.js @@ -270,6 +270,12 @@ export const ProjectTracker = () => { wrapperHover[column.id] ? "tasks__board__hover" : "" }`} > +
{/**/} {column.title} @@ -303,7 +309,6 @@ export const ProjectTracker = () => { [column.id]: false, })); dispatch(modalToggle("editColumn")); - dispatch(setColumnTitle(column.title)); setModalAdd(true); }} > diff --git a/src/redux/projectsTrackerSlice.js b/src/redux/projectsTrackerSlice.js index 0ee4459e..9efb3268 100644 --- a/src/redux/projectsTrackerSlice.js +++ b/src/redux/projectsTrackerSlice.js @@ -6,7 +6,6 @@ const initialState = { projectBoard: {}, toggleTab: 1, modalType: "", - titleColumn: "", boardLoader: false, }; @@ -66,9 +65,6 @@ export const projectsTrackerSlice = createSlice({ modalToggle: (state, action) => { state.modalType = action.payload; }, - setColumnTitle: (state, action) => { - state.titleColumn = action.payload; - }, }, extraReducers: { [setProjectBoardFetch.fulfilled]: (state, action) => { @@ -94,7 +90,6 @@ export const getProjects = (state) => state.tracker.projects; export const getProjectBoard = (state) => state.tracker.projectBoard; export const getToggleTab = (state) => state.tracker.toggleTab; export const getValueModalType = (state) => state.tracker.modalType; -export const getColumnTitle = (state) => state.tracker.titleColumn; export const getBoarderLoader = (state) => state.tracker.boardLoader; export default projectsTrackerSlice.reducer;