Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/src/providers/selfClientProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ export const SelfClientProvider = ({ children }: PropsWithChildren) => {
({ passportData }) => {
if (navigationRef.isReady()) {
navigationRef.navigate('UnsupportedDocument', {
passportData,
countryCode: passportData.passportMetadata?.countryCode,
documentCategory: passportData.documentCategory,
} as any);
}
},
Expand Down
16 changes: 8 additions & 8 deletions app/src/screens/document/UnsupportedDocumentScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { XStack, YStack } from 'tamagui';
import type { RouteProp } from '@react-navigation/native';

import { countryCodes } from '@selfxyz/common/constants';
import type { PassportData } from '@selfxyz/common/types';
import type { DocumentCategory } from '@selfxyz/common/types';
import {
hasAnyValidRegisteredDocument,
useSelfClient,
Expand Down Expand Up @@ -39,7 +39,8 @@ type CountryFlagsRecord = Record<string, CountryFlagComponent>;
type UnsupportedDocumentScreenRouteProp = RouteProp<
{
UnsupportedDocument: {
passportData: PassportData | null;
countryCode: string;
documentCategory: DocumentCategory;
};
},
'UnsupportedDocument'
Expand All @@ -55,11 +56,10 @@ const UnsupportedDocumentScreen: React.FC<UnsupportedDocumentScreenProps> = ({
const selfClient = useSelfClient();
const navigateToLaunch = useHapticNavigation('Launch');
const navigateToHome = useHapticNavigation('Home');
const passportData = route.params?.passportData;

const { countryName, country2AlphaCode, documentTypeText } = useMemo(() => {
try {
const countryCode = passportData?.passportMetadata?.countryCode;
const countryCode = route.params?.countryCode;
if (countryCode) {
// Handle Germany corner case where country code is "D<<" instead of "DEU"
let normalizedCountryCode = countryCode;
Expand All @@ -74,7 +74,7 @@ const UnsupportedDocumentScreen: React.FC<UnsupportedDocumentScreenProps> = ({
const name =
countryCodes[normalizedCountryCode as keyof typeof countryCodes];
const docType =
passportData?.documentCategory === 'id_card'
route.params?.documentCategory === 'id_card'
? 'ID Cards'
: 'Passports';
return {
Expand All @@ -87,13 +87,13 @@ const UnsupportedDocumentScreen: React.FC<UnsupportedDocumentScreenProps> = ({
console.error('Error extracting country from passport data:', error);
}
const docType =
passportData?.documentCategory === 'id_card' ? 'ID Cards' : 'Passports';
route.params?.documentCategory === 'id_card' ? 'ID Cards' : 'Passports';
return {
countryName: 'Unknown',
country2AlphaCode: 'Unknown',
documentTypeText: docType,
};
}, [passportData]);
}, [route.params?.documentCategory, route.params?.countryCode]);

// Get country flag component dynamically
const getCountryFlag = (code: string) => {
Expand Down Expand Up @@ -127,7 +127,7 @@ const UnsupportedDocumentScreen: React.FC<UnsupportedDocumentScreenProps> = ({
countryName,
countryCode:
country2AlphaCode !== 'Unknown' ? country2AlphaCode : undefined,
documentCategory: passportData?.documentCategory,
documentCategory: route.params?.documentCategory,
});
} catch (error) {
console.error('Failed to open email client:', error);
Expand Down
3 changes: 2 additions & 1 deletion app/tests/utils/proving/provingMachine.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ describe('events', () => {
expect(emitMock).toHaveBeenCalledWith(
SdkEvents.PROVING_PASSPORT_NOT_SUPPORTED,
{
passportData: mockPassportData,
countryCode: mockPassportData.passportMetadata?.countryCode,
documentCategory: mockPassportData.documentCategory,
},
);
});
Expand Down
Loading