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 FieldErrors,
|
||||||
type ValidationIssue,
|
type ValidationIssue,
|
||||||
} from '@ema-platform/api';
|
} from '@ema-platform/api';
|
||||||
import { ModalFooter } from '@ema-platform/ui';
|
import { getCountryCode, ModalFooter } from '@ema-platform/ui';
|
||||||
import { useCurrentProfile } from '@ema-platform/auth';
|
import { useCurrentProfile } from '@ema-platform/auth';
|
||||||
import { ConfigDrivenSection } from '../components/ConfigDrivenSection';
|
import { ConfigDrivenSection } from '../components/ConfigDrivenSection';
|
||||||
import { DocumentSlots } from '../components/DocumentSlots';
|
import { DocumentSlots } from '../components/DocumentSlots';
|
||||||
@@ -124,11 +124,15 @@ export function LicenseApplicationPage() {
|
|||||||
const section = config.licenseType.formSchema.sections.find((s) =>
|
const section = config.licenseType.formSchema.sections.find((s) =>
|
||||||
s.fields.some((f) => f.key === 'nationality'),
|
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) =>
|
setDraft((prev) =>
|
||||||
prev[section.key]?.nationality
|
prev[section.key]?.nationality
|
||||||
? prev
|
? prev
|
||||||
: { ...prev, [section.key]: { ...prev[section.key], nationality } },
|
: { ...prev, [section.key]: { ...prev[section.key], nationality: value } },
|
||||||
);
|
);
|
||||||
}, [profile?.address?.nationality, config]);
|
}, [profile?.address?.nationality, config]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user