Refactor AddressFormContent and ProfilePage to integrate CountrySelect for nationality selection and update address payload handling

This commit is contained in:
estifanos
2026-08-08 07:40:33 +00:00
parent 451e9a7f35
commit 56de3727fa
4 changed files with 20 additions and 19 deletions

View File

@@ -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;