feat: add default values and save button to harvest and planting detail forms

This commit is contained in:
THIS ONE IS A LITTLE BIT TRICKY KRUB 2025-03-13 18:17:41 +07:00
parent 3d020fcd58
commit 5117f6399b
3 changed files with 3069 additions and 3686 deletions

View File

@ -20,13 +20,23 @@ import {
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
import { Button } from "@/components/ui/button";
type harvestSchema = z.infer<typeof harvestDetailsFormSchema>;
export default function HarvestDetailsForm() {
const form = useForm<harvestSchema>({
resolver: zodResolver(harvestDetailsFormSchema),
defaultValues: {},
defaultValues: {
daysToFlower: 0,
daysToMaturity: 0,
harvestWindow: 0,
estimatedLossRate: 0,
harvestUnits: "",
estimatedRevenue: 0,
expectedYieldPer100ft: 0,
expectedYieldPerAcre: 0,
},
});
return (
<Form {...form}>
@ -224,6 +234,9 @@ export default function HarvestDetailsForm() {
</FormItem>
)}
/>
<div className="col-span-3 flex justify-center">
<Button type="submit">Save</Button>
</div>
</form>
</Form>
);

View File

@ -22,13 +22,27 @@ import {
} 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<typeof plantingDetailsFormSchema>;
export default function PlantingDetailsForm() {
const form = useForm<plantingSchema>({
resolver: zodResolver(plantingDetailsFormSchema),
defaultValues: {},
defaultValues: {
daysToEmerge: 0,
plantSpacing: 0,
rowSpacing: 0,
plantingDepth: 0,
averageHeight: 0,
startMethod: "",
lightProfile: "",
soilConditions: "",
plantingDetails: "",
pruningDetails: "",
isPerennial: false,
autoCreateTasks: false,
},
});
return (
<Form {...form}>
@ -289,7 +303,7 @@ export default function PlantingDetailsForm() {
/>
<FormField
control={form.control}
name="isPerennial"
name="autoCreateTasks"
render={({ field }: { field: any }) => (
<FormItem>
<FormControl>
@ -308,6 +322,9 @@ export default function PlantingDetailsForm() {
</FormItem>
)}
/>
<div className="col-span-3 flex justify-center">
<Button type="submit">Save</Button>
</div>
</form>
</Form>
);

File diff suppressed because it is too large Load Diff