"use client" import { useForm } from "react-hook-form" import { zodResolver } from "@hookform/resolvers/zod" import { Form, FormField, FormItem, FormLabel, FormControl, FormMessage } from "@/components/ui/form" import { Input } from "@/components/ui/input" import { Button } from "@/components/ui/button" import { Separator } from "@/components/ui/separator" import { PeopleAdd, personAddSchema } from "./schema" import { useAddPeopleMutation } from "./queries" import { DateTimePicker } from "@/components/ui/date-time-picker" const PeopleForm = ({ refetchTable }: { refetchTable: () => void }) => { const form = useForm({ resolver: zodResolver(personAddSchema), defaultValues: { firstName: "", surname: "", middleName: "", sexCode: "", personRef: "", personTag: "", fatherName: "", motherName: "", countryCode: "", nationalIdentityId: "", birthPlace: "", birthDate: "", taxNo: "", birthname: "", expiryStarts: "", expiryEnds: "", }, }); const { handleSubmit } = form; const mutation = useAddPeopleMutation(); function onSubmit(values: PeopleAdd) { mutation.mutate({ data: values }); setTimeout(() => refetchTable(), 400) }; return (
{/* BASIC INFO */}
( First Name )} /> ( Surname )} />
{/* SECOND ROW */}
( Middle Name )} /> ( Sex Code )} />
{/* THIRD ROW */}
( Person Ref )} /> ( Person Tag )} />
{/* FAMILY INFO */}
( Father Name )} /> ( Mother Name )} />
{/* COUNTRY + NATIONAL ID */}
( Country Code )} /> ( National Identity ID )} />
{/* BIRTH INFO */}
( Birth Place )} /> ( Birth Date )} />
{/* TAX/BIRTHNAME */}
( Tax No )} /> ( Birth Name )} />
{/* EXPIRY DATES */}
( Expiry Starts )} /> ( Expiry Ends )} />
); }; export { PeopleForm }