removed unused code

This commit is contained in:
pramod mahajan 2025-09-16 10:49:44 +05:30
parent d2288ea967
commit 080d2307ca

View File

@ -16,29 +16,27 @@ import { zodResolver } from "@hookform/resolvers/zod";
import { z } from "zod"; import { z } from "zod";
import { localToUtc } from "../../utils/appUtils"; import { localToUtc } from "../../utils/appUtils";
const EmpAttendance = ({ employee }) => { const EmpAttendance = ({ employee }) => {
const [attendances, setAttendnaces] = useState([]); const [attendances, setAttendnaces] = useState([]);
const [selectedDate, setSelectedDate] = useState(""); const [selectedDate, setSelectedDate] = useState("");
const [dateRange, setDateRange] = useState({ startDate: "", endDate: "" });
const [isModalOpen, setIsModalOpen] = useState(false); const [isModalOpen, setIsModalOpen] = useState(false);
const [attendanceId, setAttendanecId] = useState(); const [attendanceId, setAttendanecId] = useState();
const methods = useForm({ const methods = useForm({
resolver: zodResolver(z.object({ resolver: zodResolver(
startDate: z.string(), z.object({
endDate: z.string() startDate: z.string(),
})), endDate: z.string(),
})
),
defaultValues: { defaultValues: {
startDate: "", startDate: "",
endDate: "" endDate: "",
}, },
}); });
const { control, register, handleSubmit, reset, watch } = methods; const { control, register, handleSubmit, reset, watch } = methods;
const startDate = watch('startDate') const startDate = watch("startDate");
const endDate = watch('endDate') const endDate = watch("endDate");
const { const {
data = [], data = [],
isLoading: loading, isLoading: loading,
@ -46,15 +44,13 @@ const EmpAttendance = ({ employee }) => {
isError, isError,
error, error,
refetch, refetch,
} = useAttendanceByEmployee(employee, localToUtc(startDate), localToUtc(endDate)); } = useAttendanceByEmployee(
employee,
localToUtc(startDate),
localToUtc(endDate)
);
const dispatch = useDispatch(); const dispatch = useDispatch();
// const { data, loading, error } = useSelector(
// (store) => store.employeeAttendance
// );
const [isRefreshing, setIsRefreshing] = useState(true);
const today = new Date(); const today = new Date();
today.setHours(0, 0, 0, 0); today.setHours(0, 0, 0, 0);
@ -92,13 +88,6 @@ const EmpAttendance = ({ employee }) => {
.sort(sortByName); .sort(sortByName);
const group5 = data.filter((d) => d.activity === 5).sort(sortByName); const group5 = data.filter((d) => d.activity === 5).sort(sortByName);
// const sortedFinalList = [
// ...group1,
// ...group2,
// ...group3,
// ...group4,
// ...group5,
// ];
const uniqueMap = new Map(); const uniqueMap = new Map();
@ -111,7 +100,7 @@ const EmpAttendance = ({ employee }) => {
if ( if (
!existing || !existing ||
new Date(rec.checkInTime || rec.checkOutTime) > new Date(rec.checkInTime || rec.checkOutTime) >
new Date(existing.checkInTime || existing.checkOutTime) new Date(existing.checkInTime || existing.checkOutTime)
) { ) {
uniqueMap.set(key, rec); uniqueMap.set(key, rec);
} }
@ -135,11 +124,7 @@ const EmpAttendance = ({ employee }) => {
}; };
const closeModal = () => setIsModalOpen(false); const closeModal = () => setIsModalOpen(false);
const onSubmit = (formData) => {};
const onSubmit = (formData) => {
}
return ( return (
<> <>
{isModalOpen && ( {isModalOpen && (
@ -152,27 +137,28 @@ const EmpAttendance = ({ employee }) => {
className="dataTables_length text-start py-2 d-flex justify-content-between " className="dataTables_length text-start py-2 d-flex justify-content-between "
id="DataTables_Table_0_length" id="DataTables_Table_0_length"
> >
<div className="col-md-4 my-0 "> <div className="col-3 my-0 ">
<> <>
<FormProvider {...methods}> <FormProvider {...methods}>
<form onSubmit={handleSubmit(onSubmit)} className="p-2 text-start"> <form
onSubmit={handleSubmit(onSubmit)}
className="p-2 text-start"
>
<DateRangePicker1 <DateRangePicker1
placeholder="DD-MM-YYYY To DD-MM-YYYY" placeholder="DD-MM-YYYY To DD-MM-YYYY"
startField="startDate" startField="startDate"
endField="endDate" endField="endDate"
defaultRange={true} defaultRange={true}
/> />
</form> </form>
</FormProvider> </FormProvider>
</> </>
</div> </div>
<div className="col-md-2 m-0 text-end"> <div className="col-md-2 m-0 text-end">
<i <i
className={`bx bx-refresh cursor-pointer fs-4 ${isFetching ? "spin" : "" className={`bx bx-refresh cursor-pointer fs-4 ${
}`} isFetching ? "spin" : ""
}`}
data-toggle="tooltip" data-toggle="tooltip"
title="Refresh" title="Refresh"
onClick={() => refetch()} onClick={() => refetch()}
@ -265,8 +251,9 @@ const EmpAttendance = ({ employee }) => {
{[...Array(totalPages)].map((_, index) => ( {[...Array(totalPages)].map((_, index) => (
<li <li
key={index} key={index}
className={`page-item ${currentPage === index + 1 ? "active" : "" className={`page-item ${
}`} currentPage === index + 1 ? "active" : ""
}`}
> >
<button <button
className="page-link " className="page-link "
@ -277,8 +264,9 @@ const EmpAttendance = ({ employee }) => {
</li> </li>
))} ))}
<li <li
className={`page-item ${currentPage === totalPages ? "disabled" : "" className={`page-item ${
}`} currentPage === totalPages ? "disabled" : ""
}`}
> >
<button <button
className="page-link " className="page-link "