"use client"; import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage, } from "@/components/ui/form"; import { plantingDetailsFormSchema } from "@/schemas/application.schema"; import { useForm } from "react-hook-form"; import { z } from "zod"; import { zodResolver } from "@hookform/resolvers/zod"; import { Input } from "@/components/ui/input"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select"; import { Textarea } from "@/components/ui/textarea"; import { Switch } from "@/components/ui/switch"; import { Button } from "@/components/ui/button"; type plantingSchema = z.infer; export default function PlantingDetailsForm({ onChange, }: { onChange: (data: plantingSchema) => void; }) { const form = useForm({ resolver: zodResolver(plantingDetailsFormSchema), defaultValues: { daysToEmerge: 0, plantSpacing: 0, rowSpacing: 0, plantingDepth: 0, averageHeight: 0, startMethod: "", lightProfile: "", soilConditions: "", plantingDetails: "", pruningDetails: "", isPerennial: false, autoCreateTasks: false, }, }); const onSubmit = (data: plantingSchema) => { onChange(data); }; return (
( Day to Emerge
{ // convert to number const value = e.target.value ? parseInt(e.target.value, 10) : ""; field.onChange(value); }} />
)} /> ( Plant Spacing
{ // convert to number const value = e.target.value ? parseInt(e.target.value, 10) : ""; field.onChange(value); }} />
)} /> ( Row Spacing
{ // convert to number const value = e.target.value ? parseInt(e.target.value, 10) : ""; field.onChange(value); }} />
)} /> ( Planting Depth
{ // convert to number const value = e.target.value ? parseInt(e.target.value, 10) : ""; field.onChange(value); }} />
)} /> ( Average Height
{ // convert to number const value = e.target.value ? parseInt(e.target.value, 10) : ""; field.onChange(value); }} />
)} /> ( Start Method )} /> ( Light Profile )} /> ( Soil Conditions )} /> ( Planting Details