fix: show country nationality in view id card screen (#1777)

* fix: show country nationality in view id card screen

Was showing country code, now tries to fetch the country name. If can't find, resolves back to raw country code.

* port fix over

---------

Co-authored-by: Justin Hernandez <justin.hernandez@self.xyz>
This commit is contained in:
Evi Nova
2026-02-20 20:04:01 +10:00
committed by GitHub
parent ac1e6fdb44
commit 0f5d8cbff5

View File

@@ -8,6 +8,7 @@ import { Dimensions } from 'react-native';
import { Separator, Text, XStack, YStack } from 'tamagui';
import type { AadhaarData } from '@selfxyz/common';
import { commonNames } from '@selfxyz/common/constants';
import type { PassportData } from '@selfxyz/common/types/passport';
import { isAadhaarDocument, isMRZDocument } from '@selfxyz/common/utils/types';
import {
@@ -37,6 +38,17 @@ const logoSvg = `<svg width="47" height="46" viewBox="0 0 47 46" fill="none" xml
<path d="M28.9703 17.6525H18.0362V28.3539H28.9703V17.6525Z" fill="#00FFB6"/>
</svg>`;
/**
* Resolve a 3-letter country code to its full country name.
* Falls back to the code itself if no mapping exists.
*/
const getCountryName = (code: string): string => {
if (!code) return '';
const cleaned = code.toUpperCase().replace(/</g, '').trim();
if (!cleaned) return '';
return (commonNames as Record<string, string>)[cleaned] || cleaned;
};
interface IdCardRevealedProps {
idDocument: PassportData | AadhaarData;
}
@@ -237,7 +249,7 @@ const IdCardRevealed: FC<IdCardRevealedProps> = ({ idDocument }) => {
<YStack flex={1}>
<IdAttribute
name="NATIONALITY"
value={docAttributes.nationalitySlice}
value={getCountryName(docAttributes.nationalitySlice)}
/>
</YStack>
<YStack flex={1}>
@@ -257,7 +269,7 @@ const IdCardRevealed: FC<IdCardRevealedProps> = ({ idDocument }) => {
<YStack flex={1}>
<IdAttribute
name="AUTHORITY"
value={docAttributes.issuingStateSlice}
value={getCountryName(docAttributes.issuingStateSlice)}
/>
</YStack>
<YStack flex={1} />