mirror of
https://github.com/ForFarmTeam/ForFarm.git
synced 2025-12-19 14:04:08 +01:00
feat: replace button elements with UI component for navigation and form submission
This commit is contained in:
parent
e7c8b64e24
commit
aa3490efad
@ -9,6 +9,7 @@ import {
|
|||||||
harvestDetailsFormSchema,
|
harvestDetailsFormSchema,
|
||||||
} from "@/schemas/application.schema";
|
} from "@/schemas/application.schema";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
|
||||||
type PlantingSchema = z.infer<typeof plantingDetailsFormSchema>;
|
type PlantingSchema = z.infer<typeof plantingDetailsFormSchema>;
|
||||||
type HarvestSchema = z.infer<typeof harvestDetailsFormSchema>;
|
type HarvestSchema = z.infer<typeof harvestDetailsFormSchema>;
|
||||||
@ -99,19 +100,14 @@ export default function SetupPage() {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="mt-10 flex justify-between">
|
<div className="mt-10 flex justify-between">
|
||||||
{step > 1 && (
|
<Button onClick={handleBack} disabled={step === 1}>
|
||||||
<button onClick={handleBack} className="btn btn-secondary">
|
|
||||||
Back
|
Back
|
||||||
</button>
|
</Button>
|
||||||
)}
|
|
||||||
{step < 3 ? (
|
{step < 3 ? (
|
||||||
<button onClick={handleNext} className="btn btn-primary">
|
<Button onClick={handleNext}>Next</Button>
|
||||||
Next
|
|
||||||
</button>
|
|
||||||
) : (
|
) : (
|
||||||
<button onClick={handleSubmit} className="btn btn-success">
|
<Button onClick={handleSubmit}>Submit</Button>
|
||||||
Submit
|
|
||||||
</button>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -23,6 +23,7 @@ import {
|
|||||||
import { Textarea } from "@/components/ui/textarea";
|
import { Textarea } from "@/components/ui/textarea";
|
||||||
import { Switch } from "@/components/ui/switch";
|
import { Switch } from "@/components/ui/switch";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { useRef } from "react";
|
||||||
|
|
||||||
type plantingSchema = z.infer<typeof plantingDetailsFormSchema>;
|
type plantingSchema = z.infer<typeof plantingDetailsFormSchema>;
|
||||||
|
|
||||||
@ -31,6 +32,7 @@ export default function PlantingDetailsForm({
|
|||||||
}: {
|
}: {
|
||||||
onChange: (data: plantingSchema) => void;
|
onChange: (data: plantingSchema) => void;
|
||||||
}) {
|
}) {
|
||||||
|
const formRef = useRef<HTMLFormElement>(null);
|
||||||
const form = useForm({
|
const form = useForm({
|
||||||
resolver: zodResolver(plantingDetailsFormSchema),
|
resolver: zodResolver(plantingDetailsFormSchema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
@ -57,6 +59,7 @@ export default function PlantingDetailsForm({
|
|||||||
<form
|
<form
|
||||||
className="grid grid-cols-3 gap-5"
|
className="grid grid-cols-3 gap-5"
|
||||||
onSubmit={form.handleSubmit(onSubmit)}
|
onSubmit={form.handleSubmit(onSubmit)}
|
||||||
|
ref={formRef}
|
||||||
>
|
>
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
@ -369,7 +372,9 @@ export default function PlantingDetailsForm({
|
|||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<div className="col-span-3 flex justify-center">
|
<div className="col-span-3 flex justify-center">
|
||||||
<Button type="submit">Save</Button>
|
<Button type="submit">
|
||||||
|
Save
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</Form>
|
</Form>
|
||||||
|
|||||||
@ -27,7 +27,7 @@ const GoogleMapWithDrawing = ({
|
|||||||
lat: latLng.lat(),
|
lat: latLng.lat(),
|
||||||
lng: latLng.lng(),
|
lng: latLng.lng(),
|
||||||
}));
|
}));
|
||||||
console.log("Polyline coordinates:", coordinates);
|
// console.log("Polyline coordinates:", coordinates);
|
||||||
onAreaSelected(coordinates);
|
onAreaSelected(coordinates);
|
||||||
} else {
|
} else {
|
||||||
console.log("Unknown shape detected:", shape);
|
console.log("Unknown shape detected:", shape);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user