"use client"; import { useActionState, useEffect, useState } from "react"; import { toast } from "sonner"; import { Button } from "@/components/ui/button"; import { Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSet, } from "@/components/ui/field"; import { Input } from "@/components/ui/input"; import { Textarea } from "@/components/ui/textarea"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select"; import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"; import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; import { InfoIcon } from "lucide-react"; import { submitCitizenshipApplication } from "@/lib/citizenship/actions"; import { initialFormState } from "@/lib/form-action"; import { EYE_COLORS } from "@/lib/citizenship/types"; import { Spinner } from "@/components/ui/spinner"; import { ImageUploader } from "@/components/image-uploader"; type Props = { firstName: string; secondName: string; sex: string; birthDate: Date; regions: { id: string; name: string }[]; }; function formatDate(d: Date | null): string { if (!d) return ""; return d.toISOString().split("T")[0]; } type AppType = "PREVIOUS_CITIZENSHIP" | "NATURALIZATION"; export function CitizenshipApplicationForm({ firstName, secondName, sex, birthDate, regions }: Props) { const [appType, setAppType] = useState(""); const [state, formAction, isPending] = useActionState(submitCitizenshipApplication, initialFormState); const [isEuResident, setIsEuResident] = useState(null); useEffect(() => { if (state.error) { toast.error(state.error); } }, [state.error]); const errors = state.fieldErrors ?? {}; return (
Personal information Important notice Personal data is sourced from your account profile. Please ensure that all information is accurate. If corrections are required, update your details in Kotosoft ID and synchronise your account. Surname Given names
Sex Date of birth
Eligibility basis Select the basis on which you are applying for citizenship. setAppType(v as AppType)} aria-invalid={!!errors.applicationType?.length} required > Previous citizenship holder I held citizenship of the Duspean Republic or the Country of Reality on 31 March 2026. Naturalisation I am a foreign national seeking naturalisation. {errors.applicationType && {errors.applicationType[0]}}
{appType === "PREVIOUS_CITIZENSHIP" && (
Previous citizenship details Country {errors.previousCountry && {errors.previousCountry[0]}} Region of issuance The region or authority that issued your previous citizenship. {errors.previousRegion && {errors.previousRegion[0]}}
)} {appType === "NATURALIZATION" && (
Naturalisation statement Why do you wish to become a citizen of the European Federation?