mirror of
https://github.com/Tria-plc/emaui.git
synced 2026-08-26 19:12:50 +00:00
Refactor AddressFormContent and ProfilePage to integrate CountrySelect for nationality selection and update address payload handling
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { useMemo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Group, Select, Text, type ComboboxItem, type SelectProps } from '@mantine/core';
|
||||
import { registerLocale, getNames, getName } from 'i18n-iso-countries';
|
||||
import { registerLocale, getNames, getName, getAlpha2Code } from 'i18n-iso-countries';
|
||||
import * as Flags from 'country-flag-icons/react/3x2';
|
||||
import en from 'i18n-iso-countries/langs/en.json';
|
||||
import am from 'i18n-iso-countries/langs/am.json';
|
||||
@@ -21,6 +21,11 @@ export function getCountryName(code: string | null | undefined, lang: CountryLan
|
||||
return code ? (getName(code, lang) ?? '') : '';
|
||||
}
|
||||
|
||||
/** Alpha-2 code for a stored country name (e.g. "Ethiopian" data); undefined when unmatched. */
|
||||
export function getCountryCode(name: string | null | undefined, lang: CountryLang = 'en'): string | undefined {
|
||||
return name ? getAlpha2Code(name, lang) : undefined;
|
||||
}
|
||||
|
||||
function CountryFlag({ code }: { code: string }) {
|
||||
const Flag = Flags[code as keyof typeof Flags];
|
||||
return Flag ? <Flag style={{ width: 22, borderRadius: 2, display: 'block' }} /> : null;
|
||||
|
||||
Reference in New Issue
Block a user