From 18b328743acbda72be9be4976644cbff322944c5 Mon Sep 17 00:00:00 2001 From: Pramod Mahajan Date: Sat, 10 May 2025 11:54:23 +0530 Subject: [PATCH 1/9] handled properly checkInTime for timeElapsed --- src/utils/dateUtils.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/dateUtils.jsx b/src/utils/dateUtils.jsx index f18efd0f..cb393e41 100644 --- a/src/utils/dateUtils.jsx +++ b/src/utils/dateUtils.jsx @@ -41,7 +41,7 @@ export const convertShortTime = (dateString) => { }; export const timeElapsed = (checkInTime, timeElapsedInHours) => { - const checkInDate = new Date(checkInTime); + const checkInDate = new Date( checkInTime.split( "T" )[ 0 ] ); const currentTime = new Date(); From 19e4962ef8a165e1a27ea5aa81ac16d86e2dc065 Mon Sep 17 00:00:00 2001 From: Pramod Mahajan Date: Sat, 10 May 2025 12:30:17 +0530 Subject: [PATCH 2/9] time slot display correct slots and if check-In so must display grather than check-in --- src/components/Activities/CheckCheckOutForm.jsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/Activities/CheckCheckOutForm.jsx b/src/components/Activities/CheckCheckOutForm.jsx index 419e7b12..b820233d 100644 --- a/src/components/Activities/CheckCheckOutForm.jsx +++ b/src/components/Activities/CheckCheckOutForm.jsx @@ -50,8 +50,11 @@ const CheckCheckOutmodel = ({modeldata,closeModal,handleSubmitForm,}) => { showToast("Attendance Marked Successfully", "success"); }) - .catch((error) => { - showToast(error, "error"); + .catch( ( error ) => + { + + showToast(error, "error" ); + }); // } else From 349d2a62ff26ea00a1a850c425dbbd75833771a2 Mon Sep 17 00:00:00 2001 From: Pramod Mahajan Date: Sat, 10 May 2025 12:31:25 +0530 Subject: [PATCH 3/9] handled correct time slots --- src/components/common/TimePicker.jsx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/components/common/TimePicker.jsx b/src/components/common/TimePicker.jsx index cb76a5d1..7676e013 100644 --- a/src/components/common/TimePicker.jsx +++ b/src/components/common/TimePicker.jsx @@ -120,15 +120,21 @@ const TimePicker = ({ label, onChange, interval = 10, value,checkInTime,checkOut }, [value, interval, onChange]); - useEffect(() => { - if (isOpen && time && slotRefs.current[time]) { - const selectedSlot = slotRefs.current[time]; - selectedSlot.scrollIntoView({ + useEffect(() => { + if (isOpen) { + const slots = generateTimeSlots(); + const targetTime = slots.find(slot => slot.time === time && slot.isSelectable) + ? time + : (slots.find(slot => slot.isSelectable)?.time || null); + + if (targetTime && slotRefs.current[targetTime]) { + slotRefs.current[targetTime].scrollIntoView({ behavior: "smooth", block: "center", }); } - }, [isOpen, time]); + } +}, [isOpen, time]); return ( From 3a84d2f4c9bdbb25d5a2627d51c33276bff395a8 Mon Sep 17 00:00:00 2001 From: Pramod Mahajan Date: Sat, 10 May 2025 12:32:26 +0530 Subject: [PATCH 4/9] handled attendance error object in readble format --- src/slices/apiSlice/attedanceLogsSlice.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/slices/apiSlice/attedanceLogsSlice.js b/src/slices/apiSlice/attedanceLogsSlice.js index e09ab294..249d5445 100644 --- a/src/slices/apiSlice/attedanceLogsSlice.js +++ b/src/slices/apiSlice/attedanceLogsSlice.js @@ -38,8 +38,10 @@ export const markAttendance = createAsyncThunk( const response = await AttendanceRepository.markAttendance( newRecordAttendance ); return response.data; - } catch (error) { - return thunkAPI.rejectWithValue(error.message); + } catch ( error ) + { + const message = error?.response?.data?.message || error.message || "Error Occured During Api Call"; + return thunkAPI.rejectWithValue(message); } } ); From c860a63ad6d8ece5365d8cac6e9bce6eaa7a6930 Mon Sep 17 00:00:00 2001 From: Pramod Mahajan Date: Sat, 10 May 2025 12:33:21 +0530 Subject: [PATCH 5/9] completedWork can't not update if it grather than zero --- src/components/Project/Infrastructure/EditActivityModal.jsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/Project/Infrastructure/EditActivityModal.jsx b/src/components/Project/Infrastructure/EditActivityModal.jsx index a0077e26..e8927ae3 100644 --- a/src/components/Project/Infrastructure/EditActivityModal.jsx +++ b/src/components/Project/Infrastructure/EditActivityModal.jsx @@ -303,6 +303,7 @@ const EditActivityModal = ({ type="number" className="form-control form-control-sm me-2" placeholder="Completed Work" + disabled={getValues("completedWork") > 0} /> {errors.completedWork && (

{errors.completedWork.message}

From c728b162e8698d27299d4792ef20a5137c5014a9 Mon Sep 17 00:00:00 2001 From: Pramod Mahajan Date: Sat, 10 May 2025 12:53:11 +0530 Subject: [PATCH 6/9] action position changed center to end --- src/components/Project/Infrastructure/WorkArea.jsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/Project/Infrastructure/WorkArea.jsx b/src/components/Project/Infrastructure/WorkArea.jsx index 8ac3ef60..493312b1 100644 --- a/src/components/Project/Infrastructure/WorkArea.jsx +++ b/src/components/Project/Infrastructure/WorkArea.jsx @@ -69,7 +69,9 @@ const WorkArea = ({ workArea, floor, forBuilding }) => { {/* ************************** */} Progress - Actions + + Actions + From 1dbd8ba317b645af58f07e9ef1ebcb4c15becfc4 Mon Sep 17 00:00:00 2001 From: Pramod Mahajan Date: Sat, 10 May 2025 12:54:10 +0530 Subject: [PATCH 7/9] can't update completed is greather than zero --- .../Project/Infrastructure/WorkItem.jsx | 112 ++++++++++-------- 1 file changed, 62 insertions(+), 50 deletions(-) diff --git a/src/components/Project/Infrastructure/WorkItem.jsx b/src/components/Project/Infrastructure/WorkItem.jsx index 7a7dfb38..0b050068 100644 --- a/src/components/Project/Infrastructure/WorkItem.jsx +++ b/src/components/Project/Infrastructure/WorkItem.jsx @@ -119,6 +119,9 @@ const WorkItem = ({ workItem, forBuilding, forFloor, forWorkArea }) => { showToast(message, "error"); } }; + + const PlannedWork = NewWorkItem?.workItem?.plannedWork || workItem?.plannedWork; + const CompletedWork = NewWorkItem?.workItem?.completedWork ?? workItem?.completedWork; return ( <> {isModalOpen && ( @@ -233,56 +236,65 @@ const WorkItem = ({ workItem, forBuilding, forFloor, forWorkArea }) => { > - -
- {!projectId && ManageTasks && ( - - )} - {ManageInfra && ( - <> - - - - )} -
- + +
+ {/* Reserve space for Assign button */} +
+ {(!projectId && ManageTasks) && (PlannedWork !== CompletedWork) ? ( + + ) : ( + // Hidden placeholder to preserve layout + + Assign + + )} +
+ + {/* Edit and Delete buttons */} + {ManageInfra && ( + <> + + + + )} +
+ + + + ); From ebb5a57b7038e5bd18d573616aa0fef1f4c3bc6f Mon Sep 17 00:00:00 2001 From: Pramod Mahajan Date: Sat, 10 May 2025 12:59:33 +0530 Subject: [PATCH 8/9] changed class too className --- src/components/Project/Infrastructure/Floor.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Project/Infrastructure/Floor.jsx b/src/components/Project/Infrastructure/Floor.jsx index f59fece2..fe015b16 100644 --- a/src/components/Project/Infrastructure/Floor.jsx +++ b/src/components/Project/Infrastructure/Floor.jsx @@ -23,7 +23,7 @@ const Floor = ({ floor, workAreas, forBuilding }) => { Floor:  {" "} - + {floor.floorName} From 6bb1f98ae77284d95448917d9cef8ef2f84f9aa5 Mon Sep 17 00:00:00 2001 From: Pramod Mahajan Date: Sat, 10 May 2025 19:06:34 +0530 Subject: [PATCH 9/9] Merge branch 'Issue_May_2W' of https://git.marcoaiot.com/admin/marco.pms.web into pramod_Task#207, --- .../Project/Infrastructure/WorkArea.jsx | 76 ++++++- .../Project/Infrastructure/WorkItem.jsx | 201 +++++++----------- 2 files changed, 151 insertions(+), 126 deletions(-) diff --git a/src/components/Project/Infrastructure/WorkArea.jsx b/src/components/Project/Infrastructure/WorkArea.jsx index 493312b1..9e796dd6 100644 --- a/src/components/Project/Infrastructure/WorkArea.jsx +++ b/src/components/Project/Infrastructure/WorkArea.jsx @@ -1,22 +1,83 @@ import React, { useEffect, useState } from "react"; import WorkItem from "./WorkItem"; import { useProjectDetails } from "../../../hooks/useProjects"; -import { getCachedData } from "../../../slices/apiDataManager"; +import { cacheData, getCachedData } from "../../../slices/apiDataManager"; +import {useDispatch} from "react-redux"; +import {refreshData} from "../../../slices/localVariablesSlice"; +import ProjectRepository from "../../../repositories/ProjectRepository"; +import showToast from "../../../services/toastService"; const WorkArea = ({ workArea, floor, forBuilding }) => { - const [workItems, setWorkItems] = useState([]); + const [ workItems, setWorkItems ] = useState( [] ); + const dispatch = useDispatch() + const [Project,setProject] = useState() + useEffect(() => { - const project = getCachedData("projectInfo"); + const project = getCachedData( "projectInfo" ); + setProject(project) + if (!project || !forBuilding?.id || !floor?.id || !workArea?.id) return; - const building = project.buildings?.find((b) => b.id === forBuilding.id); const floors = building?.floors?.find((f) => f.id === floor.id); const workAreas = floor?.workAreas?.find((wa) => wa.id === workArea.id); - setWorkItems(workAreas?.workItems || []); - }, [workArea, floor, floor]); + }, [ workArea, floor, floor ] ); + const HanldeDeleteActivity = async (workItemId) => { + + try + { + const updatedProject = { ...Project.data }; + const response = await ProjectRepository.deleteProjectTask( workItemId); + const newProject = { + ...updatedProject, + buildings: updatedProject?.buildings.map((building) => + building?.id === building?.id + ? { + ...building, + floors: building?.floors?.map((floor) => + floor.id === floor?.id + ? { + ...floor, + workAreas: floor.workAreas.map((workArea) => + workArea.id === workArea?.id + ? { + ...workArea, + workItems: workArea.workItems.filter( + (item) => + String(item?.workItem?.id ?? item?.id) !== + String(workItemId) + ), + } + : workArea + ), + } + : floor + ), + } + : building + ), + }; + + cacheData("projectInfo", { + projectId: newProject.id, + data: newProject, + } ); + + dispatch(refreshData(true)); + + + showToast("Activity Deleted Successfully", "success"); + } catch (error) { + const message = + error.response?.data?.message || + error.message || + "An unexpected error occurred"; + showToast(message, "error"); + } + }; + return ( @@ -70,7 +131,7 @@ const WorkArea = ({ workArea, floor, forBuilding }) => { {/* ************************** */} Progress - Actions + Actions @@ -83,6 +144,7 @@ const WorkArea = ({ workArea, floor, forBuilding }) => { forBuilding={forBuilding} forFloor={floor} forWorkArea={workArea} + deleteHandleTask={HanldeDeleteActivity} /> )) ) : ( diff --git a/src/components/Project/Infrastructure/WorkItem.jsx b/src/components/Project/Infrastructure/WorkItem.jsx index 0b050068..965f44f1 100644 --- a/src/components/Project/Infrastructure/WorkItem.jsx +++ b/src/components/Project/Infrastructure/WorkItem.jsx @@ -9,11 +9,22 @@ import ConfirmModal from "../../common/ConfirmModal"; import ProjectRepository from "../../../repositories/ProjectRepository"; import { useProjectDetails } from "../../../hooks/useProjects"; import showToast from "../../../services/toastService"; -import { cacheData, getCachedData } from "../../../slices/apiDataManager"; +import { + cacheData, + clearCacheKey, + getCachedData, +} from "../../../slices/apiDataManager"; import { useDispatch } from "react-redux"; import { refreshData } from "../../../slices/localVariablesSlice"; -const WorkItem = ({ workItem, forBuilding, forFloor, forWorkArea }) => { +const WorkItem = ( { + key, + workItem, + forBuilding, + forFloor, + forWorkArea, + deleteHandleTask, +}) => { const { projectId } = useParams(); const [itemName, setItemName] = useState(""); const [NewWorkItem, setNewWorkItem] = useState(); @@ -26,10 +37,6 @@ const WorkItem = ({ workItem, forBuilding, forFloor, forWorkArea }) => { const project = getCachedData("projectInfo"); const dispatch = useDispatch(); - const { projects_Details } = useProjectDetails( - projectId || project?.projectId - ); - const openModal = () => setIsModalOpen(true); const closeModal = () => setIsModalOpen(false); const getProgress = (planned, completed) => { @@ -66,62 +73,17 @@ const WorkItem = ({ workItem, forBuilding, forFloor, forWorkArea }) => { const handleSubmit = async () => { setLoadingDelete(true); - try - { - const updatedProject = { ...projects_Details }; - const response = await ProjectRepository.deleteProjectTask( workItem.workItemId || workItem.id); - const newProject = { - ...updatedProject, - buildings: updatedProject.buildings.map((building) => - building.id === forBuilding?.id - ? { - ...building, - floors: building.floors.map((floor) => - floor.id === forFloor?.id - ? { - ...floor, - workAreas: floor.workAreas.map((workArea) => - workArea.id === forWorkArea?.id - ? { - ...workArea, - workItems: workArea.workItems.filter( - (item) => - String(item?.workItem?.id ?? item?.id) !== - String(workItem.workItemId) - ), - } - : workArea - ), - } - : floor - ), - } - : building - ), - }; - - cacheData("projectInfo", { - projectId: newProject.id, - data: newProject, - }); - - dispatch(refreshData(true)); - closeModalDelete(); - setLoadingDelete(false); - showToast("Activity Deleted Successfully", "success"); - } catch (error) { - setLoadingDelete(false); - closeModalDelete(); - const message = - error.response?.data?.message || - error.message || - "An unexpected error occurred"; - showToast(message, "error"); - } + let WorkItemId = workItem.workItemId || workItem.id; + deleteHandleTask( WorkItemId ); + setLoadingDelete(false); + closeModalDelete(); + }; - const PlannedWork = NewWorkItem?.workItem?.plannedWork || workItem?.plannedWork; - const CompletedWork = NewWorkItem?.workItem?.completedWork ?? workItem?.completedWork; + const PlannedWork = + NewWorkItem?.workItem?.plannedWork || workItem?.plannedWork; + const CompletedWork = + NewWorkItem?.workItem?.completedWork ?? workItem?.completedWork; return ( <> {isModalOpen && ( @@ -176,7 +138,7 @@ const WorkItem = ({ workItem, forBuilding, forFloor, forWorkArea }) => { )} - + @@ -236,65 +198,66 @@ const WorkItem = ({ workItem, forBuilding, forFloor, forWorkArea }) => { > - -
- {/* Reserve space for Assign button */} -
- {(!projectId && ManageTasks) && (PlannedWork !== CompletedWork) ? ( - - ) : ( - // Hidden placeholder to preserve layout - - Assign - - )} -
- - {/* Edit and Delete buttons */} - {ManageInfra && ( - <> - - - - )} -
- - - + +
+ {/* Reserve space for Assign button */} +
+ {!projectId && ManageTasks && PlannedWork !== CompletedWork ? ( + + ) : ( + // Hidden placeholder to preserve layout + + + Assign + + + )} +
+ {/* Edit and Delete buttons */} + {ManageInfra && ( + <> + + + + )} +
+ );