"use client"; import { zodResolver } from "@hookform/resolvers/zod"; import { useForm } from "react-hook-form"; import * as z from "zod"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from "@/components/ui/form"; import { Crop } from "@/types"; import { cropFormSchema } from "@/schemas/form.schema"; interface AddCropFormProps { onSubmit: (data: Partial) => Promise; onCancel: () => void; } export function AddCropForm({ onSubmit, onCancel }: AddCropFormProps) { const form = useForm>({ resolver: zodResolver(cropFormSchema), defaultValues: { name: "", plantedDate: "", status: "planned", }, }); const handleSubmit = (values: z.infer) => { onSubmit({ ...values, plantedDate: new Date(values.plantedDate), }); }; return (
( Crop Name )} /> ( Planted Date )} /> ( Status )} />
); }