"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 { DateTimePicker } from "@/components/ui/date-time-picker" import { BuildPartsAdd, buildPartsAddSchema } from "./schema" import { useAddBuildAreasMutation } from "./queries" import { Checkbox } from "@/components/ui/checkbox" const BuildPartsForm = ({ refetchTable, selectedBuildId }: { refetchTable: () => void, selectedBuildId: string }) => { const form = useForm({ resolver: zodResolver(buildPartsAddSchema), defaultValues: { addressGovCode: "", no: 0, level: 0, code: "", grossSize: 0, netSize: 0, defaultAccessory: "", humanLivability: false, key: "", directionId: "", typeId: "", active: false, isConfirmed: false, expiryStarts: "", expiryEnds: "", }, }); const { handleSubmit } = form; const mutation = useAddBuildAreasMutation(); function onSubmit(values: BuildPartsAdd) { mutation.mutate({ data: values, buildId: selectedBuildId, refetchTable }) }; return (
{/* ROW 1 */}
( Address Gov Code )} /> ( No field.onChange(e.target.value === "" ? undefined : Number(e.target.value))} /> )} />
{/* ROW 2 */}
( Level field.onChange(e.target.value === "" ? undefined : Number(e.target.value))} /> )} /> ( Code )} />
{/* ROW 3 */}
( Key )} /> ( Gross Size field.onChange(e.target.value === "" ? undefined : Number(e.target.value))} /> )} />
{/* ROW 4 */}
( Net Size field.onChange(e.target.value === "" ? undefined : Number(e.target.value))} /> )} /> ( Default Accessory )} />
{/* ROW 5 */}
( Direction Id )} /> ( Type Id )} />
{/* BOOLEAN ROW */}
{/* boşluk kalmasın diye aktif alanını buraya koydum */} ( Active )} /> ( Human Livability )} /> ( Is Confirmed )} />
{/* EXPIRY DATES */}
( Expiry Starts )} /> ( Expiry Ends )} />
); }; export { BuildPartsForm }