@transfergratis/react-native-sdk 0.1.3 → 0.1.5
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/android/.idea/caches/deviceStreaming.xml +860 -0
- package/android/build/.transforms/{7ec900c0f64f5f1a7c88998dd44001b8 → 01c28d00c798aa4846f16ce72123ebf9}/transformed/classes/classes_dex/classes.dex +0 -0
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/processDebugManifest/aapt/AndroidManifest.xml +1 -0
- package/android/build/intermediates/aar_main_jar/debug/syncDebugLibJars/classes.jar +0 -0
- package/android/build/intermediates/annotations_typedef_file/debug/extractDebugAnnotations/typedefs.txt +0 -0
- package/android/build/intermediates/compile_library_classes_jar/debug/bundleLibCompileToJarDebug/classes.jar +0 -0
- package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +2 -2
- package/android/build/intermediates/incremental/debug-mergeJavaRes/merge-state +0 -0
- package/android/build/intermediates/manifest_merge_blame_file/debug/processDebugManifest/manifest-merger-blame-debug-report.txt +51 -48
- package/android/build/intermediates/merged_java_res/debug/mergeDebugJavaResource/feature-transfergratis-react-native-sdk.jar +0 -0
- package/android/build/intermediates/merged_manifest/debug/processDebugManifest/AndroidManifest.xml +1 -0
- package/android/build/intermediates/runtime_library_classes_jar/debug/bundleLibRuntimeToJarDebug/classes.jar +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/counters.tab +1 -1
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/last-build.bin +0 -0
- package/android/build/kotlin/compileDebugKotlin/classpath-snapshot/shrunk-classpath-snapshot.bin +0 -0
- package/android/build/kotlin/compileDebugKotlin/local-state/build-history.bin +0 -0
- package/android/build/outputs/aar/transfergratis-react-native-sdk-debug.aar +0 -0
- package/android/build/outputs/logs/manifest-merger-debug-report.txt +27 -23
- package/android/build/tmp/kotlin-classes/debug/kyc/transfergratis/com/TransfergratisSdkModule.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/kyc/transfergratis/com/TransfergratisSdkView.class +0 -0
- package/android/build.gradle +1 -5
- package/android/src/main/AndroidManifest.xml +1 -0
- 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 +76 -35
- 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 +71 -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 +105 -35
- 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 +93 -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.map +1 -1
- package/build/components/TemplateKYCExample.js +72 -197
- package/build/components/TemplateKYCExample.js.map +1 -1
- package/build/components/TemplateKYCFlowRefactored.d.ts.map +1 -1
- package/build/components/TemplateKYCFlowRefactored.js +63 -39
- package/build/components/TemplateKYCFlowRefactored.js.map +1 -1
- package/build/components/VisionCameraView.js +1 -1
- package/build/components/VisionCameraView.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/components/ui/Button.js +1 -1
- package/build/components/ui/Button.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 +1 -0
- package/build/hooks/useTemplateKYCFlow.d.ts.map +1 -1
- package/build/hooks/useTemplateKYCFlow.js +337 -38
- 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/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 +57 -1
- package/build/modules/api/KYCService.d.ts.map +1 -1
- package/build/modules/api/KYCService.js +348 -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 +20 -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/modules/camera/VisionCameraModule.d.ts +1 -1
- package/build/modules/camera/VisionCameraModule.d.ts.map +1 -1
- package/build/modules/camera/VisionCameraModule.js +8 -2
- package/build/modules/camera/VisionCameraModule.js.map +1 -1
- package/build/types/KYC.types.d.ts +59 -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/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 +104 -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 +140 -53
- package/src/components/KYCElements/VerificationProgressTemplate.tsx +123 -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 +76 -197
- package/src/components/TemplateKYCFlowRefactored.tsx +74 -46
- package/src/components/VisionCameraView.tsx +1 -1
- package/src/components/example/OrientationVideoExample.tsx +3 -7
- package/src/components/ui/Button.tsx +1 -1
- 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 +375 -53
- 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/modules/api/CardAuthentification.ts +114 -0
- package/src/modules/api/KYCService.ts +403 -30
- package/src/modules/api/SelfieVerification.ts +11 -0
- package/src/modules/api/backendApi.ts +8 -0
- package/src/modules/api/types.ts +24 -0
- package/src/modules/camera/VisionCameraModule.ts +16 -7
- package/src/types/KYC.types.ts +83 -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/android/build/.transforms/d6df0e53bfc3165a876965af720f910a/results.bin +0 -1
- package/android/build/.transforms/d6df0e53bfc3165a876965af720f910a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/kyc/transfergratis/com/BuildConfig.dex +0 -0
- package/android/build/.transforms/d6df0e53bfc3165a876965af720f910a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/kyc/transfergratis/com/TransfergratisSdkModule$definition$1$5$1.dex +0 -0
- package/android/build/.transforms/d6df0e53bfc3165a876965af720f910a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/kyc/transfergratis/com/TransfergratisSdkModule$definition$1$5$2.dex +0 -0
- package/android/build/.transforms/d6df0e53bfc3165a876965af720f910a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunction$1.dex +0 -0
- package/android/build/.transforms/d6df0e53bfc3165a876965af720f910a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunction$2.dex +0 -0
- package/android/build/.transforms/d6df0e53bfc3165a876965af720f910a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunction$3.dex +0 -0
- package/android/build/.transforms/d6df0e53bfc3165a876965af720f910a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunction$4.dex +0 -0
- package/android/build/.transforms/d6df0e53bfc3165a876965af720f910a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunction$5.dex +0 -0
- package/android/build/.transforms/d6df0e53bfc3165a876965af720f910a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunction$6.dex +0 -0
- package/android/build/.transforms/d6df0e53bfc3165a876965af720f910a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunctionWithPromise$1.dex +0 -0
- package/android/build/.transforms/d6df0e53bfc3165a876965af720f910a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunctionWithPromise$2.dex +0 -0
- package/android/build/.transforms/d6df0e53bfc3165a876965af720f910a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunctionWithPromise$3.dex +0 -0
- package/android/build/.transforms/d6df0e53bfc3165a876965af720f910a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunctionWithPromise$4.dex +0 -0
- package/android/build/.transforms/d6df0e53bfc3165a876965af720f910a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$View$1.dex +0 -0
- package/android/build/.transforms/d6df0e53bfc3165a876965af720f910a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$lambda$4$$inlined$Prop$1.dex +0 -0
- package/android/build/.transforms/d6df0e53bfc3165a876965af720f910a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$lambda$4$$inlined$Prop$2.dex +0 -0
- package/android/build/.transforms/d6df0e53bfc3165a876965af720f910a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/kyc/transfergratis/com/TransfergratisSdkModule.dex +0 -0
- package/android/build/.transforms/d6df0e53bfc3165a876965af720f910a/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/kyc/transfergratis/com/TransfergratisSdkView.dex +0 -0
- package/android/build/.transforms/d6df0e53bfc3165a876965af720f910a/transformed/bundleLibRuntimeToDirDebug/desugar_graph.bin +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/kyc/transfergratis/com/BuildConfig.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/kyc/transfergratis/com/TransfergratisSdkModule$definition$1$5$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/kyc/transfergratis/com/TransfergratisSdkModule$definition$1$5$2.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunction$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunction$2.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunction$3.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunction$4.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunction$5.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunction$6.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunctionWithPromise$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunctionWithPromise$2.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunctionWithPromise$3.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunctionWithPromise$4.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$View$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$lambda$4$$inlined$Prop$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$lambda$4$$inlined$Prop$2.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/kyc/transfergratis/com/TransfergratisSdkModule.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/kyc/transfergratis/com/TransfergratisSdkView.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/META-INF/transfergratis-sdk_debug.kotlin_module +0 -0
- package/src/types/nativewind.d.ts +0 -2
- /package/android/build/.transforms/{7ec900c0f64f5f1a7c88998dd44001b8 → 01c28d00c798aa4846f16ce72123ebf9}/results.bin +0 -0
- /package/android/build/intermediates/java_res/debug/processDebugJavaRes/out/META-INF/{transfergratis-sdk_debug.kotlin_module → transfergratis-react-native-sdk_debug.kotlin_module} +0 -0
- /package/android/build/{intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/META-INF/transfergratis-sdk_debug.kotlin_module → tmp/kotlin-classes/debug/META-INF/transfergratis-react-native-sdk_debug.kotlin_module} +0 -0
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import React, { useState, useCallback, useMemo, createContext, useContext } from 'react';
|
|
1
|
+
import React, { useState, useCallback, useMemo, createContext, useContext, useEffect } from 'react';
|
|
2
|
+
import kycService, { authentification, truncateFields } from '../modules/api/KYCService';
|
|
3
|
+
import useI18n from './useI18n';
|
|
2
4
|
const TemplateKYCFlowContext = createContext(undefined);
|
|
3
5
|
export const TemplateKYCFlowProvider = ({ children, template, onComplete, onError, initialLanguage = 'en', }) => {
|
|
4
6
|
const hookResult = useTemplateKYCFlow(template, onComplete, onError, initialLanguage);
|
|
@@ -15,9 +17,137 @@ export const useTemplateKYCFlowContext = () => {
|
|
|
15
17
|
return context;
|
|
16
18
|
};
|
|
17
19
|
export const useTemplateKYCFlow = (template, onComplete, onError, initialLanguage = 'en') => {
|
|
20
|
+
const { setLocale } = useI18n();
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
setLocale(initialLanguage);
|
|
23
|
+
}, [initialLanguage]);
|
|
24
|
+
// Helpers to align SDK steps with backend actions/templates
|
|
25
|
+
const isUiOnlyStep = useCallback((type) => {
|
|
26
|
+
return type === 'verification_progress';
|
|
27
|
+
}, []);
|
|
28
|
+
const mapComponentTypeToAction = useCallback((type) => {
|
|
29
|
+
switch (type) {
|
|
30
|
+
case 'id_card':
|
|
31
|
+
case 'file_upload':
|
|
32
|
+
return 'document_upload';
|
|
33
|
+
case 'selfie':
|
|
34
|
+
return 'selfie_capture';
|
|
35
|
+
case 'location':
|
|
36
|
+
return 'location_permission';
|
|
37
|
+
case 'review_submit':
|
|
38
|
+
return 'final_submit';
|
|
39
|
+
case 'country_selection':
|
|
40
|
+
// No direct backend action; pack into metadata of next actionable step
|
|
41
|
+
return null;
|
|
42
|
+
case 'initialization':
|
|
43
|
+
return 'initialize_session';
|
|
44
|
+
case 'verification_progress':
|
|
45
|
+
return null; // UI-only
|
|
46
|
+
default:
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
}, []);
|
|
50
|
+
const chooseTemplateId = useCallback((tpl) => {
|
|
51
|
+
const types = tpl.components.map(c => c.type);
|
|
52
|
+
const hasLocation = types.includes('location');
|
|
53
|
+
const hasSelfie = types.includes('selfie');
|
|
54
|
+
const hasIdDoc = types.includes('id_card') || types.includes('file_upload');
|
|
55
|
+
// Simple heuristic to map to backend examples
|
|
56
|
+
if (hasLocation && hasSelfie && hasIdDoc)
|
|
57
|
+
return 'enhanced_id';
|
|
58
|
+
if (hasSelfie && hasIdDoc)
|
|
59
|
+
return 'standard_passport';
|
|
60
|
+
return 'standard_passport';
|
|
61
|
+
}, []);
|
|
62
|
+
const computeServerStepIndex = useCallback((tpl, upToIndex) => {
|
|
63
|
+
// Count actionable steps before the current component (exclude UI-only and country_selection)
|
|
64
|
+
const actionable = tpl.components
|
|
65
|
+
.slice(0, upToIndex)
|
|
66
|
+
.filter(c => !isUiOnlyStep(c.type) && mapComponentTypeToAction(c.type) !== null);
|
|
67
|
+
return actionable.length; // 0-based
|
|
68
|
+
}, [isUiOnlyStep, mapComponentTypeToAction]);
|
|
69
|
+
// Build backend-friendly payloads per action
|
|
70
|
+
const buildPayloadForComponent = useCallback((action, component, rawData, templateId, step) => {
|
|
71
|
+
const base = { template_id: null, step: component.order, permissionGranted: true };
|
|
72
|
+
if (!action) {
|
|
73
|
+
return base;
|
|
74
|
+
}
|
|
75
|
+
// Document upload expects an array of documents with base64 and metadata
|
|
76
|
+
if (action === 'document_upload') {
|
|
77
|
+
const documents = {};
|
|
78
|
+
if (rawData && typeof rawData === 'object') {
|
|
79
|
+
Object.keys(rawData).forEach((key) => {
|
|
80
|
+
documents[key] = rawData[key];
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
...base,
|
|
85
|
+
documents,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
if (action === 'selfie_capture') {
|
|
89
|
+
const metatada = {};
|
|
90
|
+
if (rawData && typeof rawData === 'object') {
|
|
91
|
+
Object.keys(rawData).forEach((key) => {
|
|
92
|
+
metatada[key] = rawData[key];
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
return { ...base, metatada };
|
|
96
|
+
}
|
|
97
|
+
if (action === 'location_permission') {
|
|
98
|
+
return { ...base, ...({ metadata: rawData || {} }), ...({ permissionGranted: true, }) };
|
|
99
|
+
}
|
|
100
|
+
// Default: wrap as metadata
|
|
101
|
+
return { ...base, metadata: { ...(rawData || {}) } };
|
|
102
|
+
}, []);
|
|
103
|
+
// Ensure the template contains a final review step
|
|
104
|
+
const ensureReviewSubmitStep = useCallback((tpl) => {
|
|
105
|
+
const hasReview = tpl.components.some(c => c.type === 'review_submit');
|
|
106
|
+
if (hasReview)
|
|
107
|
+
return tpl;
|
|
108
|
+
const lastOrder = tpl.components.reduce((acc, c) => Math.max(acc, c.order ?? 0), 0);
|
|
109
|
+
const lastId = tpl.components.reduce((acc, c) => Math.max(acc, c.id), 0);
|
|
110
|
+
const reviewComponent = {
|
|
111
|
+
id: lastId + 1,
|
|
112
|
+
type: 'review_submit',
|
|
113
|
+
order: lastOrder + 1,
|
|
114
|
+
labels: { en: 'Review & Submit', fr: 'Revoir & Soumettre' },
|
|
115
|
+
instructions: { en: 'Confirm and submit', fr: 'Confirmer et soumettre' },
|
|
116
|
+
ui: { buttonText: { en: 'Complete Verification', fr: 'Terminer la vérification' } },
|
|
117
|
+
// @ts-ignore - config unused for review component
|
|
118
|
+
config: {},
|
|
119
|
+
};
|
|
120
|
+
return {
|
|
121
|
+
...tpl,
|
|
122
|
+
components: [...tpl.components, reviewComponent],
|
|
123
|
+
};
|
|
124
|
+
}, []);
|
|
125
|
+
const ensureVerificationProgressStep = useCallback((tpl) => {
|
|
126
|
+
const hasVerification = tpl.components.some(c => c.type === 'verification_progress');
|
|
127
|
+
if (hasVerification)
|
|
128
|
+
return tpl;
|
|
129
|
+
const lastOrder = tpl.components.reduce((acc, c) => Math.max(acc, c.order ?? 0), 0);
|
|
130
|
+
const lastId = tpl.components.reduce((acc, c) => Math.max(acc, c.id), 0);
|
|
131
|
+
const verificationComponent = {
|
|
132
|
+
id: lastId + 2,
|
|
133
|
+
type: 'verification_progress',
|
|
134
|
+
order: lastOrder + 2,
|
|
135
|
+
labels: { en: 'Verification', fr: 'Vérification' },
|
|
136
|
+
instructions: { en: 'We\'re reviewing your documents', fr: 'Nous analysons vos documents' },
|
|
137
|
+
ui: { buttonText: { en: '', fr: '' } },
|
|
138
|
+
// @ts-ignore - config unused for progress component
|
|
139
|
+
config: {},
|
|
140
|
+
};
|
|
141
|
+
return {
|
|
142
|
+
...tpl,
|
|
143
|
+
components: [...tpl.components, verificationComponent],
|
|
144
|
+
};
|
|
145
|
+
}, []);
|
|
146
|
+
const templateWithReview = useMemo(() => ensureReviewSubmitStep(template), [template, ensureReviewSubmitStep]);
|
|
147
|
+
const templateWithReviewAndVerification = useMemo(() => ensureVerificationProgressStep(templateWithReview), [templateWithReview, ensureVerificationProgressStep]);
|
|
18
148
|
// État du flux
|
|
19
149
|
const [state, setState] = useState({
|
|
20
|
-
template,
|
|
150
|
+
template: templateWithReviewAndVerification,
|
|
21
151
|
currentComponentIndex: 0,
|
|
22
152
|
completedComponents: [],
|
|
23
153
|
componentData: {},
|
|
@@ -25,35 +155,102 @@ export const useTemplateKYCFlow = (template, onComplete, onError, initialLanguag
|
|
|
25
155
|
isProcessing: false,
|
|
26
156
|
currentLanguage: initialLanguage,
|
|
27
157
|
showCustomStepper: true,
|
|
158
|
+
session: {
|
|
159
|
+
session_id: '',
|
|
160
|
+
token: '',
|
|
161
|
+
isInitialized: false,
|
|
162
|
+
isProcessing: false,
|
|
163
|
+
error: null,
|
|
164
|
+
},
|
|
165
|
+
verification: {
|
|
166
|
+
status: 'idle',
|
|
167
|
+
},
|
|
28
168
|
});
|
|
29
169
|
// Composant actuel
|
|
30
170
|
const currentComponent = useMemo(() => {
|
|
31
|
-
return template.components[state.currentComponentIndex] || null;
|
|
32
|
-
}, [template.components, state.currentComponentIndex]);
|
|
171
|
+
return state.template.components[state.currentComponentIndex] || null;
|
|
172
|
+
}, [state.template.components, state.currentComponentIndex]);
|
|
33
173
|
// Progression du flux
|
|
34
174
|
const progress = useMemo(() => {
|
|
35
|
-
return template.components.length > 0
|
|
36
|
-
? ((state.currentComponentIndex + 1) / template.components.length) * 100
|
|
175
|
+
return state.template.components.length > 0
|
|
176
|
+
? ((state.currentComponentIndex + 1) / state.template.components.length) * 100
|
|
37
177
|
: 0;
|
|
38
|
-
}, [state.currentComponentIndex, template.components.length]);
|
|
178
|
+
}, [state.currentComponentIndex, state.template.components.length]);
|
|
39
179
|
// Vérifications de navigation
|
|
40
180
|
const canGoNext = useMemo(() => {
|
|
41
|
-
return state.currentComponentIndex < template.components.length - 1;
|
|
42
|
-
}, [state.currentComponentIndex, template.components.length]);
|
|
181
|
+
return state.currentComponentIndex < state.template.components.length - 1;
|
|
182
|
+
}, [state.currentComponentIndex, state.template.components.length]);
|
|
43
183
|
const canGoPrevious = useMemo(() => {
|
|
44
184
|
return state.currentComponentIndex > 0;
|
|
45
185
|
}, [state.currentComponentIndex]);
|
|
46
186
|
const isComplete = useMemo(() => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
187
|
+
const atReview = state.template.components[state.currentComponentIndex]?.type === 'review_submit';
|
|
188
|
+
const nonReviewCount = state.template.components.filter(c => c.type !== 'review_submit').length;
|
|
189
|
+
const completedNonReview = state.completedComponents.length >= nonReviewCount;
|
|
190
|
+
return atReview && completedNonReview;
|
|
191
|
+
}, [state.currentComponentIndex, state.completedComponents.length, state.template.components]);
|
|
50
192
|
// Fonction pour obtenir le texte localisé
|
|
51
193
|
const getLocalizedText = useCallback((text) => {
|
|
52
194
|
return text[state.currentLanguage] || text.en || '';
|
|
53
195
|
}, [state.currentLanguage]);
|
|
196
|
+
const initializeSession = useCallback(async () => {
|
|
197
|
+
try {
|
|
198
|
+
setState(prev => ({
|
|
199
|
+
...prev,
|
|
200
|
+
session: {
|
|
201
|
+
...prev.session,
|
|
202
|
+
isInitialized: false,
|
|
203
|
+
isProcessing: true,
|
|
204
|
+
error: null,
|
|
205
|
+
},
|
|
206
|
+
}));
|
|
207
|
+
console.log('Initializing session');
|
|
208
|
+
const token = await authentification();
|
|
209
|
+
const session = await kycService.newSession(token);
|
|
210
|
+
// Align backend flow from step 0 with initialize_session
|
|
211
|
+
try {
|
|
212
|
+
const templateId = chooseTemplateId(templateWithReviewAndVerification);
|
|
213
|
+
await kycService.verificationSession({
|
|
214
|
+
session_id: session.session_id,
|
|
215
|
+
step: 0,
|
|
216
|
+
data: { template_id: templateId, metadata: { language: initialLanguage } },
|
|
217
|
+
templateId: templateId,
|
|
218
|
+
token: token,
|
|
219
|
+
action: 'initialize_session'
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
catch (e) {
|
|
223
|
+
console.error('Error initializing session:', JSON.stringify(e, null, 2));
|
|
224
|
+
// Non-fatal: we will surface errors via state below if needed
|
|
225
|
+
}
|
|
226
|
+
setState(prev => ({
|
|
227
|
+
...prev,
|
|
228
|
+
session: {
|
|
229
|
+
...prev.session,
|
|
230
|
+
session_id: session.session_id,
|
|
231
|
+
token: token,
|
|
232
|
+
isInitialized: true,
|
|
233
|
+
isProcessing: false,
|
|
234
|
+
error: null,
|
|
235
|
+
}
|
|
236
|
+
}));
|
|
237
|
+
}
|
|
238
|
+
catch (error) {
|
|
239
|
+
console.error('Error initializing session:', JSON.stringify(error, null, 2));
|
|
240
|
+
setState(prev => ({
|
|
241
|
+
...prev,
|
|
242
|
+
session: {
|
|
243
|
+
...prev.session,
|
|
244
|
+
isInitialized: false,
|
|
245
|
+
isProcessing: false,
|
|
246
|
+
error: "Erreur lors de l'initialisation de la session",
|
|
247
|
+
},
|
|
248
|
+
}));
|
|
249
|
+
}
|
|
250
|
+
}, []);
|
|
54
251
|
// Validation d'un composant
|
|
55
252
|
const validateComponent = useCallback((componentId) => {
|
|
56
|
-
const component = template.components.find(c => c.id === componentId);
|
|
253
|
+
const component = state.template.components.find(c => c.id === componentId);
|
|
57
254
|
if (!component)
|
|
58
255
|
return false;
|
|
59
256
|
const componentData = state.componentData[componentId];
|
|
@@ -74,54 +271,144 @@ export const useTemplateKYCFlow = (template, onComplete, onError, initialLanguag
|
|
|
74
271
|
return componentData && componentData.latitude && componentData.longitude;
|
|
75
272
|
case 'country_selection':
|
|
76
273
|
// Vérifier si un pays a été sélectionné
|
|
77
|
-
|
|
274
|
+
console.log("componentData", truncateFields(componentData), componentId);
|
|
275
|
+
return componentData && componentData.code && componentData.regionMapping;
|
|
276
|
+
case 'review_submit':
|
|
277
|
+
return true;
|
|
78
278
|
default:
|
|
79
279
|
return false;
|
|
80
280
|
}
|
|
81
|
-
}, [template.components, state.componentData]);
|
|
281
|
+
}, [state.template.components, state.componentData]);
|
|
82
282
|
// Actions du flux
|
|
83
283
|
const actions = {
|
|
84
284
|
// Initialiser le template
|
|
85
285
|
initializeTemplate: useCallback((newTemplate) => {
|
|
286
|
+
const withReview = ensureReviewSubmitStep(newTemplate);
|
|
287
|
+
const withVerification = ensureVerificationProgressStep(withReview);
|
|
86
288
|
setState(prev => ({
|
|
87
289
|
...prev,
|
|
88
|
-
template:
|
|
290
|
+
template: withVerification,
|
|
89
291
|
currentComponentIndex: 0,
|
|
90
292
|
completedComponents: [],
|
|
91
293
|
componentData: {},
|
|
92
294
|
errors: {},
|
|
93
295
|
isProcessing: false,
|
|
296
|
+
verification: { status: 'idle', result: undefined },
|
|
94
297
|
}));
|
|
95
|
-
}, []),
|
|
298
|
+
}, [ensureReviewSubmitStep, ensureVerificationProgressStep]),
|
|
96
299
|
// Passer au composant suivant
|
|
97
|
-
nextComponent: useCallback(() => {
|
|
300
|
+
nextComponent: useCallback(async () => {
|
|
98
301
|
if (!canGoNext)
|
|
99
302
|
return;
|
|
100
|
-
const currentComp = template.components[state.currentComponentIndex];
|
|
303
|
+
const currentComp = state.template.components[state.currentComponentIndex];
|
|
101
304
|
if (!currentComp)
|
|
102
305
|
return;
|
|
306
|
+
setState(prev => ({
|
|
307
|
+
...prev,
|
|
308
|
+
isProcessing: true,
|
|
309
|
+
}));
|
|
103
310
|
// Valider le composant actuel
|
|
104
311
|
if (!validateComponent(currentComp.id)) {
|
|
105
312
|
setState(prev => ({
|
|
106
313
|
...prev,
|
|
314
|
+
isProcessing: false,
|
|
107
315
|
errors: {
|
|
108
316
|
...prev.errors,
|
|
109
|
-
[currentComp.id]: 'Veuillez compléter cette étape avant de continuer'
|
|
317
|
+
[currentComp.id]: state.currentLanguage === "en" ? "please complete this step before move on" : " 'Veuillez compléter cette étape avant de continuer'"
|
|
110
318
|
}
|
|
111
319
|
}));
|
|
112
320
|
return;
|
|
113
321
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
322
|
+
try {
|
|
323
|
+
const component = state.template.components.find(c => c.id === currentComp.id);
|
|
324
|
+
if (!component)
|
|
325
|
+
return;
|
|
326
|
+
if (component.type === 'review_submit') {
|
|
327
|
+
// Move to verification screen and mark verification in progress
|
|
328
|
+
setState(prev => ({
|
|
329
|
+
...prev,
|
|
330
|
+
currentComponentIndex: prev.currentComponentIndex + 1,
|
|
331
|
+
completedComponents: [...prev.completedComponents, currentComp.id],
|
|
332
|
+
isProcessing: false,
|
|
333
|
+
verification: { status: 'in_progress' },
|
|
334
|
+
errors: {
|
|
335
|
+
...prev.errors,
|
|
336
|
+
[currentComp.id]: ''
|
|
337
|
+
}
|
|
338
|
+
}));
|
|
339
|
+
return;
|
|
122
340
|
}
|
|
123
|
-
|
|
124
|
-
|
|
341
|
+
// Determine backend action and step index
|
|
342
|
+
const action = mapComponentTypeToAction(component.type);
|
|
343
|
+
const templateId = chooseTemplateId(state.template);
|
|
344
|
+
const serverStep = computeServerStepIndex(state.template, state.currentComponentIndex);
|
|
345
|
+
// Optionally send initialize_session at step 0 before first actionable action
|
|
346
|
+
if (serverStep === 0) {
|
|
347
|
+
try {
|
|
348
|
+
// await kycService.verificationSession({
|
|
349
|
+
// sessionId: state.session.session_id,
|
|
350
|
+
// step: 0,
|
|
351
|
+
// data: { template_id: templateId, metadata: { language: state.currentLanguage } },
|
|
352
|
+
// templateId: templateId,
|
|
353
|
+
// token: state.session.token,
|
|
354
|
+
// action: 'initialize_session'
|
|
355
|
+
// });
|
|
356
|
+
}
|
|
357
|
+
catch (e) {
|
|
358
|
+
// if init fails, surface error below in the main call handling
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
// Skip UI-only and data-only steps that have no backend action
|
|
362
|
+
if (!action) {
|
|
363
|
+
setState(prev => ({
|
|
364
|
+
...prev,
|
|
365
|
+
currentComponentIndex: prev.currentComponentIndex + 1,
|
|
366
|
+
completedComponents: [...prev.completedComponents, currentComp.id],
|
|
367
|
+
isProcessing: false,
|
|
368
|
+
errors: {
|
|
369
|
+
...prev.errors,
|
|
370
|
+
[currentComp.id]: ''
|
|
371
|
+
}
|
|
372
|
+
}));
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
const step = serverStep === 0 && action !== 'initialize_session' ? 1 : serverStep;
|
|
376
|
+
// Build payload data per action
|
|
377
|
+
const payloadData = buildPayloadForComponent(action, component, state.componentData[currentComp.id], templateId, step);
|
|
378
|
+
await kycService.verificationSession({
|
|
379
|
+
session_id: state.session.session_id,
|
|
380
|
+
step: step,
|
|
381
|
+
data: payloadData,
|
|
382
|
+
templateId: null,
|
|
383
|
+
token: state.session.token,
|
|
384
|
+
action: action
|
|
385
|
+
});
|
|
386
|
+
console.log("currentComp state", truncateFields(state));
|
|
387
|
+
// Marquer comme complété et passer au suivant
|
|
388
|
+
setState(prev => ({
|
|
389
|
+
...prev,
|
|
390
|
+
currentComponentIndex: prev.currentComponentIndex + 1,
|
|
391
|
+
completedComponents: [...prev.completedComponents, currentComp.id],
|
|
392
|
+
isProcessing: false,
|
|
393
|
+
...(action === "location_permission" ? { permissionGranted: true } : {}),
|
|
394
|
+
errors: {
|
|
395
|
+
...prev.errors,
|
|
396
|
+
[currentComp.id]: ''
|
|
397
|
+
}
|
|
398
|
+
}));
|
|
399
|
+
}
|
|
400
|
+
catch (error) {
|
|
401
|
+
// console.error('Error validating component:', error);
|
|
402
|
+
setState(prev => ({
|
|
403
|
+
...prev,
|
|
404
|
+
isProcessing: false,
|
|
405
|
+
errors: {
|
|
406
|
+
...prev.errors,
|
|
407
|
+
[currentComp.id]: 'Erreur lors de la validation du composant'
|
|
408
|
+
}
|
|
409
|
+
}));
|
|
410
|
+
}
|
|
411
|
+
}, [canGoNext, state.currentComponentIndex, state.template.components, validateComponent]),
|
|
125
412
|
// Retourner au composant précédent
|
|
126
413
|
previousComponent: useCallback(() => {
|
|
127
414
|
if (!canGoPrevious)
|
|
@@ -133,16 +420,17 @@ export const useTemplateKYCFlow = (template, onComplete, onError, initialLanguag
|
|
|
133
420
|
}, [canGoPrevious]),
|
|
134
421
|
// Aller à un composant spécifique
|
|
135
422
|
goToComponent: useCallback((componentId) => {
|
|
136
|
-
const componentIndex = template.components.findIndex(c => c.id === componentId);
|
|
423
|
+
const componentIndex = state.template.components.findIndex(c => c.id === componentId);
|
|
137
424
|
if (componentIndex !== -1) {
|
|
138
425
|
setState(prev => ({
|
|
139
426
|
...prev,
|
|
140
427
|
currentComponentIndex: componentIndex,
|
|
141
428
|
}));
|
|
142
429
|
}
|
|
143
|
-
}, [template.components]),
|
|
430
|
+
}, [state.template.components]),
|
|
144
431
|
// Mettre à jour les données d'un composant
|
|
145
432
|
updateComponentData: useCallback((componentId, data) => {
|
|
433
|
+
console.log("updateComponentData", componentId, truncateFields(data));
|
|
146
434
|
setState(prev => ({
|
|
147
435
|
...prev,
|
|
148
436
|
componentData: {
|
|
@@ -161,17 +449,20 @@ export const useTemplateKYCFlow = (template, onComplete, onError, initialLanguag
|
|
|
161
449
|
}, [validateComponent]),
|
|
162
450
|
// Soumettre le template complet
|
|
163
451
|
submitTemplate: useCallback(async () => {
|
|
164
|
-
|
|
452
|
+
// Allow submission when on the review step and all previous steps are valid
|
|
453
|
+
const atReview = state.template.components[state.currentComponentIndex]?.type === 'review_submit';
|
|
454
|
+
const allValid = state.template.components
|
|
455
|
+
.filter(c => c.type !== 'review_submit')
|
|
456
|
+
.every(comp => validateComponent(comp.id));
|
|
457
|
+
if (!(atReview && allValid)) {
|
|
165
458
|
onError?.('Le flux KYC n\'est pas encore terminé');
|
|
166
459
|
return;
|
|
167
460
|
}
|
|
168
461
|
setState(prev => ({ ...prev, isProcessing: true }));
|
|
169
462
|
try {
|
|
170
|
-
// Vérifier que tous les composants sont validés
|
|
171
|
-
|
|
172
|
-
if (!allValid) {
|
|
463
|
+
// Vérifier que tous les composants (hors review) sont validés
|
|
464
|
+
if (!allValid)
|
|
173
465
|
throw new Error('Certaines étapes ne sont pas complètes');
|
|
174
|
-
}
|
|
175
466
|
// Appeler le callback de completion
|
|
176
467
|
onComplete?.(state.componentData);
|
|
177
468
|
setState(prev => ({ ...prev, isProcessing: false }));
|
|
@@ -180,7 +471,7 @@ export const useTemplateKYCFlow = (template, onComplete, onError, initialLanguag
|
|
|
180
471
|
setState(prev => ({ ...prev, isProcessing: false }));
|
|
181
472
|
onError?.(error instanceof Error ? error.message : 'Erreur lors de la soumission');
|
|
182
473
|
}
|
|
183
|
-
}, [
|
|
474
|
+
}, [state.template.components, state.currentComponentIndex, validateComponent, state.componentData, onComplete, onError]),
|
|
184
475
|
// Réinitialiser le template
|
|
185
476
|
resetTemplate: useCallback(() => {
|
|
186
477
|
setState(prev => ({
|
|
@@ -190,6 +481,7 @@ export const useTemplateKYCFlow = (template, onComplete, onError, initialLanguag
|
|
|
190
481
|
componentData: {},
|
|
191
482
|
errors: {},
|
|
192
483
|
isProcessing: false,
|
|
484
|
+
verification: { status: 'idle', result: undefined },
|
|
193
485
|
}));
|
|
194
486
|
}, []),
|
|
195
487
|
// Changer la langue
|
|
@@ -206,6 +498,12 @@ export const useTemplateKYCFlow = (template, onComplete, onError, initialLanguag
|
|
|
206
498
|
showCustomStepper: show,
|
|
207
499
|
}));
|
|
208
500
|
}, []),
|
|
501
|
+
setVerificationState: useCallback((verificationState) => {
|
|
502
|
+
setState(prev => ({
|
|
503
|
+
...prev,
|
|
504
|
+
verification: verificationState,
|
|
505
|
+
}));
|
|
506
|
+
}, []),
|
|
209
507
|
};
|
|
210
508
|
return {
|
|
211
509
|
state,
|
|
@@ -216,6 +514,7 @@ export const useTemplateKYCFlow = (template, onComplete, onError, initialLanguag
|
|
|
216
514
|
canGoPrevious,
|
|
217
515
|
isComplete,
|
|
218
516
|
getLocalizedText,
|
|
517
|
+
initializeSession,
|
|
219
518
|
};
|
|
220
519
|
};
|
|
221
520
|
//# sourceMappingURL=useTemplateKYCFlow.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTemplateKYCFlow.js","sourceRoot":"","sources":["../../src/hooks/useTemplateKYCFlow.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAa,MAAM,OAAO,CAAC;AAepG,MAAM,sBAAsB,GAAG,aAAa,CAAyC,SAAS,CAAC,CAAC;AAWhG,MAAM,CAAC,MAAM,uBAAuB,GAA2C,CAAC,EAC9E,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,OAAO,EACP,eAAe,GAAG,IAAI,GACvB,EAAE,EAAE;IACH,MAAM,UAAU,GAAG,kBAAkB,CAAC,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,eAAe,CAAC,CAAC;IAEtF,OAAO,CACL,CAAC,sBAAsB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC,CACjD;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,sBAAsB,CAAC,QAAQ,CAAC,CACnC,CAAC;AACJ,CAAC,CAAC;AAEF,gCAAgC;AAChC,MAAM,CAAC,MAAM,yBAAyB,GAAG,GAA+B,EAAE;IACxE,MAAM,OAAO,GAAG,UAAU,CAAC,sBAAsB,CAAC,CAAC;IACnD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,yEAAyE,CAAC,CAAC;IAC7F,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,QAAqB,EACrB,U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QAAQ;aAC1B,CAAC,CAAC,CAAC;QACN,CAAC,EAAE,EAAE,CAAC;QAEN,mCAAmC;QACnC,iBAAiB,EAAE,WAAW,CAAC,CAAC,IAAa,EAAE,EAAE;YAC/C,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBAChB,GAAG,IAAI;gBACP,iBAAiB,EAAE,IAAI;aACxB,CAAC,CAAC,CAAC;QACN,CAAC,EAAE,EAAE,CAAC;KACP,CAAC;IAEF,OAAO;QACL,KAAK;QACL,OAAO;QACP,gBAAgB;QAChB,QAAQ;QACR,SAAS;QACT,aAAa;QACb,UAAU;QACV,gBAAgB;KACjB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React, { useState, useCallback, useMemo, createContext, useContext, ReactNode } from 'react';\nimport { KYCTemplate, TemplateState, TemplateActions, UseTemplateReturn } from '../types/KYC.types';\n\n// Context pour le provider\ninterface TemplateKYCFlowContextType {\n state: TemplateState;\n actions: TemplateActions;\n currentComponent: any;\n progress: number;\n canGoNext: boolean;\n canGoPrevious: boolean;\n isComplete: boolean;\n getLocalizedText: (text: { en: string; fr: string; [key: string]: string }) => string;\n}\n\nconst TemplateKYCFlowContext = createContext<TemplateKYCFlowContextType | undefined>(undefined);\n\n// Provider component\ninterface TemplateKYCFlowProviderProps {\n children: ReactNode;\n template: KYCTemplate;\n onComplete?: (data: Record<number, any>) => void;\n onError?: (error: string) => void;\n initialLanguage?: string;\n}\n\nexport const TemplateKYCFlowProvider: React.FC<TemplateKYCFlowProviderProps> = ({\n children,\n template,\n onComplete,\n onError,\n initialLanguage = 'en',\n}) => {\n const hookResult = useTemplateKYCFlow(template, onComplete, onError, initialLanguage);\n \n return (\n <TemplateKYCFlowContext.Provider value={hookResult}>\n {children}\n </TemplateKYCFlowContext.Provider>\n );\n};\n\n// Hook pour utiliser le context\nexport const useTemplateKYCFlowContext = (): TemplateKYCFlowContextType => {\n const context = useContext(TemplateKYCFlowContext);\n if (!context) {\n throw new Error('useTemplateKYCFlowContext must be used within a TemplateKYCFlowProvider');\n }\n return context;\n};\n\nexport const useTemplateKYCFlow = (\n template: KYCTemplate,\n onComplete?: (data: Record<number, any>) => void,\n onError?: (error: string) => void,\n initialLanguage: string = 'en'\n): UseTemplateReturn => {\n // État du flux\n const [state, setState] = useState<TemplateState>({\n template,\n currentComponentIndex: 0,\n completedComponents: [],\n componentData: {},\n errors: {},\n isProcessing: false,\n currentLanguage: initialLanguage,\n showCustomStepper: true,\n });\n\n // Composant actuel\n const currentComponent = useMemo(() => {\n return template.components[state.currentComponentIndex] || null;\n }, [template.components, state.currentComponentIndex]);\n\n // Progression du flux\n const progress = useMemo(() => {\n return template.components.length > 0 \n ? ((state.currentComponentIndex + 1) / template.components.length) * 100 \n : 0;\n }, [state.currentComponentIndex, template.components.length]);\n\n // Vérifications de navigation\n const canGoNext = useMemo(() => {\n return state.currentComponentIndex < template.components.length - 1;\n }, [state.currentComponentIndex, template.components.length]);\n\n const canGoPrevious = useMemo(() => {\n return state.currentComponentIndex > 0;\n }, [state.currentComponentIndex]);\n\n const isComplete = useMemo(() => {\n return state.currentComponentIndex === template.components.length - 1 && \n state.completedComponents.length === template.components.length;\n }, [state.currentComponentIndex, state.completedComponents.length, template.components.length]);\n\n // Fonction pour obtenir le texte localisé\n const getLocalizedText = useCallback((text: { en: string; fr: string; [key: string]: string }): string => {\n return text[state.currentLanguage] || text.en || '';\n }, [state.currentLanguage]);\n\n // Validation d'un composant\n const validateComponent = useCallback((componentId: number): boolean => {\n const component = template.components.find(c => c.id === componentId);\n if (!component) return false;\n\n const componentData = state.componentData[componentId];\n \n switch (component.type) {\n case 'id_card':\n // Vérifier si au moins un côté a été capturé\n return componentData && Object.keys(componentData).length > 0;\n \n case 'selfie':\n // Vérifier si toutes les orientations ont été capturées\n const config = component.config as any;\n const orientations = config.orientations || ['front'];\n return componentData && orientations.every((orientation: string) => componentData[orientation]);\n \n case 'file_upload':\n // Vérifier si un fichier a été uploadé\n return componentData && componentData.file;\n \n case 'location':\n // Vérifier si la localisation a été obtenue\n return componentData && componentData.latitude && componentData.longitude;\n \n case 'country_selection':\n // Vérifier si un pays a été sélectionné\n return componentData && componentData.country;\n \n default:\n return false;\n }\n }, [template.components, state.componentData]);\n\n // Actions du flux\n const actions: TemplateActions = {\n // Initialiser le template\n initializeTemplate: useCallback((newTemplate: KYCTemplate) => {\n setState(prev => ({\n ...prev,\n template: newTemplate,\n currentComponentIndex: 0,\n completedComponents: [],\n componentData: {},\n errors: {},\n isProcessing: false,\n }));\n }, []),\n\n // Passer au composant suivant\n nextComponent: useCallback(() => {\n if (!canGoNext) return;\n\n const currentComp = template.components[state.currentComponentIndex];\n if (!currentComp) return;\n\n // Valider le composant actuel\n if (!validateComponent(currentComp.id)) {\n setState(prev => ({\n ...prev,\n errors: {\n ...prev.errors,\n [currentComp.id]: 'Veuillez compléter cette étape avant de continuer'\n }\n }));\n return;\n }\n\n // Marquer comme complété et passer au suivant\n setState(prev => ({\n ...prev,\n currentComponentIndex: prev.currentComponentIndex + 1,\n completedComponents: [...prev.completedComponents, currentComp.id],\n errors: {\n ...prev.errors,\n [currentComp.id]: ''\n }\n }));\n\n\n }, [canGoNext, state.currentComponentIndex, template.components, validateComponent]),\n\n // Retourner au composant précédent\n previousComponent: useCallback(() => {\n if (!canGoPrevious) return;\n\n setState(prev => ({\n ...prev,\n currentComponentIndex: prev.currentComponentIndex - 1,\n }));\n }, [canGoPrevious]),\n\n // Aller à un composant spécifique\n goToComponent: useCallback((componentId: number) => {\n const componentIndex = template.components.findIndex(c => c.id === componentId);\n if (componentIndex !== -1) {\n setState(prev => ({\n ...prev,\n currentComponentIndex: componentIndex,\n }));\n }\n }, [template.components]),\n\n // Mettre à jour les données d'un composant\n updateComponentData: useCallback((componentId: number, data: any) => {\n setState(prev => ({\n ...prev,\n componentData: {\n ...prev.componentData,\n [componentId]: data\n },\n errors: {\n ...prev.errors,\n [componentId]: ''\n }\n }));\n \n }, []),\n\n // Valider un composant\n validateComponent: useCallback((componentId: number) => {\n return validateComponent(componentId);\n }, [validateComponent]),\n\n // Soumettre le template complet\n submitTemplate: useCallback(async () => {\n if (!isComplete) {\n onError?.('Le flux KYC n\\'est pas encore terminé');\n return;\n }\n\n setState(prev => ({ ...prev, isProcessing: true }));\n\n try {\n // Vérifier que tous les composants sont validés\n const allValid = template.components.every(comp => validateComponent(comp.id));\n \n if (!allValid) {\n throw new Error('Certaines étapes ne sont pas complètes');\n }\n\n // Appeler le callback de completion\n onComplete?.(state.componentData);\n \n setState(prev => ({ ...prev, isProcessing: false }));\n } catch (error) {\n setState(prev => ({ ...prev, isProcessing: false }));\n onError?.(error instanceof Error ? error.message : 'Erreur lors de la soumission');\n }\n }, [isComplete, template.components, validateComponent, state.componentData, onComplete, onError]),\n\n // Réinitialiser le template\n resetTemplate: useCallback(() => {\n setState(prev => ({\n ...prev,\n currentComponentIndex: 0,\n completedComponents: [],\n componentData: {},\n errors: {},\n isProcessing: false,\n }));\n }, []),\n\n // Changer la langue\n setLanguage: useCallback((language: string) => {\n setState(prev => ({\n ...prev,\n currentLanguage: language,\n }));\n }, []),\n\n // Afficher le stepper personnalisé\n showCustomStepper: useCallback((show: boolean) => {\n setState(prev => ({\n ...prev,\n showCustomStepper: show,\n }));\n }, []),\n };\n\n return {\n state,\n actions,\n currentComponent,\n progress,\n canGoNext,\n canGoPrevious,\n isComplete,\n getLocalizedText,\n };\n}; "]}
|
|
1
|
+
{"version":3,"file":"useTemplateKYCFlow.js","sourceRoot":"","sources":["../../src/hooks/useTemplateKYCFlow.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAa,SAAS,EAAE,MAAM,OAAO,CAAC;AAE/G,OAAO,UAAU,EAAE,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AACzF,OAAO,OAAO,MAAM,WAAW,CAAC;AAehC,MAAM,sBAAsB,GAAG,a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AO;QACL,KAAK;QACL,OAAO;QACP,gBAAgB;QAChB,QAAQ;QACR,SAAS;QACT,aAAa;QACb,UAAU;QACV,gBAAgB;QAChB,iBAAiB;KAClB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React, { useState, useCallback, useMemo, createContext, useContext, ReactNode, useEffect } from 'react';\nimport { KYCTemplate, TemplateState, TemplateActions, UseTemplateReturn, TemplateComponent } from '../types/KYC.types';\nimport kycService, { authentification, truncateFields } from '../modules/api/KYCService';\nimport useI18n from './useI18n';\n\n// Context pour le provider\ninterface TemplateKYCFlowContextType {\n state: TemplateState;\n actions: TemplateActions;\n currentComponent: any;\n progress: number;\n canGoNext: boolean;\n canGoPrevious: boolean;\n isComplete: boolean;\n getLocalizedText: (text: { en: string; fr: string;[key: string]: string }) => string;\n initializeSession: () => Promise<void>;\n}\n\nconst TemplateKYCFlowContext = createContext<TemplateKYCFlowContextType | undefined>(undefined);\n\n// Provider component\ninterface TemplateKYCFlowProviderProps {\n children: ReactNode;\n template: KYCTemplate;\n onComplete?: (data: Record<number, any>) => void;\n onError?: (error: string) => void;\n initialLanguage?: string;\n}\n\nexport const TemplateKYCFlowProvider: React.FC<TemplateKYCFlowProviderProps> = ({\n children,\n template,\n onComplete,\n onError,\n initialLanguage = 'en',\n}) => {\n const hookResult = useTemplateKYCFlow(template, onComplete, onError, initialLanguage);\n\n return (\n <TemplateKYCFlowContext.Provider value={hookResult}>\n {children}\n </TemplateKYCFlowContext.Provider>\n );\n};\n\n// Hook pour utiliser le context\nexport const useTemplateKYCFlowContext = (): TemplateKYCFlowContextType => {\n const context = useContext(TemplateKYCFlowContext);\n if (!context) {\n throw new Error('useTemplateKYCFlowContext must be used within a TemplateKYCFlowProvider');\n }\n return context;\n};\n\nexport const useTemplateKYCFlow = (\n template: KYCTemplate,\n onComplete?: (data: Record<number, any>) => void,\n onError?: (error: string) => void,\n initialLanguage: string = 'en',\n): UseTemplateReturn => {\n\n const { setLocale } = useI18n();\n\n useEffect(() => {\n setLocale(initialLanguage);\n }, [initialLanguage]);\n\n // Helpers to align SDK steps with backend actions/templates\n const isUiOnlyStep = useCallback((type: TemplateComponent['type']) => {\n return type === 'verification_progress';\n }, []);\n\n const mapComponentTypeToAction = useCallback((type: TemplateComponent['type']): string | null => {\n switch (type) {\n case 'id_card':\n case 'file_upload':\n return 'document_upload';\n case 'selfie':\n return 'selfie_capture';\n case 'location':\n return 'location_permission';\n case 'review_submit':\n return 'final_submit';\n case 'country_selection':\n // No direct backend action; pack into metadata of next actionable step\n return null;\n case 'initialization':\n return 'initialize_session';\n case 'verification_progress':\n return null; // UI-only\n default:\n return null;\n }\n }, []);\n\n const chooseTemplateId = useCallback((tpl: KYCTemplate): string => {\n const types = tpl.components.map(c => c.type);\n const hasLocation = types.includes('location');\n const hasSelfie = types.includes('selfie');\n const hasIdDoc = types.includes('id_card') || types.includes('file_upload');\n // Simple heuristic to map to backend examples\n if (hasLocation && hasSelfie && hasIdDoc) return 'enhanced_id';\n if (hasSelfie && hasIdDoc) return 'standard_passport';\n return 'standard_passport';\n }, []);\n\n\n const computeServerStepIndex = useCallback((tpl: KYCTemplate, upToIndex: number): number => {\n // Count actionable steps before the current component (exclude UI-only and country_selection)\n const actionable = tpl.components\n .slice(0, upToIndex)\n .filter(c => !isUiOnlyStep(c.type) && mapComponentTypeToAction(c.type) !== null);\n return actionable.length; // 0-based\n }, [isUiOnlyStep, mapComponentTypeToAction]);\n\n // Build backend-friendly payloads per action\n const buildPayloadForComponent = useCallback((action: string | null, component: TemplateComponent, rawData: any, templateId: string, step: number) => {\n const base = { template_id: null, step: component.order, permissionGranted: true } as any;\n if (!action) {\n return base;\n }\n // Document upload expects an array of documents with base64 and metadata\n if (action === 'document_upload') {\n const documents: Record<string, any> = {};\n if (rawData && typeof rawData === 'object') {\n Object.keys(rawData).forEach((key) => {\n documents[key] = rawData[key];\n });\n }\n return {\n ...base,\n documents,\n };\n }\n\n if (action === 'selfie_capture') {\n const metatada: Record<string, any> = {};\n if (rawData && typeof rawData === 'object') {\n\n Object.keys(rawData).forEach((key) => {\n metatada[key] = rawData[key];\n });\n }\n return { ...base, metatada };\n }\n\n if (action === 'location_permission') {\n return { ...base, ...({ metadata: rawData || {} }), ...({ permissionGranted: true, }) };\n }\n\n // Default: wrap as metadata\n return { ...base, metadata: { ...(rawData || {}) } };\n }, []);\n // Ensure the template contains a final review step\n const ensureReviewSubmitStep = useCallback((tpl: KYCTemplate): KYCTemplate => {\n const hasReview = tpl.components.some(c => c.type === 'review_submit');\n if (hasReview) return tpl;\n\n const lastOrder = tpl.components.reduce((acc, c) => Math.max(acc, c.order ?? 0), 0);\n const lastId = tpl.components.reduce((acc, c) => Math.max(acc, c.id), 0);\n\n const reviewComponent: TemplateComponent = {\n id: lastId + 1,\n type: 'review_submit',\n order: lastOrder + 1,\n labels: { en: 'Review & Submit', fr: 'Revoir & Soumettre' },\n instructions: { en: 'Confirm and submit', fr: 'Confirmer et soumettre' },\n ui: { buttonText: { en: 'Complete Verification', fr: 'Terminer la vérification' } },\n // @ts-ignore - config unused for review component\n config: {},\n } as TemplateComponent;\n\n return {\n ...tpl,\n components: [...tpl.components, reviewComponent],\n };\n }, []);\n\n const ensureVerificationProgressStep = useCallback((tpl: KYCTemplate): KYCTemplate => {\n const hasVerification = tpl.components.some(c => c.type === 'verification_progress');\n if (hasVerification) return tpl;\n\n const lastOrder = tpl.components.reduce((acc, c) => Math.max(acc, c.order ?? 0), 0);\n const lastId = tpl.components.reduce((acc, c) => Math.max(acc, c.id), 0);\n\n const verificationComponent: TemplateComponent = {\n id: lastId + 2,\n type: 'verification_progress',\n order: lastOrder + 2,\n labels: { en: 'Verification', fr: 'Vérification' },\n instructions: { en: 'We\\'re reviewing your documents', fr: 'Nous analysons vos documents' },\n ui: { buttonText: { en: '', fr: '' } },\n // @ts-ignore - config unused for progress component\n config: {},\n } as TemplateComponent;\n\n return {\n ...tpl,\n components: [...tpl.components, verificationComponent],\n };\n }, []);\n\n const templateWithReview = useMemo(() => ensureReviewSubmitStep(template), [template, ensureReviewSubmitStep]);\n const templateWithReviewAndVerification = useMemo(() => ensureVerificationProgressStep(templateWithReview), [templateWithReview, ensureVerificationProgressStep]);\n // État du flux\n const [state, setState] = useState<TemplateState>({\n template: templateWithReviewAndVerification,\n currentComponentIndex: 0,\n completedComponents: [],\n componentData: {},\n errors: {},\n isProcessing: false,\n currentLanguage: initialLanguage,\n showCustomStepper: true,\n session: {\n session_id: '',\n token: '',\n isInitialized: false,\n isProcessing: false,\n error: null,\n },\n verification: {\n status: 'idle',\n },\n });\n\n // Composant actuel\n const currentComponent = useMemo(() => {\n return state.template.components[state.currentComponentIndex] || null;\n }, [state.template.components, state.currentComponentIndex]);\n\n // Progression du flux\n const progress = useMemo(() => {\n return state.template.components.length > 0\n ? ((state.currentComponentIndex + 1) / state.template.components.length) * 100\n : 0;\n }, [state.currentComponentIndex, state.template.components.length]);\n\n // Vérifications de navigation\n const canGoNext = useMemo(() => {\n return state.currentComponentIndex < state.template.components.length - 1;\n }, [state.currentComponentIndex, state.template.components.length]);\n\n const canGoPrevious = useMemo(() => {\n return state.currentComponentIndex > 0;\n }, [state.currentComponentIndex]);\n\n const isComplete = useMemo(() => {\n const atReview = state.template.components[state.currentComponentIndex]?.type === 'review_submit';\n const nonReviewCount = state.template.components.filter(c => c.type !== 'review_submit').length;\n const completedNonReview = state.completedComponents.length >= nonReviewCount;\n return atReview && completedNonReview;\n }, [state.currentComponentIndex, state.completedComponents.length, state.template.components]);\n\n // Fonction pour obtenir le texte localisé\n const getLocalizedText = useCallback((text: { en: string; fr: string;[key: string]: string }): string => {\n return text[state.currentLanguage] || text.en || '';\n }, [state.currentLanguage]);\n\n const initializeSession = useCallback(async () => {\n try {\n setState(prev => ({\n ...prev,\n session: {\n ...prev.session,\n isInitialized: false,\n isProcessing: true,\n error: null,\n },\n }));\n console.log('Initializing session');\n\n const token = await authentification();\n\n const session = await kycService.newSession(token);\n\n // Align backend flow from step 0 with initialize_session\n try {\n const templateId = chooseTemplateId(templateWithReviewAndVerification);\n await kycService.verificationSession({\n session_id: session.session_id,\n step: 0,\n data: { template_id: templateId, metadata: { language: initialLanguage } },\n templateId: templateId,\n token: token,\n action: 'initialize_session'\n });\n } catch (e) {\n console.error('Error initializing session:', JSON.stringify(e, null, 2));\n // Non-fatal: we will surface errors via state below if needed\n }\n\n setState(prev => ({\n ...prev,\n session: {\n ...prev.session,\n session_id: session.session_id,\n token: token,\n isInitialized: true,\n isProcessing: false,\n error: null,\n }\n }));\n } catch (error) {\n\n console.error('Error initializing session:', JSON.stringify(error, null, 2));\n setState(prev => ({\n ...prev,\n session: {\n ...prev.session,\n isInitialized: false,\n isProcessing: false,\n error: \"Erreur lors de l'initialisation de la session\",\n },\n }));\n }\n }, []);\n // Validation d'un composant\n const validateComponent = useCallback((componentId: number): boolean => {\n const component = state.template.components.find(c => c.id === componentId);\n if (!component) return false;\n\n const componentData = state.componentData[componentId];\n\n switch (component.type) {\n case 'id_card':\n // Vérifier si au moins un côté a été capturé\n return componentData && Object.keys(componentData).length > 0;\n\n case 'selfie':\n // Vérifier si toutes les orientations ont été capturées\n const config = component.config as any;\n const orientations = config.orientations || ['front'];\n return componentData && orientations.every((orientation: string) => componentData[orientation]);\n\n case 'file_upload':\n // Vérifier si un fichier a été uploadé\n return componentData && componentData.file;\n\n case 'location':\n // Vérifier si la localisation a été obtenue\n return componentData && componentData.latitude && componentData.longitude;\n\n case 'country_selection':\n // Vérifier si un pays a été sélectionné\n console.log(\"componentData\", truncateFields(componentData), componentId);\n\n return componentData && componentData.code && componentData.regionMapping;\n\n case 'review_submit':\n return true;\n default:\n return false;\n }\n }, [state.template.components, state.componentData]);\n\n // Actions du flux\n const actions: TemplateActions = {\n // Initialiser le template\n initializeTemplate: useCallback((newTemplate: KYCTemplate) => {\n const withReview = ensureReviewSubmitStep(newTemplate);\n const withVerification = ensureVerificationProgressStep(withReview);\n setState(prev => ({\n ...prev,\n template: withVerification,\n currentComponentIndex: 0,\n completedComponents: [],\n componentData: {},\n errors: {},\n isProcessing: false,\n verification: { status: 'idle', result: undefined },\n }));\n }, [ensureReviewSubmitStep, ensureVerificationProgressStep]),\n\n // Passer au composant suivant\n nextComponent: useCallback(async () => {\n if (!canGoNext) return;\n\n const currentComp = state.template.components[state.currentComponentIndex];\n if (!currentComp) return;\n\n setState(prev => ({\n ...prev,\n isProcessing: true,\n }));\n // Valider le composant actuel\n if (!validateComponent(currentComp.id)) {\n setState(prev => ({\n ...prev,\n isProcessing: false,\n errors: {\n ...prev.errors,\n [currentComp.id]: state.currentLanguage === \"en\" ? \"please complete this step before move on\" : \" 'Veuillez compléter cette étape avant de continuer'\"\n }\n }));\n return;\n\n }\n\n try {\n const component = state.template.components.find(c => c.id === currentComp.id);\n if (!component) return;\n if (component.type === 'review_submit') {\n // Move to verification screen and mark verification in progress\n setState(prev => ({\n ...prev,\n currentComponentIndex: prev.currentComponentIndex + 1,\n completedComponents: [...prev.completedComponents, currentComp.id],\n isProcessing: false,\n verification: { status: 'in_progress' },\n errors: {\n ...prev.errors,\n [currentComp.id]: ''\n }\n }));\n return;\n }\n // Determine backend action and step index\n const action = mapComponentTypeToAction(component.type);\n const templateId = chooseTemplateId(state.template);\n const serverStep = computeServerStepIndex(state.template, state.currentComponentIndex);\n\n // Optionally send initialize_session at step 0 before first actionable action\n if (serverStep === 0) {\n try {\n // await kycService.verificationSession({\n // sessionId: state.session.session_id,\n // step: 0,\n // data: { template_id: templateId, metadata: { language: state.currentLanguage } },\n // templateId: templateId,\n // token: state.session.token,\n // action: 'initialize_session'\n // });\n } catch (e) {\n // if init fails, surface error below in the main call handling\n }\n }\n\n // Skip UI-only and data-only steps that have no backend action\n if (!action) {\n setState(prev => ({\n ...prev,\n currentComponentIndex: prev.currentComponentIndex + 1,\n completedComponents: [...prev.completedComponents, currentComp.id],\n isProcessing: false,\n errors: {\n ...prev.errors,\n [currentComp.id]: ''\n }\n }));\n return;\n }\n\n const step = serverStep === 0 && action !== 'initialize_session' ? 1 : serverStep;\n // Build payload data per action\n const payloadData = buildPayloadForComponent(action, component, state.componentData[currentComp.id], templateId, step);\n\n await kycService.verificationSession({\n session_id: state.session.session_id,\n step: step,\n data: payloadData,\n templateId: null,\n token: state.session.token,\n action: action\n });\n console.log(\"currentComp state\", truncateFields(state));\n // Marquer comme complété et passer au suivant\n setState(prev => ({\n ...prev,\n currentComponentIndex: prev.currentComponentIndex + 1,\n completedComponents: [...prev.completedComponents, currentComp.id],\n isProcessing: false,\n ...(action === \"location_permission\" ? { permissionGranted: true } : {}),\n errors: {\n ...prev.errors,\n [currentComp.id]: ''\n }\n }));\n\n } catch (error) {\n // console.error('Error validating component:', error);\n setState(prev => ({\n ...prev,\n isProcessing: false,\n errors: {\n ...prev.errors,\n [currentComp.id]: 'Erreur lors de la validation du composant'\n }\n }));\n }\n\n }, [canGoNext, state.currentComponentIndex, state.template.components, validateComponent]),\n\n // Retourner au composant précédent\n previousComponent: useCallback(() => {\n if (!canGoPrevious) return;\n\n setState(prev => ({\n ...prev,\n currentComponentIndex: prev.currentComponentIndex - 1,\n }));\n }, [canGoPrevious]),\n\n // Aller à un composant spécifique\n goToComponent: useCallback((componentId: number) => {\n const componentIndex = state.template.components.findIndex(c => c.id === componentId);\n if (componentIndex !== -1) {\n setState(prev => ({\n ...prev,\n currentComponentIndex: componentIndex,\n }));\n }\n }, [state.template.components]),\n\n // Mettre à jour les données d'un composant\n updateComponentData: useCallback((componentId: number, data: any) => {\n console.log(\"updateComponentData\", componentId, truncateFields(data));\n\n setState(prev => ({\n ...prev,\n componentData: {\n ...prev.componentData,\n [componentId]: data\n },\n errors: {\n ...prev.errors,\n [componentId]: ''\n }\n }));\n\n }, []),\n\n // Valider un composant\n validateComponent: useCallback((componentId: number) => {\n return validateComponent(componentId);\n }, [validateComponent]),\n\n // Soumettre le template complet\n submitTemplate: useCallback(async () => {\n // Allow submission when on the review step and all previous steps are valid\n const atReview = state.template.components[state.currentComponentIndex]?.type === 'review_submit';\n const allValid = state.template.components\n .filter(c => c.type !== 'review_submit')\n .every(comp => validateComponent(comp.id));\n if (!(atReview && allValid)) {\n onError?.('Le flux KYC n\\'est pas encore terminé');\n return;\n }\n\n setState(prev => ({ ...prev, isProcessing: true }));\n\n try {\n // Vérifier que tous les composants (hors review) sont validés\n if (!allValid) throw new Error('Certaines étapes ne sont pas complètes');\n\n // Appeler le callback de completion\n onComplete?.(state.componentData);\n\n setState(prev => ({ ...prev, isProcessing: false }));\n } catch (error) {\n setState(prev => ({ ...prev, isProcessing: false }));\n onError?.(error instanceof Error ? error.message : 'Erreur lors de la soumission');\n }\n }, [state.template.components, state.currentComponentIndex, validateComponent, state.componentData, onComplete, onError]),\n\n // Réinitialiser le template\n resetTemplate: useCallback(() => {\n setState(prev => ({\n ...prev,\n currentComponentIndex: 0,\n completedComponents: [],\n componentData: {},\n errors: {},\n isProcessing: false,\n verification: { status: 'idle', result: undefined },\n }));\n }, []),\n\n // Changer la langue\n setLanguage: useCallback((language: string) => {\n setState(prev => ({\n ...prev,\n currentLanguage: language,\n }));\n }, []),\n\n // Afficher le stepper personnalisé\n showCustomStepper: useCallback((show: boolean) => {\n setState(prev => ({\n ...prev,\n showCustomStepper: show,\n }));\n }, []),\n\n setVerificationState: useCallback((verificationState) => {\n setState(prev => ({\n ...prev,\n verification: verificationState,\n }));\n }, []),\n };\n\n return {\n state,\n actions,\n currentComponent,\n progress,\n canGoNext,\n canGoPrevious,\n isComplete,\n getLocalizedText,\n initializeSession,\n };\n}; "]}
|