@velion-la/onboarding-sdk-react-native 1.0.0-beta.5 → 1.0.0-beta.7
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/README.md +85 -0
- package/lib/commonjs/core/VelionOnboarding.js +296 -15
- package/lib/commonjs/core/VelionOnboarding.js.map +1 -1
- package/lib/commonjs/core/retryStepCopy.js +43 -0
- package/lib/commonjs/core/retryStepCopy.js.map +1 -0
- package/lib/commonjs/core/routingCommands.js +62 -0
- package/lib/commonjs/core/routingCommands.js.map +1 -0
- package/lib/commonjs/core/sessionStateMapper.js +63 -0
- package/lib/commonjs/core/sessionStateMapper.js.map +1 -1
- package/lib/commonjs/i18n/strings/en.js +28 -0
- package/lib/commonjs/i18n/strings/en.js.map +1 -1
- package/lib/commonjs/i18n/strings/es.js +28 -0
- package/lib/commonjs/i18n/strings/es.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/steps/AddressInfoStep.js +30 -18
- package/lib/commonjs/steps/AddressInfoStep.js.map +1 -1
- package/lib/commonjs/steps/DocumentsOcrStep.js +4 -0
- package/lib/commonjs/steps/DocumentsOcrStep.js.map +1 -1
- package/lib/commonjs/steps/EmailContactStep.js +5 -0
- package/lib/commonjs/steps/EmailContactStep.js.map +1 -1
- package/lib/commonjs/steps/EmailOtpStep.js +5 -0
- package/lib/commonjs/steps/EmailOtpStep.js.map +1 -1
- package/lib/commonjs/steps/FaceMatchStep.js +16 -13
- package/lib/commonjs/steps/FaceMatchStep.js.map +1 -1
- package/lib/commonjs/steps/HumanBasicInfoStep.js +12 -4
- package/lib/commonjs/steps/HumanBasicInfoStep.js.map +1 -1
- package/lib/commonjs/steps/HumanExtendedInfoStep.js +15 -8
- package/lib/commonjs/steps/HumanExtendedInfoStep.js.map +1 -1
- package/lib/commonjs/steps/LegalBasicInfoStep.js +13 -6
- package/lib/commonjs/steps/LegalBasicInfoStep.js.map +1 -1
- package/lib/commonjs/steps/LegalExtendedInfoStep.js +9 -2
- package/lib/commonjs/steps/LegalExtendedInfoStep.js.map +1 -1
- package/lib/commonjs/steps/PhoneContactStep.js +5 -0
- package/lib/commonjs/steps/PhoneContactStep.js.map +1 -1
- package/lib/commonjs/steps/PhoneOtpStep.js +5 -0
- package/lib/commonjs/steps/PhoneOtpStep.js.map +1 -1
- package/lib/commonjs/steps/SwornDeclarationStep.js +16 -6
- package/lib/commonjs/steps/SwornDeclarationStep.js.map +1 -1
- package/lib/commonjs/steps/TaxInfoStep.js +10 -3
- package/lib/commonjs/steps/TaxInfoStep.js.map +1 -1
- package/lib/commonjs/steps/TermsAndConditionsStep.js +7 -0
- package/lib/commonjs/steps/TermsAndConditionsStep.js.map +1 -1
- package/lib/commonjs/steps/_shared.js +21 -0
- package/lib/commonjs/steps/_shared.js.map +1 -1
- package/lib/commonjs/types/index.js +36 -1
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/commonjs/ui/StepShell.js +10 -2
- package/lib/commonjs/ui/StepShell.js.map +1 -1
- package/lib/commonjs/ui/VelionOnboardingScreen.js +25 -5
- package/lib/commonjs/ui/VelionOnboardingScreen.js.map +1 -1
- package/lib/commonjs/ui/icons/StepIcon.js.map +1 -1
- package/lib/commonjs/ui/primitives/BackButton.js +75 -0
- package/lib/commonjs/ui/primitives/BackButton.js.map +1 -0
- package/lib/commonjs/ui/primitives/index.js +7 -0
- package/lib/commonjs/ui/primitives/index.js.map +1 -1
- package/lib/module/core/VelionOnboarding.js +297 -16
- package/lib/module/core/VelionOnboarding.js.map +1 -1
- package/lib/module/core/retryStepCopy.js +39 -0
- package/lib/module/core/retryStepCopy.js.map +1 -0
- package/lib/module/core/routingCommands.js +57 -0
- package/lib/module/core/routingCommands.js.map +1 -0
- package/lib/module/core/sessionStateMapper.js +61 -0
- package/lib/module/core/sessionStateMapper.js.map +1 -1
- package/lib/module/i18n/strings/en.js +28 -0
- package/lib/module/i18n/strings/en.js.map +1 -1
- package/lib/module/i18n/strings/es.js +28 -0
- package/lib/module/i18n/strings/es.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/steps/AddressInfoStep.js +31 -19
- package/lib/module/steps/AddressInfoStep.js.map +1 -1
- package/lib/module/steps/DocumentsOcrStep.js +4 -0
- package/lib/module/steps/DocumentsOcrStep.js.map +1 -1
- package/lib/module/steps/EmailContactStep.js +5 -0
- package/lib/module/steps/EmailContactStep.js.map +1 -1
- package/lib/module/steps/EmailOtpStep.js +5 -0
- package/lib/module/steps/EmailOtpStep.js.map +1 -1
- package/lib/module/steps/FaceMatchStep.js +16 -13
- package/lib/module/steps/FaceMatchStep.js.map +1 -1
- package/lib/module/steps/HumanBasicInfoStep.js +12 -4
- package/lib/module/steps/HumanBasicInfoStep.js.map +1 -1
- package/lib/module/steps/HumanExtendedInfoStep.js +16 -9
- package/lib/module/steps/HumanExtendedInfoStep.js.map +1 -1
- package/lib/module/steps/LegalBasicInfoStep.js +14 -7
- package/lib/module/steps/LegalBasicInfoStep.js.map +1 -1
- package/lib/module/steps/LegalExtendedInfoStep.js +10 -3
- package/lib/module/steps/LegalExtendedInfoStep.js.map +1 -1
- package/lib/module/steps/PhoneContactStep.js +5 -0
- package/lib/module/steps/PhoneContactStep.js.map +1 -1
- package/lib/module/steps/PhoneOtpStep.js +5 -0
- package/lib/module/steps/PhoneOtpStep.js.map +1 -1
- package/lib/module/steps/SwornDeclarationStep.js +18 -6
- package/lib/module/steps/SwornDeclarationStep.js.map +1 -1
- package/lib/module/steps/TaxInfoStep.js +11 -4
- package/lib/module/steps/TaxInfoStep.js.map +1 -1
- package/lib/module/steps/TermsAndConditionsStep.js +7 -0
- package/lib/module/steps/TermsAndConditionsStep.js.map +1 -1
- package/lib/module/steps/_shared.js +19 -0
- package/lib/module/steps/_shared.js.map +1 -1
- package/lib/module/types/index.js +38 -1
- package/lib/module/types/index.js.map +1 -1
- package/lib/module/ui/StepShell.js +10 -2
- package/lib/module/ui/StepShell.js.map +1 -1
- package/lib/module/ui/VelionOnboardingScreen.js +25 -5
- package/lib/module/ui/VelionOnboardingScreen.js.map +1 -1
- package/lib/module/ui/icons/StepIcon.js.map +1 -1
- package/lib/module/ui/primitives/BackButton.js +71 -0
- package/lib/module/ui/primitives/BackButton.js.map +1 -0
- package/lib/module/ui/primitives/index.js +1 -0
- package/lib/module/ui/primitives/index.js.map +1 -1
- package/lib/typescript/core/VelionOnboarding.d.ts +56 -2
- package/lib/typescript/core/VelionOnboarding.d.ts.map +1 -1
- package/lib/typescript/core/retryStepCopy.d.ts +27 -0
- package/lib/typescript/core/retryStepCopy.d.ts.map +1 -0
- package/lib/typescript/core/routingCommands.d.ts +39 -0
- package/lib/typescript/core/routingCommands.d.ts.map +1 -0
- package/lib/typescript/core/sessionStateMapper.d.ts +20 -1
- package/lib/typescript/core/sessionStateMapper.d.ts.map +1 -1
- package/lib/typescript/i18n/strings/en.d.ts.map +1 -1
- package/lib/typescript/i18n/strings/es.d.ts +25 -0
- package/lib/typescript/i18n/strings/es.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +1 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/steps/AddressInfoStep.d.ts.map +1 -1
- package/lib/typescript/steps/DocumentsOcrStep.d.ts.map +1 -1
- package/lib/typescript/steps/EmailContactStep.d.ts.map +1 -1
- package/lib/typescript/steps/EmailOtpStep.d.ts.map +1 -1
- package/lib/typescript/steps/FaceMatchStep.d.ts.map +1 -1
- package/lib/typescript/steps/HumanBasicInfoStep.d.ts.map +1 -1
- package/lib/typescript/steps/HumanExtendedInfoStep.d.ts.map +1 -1
- package/lib/typescript/steps/LegalBasicInfoStep.d.ts.map +1 -1
- package/lib/typescript/steps/LegalExtendedInfoStep.d.ts.map +1 -1
- package/lib/typescript/steps/PhoneContactStep.d.ts.map +1 -1
- package/lib/typescript/steps/PhoneOtpStep.d.ts.map +1 -1
- package/lib/typescript/steps/SwornDeclarationStep.d.ts.map +1 -1
- package/lib/typescript/steps/TaxInfoStep.d.ts.map +1 -1
- package/lib/typescript/steps/TermsAndConditionsStep.d.ts.map +1 -1
- package/lib/typescript/steps/_shared.d.ts +11 -0
- package/lib/typescript/steps/_shared.d.ts.map +1 -1
- package/lib/typescript/steps/types.d.ts +15 -0
- package/lib/typescript/steps/types.d.ts.map +1 -1
- package/lib/typescript/types/index.d.ts +127 -5
- package/lib/typescript/types/index.d.ts.map +1 -1
- package/lib/typescript/ui/StepShell.d.ts +11 -1
- package/lib/typescript/ui/StepShell.d.ts.map +1 -1
- package/lib/typescript/ui/VelionOnboardingScreen.d.ts +9 -2
- package/lib/typescript/ui/VelionOnboardingScreen.d.ts.map +1 -1
- package/lib/typescript/ui/icons/StepIcon.d.ts +1 -1
- package/lib/typescript/ui/icons/StepIcon.d.ts.map +1 -1
- package/lib/typescript/ui/primitives/BackButton.d.ts +20 -0
- package/lib/typescript/ui/primitives/BackButton.d.ts.map +1 -0
- package/lib/typescript/ui/primitives/index.d.ts +1 -0
- package/lib/typescript/ui/primitives/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/core/VelionOnboarding.ts +315 -16
- package/src/core/retryStepCopy.ts +54 -0
- package/src/core/routingCommands.ts +63 -0
- package/src/core/sessionStateMapper.ts +65 -0
- package/src/i18n/strings/en.ts +33 -0
- package/src/i18n/strings/es.ts +33 -0
- package/src/index.ts +2 -0
- package/src/steps/AddressInfoStep.tsx +38 -20
- package/src/steps/DocumentsOcrStep.tsx +5 -0
- package/src/steps/EmailContactStep.tsx +6 -0
- package/src/steps/EmailOtpStep.tsx +6 -0
- package/src/steps/FaceMatchStep.tsx +18 -19
- package/src/steps/HumanBasicInfoStep.tsx +16 -4
- package/src/steps/HumanExtendedInfoStep.tsx +18 -9
- package/src/steps/LegalBasicInfoStep.tsx +16 -7
- package/src/steps/LegalExtendedInfoStep.tsx +16 -3
- package/src/steps/PhoneContactStep.tsx +6 -0
- package/src/steps/PhoneOtpStep.tsx +6 -0
- package/src/steps/SwornDeclarationStep.tsx +23 -6
- package/src/steps/TaxInfoStep.tsx +15 -4
- package/src/steps/TermsAndConditionsStep.tsx +8 -0
- package/src/steps/_shared.ts +25 -0
- package/src/steps/types.ts +15 -0
- package/src/types/index.ts +131 -3
- package/src/ui/StepShell.tsx +17 -0
- package/src/ui/VelionOnboardingScreen.tsx +36 -2
- package/src/ui/icons/StepIcon.tsx +2 -1
- package/src/ui/primitives/BackButton.tsx +65 -0
- package/src/ui/primitives/index.ts +1 -0
|
@@ -39,6 +39,7 @@ export class PhoneContactStep implements StepModule {
|
|
|
39
39
|
api={this.deps.api}
|
|
40
40
|
sessionId={this.deps.sessionId}
|
|
41
41
|
locale={this.deps.locale}
|
|
42
|
+
onBack={this.deps.onBack}
|
|
42
43
|
onComplete={() => {
|
|
43
44
|
if (this.destroyed) return;
|
|
44
45
|
this.deps.ui.setNode(null);
|
|
@@ -64,6 +65,7 @@ interface ViewProps {
|
|
|
64
65
|
api: ApiCaller;
|
|
65
66
|
sessionId: string;
|
|
66
67
|
locale: string;
|
|
68
|
+
onBack?: (() => void) | undefined;
|
|
67
69
|
onComplete: () => void;
|
|
68
70
|
onCancel: (err: SdkError) => void;
|
|
69
71
|
}
|
|
@@ -72,6 +74,7 @@ function PhoneContactView({
|
|
|
72
74
|
api,
|
|
73
75
|
sessionId,
|
|
74
76
|
locale,
|
|
77
|
+
onBack,
|
|
75
78
|
onComplete,
|
|
76
79
|
onCancel,
|
|
77
80
|
}: ViewProps) {
|
|
@@ -133,6 +136,9 @@ function PhoneContactView({
|
|
|
133
136
|
title={t.phone_contact.title}
|
|
134
137
|
subtitle={t.phone_contact.hint}
|
|
135
138
|
iconNode={<StepIcon name="phone-iphone" />}
|
|
139
|
+
onBack={onBack}
|
|
140
|
+
backLabel={t.common.back}
|
|
141
|
+
backDisabled={submitting}
|
|
136
142
|
>
|
|
137
143
|
<Input
|
|
138
144
|
label={t.phone_contact.label}
|
|
@@ -40,6 +40,7 @@ export class PhoneOtpStep implements StepModule {
|
|
|
40
40
|
api={this.deps.api}
|
|
41
41
|
sessionId={this.deps.sessionId}
|
|
42
42
|
locale={this.deps.locale}
|
|
43
|
+
onBack={this.deps.onBack}
|
|
43
44
|
onComplete={() => {
|
|
44
45
|
if (this.destroyed) return;
|
|
45
46
|
this.deps.ui.setNode(null);
|
|
@@ -65,6 +66,7 @@ interface ViewProps {
|
|
|
65
66
|
api: ApiCaller;
|
|
66
67
|
sessionId: string;
|
|
67
68
|
locale: string;
|
|
69
|
+
onBack?: (() => void) | undefined;
|
|
68
70
|
onComplete: () => void;
|
|
69
71
|
onCancel: (err: SdkError) => void;
|
|
70
72
|
}
|
|
@@ -73,6 +75,7 @@ function PhoneOtpView({
|
|
|
73
75
|
api,
|
|
74
76
|
sessionId,
|
|
75
77
|
locale,
|
|
78
|
+
onBack,
|
|
76
79
|
onComplete,
|
|
77
80
|
onCancel,
|
|
78
81
|
}: ViewProps) {
|
|
@@ -168,6 +171,9 @@ function PhoneOtpView({
|
|
|
168
171
|
title={t.phone_otp.title}
|
|
169
172
|
subtitle={t.phone_otp.phoneHint}
|
|
170
173
|
iconNode={<StepIcon name="phone-iphone" />}
|
|
174
|
+
onBack={stage === 'request' ? onBack : undefined}
|
|
175
|
+
backLabel={t.common.back}
|
|
176
|
+
backDisabled={busy !== null}
|
|
171
177
|
>
|
|
172
178
|
<Input
|
|
173
179
|
label={t.phone_otp.phoneLabel}
|
|
@@ -27,6 +27,14 @@ import type { ApiCaller } from '../transport/api';
|
|
|
27
27
|
import type { StepDeps, StepModule } from './types';
|
|
28
28
|
import { toSubmissionError } from './_shared';
|
|
29
29
|
|
|
30
|
+
/** Reads a boolean field from a step's prefill `result` map (reverse navigation). */
|
|
31
|
+
function prefillBool(
|
|
32
|
+
result: Record<string, unknown> | undefined,
|
|
33
|
+
key: string,
|
|
34
|
+
): boolean {
|
|
35
|
+
return result?.[key] === true;
|
|
36
|
+
}
|
|
37
|
+
|
|
30
38
|
export class SwornDeclarationStep implements StepModule {
|
|
31
39
|
private resolveStep!: () => void;
|
|
32
40
|
private rejectStep!: (err: SdkError) => void;
|
|
@@ -44,6 +52,8 @@ export class SwornDeclarationStep implements StepModule {
|
|
|
44
52
|
sessionId={this.deps.sessionId}
|
|
45
53
|
locale={this.deps.locale}
|
|
46
54
|
stepConfig={this.deps.stepConfig as SwornDeclarationStepConfig | undefined}
|
|
55
|
+
prefill={this.deps.stepResult}
|
|
56
|
+
onBack={this.deps.onBack}
|
|
47
57
|
onComplete={() => {
|
|
48
58
|
if (this.destroyed) return;
|
|
49
59
|
this.deps.ui.setNode(null);
|
|
@@ -72,6 +82,8 @@ interface ViewProps {
|
|
|
72
82
|
sessionId: string;
|
|
73
83
|
locale: string;
|
|
74
84
|
stepConfig: SwornDeclarationStepConfig | undefined;
|
|
85
|
+
prefill?: Record<string, unknown> | undefined;
|
|
86
|
+
onBack?: (() => void) | undefined;
|
|
75
87
|
onComplete: () => void;
|
|
76
88
|
onCancel: (err: SdkError) => void;
|
|
77
89
|
}
|
|
@@ -81,6 +93,8 @@ function SwornDeclarationView({
|
|
|
81
93
|
sessionId,
|
|
82
94
|
locale,
|
|
83
95
|
stepConfig,
|
|
96
|
+
prefill,
|
|
97
|
+
onBack,
|
|
84
98
|
onComplete,
|
|
85
99
|
onCancel,
|
|
86
100
|
}: ViewProps) {
|
|
@@ -95,12 +109,12 @@ function SwornDeclarationView({
|
|
|
95
109
|
return out;
|
|
96
110
|
}, [stepConfig]);
|
|
97
111
|
|
|
98
|
-
const [values, setValues] = useState<Record<DeclarationKey, boolean>>({
|
|
99
|
-
is_pep:
|
|
100
|
-
is_ssoo:
|
|
101
|
-
is_fatca:
|
|
102
|
-
is_ocde:
|
|
103
|
-
});
|
|
112
|
+
const [values, setValues] = useState<Record<DeclarationKey, boolean>>(() => ({
|
|
113
|
+
is_pep: prefillBool(prefill, 'is_pep'),
|
|
114
|
+
is_ssoo: prefillBool(prefill, 'is_ssoo'),
|
|
115
|
+
is_fatca: prefillBool(prefill, 'is_fatca'),
|
|
116
|
+
is_ocde: prefillBool(prefill, 'is_ocde'),
|
|
117
|
+
}));
|
|
104
118
|
const [bannerError, setBannerError] = useState<string | null>(null);
|
|
105
119
|
const [submitting, setSubmitting] = useState(false);
|
|
106
120
|
const [retry, setRetry] = useState<{ message: string } | null>(null);
|
|
@@ -162,6 +176,9 @@ function SwornDeclarationView({
|
|
|
162
176
|
<StepShell
|
|
163
177
|
title={t.sworn_declaration.title}
|
|
164
178
|
subtitle={t.sworn_declaration.subtitle}
|
|
179
|
+
onBack={onBack}
|
|
180
|
+
backLabel={t.common.back}
|
|
181
|
+
backDisabled={submitting}
|
|
165
182
|
>
|
|
166
183
|
{visibleKeys.includes('is_pep') ? (
|
|
167
184
|
<Checkbox
|
|
@@ -30,7 +30,7 @@ import { getStrings } from '../i18n';
|
|
|
30
30
|
import { resolveTaxInfoConfig } from '../utils/taxInfoConfig';
|
|
31
31
|
import type { ApiCaller } from '../transport/api';
|
|
32
32
|
import type { StepDeps, StepModule } from './types';
|
|
33
|
-
import { toSubmissionError } from './_shared';
|
|
33
|
+
import { prefillString, toSubmissionError } from './_shared';
|
|
34
34
|
|
|
35
35
|
export class TaxInfoStep implements StepModule {
|
|
36
36
|
private resolveStep!: () => void;
|
|
@@ -49,6 +49,8 @@ export class TaxInfoStep implements StepModule {
|
|
|
49
49
|
sessionId={this.deps.sessionId}
|
|
50
50
|
locale={this.deps.locale}
|
|
51
51
|
stepConfig={this.deps.stepConfig as TaxInfoStepConfig | undefined}
|
|
52
|
+
prefill={this.deps.stepResult}
|
|
53
|
+
onBack={this.deps.onBack}
|
|
52
54
|
onComplete={() => {
|
|
53
55
|
if (this.destroyed) return;
|
|
54
56
|
this.deps.ui.setNode(null);
|
|
@@ -108,6 +110,8 @@ interface ViewProps {
|
|
|
108
110
|
sessionId: string;
|
|
109
111
|
locale: string;
|
|
110
112
|
stepConfig: TaxInfoStepConfig | undefined;
|
|
113
|
+
prefill?: Record<string, unknown> | undefined;
|
|
114
|
+
onBack?: (() => void) | undefined;
|
|
111
115
|
onComplete: () => void;
|
|
112
116
|
onCancel: (err: SdkError) => void;
|
|
113
117
|
}
|
|
@@ -117,6 +121,8 @@ function TaxInfoView({
|
|
|
117
121
|
sessionId,
|
|
118
122
|
locale,
|
|
119
123
|
stepConfig,
|
|
124
|
+
prefill,
|
|
125
|
+
onBack,
|
|
120
126
|
onComplete,
|
|
121
127
|
onCancel,
|
|
122
128
|
}: ViewProps) {
|
|
@@ -159,9 +165,11 @@ function TaxInfoView({
|
|
|
159
165
|
}, [stepConfig]);
|
|
160
166
|
|
|
161
167
|
const [form, setForm] = useState<FormState>(() => ({
|
|
162
|
-
taxpayer_type:
|
|
163
|
-
|
|
164
|
-
|
|
168
|
+
taxpayer_type:
|
|
169
|
+
prefillString(prefill, 'taxpayer_type') || (categoryOptions[0]?.value ?? ''),
|
|
170
|
+
taxpayer_id_type:
|
|
171
|
+
prefillString(prefill, 'taxpayer_id_type') || (idTypeOptions[0]?.value ?? ''),
|
|
172
|
+
taxpayer_id: prefillString(prefill, 'taxpayer_id'),
|
|
165
173
|
}));
|
|
166
174
|
const [bannerError, setBannerError] = useState<string | null>(null);
|
|
167
175
|
const [submitting, setSubmitting] = useState(false);
|
|
@@ -232,6 +240,9 @@ function TaxInfoView({
|
|
|
232
240
|
title={t.tax_info.title}
|
|
233
241
|
subtitle={t.tax_info.subtitle}
|
|
234
242
|
iconNode={<StepIcon name="receipt-long" />}
|
|
243
|
+
onBack={onBack}
|
|
244
|
+
backLabel={t.common.back}
|
|
245
|
+
backDisabled={submitting}
|
|
235
246
|
>
|
|
236
247
|
<Select
|
|
237
248
|
label={t.tax_info.taxpayerType}
|
|
@@ -50,6 +50,7 @@ export class TermsAndConditionsStep implements StepModule {
|
|
|
50
50
|
sessionId={this.deps.sessionId}
|
|
51
51
|
locale={this.deps.locale}
|
|
52
52
|
stepConfig={this.deps.stepConfig as TermsAndConditionsStepConfig | undefined}
|
|
53
|
+
onBack={this.deps.onBack}
|
|
53
54
|
onComplete={() => {
|
|
54
55
|
if (this.destroyed) return;
|
|
55
56
|
this.deps.ui.setNode(null);
|
|
@@ -82,6 +83,7 @@ interface ViewProps {
|
|
|
82
83
|
sessionId: string;
|
|
83
84
|
locale: string;
|
|
84
85
|
stepConfig: TermsAndConditionsStepConfig | undefined;
|
|
86
|
+
onBack?: (() => void) | undefined;
|
|
85
87
|
onComplete: () => void;
|
|
86
88
|
onCancel: (err: SdkError) => void;
|
|
87
89
|
onNoItems: (err: SdkError) => void;
|
|
@@ -92,6 +94,7 @@ function TermsAndConditionsView({
|
|
|
92
94
|
sessionId,
|
|
93
95
|
locale,
|
|
94
96
|
stepConfig,
|
|
97
|
+
onBack,
|
|
95
98
|
onComplete,
|
|
96
99
|
onCancel,
|
|
97
100
|
onNoItems,
|
|
@@ -182,6 +185,8 @@ function TermsAndConditionsView({
|
|
|
182
185
|
title={t.terms_and_conditions.title}
|
|
183
186
|
subtitle={t.terms_and_conditions.subtitle}
|
|
184
187
|
iconNode={<StepIcon name="description" />}
|
|
188
|
+
onBack={onBack}
|
|
189
|
+
backLabel={t.common.back}
|
|
185
190
|
>
|
|
186
191
|
<Banner message={t.terms_and_conditions.noItems} />
|
|
187
192
|
</StepShell>
|
|
@@ -194,6 +199,9 @@ function TermsAndConditionsView({
|
|
|
194
199
|
title={t.terms_and_conditions.title}
|
|
195
200
|
subtitle={t.terms_and_conditions.subtitle}
|
|
196
201
|
iconNode={<StepIcon name="description" />}
|
|
202
|
+
onBack={onBack}
|
|
203
|
+
backLabel={t.common.back}
|
|
204
|
+
backDisabled={submitting}
|
|
197
205
|
>
|
|
198
206
|
{items.map((item) => (
|
|
199
207
|
<View
|
package/src/steps/_shared.ts
CHANGED
|
@@ -42,3 +42,28 @@ export function isE164Phone(value: string): boolean {
|
|
|
42
42
|
export function isOtpCode(value: string): boolean {
|
|
43
43
|
return OTP_REGEX.test(value.trim());
|
|
44
44
|
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Reads a string field from a step's prefill `result` map (sent by the backend
|
|
48
|
+
* on reverse navigation). Returns `''` when absent or not a string, so it can
|
|
49
|
+
* seed a controlled text input directly.
|
|
50
|
+
*/
|
|
51
|
+
export function prefillString(
|
|
52
|
+
result: Record<string, unknown> | undefined,
|
|
53
|
+
key: string,
|
|
54
|
+
): string {
|
|
55
|
+
const value = result?.[key];
|
|
56
|
+
return typeof value === 'string' ? value : '';
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Like {@link prefillString} but returns `null` for empty/absent values — handy
|
|
61
|
+
* for `<Select>` / `<CountrySelect>` / `<DatePicker>` whose empty state is `null`.
|
|
62
|
+
*/
|
|
63
|
+
export function prefillStringOrNull(
|
|
64
|
+
result: Record<string, unknown> | undefined,
|
|
65
|
+
key: string,
|
|
66
|
+
): string | null {
|
|
67
|
+
const value = result?.[key];
|
|
68
|
+
return typeof value === 'string' && value.length > 0 ? value : null;
|
|
69
|
+
}
|
package/src/steps/types.ts
CHANGED
|
@@ -42,6 +42,21 @@ export interface StepDeps {
|
|
|
42
42
|
ui: StepUiHandle;
|
|
43
43
|
step: OnboardingStep;
|
|
44
44
|
stepConfig?: Record<string, unknown>;
|
|
45
|
+
/**
|
|
46
|
+
* Previously-captured data for this step, used as form prefill when the step
|
|
47
|
+
* is re-opened by a reverse navigation (`ROUTING_COMMAND / PREVIOUS_STEP`) or
|
|
48
|
+
* resumed from GET `current_step.result`. Treat it as editable initial state —
|
|
49
|
+
* never re-fire side effects (no re-sending OTPs, no re-uploading documents).
|
|
50
|
+
*/
|
|
51
|
+
stepResult?: Record<string, unknown>;
|
|
52
|
+
/**
|
|
53
|
+
* Requests reverse navigation. Present only when the backend reports the user
|
|
54
|
+
* can go back from this step (`can_go_back`); steps render the "back" (chevron)
|
|
55
|
+
* control iff this is set. Fire-and-forget: the orchestrator POSTs
|
|
56
|
+
* `/sessions/:id/back` and the actual transition is driven by the backend over
|
|
57
|
+
* SSE (PREVIOUS_STEP to a prior step, or BACK_EXIT to leave the flow).
|
|
58
|
+
*/
|
|
59
|
+
onBack?: () => void;
|
|
45
60
|
/**
|
|
46
61
|
* Google Maps Platform API key (Maps + Places). Forwarded to the assisted
|
|
47
62
|
* `ADDRESS_INFO` flow when the consumer passes it via `VelionConfig`. Steps
|
package/src/types/index.ts
CHANGED
|
@@ -469,6 +469,21 @@ export type VelionSessionDeclinedReasonTexts = Record<
|
|
|
469
469
|
VelionSessionDeclinedReasonMessages
|
|
470
470
|
>;
|
|
471
471
|
|
|
472
|
+
/**
|
|
473
|
+
* Per-step overrides for the retry dialog shown when the backend emits a
|
|
474
|
+
* `ROUTING_COMMAND / RETRY_STEP` (the step failed but the retry quota is not
|
|
475
|
+
* exhausted). Keyed by step code (e.g. `LIVENESS_MATCH`, `DOCUMENTS_OCR`).
|
|
476
|
+
* Unspecified steps fall back to SDK per-step defaults, then generic copy.
|
|
477
|
+
*
|
|
478
|
+
* Note: the SDK intentionally ignores the backend `reason` for this dialog —
|
|
479
|
+
* it is a diagnostic string (e.g. `"STEP_FAILED_RETRY_ALLOWED (attempt 1/3)"`),
|
|
480
|
+
* not user-facing localized copy. The copy is derived from the step instead.
|
|
481
|
+
*/
|
|
482
|
+
export type VelionRetryStepTexts = Record<
|
|
483
|
+
string,
|
|
484
|
+
VelionSessionDeclinedReasonMessages
|
|
485
|
+
>;
|
|
486
|
+
|
|
472
487
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
473
488
|
// CALLBACKS
|
|
474
489
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
@@ -532,6 +547,17 @@ export interface VelionCallbacks {
|
|
|
532
547
|
*/
|
|
533
548
|
onFinalResultScreenDismiss?: () => void;
|
|
534
549
|
|
|
550
|
+
/**
|
|
551
|
+
* Fires when the user leaves the flow without a verdict — either by tapping
|
|
552
|
+
* "back" on the first reversible step (`BACK_EXIT`) or "Cancel" on the retry
|
|
553
|
+
* dialog after a `RETRY_STEP` (`RETRY_CANCELLED`). The SDK has already torn
|
|
554
|
+
* down its UI; the host should dismiss the SDK screen and return the user to
|
|
555
|
+
* the previous context. Neither `onSuccess` nor `onError` fires in this case.
|
|
556
|
+
*
|
|
557
|
+
* @param exit - Why the flow ended and, when available, the step exited from.
|
|
558
|
+
*/
|
|
559
|
+
onExit?: (exit: OnboardingExit) => void;
|
|
560
|
+
|
|
535
561
|
/**
|
|
536
562
|
* Fires when the LIVENESS_MATCH step successfully uploaded the recorded
|
|
537
563
|
* session video to the onboarding storage (GCS PUT returned 200). Best-effort:
|
|
@@ -659,6 +685,13 @@ export interface VelionConfig extends VelionCallbacks {
|
|
|
659
685
|
*/
|
|
660
686
|
sessionDeclinedReasonTexts?: VelionSessionDeclinedReasonTexts;
|
|
661
687
|
|
|
688
|
+
/**
|
|
689
|
+
* Optional copy for the retry dialog (`ROUTING_COMMAND / RETRY_STEP`), keyed by
|
|
690
|
+
* step code (e.g. `LIVENESS_MATCH`). Merged with SDK per-step defaults for
|
|
691
|
+
* `locale` `en` / `es`; unspecified steps fall back to generic retry copy.
|
|
692
|
+
*/
|
|
693
|
+
retryStepTexts?: VelionRetryStepTexts;
|
|
694
|
+
|
|
662
695
|
/**
|
|
663
696
|
* When `true` (default), shows the Velion preparation screen (face icon, tips,
|
|
664
697
|
* "Start verification") before connecting to Iris. When `false`, skips it and
|
|
@@ -776,6 +809,14 @@ export interface OnboardingStepDto {
|
|
|
776
809
|
required?: boolean;
|
|
777
810
|
/** Step-specific payload (e.g. OCR fields, fingerprint, T&C items). */
|
|
778
811
|
result?: Record<string, unknown>;
|
|
812
|
+
/**
|
|
813
|
+
* Whether the user may navigate back into this step after completing it.
|
|
814
|
+
* Resolved by the backend (step-type default merged with the workflow
|
|
815
|
+
* override) and surfaced as a first-class flag so the SDK can decide whether
|
|
816
|
+
* to render the "back" (chevron) control. The SDK never hardcodes the
|
|
817
|
+
* reversibility list — it obeys this flag verbatim.
|
|
818
|
+
*/
|
|
819
|
+
reversible?: boolean;
|
|
779
820
|
}
|
|
780
821
|
|
|
781
822
|
/**
|
|
@@ -791,12 +832,28 @@ export interface OnboardingDtoResponse {
|
|
|
791
832
|
code?: string;
|
|
792
833
|
status?: string;
|
|
793
834
|
config?: Record<string, unknown>;
|
|
835
|
+
/** When `true`, the SDK renders the "back" control for this step. */
|
|
836
|
+
reversible?: boolean;
|
|
837
|
+
/**
|
|
838
|
+
* Previously-captured data for the current step (present after a reverse
|
|
839
|
+
* navigation re-opens a completed step). Used as prefill so the form
|
|
840
|
+
* re-renders with the user's earlier answers.
|
|
841
|
+
*/
|
|
842
|
+
result?: Record<string, unknown>;
|
|
794
843
|
};
|
|
795
844
|
steps?: OnboardingStepDto[];
|
|
796
845
|
created_at?: string;
|
|
797
846
|
updated_at?: string;
|
|
798
847
|
completed_at?: string;
|
|
799
848
|
metadata?: Record<string, unknown>;
|
|
849
|
+
/**
|
|
850
|
+
* Whether the user can navigate back from `current_step`. Computed server-side
|
|
851
|
+
* from the workflow graph: `true` when there is a previous reversible step to
|
|
852
|
+
* re-open, OR when the current step is the first reversible step (back exits
|
|
853
|
+
* the flow via `BACK_EXIT`). The SDK uses **this** — not a step's intrinsic
|
|
854
|
+
* `reversible` flag — to decide whether to render the "back" control.
|
|
855
|
+
*/
|
|
856
|
+
can_go_back?: boolean;
|
|
800
857
|
/**
|
|
801
858
|
* Origins (scheme + host + port) authorized by the customer to embed the SDK.
|
|
802
859
|
* The iframe validates `event.origin` of the loader's first VELION_INIT against
|
|
@@ -815,6 +872,25 @@ export interface SessionState {
|
|
|
815
872
|
currentStep?: OnboardingStep;
|
|
816
873
|
/** Step-specific config for `currentStep` from GET /sessions/:id `current_step.config`. */
|
|
817
874
|
currentStepConfig?: Record<string, unknown>;
|
|
875
|
+
/**
|
|
876
|
+
* Whether the SDK should render the "back" control on `currentStep`. Sourced
|
|
877
|
+
* from GET `can_go_back` (workflow-graph computed). When absent (e.g. reached
|
|
878
|
+
* via SSE), the orchestrator derives it from {@link stepReversibility}.
|
|
879
|
+
*/
|
|
880
|
+
canGoBack?: boolean;
|
|
881
|
+
/**
|
|
882
|
+
* Per-step reversibility in workflow order, cached at session load so the
|
|
883
|
+
* orchestrator can derive `can_go_back` for steps reached via SSE (which does
|
|
884
|
+
* not carry the flag): a step can go back when any earlier step is reversible
|
|
885
|
+
* or the step itself is the first reversible one (back exits).
|
|
886
|
+
*/
|
|
887
|
+
stepReversibility?: Array<{ code: OnboardingStep; reversible: boolean }>;
|
|
888
|
+
/**
|
|
889
|
+
* Previously-captured data for `currentStep`, used as form prefill after a
|
|
890
|
+
* reverse navigation re-opens a completed step. Sourced from GET
|
|
891
|
+
* `current_step.result`.
|
|
892
|
+
*/
|
|
893
|
+
currentStepResult?: Record<string, unknown>;
|
|
818
894
|
/** Cached configs discovered from GET session and SSE `step_config`. */
|
|
819
895
|
stepConfigs?: StepConfigMap;
|
|
820
896
|
/** Session type (HUMAN or LEGAL). Constrains which steps are applicable. */
|
|
@@ -828,6 +904,28 @@ export interface SessionState {
|
|
|
828
904
|
allowedParentOrigins?: string[];
|
|
829
905
|
}
|
|
830
906
|
|
|
907
|
+
/**
|
|
908
|
+
* Emitted when the user leaves the onboarding flow without a backend verdict.
|
|
909
|
+
*
|
|
910
|
+
* Triggers:
|
|
911
|
+
* - `BACK_EXIT`: the user tapped "back" on the first reversible step, where
|
|
912
|
+
* there is no earlier step to return to, so the backend instructs the SDK to
|
|
913
|
+
* exit.
|
|
914
|
+
* - `RETRY_CANCELLED`: the user tapped "Cancel" on the retry dialog shown after
|
|
915
|
+
* a `ROUTING_COMMAND / RETRY_STEP`. The backend session stays `IN_PROGRESS`
|
|
916
|
+
* (there is no cancellation endpoint); the host may re-open it later via
|
|
917
|
+
* `GET /sessions/:id`.
|
|
918
|
+
*
|
|
919
|
+
* This is neither success nor error — the host should dismiss the SDK screen and
|
|
920
|
+
* return the user to wherever they came from. See {@link VelionCallbacks.onExit}.
|
|
921
|
+
*/
|
|
922
|
+
export interface OnboardingExit {
|
|
923
|
+
/** Why the flow ended without a verdict. */
|
|
924
|
+
reason: 'BACK_EXIT' | 'RETRY_CANCELLED';
|
|
925
|
+
/** The step the user exited from (SSE `step_code`), when the backend provides it. */
|
|
926
|
+
step?: OnboardingStep;
|
|
927
|
+
}
|
|
928
|
+
|
|
831
929
|
/**
|
|
832
930
|
* A single T&C line item (matches backend TermsAndConditionsItemDto / domain record).
|
|
833
931
|
*/
|
|
@@ -1078,10 +1176,20 @@ export interface TermsAndConditionsSubmitPayload {
|
|
|
1078
1176
|
*
|
|
1079
1177
|
* Event types (event_type):
|
|
1080
1178
|
* - STEP_UPDATED — a workflow step changed status (step_code, step_status)
|
|
1081
|
-
* - ROUTING_COMMAND — next/retry/terminate instruction
|
|
1179
|
+
* - ROUTING_COMMAND — next/previous/retry/terminate instruction
|
|
1180
|
+
* (action: NEXT_STEP | PREVIOUS_STEP | RETRY_STEP | TERMINATE)
|
|
1082
1181
|
* - SESSION_APPROVED — all checks passed; session_status = APPROVED
|
|
1083
1182
|
* - SESSION_MANUAL_REVIEW — manual review required; session_status = MANUAL_REVIEW
|
|
1084
1183
|
* - SESSION_DECLINED — session ended with decline (step_code, session_status DECLINED, reason)
|
|
1184
|
+
*
|
|
1185
|
+
* Reverse navigation ("back") arrives as a STEP_UPDATED (the re-opened step
|
|
1186
|
+
* moves to IN_PROGRESS) followed by a ROUTING_COMMAND with action PREVIOUS_STEP
|
|
1187
|
+
* carrying `step_config` and `step_result` (prefill) for the re-opened step.
|
|
1188
|
+
*
|
|
1189
|
+
* Tapping "back" on the first interactive (reversible) step instead yields a
|
|
1190
|
+
* ROUTING_COMMAND with action BACK_EXIT (`step_code` = the step exited from):
|
|
1191
|
+
* there is no earlier reversible step, so the SDK leaves the flow and returns
|
|
1192
|
+
* control to the host (see {@link VelionCallbacks.onExit}).
|
|
1085
1193
|
*/
|
|
1086
1194
|
export interface OnboardingSessionEvent {
|
|
1087
1195
|
/** Onboarding session identifier (Long in backend). */
|
|
@@ -1094,12 +1202,29 @@ export interface OnboardingSessionEvent {
|
|
|
1094
1202
|
step_status?: string;
|
|
1095
1203
|
/** Present for terminal events; e.g. APPROVED | MANUAL_REVIEW | REJECTED. */
|
|
1096
1204
|
session_status?: string;
|
|
1097
|
-
/**
|
|
1205
|
+
/**
|
|
1206
|
+
* For ROUTING_COMMAND: NEXT_STEP | PREVIOUS_STEP | RETRY_STEP (render step_code),
|
|
1207
|
+
* BACK_EXIT (user backed out of the first reversible step — leave the flow),
|
|
1208
|
+
* or TERMINATE (end flow).
|
|
1209
|
+
*/
|
|
1098
1210
|
action?: string;
|
|
1099
1211
|
/** For SESSION_DECLINED / SESSION_MANUAL_REVIEW or ROUTING_COMMAND TERMINATE; e.g. UNREADABLE_DOCUMENT. */
|
|
1100
1212
|
reason?: string;
|
|
1101
|
-
/** Step-specific config sent with ROUTING_COMMAND NEXT_STEP. */
|
|
1213
|
+
/** Step-specific config sent with ROUTING_COMMAND NEXT_STEP / PREVIOUS_STEP. */
|
|
1102
1214
|
step_config?: Record<string, unknown>;
|
|
1215
|
+
/**
|
|
1216
|
+
* Previously-captured data for the re-opened step, sent with ROUTING_COMMAND
|
|
1217
|
+
* PREVIOUS_STEP. The SDK uses it to prefill the step's form on reverse
|
|
1218
|
+
* navigation.
|
|
1219
|
+
*/
|
|
1220
|
+
step_result?: Record<string, unknown>;
|
|
1221
|
+
/**
|
|
1222
|
+
* Whether the user can navigate back from the step this command routes to.
|
|
1223
|
+
* Optional: when the backend includes it on a ROUTING_COMMAND the SDK uses it
|
|
1224
|
+
* to decide the "back" control verbatim; otherwise the SDK derives it from the
|
|
1225
|
+
* step reversibility map cached at session load.
|
|
1226
|
+
*/
|
|
1227
|
+
can_go_back?: boolean;
|
|
1103
1228
|
/** Epoch millis; used as SSE id for Last-Event-ID on reconnect. */
|
|
1104
1229
|
event_id?: number;
|
|
1105
1230
|
}
|
|
@@ -1175,6 +1300,7 @@ export type SdkStatus =
|
|
|
1175
1300
|
| 'RUNNING' // Orchestrating steps
|
|
1176
1301
|
| 'STEP_PROCESSING'// A module is actively running
|
|
1177
1302
|
| 'COMPLETED' // All steps done, onSuccess fired
|
|
1303
|
+
| 'EXITED' // User left the flow via back on the first step, onExit fired
|
|
1178
1304
|
| 'ERROR' // Unrecoverable error, onError fired
|
|
1179
1305
|
| 'DESTROYED'; // destroy() was called, instance is a no-op
|
|
1180
1306
|
|
|
@@ -1187,6 +1313,7 @@ export type SdkEventName =
|
|
|
1187
1313
|
| 'step:complete'
|
|
1188
1314
|
| 'session:loaded'
|
|
1189
1315
|
| 'flow:complete'
|
|
1316
|
+
| 'flow:exit'
|
|
1190
1317
|
| 'error'
|
|
1191
1318
|
| 'status:change';
|
|
1192
1319
|
|
|
@@ -1200,6 +1327,7 @@ export interface SdkEventMap extends Record<string, unknown> {
|
|
|
1200
1327
|
'step:complete': { step: OnboardingStep };
|
|
1201
1328
|
'session:loaded': SessionState;
|
|
1202
1329
|
'flow:complete': OnboardingResult;
|
|
1330
|
+
'flow:exit': OnboardingExit;
|
|
1203
1331
|
'error': SdkError;
|
|
1204
1332
|
'status:change': SdkStatus;
|
|
1205
1333
|
}
|
package/src/ui/StepShell.tsx
CHANGED
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
View,
|
|
17
17
|
} from 'react-native';
|
|
18
18
|
import { useTheme, withAlpha } from './theme';
|
|
19
|
+
import { BackButton } from './primitives/BackButton';
|
|
19
20
|
|
|
20
21
|
export interface StepShellProps {
|
|
21
22
|
title: string;
|
|
@@ -25,6 +26,16 @@ export interface StepShellProps {
|
|
|
25
26
|
children: ReactNode;
|
|
26
27
|
/** When true, the body is wrapped in a `KeyboardAvoidingView` (form-friendly). */
|
|
27
28
|
avoidKeyboard?: boolean | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* When provided, renders a top-left "back" (chevron) control. Only reversible
|
|
31
|
+
* steps wire this — the orchestrator decides based on the backend's
|
|
32
|
+
* `reversible` flag, so non-reversible steps simply omit it.
|
|
33
|
+
*/
|
|
34
|
+
onBack?: (() => void) | undefined;
|
|
35
|
+
/** Label for the back control (localized). Defaults are provided by callers. */
|
|
36
|
+
backLabel?: string | undefined;
|
|
37
|
+
/** Disables the back control (e.g. while a back request is already in flight). */
|
|
38
|
+
backDisabled?: boolean | undefined;
|
|
28
39
|
}
|
|
29
40
|
|
|
30
41
|
export function StepShell({
|
|
@@ -33,6 +44,9 @@ export function StepShell({
|
|
|
33
44
|
iconNode,
|
|
34
45
|
children,
|
|
35
46
|
avoidKeyboard = true,
|
|
47
|
+
onBack,
|
|
48
|
+
backLabel = 'Atrás',
|
|
49
|
+
backDisabled = false,
|
|
36
50
|
}: StepShellProps) {
|
|
37
51
|
const theme = useTheme();
|
|
38
52
|
|
|
@@ -44,6 +58,9 @@ export function StepShell({
|
|
|
44
58
|
contentContainerStyle={styles.scrollBody}
|
|
45
59
|
keyboardShouldPersistTaps="handled"
|
|
46
60
|
>
|
|
61
|
+
{onBack ? (
|
|
62
|
+
<BackButton label={backLabel} onPress={onBack} disabled={backDisabled} />
|
|
63
|
+
) : null}
|
|
47
64
|
<View style={styles.header}>
|
|
48
65
|
{showIconCircle ? (
|
|
49
66
|
<View
|
|
@@ -17,7 +17,12 @@ import React, {
|
|
|
17
17
|
} from 'react';
|
|
18
18
|
import { StyleSheet, Text, View } from 'react-native';
|
|
19
19
|
import { VelionOnboarding, type VelionConfig } from '../core/VelionOnboarding';
|
|
20
|
-
import type {
|
|
20
|
+
import type {
|
|
21
|
+
OnboardingExit,
|
|
22
|
+
OnboardingResult,
|
|
23
|
+
OnboardingStep,
|
|
24
|
+
SdkError,
|
|
25
|
+
} from '../types';
|
|
21
26
|
import { ThemeProvider, useTheme } from './theme';
|
|
22
27
|
import { LoadingOverlay } from './overlays/LoadingOverlay';
|
|
23
28
|
import { PROGRESS_BAR, ProgressBar } from './overlays/ProgressBar';
|
|
@@ -31,6 +36,13 @@ export interface VelionOnboardingScreenProps {
|
|
|
31
36
|
config: VelionConfig;
|
|
32
37
|
onComplete?: ((result: OnboardingResult) => void) | undefined;
|
|
33
38
|
onFail?: ((err: SdkError) => void) | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Fires when the user leaves the flow without a verdict — they tapped "back"
|
|
41
|
+
* on the first reversible step (`BACK_EXIT`). The SDK has cleared its UI; the
|
|
42
|
+
* host should dismiss/unmount this screen and return the user to the previous
|
|
43
|
+
* context. Mirrors `VelionConfig.onExit`.
|
|
44
|
+
*/
|
|
45
|
+
onExit?: ((exit: OnboardingExit) => void) | undefined;
|
|
34
46
|
}
|
|
35
47
|
|
|
36
48
|
interface ViewState {
|
|
@@ -38,6 +50,8 @@ interface ViewState {
|
|
|
38
50
|
stepNode: ReactNode | null;
|
|
39
51
|
error: SdkError | null;
|
|
40
52
|
result: OnboardingResult | null;
|
|
53
|
+
/** Set once the user backed out of the first step; renders a blank surface. */
|
|
54
|
+
exited: boolean;
|
|
41
55
|
}
|
|
42
56
|
|
|
43
57
|
const INITIAL_STATE: ViewState = {
|
|
@@ -45,12 +59,14 @@ const INITIAL_STATE: ViewState = {
|
|
|
45
59
|
stepNode: null,
|
|
46
60
|
error: null,
|
|
47
61
|
result: null,
|
|
62
|
+
exited: false,
|
|
48
63
|
};
|
|
49
64
|
|
|
50
65
|
export function VelionOnboardingScreen({
|
|
51
66
|
config,
|
|
52
67
|
onComplete,
|
|
53
68
|
onFail,
|
|
69
|
+
onExit,
|
|
54
70
|
}: VelionOnboardingScreenProps) {
|
|
55
71
|
return (
|
|
56
72
|
<ThemeProvider
|
|
@@ -61,6 +77,7 @@ export function VelionOnboardingScreen({
|
|
|
61
77
|
config={config}
|
|
62
78
|
onComplete={onComplete}
|
|
63
79
|
onFail={onFail}
|
|
80
|
+
onExit={onExit}
|
|
64
81
|
/>
|
|
65
82
|
</ThemeProvider>
|
|
66
83
|
);
|
|
@@ -70,6 +87,7 @@ function VelionOnboardingInner({
|
|
|
70
87
|
config,
|
|
71
88
|
onComplete,
|
|
72
89
|
onFail,
|
|
90
|
+
onExit,
|
|
73
91
|
}: VelionOnboardingScreenProps) {
|
|
74
92
|
const theme = useTheme();
|
|
75
93
|
const t = getStrings(config.locale);
|
|
@@ -89,8 +107,10 @@ function VelionOnboardingInner({
|
|
|
89
107
|
|
|
90
108
|
const onCompleteRef = useRef(onComplete);
|
|
91
109
|
const onFailRef = useRef(onFail);
|
|
110
|
+
const onExitRef = useRef(onExit);
|
|
92
111
|
onCompleteRef.current = onComplete;
|
|
93
112
|
onFailRef.current = onFail;
|
|
113
|
+
onExitRef.current = onExit;
|
|
94
114
|
|
|
95
115
|
useEffect(() => {
|
|
96
116
|
// Hold a wake lock for the full duration of the flow. Camera-heavy steps
|
|
@@ -113,6 +133,20 @@ function VelionOnboardingInner({
|
|
|
113
133
|
setTimeout(() => setProgressHidden(true), 400);
|
|
114
134
|
onCompleteRef.current?.(result);
|
|
115
135
|
},
|
|
136
|
+
setExit: (exit) => {
|
|
137
|
+
// User backed out of the first step: blank the surface (no overlay, no
|
|
138
|
+
// result) and let the host dismiss the screen via onExit.
|
|
139
|
+
setState((s) => ({
|
|
140
|
+
...s,
|
|
141
|
+
exited: true,
|
|
142
|
+
loading: null,
|
|
143
|
+
stepNode: null,
|
|
144
|
+
error: null,
|
|
145
|
+
result: null,
|
|
146
|
+
}));
|
|
147
|
+
setProgressHidden(true);
|
|
148
|
+
onExitRef.current?.(exit);
|
|
149
|
+
},
|
|
116
150
|
});
|
|
117
151
|
|
|
118
152
|
const unsubStepChange = sdk.on('step:change', () => {
|
|
@@ -169,7 +203,7 @@ function VelionOnboardingInner({
|
|
|
169
203
|
}, [state, theme, t]);
|
|
170
204
|
|
|
171
205
|
const showLoadingOverlay =
|
|
172
|
-
!state.error && !state.result && !state.stepNode;
|
|
206
|
+
!state.error && !state.result && !state.stepNode && !state.exited;
|
|
173
207
|
const loadingText = state.loading ?? t.common.loading;
|
|
174
208
|
// Progress bar is shown unless EITHER `config.showProgressBar === false`
|
|
175
209
|
// OR `theme.hideProgressBar === true`. Both paths exist for parity with
|