From 7572ad077753ecced06008ef8340a2d2db23cce3 Mon Sep 17 00:00:00 2001 From: Pramod Mahajan Date: Mon, 12 May 2025 17:00:01 +0530 Subject: [PATCH] modified attend log, icons, correct for regualarize and check-out --- src/components/Activities/AttendLogs.jsx | 69 +++++++++++++++++------- 1 file changed, 50 insertions(+), 19 deletions(-) diff --git a/src/components/Activities/AttendLogs.jsx b/src/components/Activities/AttendLogs.jsx index b246768b..60c94448 100644 --- a/src/components/Activities/AttendLogs.jsx +++ b/src/components/Activities/AttendLogs.jsx @@ -1,13 +1,28 @@ import React, { useEffect, useState } from "react"; import { useEmployeeAttendacesLog } from "../../hooks/useAttendance"; import { convertShortTime } from "../../utils/dateUtils"; -import { useNavigate } from "react-router-dom"; +import {useNavigate} from "react-router-dom"; +import {THRESH_HOLD} from "../../utils/constants"; const AttendLogs = ({ Id }) => { const { logs, loading } = useEmployeeAttendacesLog(Id); const navigate = useNavigate(); - const whichActivityPerform = (actvity) => { + const isCheckoutRegularized = ( + activityTimeStr, + checkoutTimeStr, + threshHours + )=> { + if (!activityTimeStr || !checkoutTimeStr) return false; + + const activityTime = new Date(activityTimeStr); + const checkoutTime = new Date(checkoutTimeStr); + const threshTimeMs = threshHours * 60 * 60 * 1000; + + return checkoutTime - activityTime > threshTimeMs; + } + + const whichActivityPerform = (actvity,checkOutTime) => { switch (actvity) { case 1: return ( @@ -24,12 +39,12 @@ const AttendLogs = ({ Id }) => { case 2: return ( ); break; @@ -41,27 +56,43 @@ const AttendLogs = ({ Id }) => { data-bs-offset="0,8" data-bs-placement="top" data-bs-custom-class="tooltip" - title="Regularized" + title="Request Deleted !" > ); break; case 4: - return ( - - ); + if ( + checkOutTime && + isCheckoutRegularized(logs[0]?.activityTime, checkOutTime, THRESH_HOLD) + ) { + return ( + + ); + } else { + return ( + + ); + } break; case 5: return ( { {log.activityTime.slice(0, 10)} {convertShortTime(log.activityTime)} - {whichActivityPerform(log.activity)} + {whichActivityPerform(log.activity,log.activityTime)} - {log?.latitude != 0 ? ( + {(log?.latitude && log?.longitude) ? (