@transfergratis/react-native-sdk 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/api/axios.d.ts +30 -0
- package/build/api/axios.d.ts.map +1 -0
- package/build/api/axios.js +92 -0
- package/build/api/axios.js.map +1 -0
- package/build/components/EnhancedCameraView.d.ts +1 -41
- package/build/components/EnhancedCameraView.d.ts.map +1 -1
- package/build/components/EnhancedCameraView.js +75 -34
- package/build/components/EnhancedCameraView.js.map +1 -1
- package/build/components/EnhancedCameraView.web.d.ts +1 -41
- package/build/components/EnhancedCameraView.web.d.ts.map +1 -1
- package/build/components/EnhancedCameraView.web.js +28 -4
- package/build/components/EnhancedCameraView.web.js.map +1 -1
- package/build/components/KYCElements/CountrySelectionTemplate.d.ts +2 -2
- package/build/components/KYCElements/CountrySelectionTemplate.d.ts.map +1 -1
- package/build/components/KYCElements/CountrySelectionTemplate.js +77 -114
- package/build/components/KYCElements/CountrySelectionTemplate.js.map +1 -1
- package/build/components/KYCElements/FileUploadTemplate.d.ts.map +1 -1
- package/build/components/KYCElements/FileUploadTemplate.js +7 -3
- package/build/components/KYCElements/FileUploadTemplate.js.map +1 -1
- package/build/components/KYCElements/IDCardCapture.d.ts +7 -2
- package/build/components/KYCElements/IDCardCapture.d.ts.map +1 -1
- package/build/components/KYCElements/IDCardCapture.js +253 -104
- package/build/components/KYCElements/IDCardCapture.js.map +1 -1
- package/build/components/KYCElements/InitializationStep.d.ts +5 -0
- package/build/components/KYCElements/InitializationStep.d.ts.map +1 -0
- package/build/components/KYCElements/InitializationStep.js +41 -0
- package/build/components/KYCElements/InitializationStep.js.map +1 -0
- package/build/components/KYCElements/LocationCaptureTemplate.d.ts.map +1 -1
- package/build/components/KYCElements/LocationCaptureTemplate.js +15 -13
- package/build/components/KYCElements/LocationCaptureTemplate.js.map +1 -1
- package/build/components/KYCElements/OrientationVideoCapture.d.ts +2 -2
- package/build/components/KYCElements/OrientationVideoCapture.d.ts.map +1 -1
- package/build/components/KYCElements/OrientationVideoCapture.js.map +1 -1
- package/build/components/KYCElements/OrientationVideoCaptureEnhanced.d.ts +2 -2
- package/build/components/KYCElements/OrientationVideoCaptureEnhanced.d.ts.map +1 -1
- package/build/components/KYCElements/OrientationVideoCaptureEnhanced.js.map +1 -1
- package/build/components/KYCElements/OrientationVideoCaptureFinal.d.ts +2 -2
- package/build/components/KYCElements/OrientationVideoCaptureFinal.d.ts.map +1 -1
- package/build/components/KYCElements/OrientationVideoCaptureFinal.js.map +1 -1
- package/build/components/KYCElements/ReviewSubmitTemplate.d.ts +12 -0
- package/build/components/KYCElements/ReviewSubmitTemplate.d.ts.map +1 -0
- package/build/components/KYCElements/ReviewSubmitTemplate.js +171 -0
- package/build/components/KYCElements/ReviewSubmitTemplate.js.map +1 -0
- package/build/components/KYCElements/SelfieCaptureTemplate.d.ts +6 -2
- package/build/components/KYCElements/SelfieCaptureTemplate.d.ts.map +1 -1
- package/build/components/KYCElements/SelfieCaptureTemplate.js +137 -38
- package/build/components/KYCElements/SelfieCaptureTemplate.js.map +1 -1
- package/build/components/KYCElements/VerificationProgressTemplate.d.ts +12 -0
- package/build/components/KYCElements/VerificationProgressTemplate.d.ts.map +1 -0
- package/build/components/KYCElements/VerificationProgressTemplate.js +194 -0
- package/build/components/KYCElements/VerificationProgressTemplate.js.map +1 -0
- package/build/components/OverLay/IdCard.d.ts +1 -1
- package/build/components/OverLay/IdCard.d.ts.map +1 -1
- package/build/components/OverLay/IdCard.js +10 -6
- package/build/components/OverLay/IdCard.js.map +1 -1
- package/build/components/OverLay/SelfieOverlay.d.ts +1 -1
- package/build/components/OverLay/SelfieOverlay.d.ts.map +1 -1
- package/build/components/OverLay/SelfieOverlay.js +5 -4
- package/build/components/OverLay/SelfieOverlay.js.map +1 -1
- package/build/components/OverLay/type.d.ts +71 -1
- package/build/components/OverLay/type.d.ts.map +1 -1
- package/build/components/OverLay/type.js.map +1 -1
- package/build/components/TemplateKYCExample.d.ts +4 -1
- package/build/components/TemplateKYCExample.d.ts.map +1 -1
- package/build/components/TemplateKYCExample.js +74 -199
- package/build/components/TemplateKYCExample.js.map +1 -1
- package/build/components/TemplateKYCFlowRefactored.d.ts +3 -2
- package/build/components/TemplateKYCFlowRefactored.d.ts.map +1 -1
- package/build/components/TemplateKYCFlowRefactored.js +64 -40
- package/build/components/TemplateKYCFlowRefactored.js.map +1 -1
- package/build/components/example/OrientationVideoExample.d.ts.map +1 -1
- package/build/components/example/OrientationVideoExample.js +1 -5
- package/build/components/example/OrientationVideoExample.js.map +1 -1
- package/build/config/countriesData.d.ts +3 -0
- package/build/config/countriesData.d.ts.map +1 -0
- package/build/config/countriesData.js +79 -0
- package/build/config/countriesData.js.map +1 -0
- package/build/config/region_mapping.d.ts +3 -0
- package/build/config/region_mapping.d.ts.map +1 -0
- package/build/config/region_mapping.js +687 -0
- package/build/config/region_mapping.js.map +1 -0
- package/build/hooks/useI18n.d.ts +11 -0
- package/build/hooks/useI18n.d.ts.map +1 -0
- package/build/hooks/useI18n.js +37 -0
- package/build/hooks/useI18n.js.map +1 -0
- package/build/hooks/useOrientationVideo.d.ts +1 -2
- package/build/hooks/useOrientationVideo.d.ts.map +1 -1
- package/build/hooks/useOrientationVideo.js +2 -1
- package/build/hooks/useOrientationVideo.js.map +1 -1
- package/build/hooks/useRealtimeVerifier.d.ts +28 -0
- package/build/hooks/useRealtimeVerifier.d.ts.map +1 -0
- package/build/hooks/useRealtimeVerifier.js +91 -0
- package/build/hooks/useRealtimeVerifier.js.map +1 -0
- package/build/hooks/useTemplateKYCFlow.d.ts +6 -3
- package/build/hooks/useTemplateKYCFlow.d.ts.map +1 -1
- package/build/hooks/useTemplateKYCFlow.js +356 -42
- package/build/hooks/useTemplateKYCFlow.js.map +1 -1
- package/build/i18n/en/index.d.ts +168 -0
- package/build/i18n/en/index.d.ts.map +1 -0
- package/build/i18n/en/index.js +195 -0
- package/build/i18n/en/index.js.map +1 -0
- package/build/i18n/fr/index.d.ts +168 -0
- package/build/i18n/fr/index.d.ts.map +1 -0
- package/build/i18n/fr/index.js +194 -0
- package/build/i18n/fr/index.js.map +1 -0
- package/build/i18n/index.d.ts +10 -0
- package/build/i18n/index.d.ts.map +1 -0
- package/build/i18n/index.js +56 -0
- package/build/i18n/index.js.map +1 -0
- package/build/i18n/types.d.ts +153 -0
- package/build/i18n/types.d.ts.map +1 -0
- package/build/i18n/types.js +3 -0
- package/build/i18n/types.js.map +1 -0
- package/build/i18n/usage-example.d.ts +4 -0
- package/build/i18n/usage-example.d.ts.map +1 -0
- package/build/i18n/usage-example.js +189 -0
- package/build/i18n/usage-example.js.map +1 -0
- package/build/index.d.ts +1 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +2 -0
- package/build/index.js.map +1 -1
- package/build/modules/api/CardAuthentification.d.ts +22 -0
- package/build/modules/api/CardAuthentification.d.ts.map +1 -0
- package/build/modules/api/CardAuthentification.js +107 -0
- package/build/modules/api/CardAuthentification.js.map +1 -0
- package/build/modules/api/KYCService.d.ts +58 -1
- package/build/modules/api/KYCService.d.ts.map +1 -1
- package/build/modules/api/KYCService.js +304 -27
- package/build/modules/api/KYCService.js.map +1 -1
- package/build/modules/api/SelfieVerification.d.ts +3 -0
- package/build/modules/api/SelfieVerification.d.ts.map +1 -0
- package/build/modules/api/SelfieVerification.js +9 -0
- package/build/modules/api/SelfieVerification.js.map +1 -0
- package/build/modules/api/backendApi.d.ts +2 -0
- package/build/modules/api/backendApi.d.ts.map +1 -0
- package/build/modules/api/backendApi.js +6 -0
- package/build/modules/api/backendApi.js.map +1 -0
- package/build/modules/api/types.d.ts +45 -0
- package/build/modules/api/types.d.ts.map +1 -0
- package/build/modules/api/types.js +2 -0
- package/build/modules/api/types.js.map +1 -0
- package/build/types/KYC.types.d.ts +56 -7
- package/build/types/KYC.types.d.ts.map +1 -1
- package/build/types/KYC.types.js +9 -1
- package/build/types/KYC.types.js.map +1 -1
- package/build/utils/cropByObb.d.ts +11 -0
- package/build/utils/cropByObb.d.ts.map +1 -0
- package/build/utils/cropByObb.js +78 -0
- package/build/utils/cropByObb.js.map +1 -0
- package/build/utils/get-document-type-info.d.ts +13 -0
- package/build/utils/get-document-type-info.d.ts.map +1 -0
- package/build/utils/get-document-type-info.js +59 -0
- package/build/utils/get-document-type-info.js.map +1 -0
- package/build/utils/pathToBase64.d.ts +3 -0
- package/build/utils/pathToBase64.d.ts.map +1 -0
- package/build/utils/pathToBase64.js +47 -0
- package/build/utils/pathToBase64.js.map +1 -0
- package/build/utils/remove-duplicate.d.ts +2 -0
- package/build/utils/remove-duplicate.d.ts.map +1 -0
- package/build/utils/remove-duplicate.js +4 -0
- package/build/utils/remove-duplicate.js.map +1 -0
- package/build/web/WebKYCEntry.d.ts +9 -0
- package/build/web/WebKYCEntry.d.ts.map +1 -0
- package/build/web/WebKYCEntry.js +156 -0
- package/build/web/WebKYCEntry.js.map +1 -0
- package/build/web/index.d.ts +2 -0
- package/build/web/index.d.ts.map +1 -0
- package/build/web/index.js +2 -0
- package/build/web/index.js.map +1 -0
- package/package.json +3 -1
- package/src/api/axios.ts +144 -0
- package/src/components/EnhancedCameraView.tsx +96 -78
- package/src/components/EnhancedCameraView.web.tsx +41 -40
- package/src/components/KYCElements/CountrySelectionTemplate.tsx +111 -136
- package/src/components/KYCElements/FileUploadTemplate.tsx +14 -8
- package/src/components/KYCElements/IDCardCapture.tsx +311 -115
- package/src/components/KYCElements/InitializationStep.tsx +53 -0
- package/src/components/KYCElements/LocationCaptureTemplate.tsx +17 -15
- package/src/components/KYCElements/OrientationVideoCapture.tsx +2 -2
- package/src/components/KYCElements/OrientationVideoCaptureEnhanced.tsx +2 -2
- package/src/components/KYCElements/OrientationVideoCaptureFinal.tsx +2 -2
- package/src/components/KYCElements/ReviewSubmitTemplate.tsx +201 -0
- package/src/components/KYCElements/SelfieCaptureTemplate.tsx +174 -57
- package/src/components/KYCElements/VerificationProgressTemplate.tsx +246 -0
- package/src/components/OverLay/IdCard.tsx +17 -9
- package/src/components/OverLay/SelfieOverlay.tsx +6 -5
- package/src/components/OverLay/type.ts +64 -2
- package/src/components/TemplateKYCExample.tsx +80 -200
- package/src/components/TemplateKYCFlowRefactored.tsx +80 -48
- package/src/components/example/OrientationVideoExample.tsx +3 -7
- package/src/config/countriesData.ts +84 -0
- package/src/config/region_mapping.ts +688 -0
- package/src/hooks/useI18n.ts +53 -0
- package/src/hooks/useOrientationVideo.ts +2 -2
- package/src/hooks/useRealtimeVerifier.ts +128 -0
- package/src/hooks/useTemplateKYCFlow.tsx +407 -57
- package/src/i18n/README.md +288 -0
- package/src/i18n/en/index.ts +206 -0
- package/src/i18n/fr/index.ts +205 -0
- package/src/i18n/index.ts +65 -0
- package/src/i18n/types.ts +172 -0
- package/src/i18n/usage-example.tsx +202 -0
- package/src/index.ts +3 -0
- package/src/modules/api/CardAuthentification.ts +114 -0
- package/src/modules/api/KYCService.ts +350 -30
- package/src/modules/api/SelfieVerification.ts +11 -0
- package/src/modules/api/backendApi.ts +8 -0
- package/src/modules/api/types.ts +51 -0
- package/src/types/KYC.types.ts +82 -14
- package/src/utils/cropByObb.ts +99 -0
- package/src/utils/get-document-type-info.ts +62 -0
- package/src/utils/pathToBase64.ts +47 -0
- package/src/utils/remove-duplicate.ts +3 -0
- package/src/web/WebKYCEntry.tsx +215 -0
- package/src/web/index.ts +1 -0
- package/src/types/nativewind.d.ts +0 -2
|
@@ -6,6 +6,7 @@ import GpsIcon from '../Svgs/GpsIcon';
|
|
|
6
6
|
import { Button } from '../ui/Button';
|
|
7
7
|
import * as Location from 'expo-location';
|
|
8
8
|
import { useTemplateKYCFlowContext } from '../../hooks/useTemplateKYCFlow';
|
|
9
|
+
import { useI18n } from '../../hooks/useI18n';
|
|
9
10
|
|
|
10
11
|
interface LocationCaptureTemplateProps {
|
|
11
12
|
component: TemplateComponent;
|
|
@@ -22,6 +23,7 @@ export const LocationCaptureTemplate: React.FC<LocationCaptureTemplateProps> = (
|
|
|
22
23
|
error,
|
|
23
24
|
language = 'en',
|
|
24
25
|
}) => {
|
|
26
|
+
const { t } = useI18n();
|
|
25
27
|
const [isRequesting, setIsRequesting] = useState(false);
|
|
26
28
|
const [currentLocation, setCurrentLocation] = useState<{ latitude: number; longitude: number; accuracy: number } | null>(value || null);
|
|
27
29
|
const { actions } = useTemplateKYCFlowContext();
|
|
@@ -44,8 +46,8 @@ export const LocationCaptureTemplate: React.FC<LocationCaptureTemplateProps> = (
|
|
|
44
46
|
const hasLocationPermission = await requestLocationPermission();
|
|
45
47
|
if (!hasLocationPermission) {
|
|
46
48
|
Alert.alert(
|
|
47
|
-
'
|
|
48
|
-
'
|
|
49
|
+
t('kyc.locationCapture.permissionDeniedTitle'),
|
|
50
|
+
t('kyc.locationCapture.permissionDeniedMessage')
|
|
49
51
|
);
|
|
50
52
|
setIsRequesting(false);
|
|
51
53
|
return;
|
|
@@ -55,8 +57,8 @@ export const LocationCaptureTemplate: React.FC<LocationCaptureTemplateProps> = (
|
|
|
55
57
|
const isLocationEnabled = await Location.hasServicesEnabledAsync();
|
|
56
58
|
if (!isLocationEnabled) {
|
|
57
59
|
Alert.alert(
|
|
58
|
-
'
|
|
59
|
-
'
|
|
60
|
+
t('kyc.locationCapture.locationDisabledTitle'),
|
|
61
|
+
t('kyc.locationCapture.locationDisabledMessage')
|
|
60
62
|
);
|
|
61
63
|
setIsRequesting(false);
|
|
62
64
|
return;
|
|
@@ -81,7 +83,7 @@ export const LocationCaptureTemplate: React.FC<LocationCaptureTemplateProps> = (
|
|
|
81
83
|
|
|
82
84
|
} catch (error) {
|
|
83
85
|
console.error('Erreur lors de la récupération de la localisation:', error);
|
|
84
|
-
Alert.alert('
|
|
86
|
+
Alert.alert(t('kyc.locationCapture.errorTitle'), t('kyc.locationCapture.errorMessage'));
|
|
85
87
|
} finally {
|
|
86
88
|
setIsRequesting(false);
|
|
87
89
|
}
|
|
@@ -119,34 +121,34 @@ export const LocationCaptureTemplate: React.FC<LocationCaptureTemplateProps> = (
|
|
|
119
121
|
</View>
|
|
120
122
|
</View>
|
|
121
123
|
<View style={{ flexDirection: 'column', alignItems: 'center', justifyContent: 'center', marginTop: 36 }}>
|
|
122
|
-
<Text style={{ fontSize: 24, fontWeight: 'bold', color: '#333', marginBottom: 8 }}>
|
|
124
|
+
<Text style={{ fontSize: 24, fontWeight: 'bold', color: '#333', marginBottom: 8 }}>{t('kyc.locationCapture.title')}</Text>
|
|
123
125
|
<Text style={{ fontSize: 16, color: '#666', textAlign: 'center', marginBottom: 24, lineHeight: 22 }}>
|
|
124
|
-
|
|
126
|
+
{t('kyc.locationCapture.description')}
|
|
125
127
|
</Text>
|
|
126
128
|
</View>
|
|
127
129
|
<View style={{ flexDirection: 'column', marginTop: 36, backgroundColor: "#F9FAFB", padding: 12, borderRadius: 12, width: '100%', }}>
|
|
128
130
|
<Text style={{ fontSize: 16, color: 'black', fontWeight: 'bold', textAlign: 'left', lineHeight: 22 }}>
|
|
129
|
-
{
|
|
131
|
+
{t('kyc.locationCapture.howThisHelps')}
|
|
130
132
|
</Text>
|
|
131
133
|
<Text style={{ fontSize: 16, color: '#666', textAlign: 'left', lineHeight: 22 }}>
|
|
132
|
-
{
|
|
134
|
+
{t('kyc.locationCapture.howThisHelpsList')}
|
|
133
135
|
</Text>
|
|
134
136
|
</View>
|
|
135
137
|
|
|
136
138
|
{currentLocation ? (
|
|
137
139
|
<View style={styles.locationInfo}>
|
|
138
|
-
<Text style={styles.locationTitle}>
|
|
140
|
+
<Text style={styles.locationTitle}>{t('kyc.locationCapture.obtained')}</Text>
|
|
139
141
|
<Text style={styles.locationDetails}>
|
|
140
|
-
|
|
142
|
+
{t('kyc.locationCapture.latitudeLabel')}: {currentLocation.latitude.toFixed(6)}
|
|
141
143
|
</Text>
|
|
142
144
|
<Text style={styles.locationDetails}>
|
|
143
|
-
|
|
145
|
+
{t('kyc.locationCapture.longitudeLabel')}: {currentLocation.longitude.toFixed(6)}
|
|
144
146
|
</Text>
|
|
145
147
|
<Text style={styles.locationDetails}>
|
|
146
|
-
|
|
148
|
+
{t('kyc.locationCapture.accuracyLabel')}: {currentLocation.accuracy.toFixed(1)}m
|
|
147
149
|
</Text>
|
|
148
150
|
<Button
|
|
149
|
-
title=
|
|
151
|
+
title={t('kyc.locationCapture.resetButton')}
|
|
150
152
|
fullWidth
|
|
151
153
|
onPress={resetLocation}
|
|
152
154
|
style={{ paddingVertical: 20, marginTop: 24, backgroundColor: '#6B7280' }}
|
|
@@ -154,7 +156,7 @@ export const LocationCaptureTemplate: React.FC<LocationCaptureTemplateProps> = (
|
|
|
154
156
|
</View>
|
|
155
157
|
) : (
|
|
156
158
|
<Button
|
|
157
|
-
title={isRequesting ?
|
|
159
|
+
title={isRequesting ? t('kyc.locationCapture.fetching') : t('kyc.locationCapture.enableButton')}
|
|
158
160
|
fullWidth
|
|
159
161
|
onPress={getCurrentLocation}
|
|
160
162
|
disabled={isRequesting}
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
import Svg, { Rect, Path, Mask, Defs } from 'react-native-svg';
|
|
12
12
|
import { Camera, useCameraDevice } from 'react-native-vision-camera';
|
|
13
13
|
import { OrientationVideoConfig, OrientationVideoState } from '../../types/KYC.types';
|
|
14
|
-
import
|
|
14
|
+
import kycService from '../../modules/api/KYCService';
|
|
15
15
|
import VisionCameraModule from '../../modules/camera/VisionCameraModule';
|
|
16
16
|
import SideSelfieIcon from '../Svgs/sideSelfieIcon';
|
|
17
17
|
|
|
@@ -19,7 +19,7 @@ interface OrientationVideoCaptureProps {
|
|
|
19
19
|
config?: Partial<OrientationVideoConfig>;
|
|
20
20
|
onComplete: (result: any) => void;
|
|
21
21
|
onError: (error: string) => void;
|
|
22
|
-
kycService:
|
|
22
|
+
kycService: typeof kycService;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
const defaultConfig: OrientationVideoConfig = {
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
import Svg, { Rect, Path, Mask, Defs } from 'react-native-svg';
|
|
13
13
|
import { EnhancedCameraView } from '../EnhancedCameraView';
|
|
14
14
|
import { OrientationVideoConfig, OrientationVideoState } from '../../types/KYC.types';
|
|
15
|
-
import
|
|
15
|
+
import kycService from '../../modules/api/KYCService';
|
|
16
16
|
import FrontSelfieIcon from '../Svgs/frontSelfieIcon';
|
|
17
17
|
import ScanningLine from '../Svgs/scanningLine';
|
|
18
18
|
|
|
@@ -20,7 +20,7 @@ interface OrientationVideoCaptureEnhancedProps {
|
|
|
20
20
|
config?: Partial<OrientationVideoConfig>;
|
|
21
21
|
onComplete: (result: any) => void;
|
|
22
22
|
onError: (error: string) => void;
|
|
23
|
-
kycService:
|
|
23
|
+
kycService: typeof kycService;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
const defaultConfig: OrientationVideoConfig = {
|
|
@@ -11,14 +11,14 @@ import {
|
|
|
11
11
|
import Svg, { Rect, Path, Mask, Defs } from 'react-native-svg';
|
|
12
12
|
import { EnhancedCameraView } from '../EnhancedCameraView';
|
|
13
13
|
import { OrientationVideoConfig, OrientationVideoState } from '../../types/KYC.types';
|
|
14
|
-
import KYCService from '../../modules/api/KYCService';
|
|
15
14
|
import SideSelfieIcon from '../Svgs/sideSelfieIcon';
|
|
15
|
+
import kycService from '../../modules/api/KYCService';
|
|
16
16
|
|
|
17
17
|
interface OrientationVideoCaptureFinalProps {
|
|
18
18
|
config?: Partial<OrientationVideoConfig>;
|
|
19
19
|
onComplete: (result: any) => void;
|
|
20
20
|
onError: (error: string) => void;
|
|
21
|
-
kycService:
|
|
21
|
+
kycService: typeof kycService;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
const defaultConfig: OrientationVideoConfig = {
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import { View, Text, StyleSheet, TouchableOpacity, ScrollView } from 'react-native';
|
|
3
|
+
import { TemplateComponent } from '../../types/KYC.types';
|
|
4
|
+
import { useTemplateKYCFlowContext } from '../../hooks/useTemplateKYCFlow';
|
|
5
|
+
import { useI18n } from '../../hooks/useI18n';
|
|
6
|
+
|
|
7
|
+
interface ReviewSubmitTemplateProps {
|
|
8
|
+
component: TemplateComponent;
|
|
9
|
+
value: unknown;
|
|
10
|
+
onValueChange: (data: unknown) => void;
|
|
11
|
+
error?: string;
|
|
12
|
+
language?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const ReviewSubmitTemplate: React.FC<ReviewSubmitTemplateProps> = () => {
|
|
16
|
+
const { t } = useI18n();
|
|
17
|
+
const { state, actions, getLocalizedText } = useTemplateKYCFlowContext();
|
|
18
|
+
|
|
19
|
+
const idSection = useMemo(() => {
|
|
20
|
+
const idComp = state.template.components.find(c => c.type === 'id_card');
|
|
21
|
+
return idComp ? state.componentData[idComp.id] : null;
|
|
22
|
+
}, [state.template.components, state.componentData]);
|
|
23
|
+
|
|
24
|
+
// Helper to coerce possibly-nested localized configs into the expected shape
|
|
25
|
+
const coerceLocalized = (value: any, fallback: { en: string; fr: string }) => {
|
|
26
|
+
if (value && typeof value === 'object') {
|
|
27
|
+
if (typeof value.en === 'string' || typeof value.fr === 'string') {
|
|
28
|
+
return {
|
|
29
|
+
en: typeof value.en === 'string' ? value.en : fallback.en,
|
|
30
|
+
fr: typeof value.fr === 'string' ? value.fr : fallback.fr,
|
|
31
|
+
...value,
|
|
32
|
+
} as { [key: string]: string; en: string; fr: string };
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return fallback;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// const reviewComp = useMemo(() => {
|
|
39
|
+
// return state.template.components.find(c => c.type === 'review_submit');
|
|
40
|
+
// }, [state.template.components]);
|
|
41
|
+
|
|
42
|
+
const dynamicComponents = useMemo(() => {
|
|
43
|
+
return state.template.components.filter(c => c.type !== 'review_submit' && c.type !== 'verification_progress');
|
|
44
|
+
}, [state.template.components]);
|
|
45
|
+
|
|
46
|
+
const handleSubmit = async () => {
|
|
47
|
+
await actions.nextComponent();
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<View style={styles.container}>
|
|
52
|
+
<Text style={styles.title}>{t('kyc.reviewSubmit.title')}</Text>
|
|
53
|
+
<Text style={styles.subtitle}>{t('kyc.reviewSubmit.subtitle')}</Text>
|
|
54
|
+
|
|
55
|
+
<ScrollView contentContainerStyle={styles.scrollContent}>
|
|
56
|
+
{dynamicComponents.map((comp) => {
|
|
57
|
+
const compData = state.componentData[comp.id] || {};
|
|
58
|
+
const isCompleted = state.completedComponents.includes(comp.id);
|
|
59
|
+
if (comp.type === 'id_card') {
|
|
60
|
+
const hasFront = !!(compData.front || compData.front_base64 || compData.front_mrz);
|
|
61
|
+
const hasBack = !!(compData.back || compData.back_base64 || compData.back_mrz);
|
|
62
|
+
return (
|
|
63
|
+
<View key={comp.id} style={styles.section}>
|
|
64
|
+
<Text style={styles.sectionTitle}>{t('kyc.reviewSubmit.documentInfo')}</Text>
|
|
65
|
+
<View style={styles.row}>
|
|
66
|
+
<View style={[styles.tile, hasFront ? styles.active : null]}>
|
|
67
|
+
<Text style={styles.tileLabel}>{t('kyc.idCardCapture.frontSide')}</Text>
|
|
68
|
+
{hasFront ? <Text style={styles.check}>✓</Text> : null}
|
|
69
|
+
</View>
|
|
70
|
+
<View style={[styles.tile, hasBack ? styles.active : null]}>
|
|
71
|
+
<Text style={styles.tileLabel}>{t('kyc.idCardCapture.backSide')}</Text>
|
|
72
|
+
{hasBack ? <Text style={styles.check}>✓</Text> : null}
|
|
73
|
+
</View>
|
|
74
|
+
</View>
|
|
75
|
+
{idSection?.documentType ? (
|
|
76
|
+
<Text style={styles.caption}>{idSection.documentType}</Text>
|
|
77
|
+
) : null}
|
|
78
|
+
</View>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
if (comp.type === 'selfie') {
|
|
82
|
+
const orientations = ((comp.config as any)?.orientations || ['center', 'right', 'left']) as string[];
|
|
83
|
+
return (
|
|
84
|
+
<View key={comp.id} style={styles.section}>
|
|
85
|
+
<Text style={styles.sectionTitle}>{t('kyc.selfieCapture.title')}</Text>
|
|
86
|
+
<View style={styles.row}>
|
|
87
|
+
{orientations.map((o) => {
|
|
88
|
+
const has = !!compData[o];
|
|
89
|
+
const colorStyle = o === 'center' ? styles.pink : o === 'right' ? styles.blue : styles.purple;
|
|
90
|
+
return (
|
|
91
|
+
<View key={o} style={[styles.tile, colorStyle, has ? styles.active : null]}>
|
|
92
|
+
<Text style={styles.tileLabel}>{o.charAt(0).toUpperCase() + o.slice(1)}</Text>
|
|
93
|
+
{has ? <Text style={styles.check}>✓</Text> : null}
|
|
94
|
+
</View>
|
|
95
|
+
);
|
|
96
|
+
})}
|
|
97
|
+
</View>
|
|
98
|
+
<Text style={styles.caption}>{t('kyc.selfieCapture.success')}</Text>
|
|
99
|
+
</View>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
// Generic fallback for other component types
|
|
103
|
+
return (
|
|
104
|
+
<View key={comp.id} style={styles.section}>
|
|
105
|
+
<Text style={styles.sectionTitle}>{getLocalizedText(coerceLocalized(comp.labels, { en: comp.type, fr: comp.type }))}</Text>
|
|
106
|
+
<Text style={styles.caption}>{isCompleted ? t('common.success') : t('kyc.verificationProgress.status.pending')}</Text>
|
|
107
|
+
</View>
|
|
108
|
+
);
|
|
109
|
+
})}
|
|
110
|
+
</ScrollView>
|
|
111
|
+
|
|
112
|
+
<TouchableOpacity style={[styles.button, styles.primary]} onPress={handleSubmit}>
|
|
113
|
+
<Text style={styles.buttonText}>{t('kyc.reviewSubmit.submitButton')}</Text>
|
|
114
|
+
</TouchableOpacity>
|
|
115
|
+
</View>
|
|
116
|
+
);
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const styles = StyleSheet.create({
|
|
120
|
+
container: {
|
|
121
|
+
flex: 1,
|
|
122
|
+
width: '100%',
|
|
123
|
+
paddingHorizontal: 16,
|
|
124
|
+
paddingVertical: 12,
|
|
125
|
+
},
|
|
126
|
+
title: {
|
|
127
|
+
fontSize: 24,
|
|
128
|
+
fontWeight: 'bold',
|
|
129
|
+
color: '#111827',
|
|
130
|
+
marginBottom: 4,
|
|
131
|
+
},
|
|
132
|
+
subtitle: {
|
|
133
|
+
fontSize: 14,
|
|
134
|
+
color: '#6B7280',
|
|
135
|
+
marginBottom: 16,
|
|
136
|
+
},
|
|
137
|
+
section: {
|
|
138
|
+
backgroundColor: 'white',
|
|
139
|
+
borderRadius: 16,
|
|
140
|
+
padding: 16,
|
|
141
|
+
marginBottom: 16,
|
|
142
|
+
},
|
|
143
|
+
sectionTitle: {
|
|
144
|
+
fontSize: 18,
|
|
145
|
+
fontWeight: '700',
|
|
146
|
+
color: '#111827',
|
|
147
|
+
marginBottom: 12,
|
|
148
|
+
},
|
|
149
|
+
scrollContent: {
|
|
150
|
+
paddingBottom: 24,
|
|
151
|
+
},
|
|
152
|
+
row: {
|
|
153
|
+
flexDirection: 'row',
|
|
154
|
+
gap: 12,
|
|
155
|
+
},
|
|
156
|
+
tile: {
|
|
157
|
+
flex: 1,
|
|
158
|
+
height: 110,
|
|
159
|
+
borderRadius: 16,
|
|
160
|
+
backgroundColor: '#F3F4F6',
|
|
161
|
+
alignItems: 'center',
|
|
162
|
+
justifyContent: 'center',
|
|
163
|
+
},
|
|
164
|
+
tileLabel: {
|
|
165
|
+
fontSize: 14,
|
|
166
|
+
color: '#111827',
|
|
167
|
+
marginBottom: 8,
|
|
168
|
+
},
|
|
169
|
+
check: {
|
|
170
|
+
fontSize: 18,
|
|
171
|
+
color: '#10B981',
|
|
172
|
+
fontWeight: '700',
|
|
173
|
+
},
|
|
174
|
+
active: {
|
|
175
|
+
backgroundColor: '#DDE9FF',
|
|
176
|
+
},
|
|
177
|
+
pink: { backgroundColor: '#FDE2E7' },
|
|
178
|
+
blue: { backgroundColor: '#DDE9FF' },
|
|
179
|
+
purple: { backgroundColor: '#EDE2FF' },
|
|
180
|
+
caption: {
|
|
181
|
+
marginTop: 10,
|
|
182
|
+
fontSize: 12,
|
|
183
|
+
color: '#6B7280',
|
|
184
|
+
},
|
|
185
|
+
button: {
|
|
186
|
+
paddingVertical: 14,
|
|
187
|
+
borderRadius: 10,
|
|
188
|
+
alignItems: 'center',
|
|
189
|
+
marginTop: 12,
|
|
190
|
+
},
|
|
191
|
+
primary: {
|
|
192
|
+
backgroundColor: '#2DBD60',
|
|
193
|
+
},
|
|
194
|
+
buttonText: {
|
|
195
|
+
color: 'white',
|
|
196
|
+
fontSize: 16,
|
|
197
|
+
fontWeight: '600',
|
|
198
|
+
},
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
|