diff --git a/src/components/forms/user-profile-stepper/create-profile.tsx b/src/components/forms/user-profile-stepper/create-profile.tsx index bbcd989..18bde35 100644 --- a/src/components/forms/user-profile-stepper/create-profile.tsx +++ b/src/components/forms/user-profile-stepper/create-profile.tsx @@ -31,7 +31,7 @@ import { cn } from "@/lib/utils"; import { zodResolver } from "@hookform/resolvers/zod"; import { AlertTriangleIcon, Trash, Trash2Icon } from "lucide-react"; import { useParams, useRouter } from "next/navigation"; -import { useState } from "react"; +import { useEffect, useState } from "react"; import { SubmitHandler, useFieldArray, useForm } from "react-hook-form"; interface ProfileFormType { @@ -60,6 +60,8 @@ export const CreateProfileOne: React.FC = ({ const delta = currentStep - previousStep; const [countryGeoId, setCountryGeoId] = useState(null); const [stateGeoId, setStateGeoId] = useState(null); + const [countryGeoId2, setCountryGeoId2] = useState(null); + const [stateGeoId2, setStateGeoId2] = useState(null); const defaultValues = { // state: "", @@ -70,6 +72,7 @@ export const CreateProfileOne: React.FC = ({ startdate: "", enddate: "", jobcountry: "", + jobstate: "", jobcity: "", }, ], @@ -155,6 +158,7 @@ export const CreateProfileOne: React.FC = ({ `jobs.${index}.startdate`, `jobs.${index}.enddate`, `jobs.${index}.jobcountry`, + `jobs.${index}.jobstate`, `jobs.${index}.jobcity`, // Add other field names as needed ]) @@ -191,8 +195,6 @@ export const CreateProfileOne: React.FC = ({ const countries = [{ id: "1", name: "india" }]; const cities = [{ id: "1", name: "kerala" }]; - console.log(form.getValues()); - return ( <>
@@ -520,31 +522,42 @@ export const CreateProfileOne: React.FC = ({ render={({ field }) => ( Job country - + { + setCountryGeoId2(geoId); + field.onChange(country); + }} + isCountry + placeholderText="Select job country" + searchPlaceholder="Search country..." + emptyPlaceholder="No country found" + isDisabled={false} + /> + + + + )} + /> + ( + + Job State + { + setStateGeoId2(geoId); + field.onChange(state); + }} + isCountry={false} + placeholderText="Select job state" + searchPlaceholder="Search state..." + emptyPlaceholder="No state found" + isDisabled={!countryGeoId2} + /> + )} @@ -555,28 +568,16 @@ export const CreateProfileOne: React.FC = ({ render={({ field }) => ( Job city - + field.onChange(v)} + isCountry={false} + placeholderText="Select job city" + searchPlaceholder="Search city..." + emptyPlaceholder="No city found" + isDisabled={!stateGeoId2} + /> + )} @@ -599,6 +600,7 @@ export const CreateProfileOne: React.FC = ({ startdate: "", enddate: "", jobcountry: "", + jobstate: "", jobcity: "", }) } diff --git a/src/lib/form-schema.ts b/src/lib/form-schema.ts index db534e0..a96f0f9 100644 --- a/src/lib/form-schema.ts +++ b/src/lib/form-schema.ts @@ -34,6 +34,7 @@ export const profileSchema = z.object({ jobs: z.array( z.object({ jobcountry: z.string().min(1, { message: "Please select a country" }), + jobstate: z.string().min(1, { message: "Please select a job state" }), jobcity: z.string().min(1, { message: "Please select a city" }), jobtitle: z.string(), // .min(3, { message: "First Name must be at least 3 characters" }),