diff --git a/src/components/Employee/ManageEmployee.jsx b/src/components/Employee/ManageEmployee.jsx index 1f1b3a62..2e52f29c 100644 --- a/src/components/Employee/ManageEmployee.jsx +++ b/src/components/Employee/ManageEmployee.jsx @@ -16,13 +16,13 @@ import { getCachedData, } from "../../slices/apiDataManager"; import { clearApiCacheKey } from "../../slices/apiCacheSlice"; -import {useMutation} from "@tanstack/react-query"; +import { useMutation } from "@tanstack/react-query"; const mobileNumberRegex = /^[0-9]\d{9}$/; -const ManageEmployee = ({ employeeId, onClosed,IsAllEmployee }) => { +const ManageEmployee = ({ employeeId, onClosed, IsAllEmployee }) => { const dispatch = useDispatch(); -const { mutate: updateEmployee, isPending } = useUpdateEmployee(); + const { mutate: updateEmployee, isPending } = useUpdateEmployee(); const { employee, @@ -130,12 +130,11 @@ const { mutate: updateEmployee, isPending } = useUpdateEmployee(); .min(1, { message: "Phone Number is required" }) .regex(mobileNumberRegex, { message: "Invalid phone number " }), jobRoleId: z.string().min(1, { message: "Role is required" }), - } ); - - useEffect( () => - { + }); + + useEffect(() => { refetch() - },[]) + }, []) const { register, @@ -169,19 +168,19 @@ const { mutate: updateEmployee, isPending } = useUpdateEmployee(); }); const AadharNumberValue = watch("aadharNumber") || ""; - - const onSubmit = (data) => { - if (data.email === "") { - data.email = null; - } - updateEmployee({...data,IsAllEmployee},{ - onSuccess: () => { - reset(); - onClosed(); - }, - }); -}; + const onSubmit = (data) => { + if (data.email === "") { + data.email = null; + } + + updateEmployee({ ...data, IsAllEmployee }, { + onSuccess: () => { + reset(); + onClosed(); + }, + }); + }; useEffect(() => { @@ -212,7 +211,7 @@ const { mutate: updateEmployee, isPending } = useUpdateEmployee(); phoneNumber: currentEmployee.phoneNumber || "", jobRoleId: currentEmployee.jobRoleId?.toString() || "", } - : {} + : {} ); setCurrentAddressLength(currentEmployee?.currentAddress?.length || 0); setPermanentAddressLength(currentEmployee?.permanentAddress?.length || 0); @@ -220,66 +219,82 @@ const { mutate: updateEmployee, isPending } = useUpdateEmployee(); return ( <> -