@incodetech/core 0.0.0-dev-20260317-5e90a15 → 0.0.0-dev-20260317-737b25e
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.
|
@@ -29,4 +29,10 @@ type AddressSuggestion = {
|
|
|
29
29
|
countryCode?: string;
|
|
30
30
|
};
|
|
31
31
|
//#endregion
|
|
32
|
-
|
|
32
|
+
//#region src/shared/displayErrors.d.ts
|
|
33
|
+
type DisplayErrorsResult = {
|
|
34
|
+
displayErrors: Record<string, string>;
|
|
35
|
+
errorParams: Record<string, Record<string, string | number>>;
|
|
36
|
+
};
|
|
37
|
+
//#endregion
|
|
38
|
+
export { AddressSuggestion as n, FieldDef as r, DisplayErrorsResult as t };
|
|
@@ -62,7 +62,7 @@ declare const documentUploadMachine: xstate0.StateMachine<DocumentUploadContext,
|
|
|
62
62
|
type: "stopStream";
|
|
63
63
|
params: xstate0.NonReducibleUnknown;
|
|
64
64
|
};
|
|
65
|
-
}>, never, never, "
|
|
65
|
+
}>, never, never, "error" | "initCamera" | "idle" | "capturing" | "closed" | "uploading" | "finished", string, DocumentUploadInput, xstate0.NonReducibleUnknown, xstate0.EventObject, xstate0.MetaObject, {
|
|
66
66
|
readonly id: "documentUpload";
|
|
67
67
|
readonly initial: "idle";
|
|
68
68
|
readonly context: ({
|
package/dist/ekyb.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as Manager } from "./Manager-DsNvecSe.js";
|
|
2
|
-
import { n as FieldDef, t as
|
|
2
|
+
import { n as AddressSuggestion, r as FieldDef, t as DisplayErrorsResult } from "./displayErrors-B2eFGhh_.js";
|
|
3
3
|
|
|
4
4
|
//#region src/modules/ekyb/types.d.ts
|
|
5
5
|
type UboEntry = {
|
|
@@ -49,12 +49,12 @@ type EkybFormState = {
|
|
|
49
49
|
availableCountries: readonly string[];
|
|
50
50
|
fields: EkybFieldDef[];
|
|
51
51
|
values: EkybFormValues;
|
|
52
|
-
|
|
53
|
-
errorParams: Record<string, Record<string, string | number>>;
|
|
52
|
+
errors: Record<string, string>;
|
|
54
53
|
isValid: boolean;
|
|
55
54
|
ubos: UboEntry[];
|
|
56
55
|
canAddUbo: boolean;
|
|
57
56
|
addressSuggestions: AddressSuggestion[];
|
|
57
|
+
submitAttempted: boolean;
|
|
58
58
|
};
|
|
59
59
|
type EkybSubmittingState = {
|
|
60
60
|
status: 'submitting';
|
|
@@ -86,8 +86,6 @@ declare function createEkybManager(options: CreateEkybActorOptions): Manager<Eky
|
|
|
86
86
|
setCountry(country: string): void;
|
|
87
87
|
/** Sets a form field value and triggers revalidation */
|
|
88
88
|
setField(name: string, value: string): void;
|
|
89
|
-
/** Marks a field as touched on blur, triggering "required" errors if empty */
|
|
90
|
-
blurField(name: string): void;
|
|
91
89
|
/** Adds a new UBO entry (max 8) */
|
|
92
90
|
addUbo(): void;
|
|
93
91
|
/** Removes a UBO entry by index */
|
|
@@ -107,6 +105,9 @@ declare function createEkybManager(options: CreateEkybActorOptions): Manager<Eky
|
|
|
107
105
|
};
|
|
108
106
|
type EkybManager = ReturnType<typeof createEkybManager>;
|
|
109
107
|
//#endregion
|
|
108
|
+
//#region src/modules/ekyb/ekybActions.d.ts
|
|
109
|
+
declare function computeDisplayErrors(errors: Record<string, string>, touched: Record<string, boolean>, submitAttempted: boolean, country: string, fields?: EkybFieldDef[]): DisplayErrorsResult;
|
|
110
|
+
//#endregion
|
|
110
111
|
//#region src/modules/ekyb/ekybConstants.d.ts
|
|
111
112
|
/**
|
|
112
113
|
* Countries available in all environments.
|
|
@@ -123,4 +124,4 @@ declare const DEV_ONLY_COUNTRIES: readonly EkybCountry[];
|
|
|
123
124
|
declare const ALL_COUNTRIES: readonly EkybCountry[];
|
|
124
125
|
declare function isSupportedCountry(code: string): code is EkybCountry;
|
|
125
126
|
//#endregion
|
|
126
|
-
export { ALL_COUNTRIES, DEV_ONLY_COUNTRIES, type AddressSuggestion as EkybAddressSuggestion, type EkybConfig, type EkybCountry, type EkybFieldDef, type EkybManager, type EkybState, SUPPORTED_COUNTRIES, type UboEntry, createEkybManager, ekybMachine, isSupportedCountry };
|
|
127
|
+
export { ALL_COUNTRIES, DEV_ONLY_COUNTRIES, type AddressSuggestion as EkybAddressSuggestion, type EkybConfig, type EkybCountry, type EkybFieldDef, type EkybManager, type EkybState, SUPPORTED_COUNTRIES, type UboEntry, computeDisplayErrors as computeEkybDisplayErrors, createEkybManager, ekybMachine, isSupportedCountry };
|
package/dist/ekyb.esm.js
CHANGED
|
@@ -402,13 +402,10 @@ const ekybMachine = setup({
|
|
|
402
402
|
fields,
|
|
403
403
|
values,
|
|
404
404
|
errors,
|
|
405
|
-
displayErrors: {},
|
|
406
|
-
errorParams: {},
|
|
407
405
|
isValid,
|
|
408
406
|
ubos,
|
|
409
407
|
canAddUbo: hasUbos,
|
|
410
408
|
hasUbos,
|
|
411
|
-
touched: {},
|
|
412
409
|
submitAttempted: false,
|
|
413
410
|
addressSuggestions: [],
|
|
414
411
|
_nextUboId: 2,
|
|
@@ -438,7 +435,6 @@ const ekybMachine = setup({
|
|
|
438
435
|
state: ""
|
|
439
436
|
};
|
|
440
437
|
const { errors, isValid } = computeEkybValidation(fields, newValues, country, ubos, hasUbos);
|
|
441
|
-
const { displayErrors, errorParams } = computeDisplayErrors(errors, context.touched, context.submitAttempted, country, fields);
|
|
442
438
|
return {
|
|
443
439
|
country,
|
|
444
440
|
fields,
|
|
@@ -448,9 +444,6 @@ const ekybMachine = setup({
|
|
|
448
444
|
ubos,
|
|
449
445
|
canAddUbo: hasUbos && ubos.length < UBO_INPUT_LIMIT,
|
|
450
446
|
hasUbos,
|
|
451
|
-
displayErrors,
|
|
452
|
-
errorParams,
|
|
453
|
-
submitAttempted: context.submitAttempted,
|
|
454
447
|
_nextUboId: nextId
|
|
455
448
|
};
|
|
456
449
|
}),
|
|
@@ -461,33 +454,11 @@ const ekybMachine = setup({
|
|
|
461
454
|
...context.values,
|
|
462
455
|
[name]: processed
|
|
463
456
|
};
|
|
464
|
-
const newTouched = {
|
|
465
|
-
...context.touched,
|
|
466
|
-
[name]: true
|
|
467
|
-
};
|
|
468
457
|
const { errors, isValid } = computeEkybValidation(context.fields, newValues, context.country, context.ubos, context.hasUbos);
|
|
469
|
-
const { displayErrors, errorParams } = computeDisplayErrors(errors, newTouched, context.submitAttempted, context.country, context.fields);
|
|
470
458
|
return {
|
|
471
459
|
values: newValues,
|
|
472
460
|
errors,
|
|
473
|
-
isValid
|
|
474
|
-
touched: newTouched,
|
|
475
|
-
displayErrors,
|
|
476
|
-
errorParams
|
|
477
|
-
};
|
|
478
|
-
}),
|
|
479
|
-
blurField: assign(({ context, event }) => {
|
|
480
|
-
const { name } = event;
|
|
481
|
-
if (context.touched[name]) return {};
|
|
482
|
-
const newTouched = {
|
|
483
|
-
...context.touched,
|
|
484
|
-
[name]: true
|
|
485
|
-
};
|
|
486
|
-
const { displayErrors, errorParams } = computeDisplayErrors(context.errors, newTouched, context.submitAttempted, context.country, context.fields);
|
|
487
|
-
return {
|
|
488
|
-
touched: newTouched,
|
|
489
|
-
displayErrors,
|
|
490
|
-
errorParams
|
|
461
|
+
isValid
|
|
491
462
|
};
|
|
492
463
|
}),
|
|
493
464
|
addUbo: assign(({ context }) => {
|
|
@@ -499,14 +470,11 @@ const ekybMachine = setup({
|
|
|
499
470
|
}];
|
|
500
471
|
const canAddUbo = ubos.length < UBO_INPUT_LIMIT;
|
|
501
472
|
const { errors, isValid } = computeEkybValidation(context.fields, context.values, context.country, ubos, context.hasUbos);
|
|
502
|
-
const { displayErrors, errorParams } = computeDisplayErrors(errors, context.touched, context.submitAttempted, context.country, context.fields);
|
|
503
473
|
return {
|
|
504
474
|
ubos,
|
|
505
475
|
canAddUbo,
|
|
506
476
|
errors,
|
|
507
477
|
isValid,
|
|
508
|
-
displayErrors,
|
|
509
|
-
errorParams,
|
|
510
478
|
_nextUboId: newId + 1
|
|
511
479
|
};
|
|
512
480
|
}),
|
|
@@ -514,75 +482,39 @@ const ekybMachine = setup({
|
|
|
514
482
|
const { index } = event;
|
|
515
483
|
const ubos = context.ubos.filter((_, i) => i !== index);
|
|
516
484
|
const canAddUbo = ubos.length < UBO_INPUT_LIMIT;
|
|
517
|
-
const touched = {};
|
|
518
|
-
for (const [key, val] of Object.entries(context.touched)) {
|
|
519
|
-
const match = key.match(/^ubo-(\d+)-(name|surname)$/);
|
|
520
|
-
if (!match) {
|
|
521
|
-
touched[key] = val;
|
|
522
|
-
continue;
|
|
523
|
-
}
|
|
524
|
-
const oldIdx = Number(match[1]);
|
|
525
|
-
if (oldIdx === index) continue;
|
|
526
|
-
const newIdx = oldIdx > index ? oldIdx - 1 : oldIdx;
|
|
527
|
-
touched[`ubo-${newIdx}-${match[2]}`] = val;
|
|
528
|
-
}
|
|
529
485
|
const { errors, isValid } = computeEkybValidation(context.fields, context.values, context.country, ubos, context.hasUbos);
|
|
530
|
-
const { displayErrors, errorParams } = computeDisplayErrors(errors, touched, context.submitAttempted, context.country, context.fields);
|
|
531
486
|
return {
|
|
532
487
|
ubos,
|
|
533
488
|
canAddUbo,
|
|
534
489
|
errors,
|
|
535
|
-
isValid
|
|
536
|
-
displayErrors,
|
|
537
|
-
errorParams,
|
|
538
|
-
touched
|
|
490
|
+
isValid
|
|
539
491
|
};
|
|
540
492
|
}),
|
|
541
493
|
setUboField: assign(({ context, event }) => {
|
|
542
494
|
const { index, field, value } = event;
|
|
543
|
-
const uboKey = `ubo-${index}-${field}`;
|
|
544
495
|
const ubos = context.ubos.map((ubo, i) => i === index ? {
|
|
545
496
|
...ubo,
|
|
546
497
|
[field]: value
|
|
547
498
|
} : ubo);
|
|
548
|
-
const newTouched = {
|
|
549
|
-
...context.touched,
|
|
550
|
-
[uboKey]: true
|
|
551
|
-
};
|
|
552
499
|
const { errors, isValid } = computeEkybValidation(context.fields, context.values, context.country, ubos, context.hasUbos);
|
|
553
|
-
const { displayErrors, errorParams } = computeDisplayErrors(errors, newTouched, context.submitAttempted, context.country, context.fields);
|
|
554
500
|
return {
|
|
555
501
|
ubos,
|
|
556
502
|
errors,
|
|
557
|
-
isValid
|
|
558
|
-
touched: newTouched,
|
|
559
|
-
displayErrors,
|
|
560
|
-
errorParams
|
|
503
|
+
isValid
|
|
561
504
|
};
|
|
562
505
|
}),
|
|
563
506
|
setErrorMessage: assign(({ event }) => ({ errorMessage: String(event.error ?? "verification.error") })),
|
|
564
507
|
clearErrorMessage: assign({ errorMessage: () => "" }),
|
|
565
|
-
markSubmitAttempted: assign(
|
|
566
|
-
const { displayErrors, errorParams } = computeDisplayErrors(context.errors, context.touched, true, context.country, context.fields);
|
|
567
|
-
return {
|
|
568
|
-
submitAttempted: true,
|
|
569
|
-
displayErrors,
|
|
570
|
-
errorParams
|
|
571
|
-
};
|
|
572
|
-
}),
|
|
508
|
+
markSubmitAttempted: assign({ submitAttempted: () => true }),
|
|
573
509
|
fillAddressFields: assign(({ context, event }) => {
|
|
574
510
|
const { suggestion } = event;
|
|
575
|
-
const { values: newValues
|
|
511
|
+
const { values: newValues } = fillFromSuggestion(context.values, {}, suggestion);
|
|
576
512
|
const { errors, isValid } = computeEkybValidation(context.fields, newValues, context.country, context.ubos, context.hasUbos);
|
|
577
|
-
const { displayErrors, errorParams } = computeDisplayErrors(errors, newTouched, context.submitAttempted, context.country, context.fields);
|
|
578
513
|
return {
|
|
579
514
|
values: newValues,
|
|
580
515
|
addressSuggestions: [],
|
|
581
516
|
errors,
|
|
582
|
-
isValid
|
|
583
|
-
touched: newTouched,
|
|
584
|
-
displayErrors,
|
|
585
|
-
errorParams
|
|
517
|
+
isValid
|
|
586
518
|
};
|
|
587
519
|
}),
|
|
588
520
|
setAddressSuggestions: assign(({ event }) => ({ addressSuggestions: event.suggestions })),
|
|
@@ -629,14 +561,11 @@ const ekybMachine = setup({
|
|
|
629
561
|
fields,
|
|
630
562
|
values,
|
|
631
563
|
errors,
|
|
632
|
-
displayErrors: {},
|
|
633
|
-
errorParams: {},
|
|
634
564
|
isValid,
|
|
635
565
|
ubos,
|
|
636
566
|
canAddUbo: hasUbos,
|
|
637
567
|
hasUbos,
|
|
638
568
|
errorMessage: "",
|
|
639
|
-
touched: {},
|
|
640
569
|
submitAttempted: false,
|
|
641
570
|
addressSuggestions: [],
|
|
642
571
|
_nextUboId: 2,
|
|
@@ -681,7 +610,6 @@ const ekybMachine = setup({
|
|
|
681
610
|
actions: "setCountry"
|
|
682
611
|
},
|
|
683
612
|
SET_FIELD: { actions: "updateField" },
|
|
684
|
-
BLUR_FIELD: { actions: "blurField" },
|
|
685
613
|
SEARCH_ADDRESS: {
|
|
686
614
|
target: ".searching",
|
|
687
615
|
actions: assign(({ event }) => ({
|
|
@@ -757,12 +685,12 @@ function mapState(snapshot) {
|
|
|
757
685
|
availableCountries: context.availableCountries,
|
|
758
686
|
fields: context.fields,
|
|
759
687
|
values: context.values,
|
|
760
|
-
|
|
761
|
-
errorParams: context.errorParams,
|
|
688
|
+
errors: context.errors,
|
|
762
689
|
isValid: context.isValid,
|
|
763
690
|
ubos: context.ubos,
|
|
764
691
|
canAddUbo: context.canAddUbo,
|
|
765
|
-
addressSuggestions: context.addressSuggestions
|
|
692
|
+
addressSuggestions: context.addressSuggestions,
|
|
693
|
+
submitAttempted: context.submitAttempted
|
|
766
694
|
};
|
|
767
695
|
if (typedSnapshot.matches("submitting")) return { status: "submitting" };
|
|
768
696
|
if (typedSnapshot.matches("success")) return { status: "success" };
|
|
@@ -792,12 +720,6 @@ function createApi({ actor }) {
|
|
|
792
720
|
value
|
|
793
721
|
});
|
|
794
722
|
},
|
|
795
|
-
blurField(name) {
|
|
796
|
-
actor.send({
|
|
797
|
-
type: "BLUR_FIELD",
|
|
798
|
-
name
|
|
799
|
-
});
|
|
800
|
-
},
|
|
801
723
|
addUbo() {
|
|
802
724
|
actor.send({ type: "ADD_UBO" });
|
|
803
725
|
},
|
|
@@ -850,4 +772,4 @@ function createEkybManager(options) {
|
|
|
850
772
|
}
|
|
851
773
|
|
|
852
774
|
//#endregion
|
|
853
|
-
export { ALL_COUNTRIES, DEV_ONLY_COUNTRIES, SUPPORTED_COUNTRIES, createEkybManager, ekybMachine, isSupportedCountry };
|
|
775
|
+
export { ALL_COUNTRIES, DEV_ONLY_COUNTRIES, SUPPORTED_COUNTRIES, computeDisplayErrors as computeEkybDisplayErrors, createEkybManager, ekybMachine, isSupportedCountry };
|
package/dist/ekyc.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as Manager } from "./Manager-DsNvecSe.js";
|
|
2
|
-
import { n as FieldDef, t as
|
|
2
|
+
import { n as AddressSuggestion, r as FieldDef, t as DisplayErrorsResult } from "./displayErrors-B2eFGhh_.js";
|
|
3
3
|
|
|
4
4
|
//#region src/modules/ekyc/types.d.ts
|
|
5
5
|
type EkycFieldSource = 'user_input' | 'document_scan' | 'poa_document' | 'phone_module_input' | 'email_module_input' | false;
|
|
@@ -85,14 +85,13 @@ type EkycFormState = {
|
|
|
85
85
|
fields: EkycFieldDef[];
|
|
86
86
|
values: EkycFormValues;
|
|
87
87
|
errors: Record<string, string>;
|
|
88
|
-
displayErrors: Record<string, string>;
|
|
89
|
-
errorParams: Record<string, Record<string, string | number>>;
|
|
90
88
|
isValid: boolean;
|
|
91
89
|
addressSuggestions: AddressSuggestion[];
|
|
92
90
|
prefilled: Record<string, boolean>;
|
|
93
91
|
hideEmail: boolean;
|
|
94
92
|
fieldsCountry: string;
|
|
95
93
|
submitError: string;
|
|
94
|
+
submitAttempted: boolean;
|
|
96
95
|
};
|
|
97
96
|
type EkycSubmittingState = {
|
|
98
97
|
status: 'submitting';
|
|
@@ -125,8 +124,6 @@ declare function createEkycManager(options: CreateEkycActorOptions): Manager<Eky
|
|
|
125
124
|
load(): void;
|
|
126
125
|
/** Sets a form field value and triggers revalidation */
|
|
127
126
|
setField(name: string, value: string): void;
|
|
128
|
-
/** Marks a field as touched on blur, triggering "required" errors if empty */
|
|
129
|
-
blurField(name: string): void;
|
|
130
127
|
/** Initiates a debounced address autocomplete search */
|
|
131
128
|
searchAddress(query: string): void;
|
|
132
129
|
/** Selects an address suggestion and populates address fields */
|
|
@@ -142,4 +139,7 @@ declare function createEkycManager(options: CreateEkycActorOptions): Manager<Eky
|
|
|
142
139
|
};
|
|
143
140
|
type EkycManager = ReturnType<typeof createEkycManager>;
|
|
144
141
|
//#endregion
|
|
145
|
-
|
|
142
|
+
//#region src/modules/ekyc/ekycActions.d.ts
|
|
143
|
+
declare function computeDisplayErrors(errors: Record<string, string>, touched: Record<string, boolean>, submitAttempted: boolean, country: string, fields?: EkycFieldDef[]): DisplayErrorsResult;
|
|
144
|
+
//#endregion
|
|
145
|
+
export { type AddressSuggestion, type EkycConfig, type EkycManager, type EkycModuleConfig, type EkycState, computeDisplayErrors as computeEkycDisplayErrors, createEkycManager, ekycMachine };
|
package/dist/ekyc.esm.js
CHANGED
|
@@ -9884,6 +9884,7 @@ function getEKYCCountry(source) {
|
|
|
9884
9884
|
function isFieldOptional(fieldName, configSource) {
|
|
9885
9885
|
if (fieldName === "middleName") return true;
|
|
9886
9886
|
if (fieldName === "dateOfBirth") return DOB_OPTIONAL_SOURCES.includes(configSource);
|
|
9887
|
+
if (fieldName === "street") return false;
|
|
9887
9888
|
if (ADDRESS_FIELDS.includes(fieldName)) return ADDRESS_OPTIONAL_SOURCES.includes(configSource);
|
|
9888
9889
|
if (fieldName === "last4SSN") return LAST4SSN_OPTIONAL_SOURCES.includes(configSource);
|
|
9889
9890
|
if (DRIVERS_LICENSE_FIELDS.includes(fieldName)) return DRIVERS_LICENSE_OPTIONAL_SOURCES.includes(configSource);
|
|
@@ -9973,7 +9974,7 @@ function buildFieldDefs(fields, configSource, country, enablePhoneRisk = false)
|
|
|
9973
9974
|
maxLength: 100,
|
|
9974
9975
|
placeholder: "verification.placeholder.firstName"
|
|
9975
9976
|
});
|
|
9976
|
-
if (configSource === "US_CREDIT_BUREAU_1" || configSource === "CA_RES_CREDIT" || country === "IN") add("middleName", "text", "verification.labels.middleName", fields.name, {
|
|
9977
|
+
if (configSource === "US_CREDIT_BUREAU_1" || configSource === "CA_RES_CREDIT" || configSource === "UK_VOTER_REGISTER" || country === "IN") add("middleName", "text", "verification.labels.middleName", fields.name, {
|
|
9977
9978
|
maxLength: 100,
|
|
9978
9979
|
placeholder: "verification.placeholder.middleName",
|
|
9979
9980
|
optional: true
|
|
@@ -10029,11 +10030,12 @@ function buildFieldDefs(fields, configSource, country, enablePhoneRisk = false)
|
|
|
10029
10030
|
label: "common.male"
|
|
10030
10031
|
}] });
|
|
10031
10032
|
if (fields.panNumber) add("panNumber", "text", "verification.labels.panNumber", fields.panNumber, { maxLength: 10 });
|
|
10032
|
-
|
|
10033
|
+
const addAddressFields = () => {
|
|
10034
|
+
if (!fields.address) return;
|
|
10033
10035
|
add("street", "text", "verification.labels.street", fields.address, { section: "address" });
|
|
10034
10036
|
add("houseNo", "text", "verification.labels.houseNo", fields.address, { section: "address" });
|
|
10035
10037
|
add("city", "text", "verification.labels.city", fields.address, { section: "address" });
|
|
10036
|
-
add("state", country === "US" ? "dropdown" : "text", "verification.labels.state", fields.address, {
|
|
10038
|
+
add("state", country === "US" ? "dropdown" : "text", country === "US" ? "verification.labels.chooseState" : "verification.labels.state", fields.address, {
|
|
10037
10039
|
section: "address",
|
|
10038
10040
|
...country === "US" ? {
|
|
10039
10041
|
options: usStateOptions,
|
|
@@ -10047,14 +10049,23 @@ function buildFieldDefs(fields, configSource, country, enablePhoneRisk = false)
|
|
|
10047
10049
|
section: "address",
|
|
10048
10050
|
maxLength: getPostalCodeMaxLength(country)
|
|
10049
10051
|
});
|
|
10052
|
+
};
|
|
10053
|
+
const addDriversLicenseFields = () => {
|
|
10054
|
+
if (fields.dlNumber) add("dlNumber", "text", "verification.labels.dlNumber", fields.dlNumber, { section: "driverLicense" });
|
|
10055
|
+
if (fields.dlState) add("dlState", "dropdown", "verification.labels.dlState", fields.dlState, {
|
|
10056
|
+
section: "driverLicense",
|
|
10057
|
+
options: usStateOptions,
|
|
10058
|
+
placeholder: "verification.placeholders.selectState"
|
|
10059
|
+
});
|
|
10060
|
+
if (fields.dlExpireAt) add("dlExpireAt", "date", "verification.labels.dlExpireAt", fields.dlExpireAt, { section: "driverLicense" });
|
|
10061
|
+
};
|
|
10062
|
+
if (configSource === "US_TELCO_1") {
|
|
10063
|
+
addDriversLicenseFields();
|
|
10064
|
+
addAddressFields();
|
|
10065
|
+
} else {
|
|
10066
|
+
addAddressFields();
|
|
10067
|
+
addDriversLicenseFields();
|
|
10050
10068
|
}
|
|
10051
|
-
if (fields.dlNumber) add("dlNumber", "text", "verification.labels.dlNumber", fields.dlNumber, { section: "driverLicense" });
|
|
10052
|
-
if (fields.dlState) add("dlState", "dropdown", "verification.labels.dlState", fields.dlState, {
|
|
10053
|
-
section: "driverLicense",
|
|
10054
|
-
options: usStateOptions,
|
|
10055
|
-
placeholder: "verification.placeholders.selectState"
|
|
10056
|
-
});
|
|
10057
|
-
if (fields.dlExpireAt) add("dlExpireAt", "date", "verification.labels.dlExpireAt", fields.dlExpireAt, { section: "driverLicense" });
|
|
10058
10069
|
return defs;
|
|
10059
10070
|
}
|
|
10060
10071
|
function validateField(name, value, required, country, configSource) {
|
|
@@ -10336,9 +10347,7 @@ const ekycMachine = setup({
|
|
|
10336
10347
|
hideEmail,
|
|
10337
10348
|
fields: updatedFields,
|
|
10338
10349
|
errors,
|
|
10339
|
-
isValid
|
|
10340
|
-
displayErrors: {},
|
|
10341
|
-
errorParams: {}
|
|
10350
|
+
isValid
|
|
10342
10351
|
};
|
|
10343
10352
|
}),
|
|
10344
10353
|
updateField: assign(({ context, event }) => {
|
|
@@ -10348,49 +10357,23 @@ const ekycMachine = setup({
|
|
|
10348
10357
|
...context.values,
|
|
10349
10358
|
[name]: processedValue
|
|
10350
10359
|
};
|
|
10351
|
-
const newTouched = {
|
|
10352
|
-
...context.touched,
|
|
10353
|
-
[name]: true
|
|
10354
|
-
};
|
|
10355
10360
|
const { errors, isValid } = computeValidation(context.fields, newValues, context.fieldsCountry, context.configSource);
|
|
10356
|
-
const { displayErrors, errorParams } = computeDisplayErrors(errors, newTouched, context.submitAttempted, context.fieldsCountry, context.fields);
|
|
10357
10361
|
return {
|
|
10358
10362
|
values: newValues,
|
|
10359
10363
|
errors,
|
|
10360
10364
|
isValid,
|
|
10361
|
-
touched: newTouched,
|
|
10362
|
-
displayErrors,
|
|
10363
|
-
errorParams,
|
|
10364
10365
|
submitError: ""
|
|
10365
10366
|
};
|
|
10366
10367
|
}),
|
|
10367
|
-
blurField: assign(({ context, event }) => {
|
|
10368
|
-
const { name } = event;
|
|
10369
|
-
if (context.touched[name]) return {};
|
|
10370
|
-
const newTouched = {
|
|
10371
|
-
...context.touched,
|
|
10372
|
-
[name]: true
|
|
10373
|
-
};
|
|
10374
|
-
const { displayErrors, errorParams } = computeDisplayErrors(context.errors, newTouched, context.submitAttempted, context.fieldsCountry, context.fields);
|
|
10375
|
-
return {
|
|
10376
|
-
touched: newTouched,
|
|
10377
|
-
displayErrors,
|
|
10378
|
-
errorParams
|
|
10379
|
-
};
|
|
10380
|
-
}),
|
|
10381
10368
|
fillAddressFields: assign(({ context, event }) => {
|
|
10382
10369
|
const { suggestion } = event;
|
|
10383
|
-
const { values: newValues
|
|
10370
|
+
const { values: newValues } = fillFromSuggestion(context.values, {}, suggestion);
|
|
10384
10371
|
const { errors, isValid } = computeValidation(context.fields, newValues, context.fieldsCountry, context.configSource);
|
|
10385
|
-
const { displayErrors, errorParams } = computeDisplayErrors(errors, newTouched, context.submitAttempted, context.fieldsCountry, context.fields);
|
|
10386
10372
|
return {
|
|
10387
10373
|
values: newValues,
|
|
10388
10374
|
addressSuggestions: [],
|
|
10389
10375
|
errors,
|
|
10390
10376
|
isValid,
|
|
10391
|
-
touched: newTouched,
|
|
10392
|
-
displayErrors,
|
|
10393
|
-
errorParams,
|
|
10394
10377
|
submitError: ""
|
|
10395
10378
|
};
|
|
10396
10379
|
}),
|
|
@@ -10399,14 +10382,7 @@ const ekycMachine = setup({
|
|
|
10399
10382
|
clearErrorMessage: assign({ errorMessage: () => "" }),
|
|
10400
10383
|
setSubmitError: assign(() => ({ submitError: "verification.errors.countryNotSupported" })),
|
|
10401
10384
|
clearSubmitError: assign({ submitError: () => "" }),
|
|
10402
|
-
markSubmitAttempted: assign(
|
|
10403
|
-
const { displayErrors, errorParams } = computeDisplayErrors(context.errors, context.touched, true, context.fieldsCountry, context.fields);
|
|
10404
|
-
return {
|
|
10405
|
-
submitAttempted: true,
|
|
10406
|
-
displayErrors,
|
|
10407
|
-
errorParams
|
|
10408
|
-
};
|
|
10409
|
-
}),
|
|
10385
|
+
markSubmitAttempted: assign({ submitAttempted: () => true }),
|
|
10410
10386
|
trackModuleOpen: () => {
|
|
10411
10387
|
addEvent({
|
|
10412
10388
|
code: "open",
|
|
@@ -10460,15 +10436,12 @@ const ekycMachine = setup({
|
|
|
10460
10436
|
fields: [],
|
|
10461
10437
|
values: {},
|
|
10462
10438
|
errors: {},
|
|
10463
|
-
displayErrors: {},
|
|
10464
|
-
errorParams: {},
|
|
10465
10439
|
isValid: false,
|
|
10466
10440
|
addressSuggestions: [],
|
|
10467
10441
|
prefilled: {},
|
|
10468
10442
|
hideEmail: false,
|
|
10469
10443
|
errorMessage: "",
|
|
10470
10444
|
submitError: "",
|
|
10471
|
-
touched: {},
|
|
10472
10445
|
submitAttempted: false,
|
|
10473
10446
|
_searchQuery: ""
|
|
10474
10447
|
}),
|
|
@@ -10543,7 +10516,6 @@ const ekycMachine = setup({
|
|
|
10543
10516
|
},
|
|
10544
10517
|
on: {
|
|
10545
10518
|
SET_FIELD: { actions: "updateField" },
|
|
10546
|
-
BLUR_FIELD: { actions: "blurField" },
|
|
10547
10519
|
SEARCH_ADDRESS: {
|
|
10548
10520
|
target: ".searching",
|
|
10549
10521
|
actions: assign(({ event }) => ({
|
|
@@ -10559,6 +10531,7 @@ const ekycMachine = setup({
|
|
|
10559
10531
|
target: "submitting",
|
|
10560
10532
|
guard: "isValid"
|
|
10561
10533
|
}, { actions: "markSubmitAttempted" }],
|
|
10534
|
+
SKIP: { target: "#ekyc.finished" },
|
|
10562
10535
|
CLOSE: { target: "#ekyc.closed" }
|
|
10563
10536
|
}
|
|
10564
10537
|
},
|
|
@@ -10621,14 +10594,13 @@ function mapState(snapshot) {
|
|
|
10621
10594
|
fields: context.fields,
|
|
10622
10595
|
values: context.values,
|
|
10623
10596
|
errors: context.errors,
|
|
10624
|
-
displayErrors: context.displayErrors,
|
|
10625
|
-
errorParams: context.errorParams,
|
|
10626
10597
|
isValid: context.isValid,
|
|
10627
10598
|
addressSuggestions: context.addressSuggestions,
|
|
10628
10599
|
prefilled: context.prefilled,
|
|
10629
10600
|
hideEmail: context.hideEmail,
|
|
10630
10601
|
fieldsCountry: context.fieldsCountry,
|
|
10631
|
-
submitError: context.submitError
|
|
10602
|
+
submitError: context.submitError,
|
|
10603
|
+
submitAttempted: context.submitAttempted
|
|
10632
10604
|
};
|
|
10633
10605
|
if (typedSnapshot.matches("submitting")) return { status: "submitting" };
|
|
10634
10606
|
if (typedSnapshot.matches("success")) return { status: "success" };
|
|
@@ -10653,12 +10625,6 @@ function createApi({ actor }) {
|
|
|
10653
10625
|
value
|
|
10654
10626
|
});
|
|
10655
10627
|
},
|
|
10656
|
-
blurField(name) {
|
|
10657
|
-
actor.send({
|
|
10658
|
-
type: "BLUR_FIELD",
|
|
10659
|
-
name
|
|
10660
|
-
});
|
|
10661
|
-
},
|
|
10662
10628
|
searchAddress(query) {
|
|
10663
10629
|
actor.send({
|
|
10664
10630
|
type: "SEARCH_ADDRESS",
|
|
@@ -10697,4 +10663,4 @@ function createEkycManager(options) {
|
|
|
10697
10663
|
}
|
|
10698
10664
|
|
|
10699
10665
|
//#endregion
|
|
10700
|
-
export { createEkycManager, ekycMachine };
|
|
10666
|
+
export { computeDisplayErrors as computeEkycDisplayErrors, createEkycManager, ekycMachine };
|