"use client"; import { useState } from "react"; import PlantingDetailsForm from "./planting-detail-form"; import HarvestDetailsForm from "./harvest-detail-form"; import GoogleMapWithDrawing from "@/components/google-map-with-drawing"; import { Separator } from "@/components/ui/separator"; import { plantingDetailsFormSchema, harvestDetailsFormSchema, } from "@/schemas/application.schema"; import { z } from "zod"; type PlantingSchema = z.infer; type HarvestSchema = z.infer; const steps = [ { title: "Step 1", description: "Planting Details" }, { title: "Step 2", description: "Harvest Details" }, { title: "Step 3", description: "Select Map Area" }, ]; export default function SetupPage() { const [step, setStep] = useState(1); const [plantingDetails, setPlantingDetails] = useState( null ); const [harvestDetails, setHarvestDetails] = useState( null ); const [mapData, setMapData] = useState<{ lat: number; lng: number }[] | null>( null ); const handleNext = () => { if (step === 1 && !plantingDetails) { alert("Please complete the Planting Details before proceeding."); return; } if (step === 2 && !harvestDetails) { alert("Please complete the Harvest Details before proceeding."); return; } setStep((prev) => prev + 1); }; const handleBack = () => { setStep((prev) => prev - 1); }; const handleSubmit = () => { if (!mapData) { alert("Please select an area on the map before submitting."); return; } console.log("Submitting:", { plantingDetails, harvestDetails, mapData }); }; return (
{/* Stepper Navigation */}
{steps.map((item, index) => (
{index + 1}
{item.title} {item.description}
))}
{step === 1 && ( <>

Planting Details

)} {step === 2 && ( <>

Harvest Details

)} {step === 3 && ( <>

Select Area on Map

)}
{step > 1 && ( )} {step < 3 ? ( ) : ( )}
); }