From ce4b517ce556bfcdce554a0173b0178a47bc0d16 Mon Sep 17 00:00:00 2001 From: Pramod Mahajan Date: Wed, 14 May 2025 15:34:40 +0530 Subject: [PATCH 01/40] Add condition to move entries to 'approved' if checkOut and date are in the past. --- src/hooks/useAttendanceStatus.js | 224 +++++++++++++++++-------------- 1 file changed, 121 insertions(+), 103 deletions(-) diff --git a/src/hooks/useAttendanceStatus.js b/src/hooks/useAttendanceStatus.js index e0dd8e6c..b1b6180b 100644 --- a/src/hooks/useAttendanceStatus.js +++ b/src/hooks/useAttendanceStatus.js @@ -1,8 +1,7 @@ -import { useEffect, useState } from 'react'; -import { timeElapsed } from '../utils/dateUtils'; -import { useSelector } from 'react-redux'; -import {THRESH_HOLD} from '../utils/constants'; - +import { useEffect, useState } from "react"; +import { timeElapsed } from "../utils/dateUtils"; +import { useSelector } from "react-redux"; +import { THRESH_HOLD } from "../utils/constants"; export const ACTIONS = { CHECK_IN: 0, @@ -10,124 +9,143 @@ export const ACTIONS = { REGULARIZATION: 2, REQUESTED: 3, APPROVED: 4, - REJECTED: 5 + REJECTED: 5, }; - +const now = new Date(); const useAttendanceStatus = (attendanceData) => { - const [status, setStatus] = useState({ status: "Unknown", action: null, disabled: true, text: "Unknown", - color: 'btn-secondary', + color: "btn-secondary", }); - useEffect(() => { - const { checkInTime, checkOutTime, activity } = attendanceData; - - if(activity === 0 && checkInTime === null && checkOutTime === null){ - setStatus({ - status: "Check-In", - action: ACTIONS.CHECK_IN, - disabled: false, - text: "Check In", - color: 'btn-primary', - }) - }else if(activity === 0&& checkInTime === null && checkOutTime === null && !timeElapsed(checkInTime,THRESH_HOLD)){ - setStatus({ - status: "Check-In", - action: ACTIONS.CHECK_IN, - disabled: false, - text: "Check In", - color: 'btn-primary', - }) - - } else if(activity === 0&& checkInTime !== null && checkOutTime === null && timeElapsed(checkInTime,THRESH_HOLD)){ - setStatus({ - status: "Request Regularize", - action: ACTIONS.REGULARIZATION, - disabled: false, - text: "Regularizes", - color: 'btn-warning', - }); - - } - - else if(activity === 1 && checkInTime !== null && checkOutTime === null && !timeElapsed(checkInTime,THRESH_HOLD)){ - setStatus({ - status: "Check-Out", - action: ACTIONS.CHECK_OUT, - disabled: false, - text: "Check Out", - color: 'btn-primary', - }); - }else if(activity === 1 && checkInTime !== null && checkOutTime === null && timeElapsed(checkInTime,THRESH_HOLD)){ - setStatus({ - status: "Request Regularize", - action: ACTIONS.REGULARIZATION, - disabled: false, - text: "Regularize", - color: 'btn-warning', - }); - } else if ( activity === 4 && checkInTime !== null && checkOutTime !== null && !timeElapsed( checkInTime, THRESH_HOLD ) ) - { - - if ( activity === 4 && checkInTime !== null && checkOutTime !== null && new Date(checkOutTime).toDateString() !== new Date().toDateString()) - { - setStatus( { - status: "Approved", - action: ACTIONS.APPROVED, - disabled: true, - text: "Approved", - color: 'btn-success', - } ); - } else - { - setStatus( { - status: "Check-In", - action: ACTIONS.CHECK_IN, - disabled: false, - text: "Check In", - color: 'btn-primary', - } ) - } - } - else if ( activity === 2 && checkInTime !== null ) - { - setStatus({ - status: "Requested", - action: ACTIONS.REQUESTED, - disabled: true, - text: "Requested", - color: 'btn-info', - }); - }else if(activity === 5 && checkInTime !== null ){ - - - setStatus({ - status: "Rejected", - action: ACTIONS.REJECTED, - disabled: true, - text: "Rejected", - color: 'btn-danger', - }); - - }else { + if (activity === 0 && checkInTime === null && checkOutTime === null) { + setStatus({ + status: "Check-In", + action: ACTIONS.CHECK_IN, + disabled: false, + text: "Check In", + color: "btn-primary", + }); + } else if (activity === 4 && new Date(checkOutTime) < now) { + setStatus({ + status: "Approved", + action: ACTIONS.APPROVED, + disabled: true, + text: "Approved", + color: "btn-success", + }); + } else if ( + activity === 0 && + checkInTime === null && + checkOutTime === null && + !timeElapsed(checkInTime, THRESH_HOLD) + ) { + setStatus({ + status: "Check-In", + action: ACTIONS.CHECK_IN, + disabled: false, + text: "Check In", + color: "btn-primary", + }); + } else if ( + activity === 0 && + checkInTime !== null && + checkOutTime === null && + timeElapsed(checkInTime, THRESH_HOLD) + ) { + setStatus({ + status: "Request Regularize", + action: ACTIONS.REGULARIZATION, + disabled: false, + text: "Regularizes", + color: "btn-warning", + }); + } else if ( + activity === 1 && + checkInTime !== null && + checkOutTime === null && + !timeElapsed(checkInTime, THRESH_HOLD) + ) { + setStatus({ + status: "Check-Out", + action: ACTIONS.CHECK_OUT, + disabled: false, + text: "Check Out", + color: "btn-primary", + }); + } else if ( + activity === 1 && + checkInTime !== null && + checkOutTime === null && + timeElapsed(checkInTime, THRESH_HOLD) + ) { + setStatus({ + status: "Request Regularize", + action: ACTIONS.REGULARIZATION, + disabled: false, + text: "Regularize", + color: "btn-warning", + }); + } else if ( + activity === 4 && + checkInTime !== null && + checkOutTime !== null && + !timeElapsed(checkInTime, THRESH_HOLD) + ) { + if ( + activity === 4 && + checkInTime !== null && + checkOutTime !== null && + new Date(checkOutTime).toDateString() !== new Date().toDateString() + ) { setStatus({ status: "Approved", action: ACTIONS.APPROVED, disabled: true, text: "Approved", - color: 'btn-success', + color: "btn-success", + }); + } else { + setStatus({ + status: "Check-In", + action: ACTIONS.CHECK_IN, + disabled: false, + text: "Check In", + color: "btn-primary", }); } - - + } else if (activity === 2 && checkInTime !== null) { + setStatus({ + status: "Requested", + action: ACTIONS.REQUESTED, + disabled: true, + text: "Requested", + color: "btn-info", + }); + } else if (activity === 5 && checkInTime !== null) { + setStatus({ + status: "Rejected", + action: ACTIONS.REJECTED, + disabled: true, + text: "Rejected", + color: "btn-danger", + }); + } else { + setStatus({ + status: "Approved", + action: ACTIONS.APPROVED, + disabled: true, + text: "Approved", + color: "btn-success", + }); + } }, [attendanceData]); return status; From 2ebd1a074fd90100fb288db7331224aa7cc59677 Mon Sep 17 00:00:00 2001 From: Pramod Mahajan Date: Wed, 14 May 2025 15:35:55 +0530 Subject: [PATCH 02/40] show 'No Reports Found' message when task list is empty and loading is complete --- src/pages/Activities/DailyTask.jsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/pages/Activities/DailyTask.jsx b/src/pages/Activities/DailyTask.jsx index 0c98dd26..5b69c596 100644 --- a/src/pages/Activities/DailyTask.jsx +++ b/src/pages/Activities/DailyTask.jsx @@ -187,6 +187,13 @@ const DailyTask = () => { )} + {!task_loading && TaskList.length === 0 && ( + + +

No Reports Found

+ + + )} {dates.map((date, i) => { return ( From 7d070025550c7565eca612381bbc98e319cec7b2 Mon Sep 17 00:00:00 2001 From: Pramod Mahajan Date: Wed, 14 May 2025 22:36:44 +0530 Subject: [PATCH 03/40] visible assign task button in mobile view --- src/components/Project/Infrastructure/WorkItem.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Project/Infrastructure/WorkItem.jsx b/src/components/Project/Infrastructure/WorkItem.jsx index b24cafa2..6cf17687 100644 --- a/src/components/Project/Infrastructure/WorkItem.jsx +++ b/src/components/Project/Infrastructure/WorkItem.jsx @@ -266,7 +266,7 @@ const WorkItem = ({ > + + + + + + + + {employeeLoading &&
Loading...
} + {!employeeLoading && + filteredEmployees?.length === 0 && + employees &&
No employees found
} + +
+
+ {selectedRole !== "" && ( +
+ {loading ? ( +
+

Loading...

+
+ ) : filteredEmployees?.length > 0 ? ( + filteredEmployees?.map((emp) => { + const jobRole = jobRoleData?.find( + (role) => role?.id === emp?.jobRoleId + ); + + return ( +
+
( { - handleEmployeeSelection( - emp.id, - field - ); + checked={field.value.includes(emp.id)} + onChange={(e) => { + handleCheckboxChange(e, emp); }} /> )} /> -
-

+

+

{emp.firstName} {emp.lastName}

- - {loading && ( -

+ + {loading ? ( + + + + ) : ( + jobRole?.name || "Unknown Role" )} - {data && - !loading && - (jobRole - ? jobRole.name - : "Unknown Role")}
-
+ ); + }) + ) : ( +
+

No employees found for the selected role.

+
+ )} +
+ )} +
+
+
+ {watch("selectedEmployees")?.length > 0 && ( +
+
+ {watch("selectedEmployees")?.map((empId) => { + const emp = employees.find( + (emp) => emp.id === empId + ); + return ( + emp && ( + + {emp.firstName} {emp.lastName} +

{ + const employeeToRemove = employees.find( + (e) => e.id === empId + ); + const updatedSelected = watch( + "selectedEmployees" + ).filter((id) => id !== empId); + setValue( + "selectedEmployees", + updatedSelected + ); + }} + > + +

+
+ ) ); })}
-
- )} - -
- {selectedEmployees.length > 0 && ( -
-
- {selectedEmployees.map((empId) => { - const emp = employees.find( - (emp) => emp.id === empId - ); - return ( - - {emp.firstName} {emp.lastName} -

{ - removeEmployee(empId); - setValue( - "selectedEmployees", - selectedEmployees.filter( - (id) => id !== empId - ) - ); - }} - > - -

-
- ); - })} -
-
- )} -
- + )} + -
-
- - -
-
-
- {errors.plannedTask && ( -
- {errors.plannedTask.message} -
- )} -
- {errors.selectedEmployees && ( -
-

{errors.selectedEmployees.message}

-
- )} - - ( -