diff --git a/src/hooks/useAttendanceStatus.js b/src/hooks/useAttendanceStatus.js index a1ba9a22..e0dd8e6c 100644 --- a/src/hooks/useAttendanceStatus.js +++ b/src/hooks/useAttendanceStatus.js @@ -74,15 +74,31 @@ const useAttendanceStatus = (attendanceData) => { text: "Regularize", color: 'btn-warning', }); - }else if(activity === 4 && 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 === 2 && checkInTime !== null ){ + } 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,