@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.
Files changed (216) hide show
  1. package/build/api/axios.d.ts +30 -0
  2. package/build/api/axios.d.ts.map +1 -0
  3. package/build/api/axios.js +92 -0
  4. package/build/api/axios.js.map +1 -0
  5. package/build/components/EnhancedCameraView.d.ts +1 -41
  6. package/build/components/EnhancedCameraView.d.ts.map +1 -1
  7. package/build/components/EnhancedCameraView.js +75 -34
  8. package/build/components/EnhancedCameraView.js.map +1 -1
  9. package/build/components/EnhancedCameraView.web.d.ts +1 -41
  10. package/build/components/EnhancedCameraView.web.d.ts.map +1 -1
  11. package/build/components/EnhancedCameraView.web.js +28 -4
  12. package/build/components/EnhancedCameraView.web.js.map +1 -1
  13. package/build/components/KYCElements/CountrySelectionTemplate.d.ts +2 -2
  14. package/build/components/KYCElements/CountrySelectionTemplate.d.ts.map +1 -1
  15. package/build/components/KYCElements/CountrySelectionTemplate.js +77 -114
  16. package/build/components/KYCElements/CountrySelectionTemplate.js.map +1 -1
  17. package/build/components/KYCElements/FileUploadTemplate.d.ts.map +1 -1
  18. package/build/components/KYCElements/FileUploadTemplate.js +7 -3
  19. package/build/components/KYCElements/FileUploadTemplate.js.map +1 -1
  20. package/build/components/KYCElements/IDCardCapture.d.ts +7 -2
  21. package/build/components/KYCElements/IDCardCapture.d.ts.map +1 -1
  22. package/build/components/KYCElements/IDCardCapture.js +253 -104
  23. package/build/components/KYCElements/IDCardCapture.js.map +1 -1
  24. package/build/components/KYCElements/InitializationStep.d.ts +5 -0
  25. package/build/components/KYCElements/InitializationStep.d.ts.map +1 -0
  26. package/build/components/KYCElements/InitializationStep.js +41 -0
  27. package/build/components/KYCElements/InitializationStep.js.map +1 -0
  28. package/build/components/KYCElements/LocationCaptureTemplate.d.ts.map +1 -1
  29. package/build/components/KYCElements/LocationCaptureTemplate.js +15 -13
  30. package/build/components/KYCElements/LocationCaptureTemplate.js.map +1 -1
  31. package/build/components/KYCElements/OrientationVideoCapture.d.ts +2 -2
  32. package/build/components/KYCElements/OrientationVideoCapture.d.ts.map +1 -1
  33. package/build/components/KYCElements/OrientationVideoCapture.js.map +1 -1
  34. package/build/components/KYCElements/OrientationVideoCaptureEnhanced.d.ts +2 -2
  35. package/build/components/KYCElements/OrientationVideoCaptureEnhanced.d.ts.map +1 -1
  36. package/build/components/KYCElements/OrientationVideoCaptureEnhanced.js.map +1 -1
  37. package/build/components/KYCElements/OrientationVideoCaptureFinal.d.ts +2 -2
  38. package/build/components/KYCElements/OrientationVideoCaptureFinal.d.ts.map +1 -1
  39. package/build/components/KYCElements/OrientationVideoCaptureFinal.js.map +1 -1
  40. package/build/components/KYCElements/ReviewSubmitTemplate.d.ts +12 -0
  41. package/build/components/KYCElements/ReviewSubmitTemplate.d.ts.map +1 -0
  42. package/build/components/KYCElements/ReviewSubmitTemplate.js +171 -0
  43. package/build/components/KYCElements/ReviewSubmitTemplate.js.map +1 -0
  44. package/build/components/KYCElements/SelfieCaptureTemplate.d.ts +6 -2
  45. package/build/components/KYCElements/SelfieCaptureTemplate.d.ts.map +1 -1
  46. package/build/components/KYCElements/SelfieCaptureTemplate.js +137 -38
  47. package/build/components/KYCElements/SelfieCaptureTemplate.js.map +1 -1
  48. package/build/components/KYCElements/VerificationProgressTemplate.d.ts +12 -0
  49. package/build/components/KYCElements/VerificationProgressTemplate.d.ts.map +1 -0
  50. package/build/components/KYCElements/VerificationProgressTemplate.js +194 -0
  51. package/build/components/KYCElements/VerificationProgressTemplate.js.map +1 -0
  52. package/build/components/OverLay/IdCard.d.ts +1 -1
  53. package/build/components/OverLay/IdCard.d.ts.map +1 -1
  54. package/build/components/OverLay/IdCard.js +10 -6
  55. package/build/components/OverLay/IdCard.js.map +1 -1
  56. package/build/components/OverLay/SelfieOverlay.d.ts +1 -1
  57. package/build/components/OverLay/SelfieOverlay.d.ts.map +1 -1
  58. package/build/components/OverLay/SelfieOverlay.js +5 -4
  59. package/build/components/OverLay/SelfieOverlay.js.map +1 -1
  60. package/build/components/OverLay/type.d.ts +71 -1
  61. package/build/components/OverLay/type.d.ts.map +1 -1
  62. package/build/components/OverLay/type.js.map +1 -1
  63. package/build/components/TemplateKYCExample.d.ts +4 -1
  64. package/build/components/TemplateKYCExample.d.ts.map +1 -1
  65. package/build/components/TemplateKYCExample.js +74 -199
  66. package/build/components/TemplateKYCExample.js.map +1 -1
  67. package/build/components/TemplateKYCFlowRefactored.d.ts +3 -2
  68. package/build/components/TemplateKYCFlowRefactored.d.ts.map +1 -1
  69. package/build/components/TemplateKYCFlowRefactored.js +64 -40
  70. package/build/components/TemplateKYCFlowRefactored.js.map +1 -1
  71. package/build/components/example/OrientationVideoExample.d.ts.map +1 -1
  72. package/build/components/example/OrientationVideoExample.js +1 -5
  73. package/build/components/example/OrientationVideoExample.js.map +1 -1
  74. package/build/config/countriesData.d.ts +3 -0
  75. package/build/config/countriesData.d.ts.map +1 -0
  76. package/build/config/countriesData.js +79 -0
  77. package/build/config/countriesData.js.map +1 -0
  78. package/build/config/region_mapping.d.ts +3 -0
  79. package/build/config/region_mapping.d.ts.map +1 -0
  80. package/build/config/region_mapping.js +687 -0
  81. package/build/config/region_mapping.js.map +1 -0
  82. package/build/hooks/useI18n.d.ts +11 -0
  83. package/build/hooks/useI18n.d.ts.map +1 -0
  84. package/build/hooks/useI18n.js +37 -0
  85. package/build/hooks/useI18n.js.map +1 -0
  86. package/build/hooks/useOrientationVideo.d.ts +1 -2
  87. package/build/hooks/useOrientationVideo.d.ts.map +1 -1
  88. package/build/hooks/useOrientationVideo.js +2 -1
  89. package/build/hooks/useOrientationVideo.js.map +1 -1
  90. package/build/hooks/useRealtimeVerifier.d.ts +28 -0
  91. package/build/hooks/useRealtimeVerifier.d.ts.map +1 -0
  92. package/build/hooks/useRealtimeVerifier.js +91 -0
  93. package/build/hooks/useRealtimeVerifier.js.map +1 -0
  94. package/build/hooks/useTemplateKYCFlow.d.ts +6 -3
  95. package/build/hooks/useTemplateKYCFlow.d.ts.map +1 -1
  96. package/build/hooks/useTemplateKYCFlow.js +356 -42
  97. package/build/hooks/useTemplateKYCFlow.js.map +1 -1
  98. package/build/i18n/en/index.d.ts +168 -0
  99. package/build/i18n/en/index.d.ts.map +1 -0
  100. package/build/i18n/en/index.js +195 -0
  101. package/build/i18n/en/index.js.map +1 -0
  102. package/build/i18n/fr/index.d.ts +168 -0
  103. package/build/i18n/fr/index.d.ts.map +1 -0
  104. package/build/i18n/fr/index.js +194 -0
  105. package/build/i18n/fr/index.js.map +1 -0
  106. package/build/i18n/index.d.ts +10 -0
  107. package/build/i18n/index.d.ts.map +1 -0
  108. package/build/i18n/index.js +56 -0
  109. package/build/i18n/index.js.map +1 -0
  110. package/build/i18n/types.d.ts +153 -0
  111. package/build/i18n/types.d.ts.map +1 -0
  112. package/build/i18n/types.js +3 -0
  113. package/build/i18n/types.js.map +1 -0
  114. package/build/i18n/usage-example.d.ts +4 -0
  115. package/build/i18n/usage-example.d.ts.map +1 -0
  116. package/build/i18n/usage-example.js +189 -0
  117. package/build/i18n/usage-example.js.map +1 -0
  118. package/build/index.d.ts +1 -0
  119. package/build/index.d.ts.map +1 -1
  120. package/build/index.js +2 -0
  121. package/build/index.js.map +1 -1
  122. package/build/modules/api/CardAuthentification.d.ts +22 -0
  123. package/build/modules/api/CardAuthentification.d.ts.map +1 -0
  124. package/build/modules/api/CardAuthentification.js +107 -0
  125. package/build/modules/api/CardAuthentification.js.map +1 -0
  126. package/build/modules/api/KYCService.d.ts +58 -1
  127. package/build/modules/api/KYCService.d.ts.map +1 -1
  128. package/build/modules/api/KYCService.js +304 -27
  129. package/build/modules/api/KYCService.js.map +1 -1
  130. package/build/modules/api/SelfieVerification.d.ts +3 -0
  131. package/build/modules/api/SelfieVerification.d.ts.map +1 -0
  132. package/build/modules/api/SelfieVerification.js +9 -0
  133. package/build/modules/api/SelfieVerification.js.map +1 -0
  134. package/build/modules/api/backendApi.d.ts +2 -0
  135. package/build/modules/api/backendApi.d.ts.map +1 -0
  136. package/build/modules/api/backendApi.js +6 -0
  137. package/build/modules/api/backendApi.js.map +1 -0
  138. package/build/modules/api/types.d.ts +45 -0
  139. package/build/modules/api/types.d.ts.map +1 -0
  140. package/build/modules/api/types.js +2 -0
  141. package/build/modules/api/types.js.map +1 -0
  142. package/build/types/KYC.types.d.ts +56 -7
  143. package/build/types/KYC.types.d.ts.map +1 -1
  144. package/build/types/KYC.types.js +9 -1
  145. package/build/types/KYC.types.js.map +1 -1
  146. package/build/utils/cropByObb.d.ts +11 -0
  147. package/build/utils/cropByObb.d.ts.map +1 -0
  148. package/build/utils/cropByObb.js +78 -0
  149. package/build/utils/cropByObb.js.map +1 -0
  150. package/build/utils/get-document-type-info.d.ts +13 -0
  151. package/build/utils/get-document-type-info.d.ts.map +1 -0
  152. package/build/utils/get-document-type-info.js +59 -0
  153. package/build/utils/get-document-type-info.js.map +1 -0
  154. package/build/utils/pathToBase64.d.ts +3 -0
  155. package/build/utils/pathToBase64.d.ts.map +1 -0
  156. package/build/utils/pathToBase64.js +47 -0
  157. package/build/utils/pathToBase64.js.map +1 -0
  158. package/build/utils/remove-duplicate.d.ts +2 -0
  159. package/build/utils/remove-duplicate.d.ts.map +1 -0
  160. package/build/utils/remove-duplicate.js +4 -0
  161. package/build/utils/remove-duplicate.js.map +1 -0
  162. package/build/web/WebKYCEntry.d.ts +9 -0
  163. package/build/web/WebKYCEntry.d.ts.map +1 -0
  164. package/build/web/WebKYCEntry.js +156 -0
  165. package/build/web/WebKYCEntry.js.map +1 -0
  166. package/build/web/index.d.ts +2 -0
  167. package/build/web/index.d.ts.map +1 -0
  168. package/build/web/index.js +2 -0
  169. package/build/web/index.js.map +1 -0
  170. package/package.json +3 -1
  171. package/src/api/axios.ts +144 -0
  172. package/src/components/EnhancedCameraView.tsx +96 -78
  173. package/src/components/EnhancedCameraView.web.tsx +41 -40
  174. package/src/components/KYCElements/CountrySelectionTemplate.tsx +111 -136
  175. package/src/components/KYCElements/FileUploadTemplate.tsx +14 -8
  176. package/src/components/KYCElements/IDCardCapture.tsx +311 -115
  177. package/src/components/KYCElements/InitializationStep.tsx +53 -0
  178. package/src/components/KYCElements/LocationCaptureTemplate.tsx +17 -15
  179. package/src/components/KYCElements/OrientationVideoCapture.tsx +2 -2
  180. package/src/components/KYCElements/OrientationVideoCaptureEnhanced.tsx +2 -2
  181. package/src/components/KYCElements/OrientationVideoCaptureFinal.tsx +2 -2
  182. package/src/components/KYCElements/ReviewSubmitTemplate.tsx +201 -0
  183. package/src/components/KYCElements/SelfieCaptureTemplate.tsx +174 -57
  184. package/src/components/KYCElements/VerificationProgressTemplate.tsx +246 -0
  185. package/src/components/OverLay/IdCard.tsx +17 -9
  186. package/src/components/OverLay/SelfieOverlay.tsx +6 -5
  187. package/src/components/OverLay/type.ts +64 -2
  188. package/src/components/TemplateKYCExample.tsx +80 -200
  189. package/src/components/TemplateKYCFlowRefactored.tsx +80 -48
  190. package/src/components/example/OrientationVideoExample.tsx +3 -7
  191. package/src/config/countriesData.ts +84 -0
  192. package/src/config/region_mapping.ts +688 -0
  193. package/src/hooks/useI18n.ts +53 -0
  194. package/src/hooks/useOrientationVideo.ts +2 -2
  195. package/src/hooks/useRealtimeVerifier.ts +128 -0
  196. package/src/hooks/useTemplateKYCFlow.tsx +407 -57
  197. package/src/i18n/README.md +288 -0
  198. package/src/i18n/en/index.ts +206 -0
  199. package/src/i18n/fr/index.ts +205 -0
  200. package/src/i18n/index.ts +65 -0
  201. package/src/i18n/types.ts +172 -0
  202. package/src/i18n/usage-example.tsx +202 -0
  203. package/src/index.ts +3 -0
  204. package/src/modules/api/CardAuthentification.ts +114 -0
  205. package/src/modules/api/KYCService.ts +350 -30
  206. package/src/modules/api/SelfieVerification.ts +11 -0
  207. package/src/modules/api/backendApi.ts +8 -0
  208. package/src/modules/api/types.ts +51 -0
  209. package/src/types/KYC.types.ts +82 -14
  210. package/src/utils/cropByObb.ts +99 -0
  211. package/src/utils/get-document-type-info.ts +62 -0
  212. package/src/utils/pathToBase64.ts +47 -0
  213. package/src/utils/remove-duplicate.ts +3 -0
  214. package/src/web/WebKYCEntry.tsx +215 -0
  215. package/src/web/index.ts +1 -0
  216. 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
