This commit is contained in:
estifanos
2026-08-10 12:06:45 +00:00
parent 3d5b9db442
commit 3b1630bf9a

View File

@@ -49,7 +49,7 @@ import {
type FieldErrors,
type ValidationIssue,
} from '@ema-platform/api';
import { ModalFooter } from '@ema-platform/ui';
import { getCountryCode, ModalFooter } from '@ema-platform/ui';
import { useCurrentProfile } from '@ema-platform/auth';
import { ConfigDrivenSection } from '../components/ConfigDrivenSection';
import { DocumentSlots } from '../components/DocumentSlots';
@@ -124,11 +124,15 @@ export function LicenseApplicationPage() {
const section = config.licenseType.formSchema.sections.find((s) =>
s.fields.some((f) => f.key === 'nationality'),
);
if (!section) return;
const field = section?.fields.find((f) => f.key === 'nationality');
if (!section || !field) return;
// Profile stores the full country name; a SELECT field's options follow the
// CountrySelect convention of alpha-2 codes, so translate for that case.
const value = field.type === 'SELECT' ? (getCountryCode(nationality) ?? nationality) : nationality;
setDraft((prev) =>
prev[section.key]?.nationality
? prev
: { ...prev, [section.key]: { ...prev[section.key], nationality } },
: { ...prev, [section.key]: { ...prev[section.key], nationality: value } },
);
}, [profile?.address?.nationality, config]);