Attendance Record Popup Shows Wrong Date Format

This commit is contained in:
Kartik Sharma 2025-08-29 12:49:33 +05:30
parent 9dddba4e30
commit 7d41412821

View File

@ -1,4 +1,4 @@
import React, { useEffect, useState } from "react";
import React, { useEffect } from "react";
import { useEmployeeAttendacesLog } from "../../hooks/useAttendance";
import { convertShortTime } from "../../utils/dateUtils";
import { useNavigate } from "react-router-dom";
@ -8,6 +8,16 @@ const AttendLogs = ({ Id }) => {
const { logs, loading } = useEmployeeAttendacesLog(Id);
const navigate = useNavigate();
// 🔹 Utility: format date as DD-MM-YYYY
const formatDate = (dateStr) => {
if (!dateStr) return "";
const date = new Date(dateStr);
const day = String(date.getDate()).padStart(2, "0");
const month = String(date.getMonth() + 1).padStart(2, "0");
const year = date.getFullYear();
return `${day}-${month}-${year}`;
};
const isCheckoutRegularized = (
activityTimeStr,
checkoutTimeStr,
@ -128,7 +138,7 @@ const AttendLogs = ({ Id }) => {
<p>
Attendance logs for{" "}
{logs[0]?.employee?.firstName + " " + logs[0]?.employee?.lastName}{" "}
on {logs[0]?.activityTime.slice(0, 10)}{" "}
on {formatDate(logs[0]?.activityTime)}
</p>
)}
</div>
@ -156,13 +166,13 @@ const AttendLogs = ({ Id }) => {
.sort((a, b) => b.id - a.id)
.map((log, index) => (
<tr key={index}>
<td>{log.activityTime.slice(0, 10)}</td>
<td>{formatDate(log.activityTime)}</td>
<td>{convertShortTime(log.activityTime)}</td>
<td>
{whichActivityPerform(log.activity, log.activityTime)}
</td>
<td>
{log?.latitude != 0 ? (
{log?.latitude !== 0 ? (
<i
className="bx bx-map text-danger cursor-pointer"
data-bs-toggle="tooltip"