- 'Permission refusée',
48
- 'La permission de localisation est nécessaire pour continuer.'
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
- 'Localisation désactivée',
59
- 'Veuillez activer la localisation sur votre appareil pour continuer.'
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('Erreur', 'Impossible de récupérer votre localisation. Veuillez réessayer.');
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 }}>Secure Your Verification</Text>
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
- Allow location access to help us protect your account and prevent fraudulent activity during verification.
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
- {`How this helps:`}
131
+ {t('kyc.locationCapture.howThisHelps')}
130
132
  </Text>
131
133
  <Text style={{ fontSize: 16, color: '#666', textAlign: 'left', lineHeight: 22 }}>
132
- {`• Verifies your device location matches your identity\n• Detects and prevents unauthorized access\n• Ensures compliance with security regulations`}
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}>Localisation obtenue</Text>
140
+ <Text style={styles.locationTitle}>{t('kyc.locationCapture.obtained')}</Text>
139
141
  <Text style={styles.locationDetails}>
140
- Latitude: {currentLocation.latitude.toFixed(6)}
142
+ {t('kyc.locationCapture.latitudeLabel')}: {currentLocation.latitude.toFixed(6)}
141
143
  </Text>
142
144
  <Text style={styles.locationDetails}>
143
- Longitude: {currentLocation.longitude.toFixed(6)}
145
+ {t('kyc.locationCapture.longitudeLabel')}: {currentLocation.longitude.toFixed(6)}
144
146
  </Text>
145
147
  <Text style={styles.locationDetails}>
146
- Précision: {currentLocation.accuracy.toFixed(1)}m
148
+ {t('kyc.locationCapture.accuracyLabel')}: {currentLocation.accuracy.toFixed(1)}m
147
149
  </Text>
148
150
  <Button
149
- title="Réinitialiser"
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 ? "Récupération..." : "Enable Location Access"}
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 KYCService from '../../modules/api/KYCService';
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: 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 KYCService from '../../modules/api/KYCService';
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: 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: 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
+