Merge pull request 'Bug#215 updated regularization logic based on 48-hour checkout threshold for attendanceLogs.' (#97) from pramod_Bug-#215 into Issue_May_2W
Reviewed-on: #97
This commit is contained in:
commit
73152dbf0a
@ -2,12 +2,27 @@ import React, { useEffect, useState } from "react";
|
||||
import { useEmployeeAttendacesLog } from "../../hooks/useAttendance";
|
||||
import { convertShortTime } from "../../utils/dateUtils";
|
||||
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 (
|
||||
<i
|
||||
className="bx bx-help-circle text-secondary"
|
||||
className="bx bx-help-circle text-danger"
|
||||
data-bs-toggle="tooltip"
|
||||
data-bs-offset="0,8"
|
||||
data-bs-placement="top"
|
||||
data-bs-custom-class="tooltip"
|
||||
title="regularize Requested"
|
||||
title="Regularize Requested"
|
||||
></i>
|
||||
);
|
||||
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!"
|
||||
></i>
|
||||
);
|
||||
break;
|
||||
case 4:
|
||||
return (
|
||||
<i
|
||||
className="bx bx-left-arrow-circle text-danger "
|
||||
data-bs-toggle="tooltip"
|
||||
data-bs-offset="0,8"
|
||||
data-bs-placement="top"
|
||||
data-bs-custom-class="tooltip"
|
||||
title="Check-Out"
|
||||
></i>
|
||||
);
|
||||
if (
|
||||
checkOutTime &&
|
||||
isCheckoutRegularized(logs[0]?.activityTime, checkOutTime, THRESH_HOLD)
|
||||
) {
|
||||
return (
|
||||
<i
|
||||
className="bx bx-check-circle text-success"
|
||||
data-bs-toggle="tooltip"
|
||||
data-bs-offset="0,8"
|
||||
data-bs-placement="top"
|
||||
data-bs-custom-class="tooltip"
|
||||
title="Regularized"
|
||||
></i>
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<i
|
||||
className="bx bx-left-arrow-circle text-danger"
|
||||
data-bs-toggle="tooltip"
|
||||
data-bs-offset="0,8"
|
||||
data-bs-placement="top"
|
||||
data-bs-custom-class="tooltip"
|
||||
title="Check-Out"
|
||||
></i>
|
||||
);
|
||||
}
|
||||
|
||||
break;
|
||||
case 5:
|
||||
return (
|
||||
<i
|
||||
className="bx bx-x-circle text-danger"
|
||||
className="bx bx-x-circle text-danger"
|
||||
data-bs-toggle="tooltip"
|
||||
data-bs-offset="0,8"
|
||||
data-bs-placement="top"
|
||||
@ -79,6 +110,7 @@ const AttendLogs = ({ Id }) => {
|
||||
const url = `https://www.google.com/maps?q=${lat},${lng}`;
|
||||
window.open(url, "_blank"); // Open in new tab
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const tooltipTriggerList = Array.from(
|
||||
document.querySelectorAll('[data-bs-toggle="tooltip"]')
|
||||
@ -122,11 +154,11 @@ const AttendLogs = ({ Id }) => {
|
||||
<tr key={index}>
|
||||
<td>{log.activityTime.slice(0, 10)}</td>
|
||||
<td>{convertShortTime(log.activityTime)}</td>
|
||||
<td>{whichActivityPerform(log.activity)}</td>
|
||||
<td>{whichActivityPerform(log.activity,log.activityTime)}</td>
|
||||
<td>
|
||||
{log?.latitude != 0 ? (
|
||||
<i
|
||||
className="bx bx-location-plus text-danger cursor-pointer"
|
||||
className="bx bx-map text-danger cursor-pointer"
|
||||
data-bs-toggle="tooltip"
|
||||
data-bs-offset="0,8"
|
||||
data-bs-placement="top"
|
||||
|
Loading…
x
Reference in New Issue
Block a user