mirror of
https://github.com/Tria-plc/emaui.git
synced 2026-08-27 15:30:57 +00:00
feat: add nationality support with demonym in CountrySelect and related components
This commit is contained in:
@@ -68,6 +68,7 @@ export function ConfigDrivenSection({
|
||||
{isNationality ? (
|
||||
<CountrySelect
|
||||
{...common}
|
||||
demonym
|
||||
value={(value as string) ?? null}
|
||||
onChange={(v) => onChange(field.key, v)}
|
||||
/>
|
||||
|
||||
@@ -50,7 +50,7 @@ import {
|
||||
type FormFieldConfig,
|
||||
type ValidationIssue,
|
||||
} from '@ema-platform/api';
|
||||
import { getCountryCode, ModalFooter } from '@ema-platform/ui';
|
||||
import { getCountryCode, getCountryName, ModalFooter } from '@ema-platform/ui';
|
||||
import { useCurrentProfile } from '@ema-platform/auth';
|
||||
import { ConfigDrivenSection } from '../components/ConfigDrivenSection';
|
||||
import { DocumentSlots } from '../components/DocumentSlots';
|
||||
@@ -210,11 +210,20 @@ export function LicenseApplicationPage() {
|
||||
// During an adjustment round only flagged sections are editable, so don't
|
||||
// even attempt a write the server would reject.
|
||||
if (isAdjusting && !flaggedSections[sectionKey]) return;
|
||||
const values = { ...(draft[sectionKey] ?? {}) };
|
||||
// The picker works in alpha-2 codes (CountrySelect); the backend, like
|
||||
// the profile Address endpoint, stores the full country name.
|
||||
const nationalityField = config?.licenseType.formSchema.sections
|
||||
.find((s) => s.key === sectionKey)
|
||||
?.fields.find((f) => f.key === 'nationality' || localized(f.label).toLowerCase().includes('nationality'));
|
||||
if (nationalityField && values[nationalityField.key]) {
|
||||
values[nationalityField.key] = getCountryName(values[nationalityField.key] as string) || values[nationalityField.key];
|
||||
}
|
||||
try {
|
||||
await patchSection({
|
||||
id: appId as string,
|
||||
sectionKey,
|
||||
values: draft[sectionKey] ?? {},
|
||||
values,
|
||||
}).unwrap();
|
||||
} catch (err) {
|
||||
notifications.show({
|
||||
|
||||
@@ -132,6 +132,7 @@ export function AddressFormContent({
|
||||
/>
|
||||
<CountrySelect
|
||||
label="Nationality"
|
||||
demonym
|
||||
required
|
||||
value={watch('nationality') || null}
|
||||
onChange={(val) => setValue('nationality', val || '', { shouldValidate: true })}
|
||||
|
||||
Reference in New Issue
Block a user