mirror of
https://github.com/Tria-plc/emaui.git
synced 2026-08-26 19:12:50 +00:00
prefill
This commit is contained in:
@@ -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]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user