diff --git a/src/components/Employee/EmpAttendance.jsx b/src/components/Employee/EmpAttendance.jsx index dfa12e98..0aa03cf3 100644 --- a/src/components/Employee/EmpAttendance.jsx +++ b/src/components/Employee/EmpAttendance.jsx @@ -1,6 +1,6 @@ import React, { useState, useEffect } from "react"; import moment from "moment"; -import DateRangePicker from "../common/DateRangePicker"; +import DateRangePicker, { DateRangePicker1 } from "../common/DateRangePicker"; import { useDispatch, useSelector } from "react-redux"; import { fetchEmployeeAttendanceData } from "../../slices/apiSlice/employeeAttendanceSlice"; import usePagination from "../../hooks/usePagination"; @@ -11,6 +11,12 @@ import AttendLogs from "../Activities/AttendLogs"; import { useAttendanceByEmployee } from "../../hooks/useAttendance"; import GlobalModel from "../common/GlobalModel"; import { ITEMS_PER_PAGE } from "../../utils/constants"; +import { FormProvider, useForm } from "react-hook-form"; +import { zodResolver } from "@hookform/resolvers/zod"; +import { z } from "zod"; +import { localToUtc } from "../../utils/appUtils"; + + const EmpAttendance = ({ employee }) => { const [attendances, setAttendnaces] = useState([]); @@ -18,6 +24,21 @@ const EmpAttendance = ({ employee }) => { const [dateRange, setDateRange] = useState({ startDate: "", endDate: "" }); const [isModalOpen, setIsModalOpen] = useState(false); const [attendanceId, setAttendanecId] = useState(); + + + const methods = useForm({ + resolver: zodResolver(z.object({ + startDate: z.string(), + endDate: z.string() + })), + defaultValues: { + startDate: "", + endDate: "" + }, + }); + const { control, register, handleSubmit, reset, watch } = methods; + const startDate = watch('startDate') + const endDate = watch('endDate') const { data = [], isLoading: loading, @@ -25,7 +46,7 @@ const EmpAttendance = ({ employee }) => { isError, error, refetch, - } = useAttendanceByEmployee(employee, dateRange.startDate, dateRange.endDate); + } = useAttendanceByEmployee(employee, localToUtc(startDate), localToUtc(endDate)); const dispatch = useDispatch(); // const { data, loading, error } = useSelector( @@ -90,7 +111,7 @@ const EmpAttendance = ({ employee }) => { if ( !existing || new Date(rec.checkInTime || rec.checkOutTime) > - new Date(existing.checkInTime || existing.checkOutTime) + new Date(existing.checkInTime || existing.checkOutTime) ) { uniqueMap.set(key, rec); } @@ -114,6 +135,11 @@ const EmpAttendance = ({ employee }) => { }; const closeModal = () => setIsModalOpen(false); + + + const onSubmit = (formData) => { + + } return ( <> {isModalOpen && ( @@ -127,17 +153,26 @@ const EmpAttendance = ({ employee }) => { id="DataTables_Table_0_length" >
- + <> + +
+ + +
+ +
refetch()} @@ -230,9 +265,8 @@ const EmpAttendance = ({ employee }) => { {[...Array(totalPages)].map((_, index) => (
  • ))}