@adyen/kyc-components 2.2.6 → 2.3.1
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/dist/es/adyen-kyc-components.es.js +1721 -1573
- package/dist/types/components/BankVerification/types.d.ts +3 -5
- package/dist/types/components/BankVerification/validate.d.ts +3 -0
- package/dist/types/components/BankVerification/verification/widget/component/BankVerificationWidget.d.ts +2 -2
- package/dist/types/components/BankVerification/verification/widget/iframeWidget.d.ts +1 -4
- package/dist/types/components/Dropins/PayoutDetailsDropin/components/PayoutDetailsDropinComponent.d.ts +1 -1
- package/dist/types/components/PayoutBankStatement/component/validate.d.ts +3 -0
- package/dist/types/components/PayoutDetails/types.d.ts +1 -1
- package/dist/types/components/internal/Address/utils.d.ts +1 -1
- package/dist/types/core/hooks/useForm/types.d.ts +1 -1
- package/dist/types/core/hooks/useFormComposer.d.ts +4 -2
- package/dist/types/language/config.d.ts +1 -0
- package/dist/types/utils/decision-maker-roles.d.ts +1 -1
- package/dist/types/utils/entity-status-util.d.ts +2 -2
- package/dist/types/utils/regex/basePatterns.d.ts +1 -0
- package/dist/types/utils/trust-util.d.ts +1 -1
- package/package.json +1 -1
|
@@ -318,6 +318,7 @@ const invalidFormatIdentityNumberSE = "Please use the Personnummer format: YYYYM
|
|
|
318
318
|
const invalidFormatIdentityNumberUS = "Please provide last 4 digits";
|
|
319
319
|
const invalidFormatIdentityNumberUS9 = "Please use the SSN format: XXXXXXXXX";
|
|
320
320
|
const invalidFormatIdentityNumberSG = "Please use the NRIC format: S1234567A";
|
|
321
|
+
const invalidFormatBankStatementDescription = "Please ensure your input contains solely letters, digits, currency codes, and the specified special characters: -._,:;'*!@#%()+?¿/「」";
|
|
321
322
|
const residencyCountry = "Country of residence";
|
|
322
323
|
const stateOrProvince = "State or province";
|
|
323
324
|
const selectStateOrProvince = "Select a state or province";
|
|
@@ -1272,6 +1273,7 @@ const defaultTrans = {
|
|
|
1272
1273
|
invalidFormatIdentityNumberUS,
|
|
1273
1274
|
invalidFormatIdentityNumberUS9,
|
|
1274
1275
|
invalidFormatIdentityNumberSG,
|
|
1276
|
+
invalidFormatBankStatementDescription,
|
|
1275
1277
|
residencyCountry,
|
|
1276
1278
|
stateOrProvince,
|
|
1277
1279
|
selectStateOrProvince,
|
|
@@ -4507,6 +4509,7 @@ const lengthValidationPatterns = {
|
|
|
4507
4509
|
message: "validationEnter9Or12Digits"
|
|
4508
4510
|
}
|
|
4509
4511
|
};
|
|
4512
|
+
const bankStatementDescriptionPattern = /^[$\xA2-\xA5\u058F\u060B\u09F2\u09F3\u09FB\u0AF1\u0BF9\u0E3F\u17DB\u20A0-\u20BD\uA838\uFDFC\uFE69\uFF04\uFFE0\uFFE1\uFFE5\uFFE6a-zA-Z0-9-."_,:;'*!@#%()+?¿/&「」]*$/;
|
|
4510
4513
|
const businessRegistrationNumberPatterns = {
|
|
4511
4514
|
[CountryCodes.Australia]: {
|
|
4512
4515
|
default: {
|
|
@@ -6760,6 +6763,13 @@ const Select = ({
|
|
|
6760
6763
|
return o("div", {
|
|
6761
6764
|
className: cx(["adyen-kyc-dropdown", styles$2["adyen-kyc-dropdown"], className, ...classNameModifiers.map((m2) => `adyen-kyc-dropdown--${m2}`)]),
|
|
6762
6765
|
ref: selectContainerRef,
|
|
6766
|
+
onClick: (e2) => {
|
|
6767
|
+
e2.stopPropagation();
|
|
6768
|
+
if (filterInputRef.current) {
|
|
6769
|
+
filterInputRef.current.focus();
|
|
6770
|
+
}
|
|
6771
|
+
},
|
|
6772
|
+
role: "presentation",
|
|
6763
6773
|
children: [o(SelectButton, {
|
|
6764
6774
|
id: uniqueId2 ?? null,
|
|
6765
6775
|
active,
|
|
@@ -9815,7 +9825,7 @@ function TextArea(props) {
|
|
|
9815
9825
|
onInput: handleInput,
|
|
9816
9826
|
onBlur: handleBlur,
|
|
9817
9827
|
onFocus: handleFocus
|
|
9818
|
-
}), maxLength && charactersLeft >= 0 ? o("span", {
|
|
9828
|
+
}), !isInvalid && maxLength && charactersLeft >= 0 ? o("span", {
|
|
9819
9829
|
className: "adyen-kyc-input__counter",
|
|
9820
9830
|
children: i18n.get("xCharactersLeft", {
|
|
9821
9831
|
values: {
|
|
@@ -10596,88 +10606,92 @@ const createPatternByDigits = (digits) => ({
|
|
|
10596
10606
|
pattern: new RegExp(`\\d{${digits}}`)
|
|
10597
10607
|
});
|
|
10598
10608
|
const postalCodePatterns = {
|
|
10599
|
-
|
|
10600
|
-
|
|
10601
|
-
|
|
10609
|
+
[CountryCodes.Australia]: createPatternByDigits(4),
|
|
10610
|
+
[CountryCodes.Austria]: createPatternByDigits(4),
|
|
10611
|
+
[CountryCodes.Belgium]: {
|
|
10602
10612
|
pattern: /(?:(?:[1-9])(?:\d{3}))/
|
|
10603
10613
|
},
|
|
10604
|
-
|
|
10605
|
-
|
|
10606
|
-
|
|
10614
|
+
[CountryCodes.Brazil]: createPatternByDigits(8),
|
|
10615
|
+
[CountryCodes.Bulgaria]: createPatternByDigits(4),
|
|
10616
|
+
[CountryCodes.Canada]: {
|
|
10607
10617
|
pattern: /(?:[ABCEGHJ-NPRSTVXY]\d[A-Z][ -]?\d[A-Z]\d)/
|
|
10608
10618
|
},
|
|
10609
|
-
|
|
10610
|
-
pattern:
|
|
10619
|
+
[CountryCodes.Croatia]: {
|
|
10620
|
+
pattern: /^([1-5])[0-9]{4}$/
|
|
10611
10621
|
},
|
|
10612
|
-
|
|
10613
|
-
|
|
10622
|
+
[CountryCodes.Cyprus]: createPatternByDigits(4),
|
|
10623
|
+
[CountryCodes.CzechRepublic]: {
|
|
10614
10624
|
pattern: /\d{3}\s?\d{2}/
|
|
10615
10625
|
},
|
|
10616
|
-
|
|
10617
|
-
DK: {
|
|
10626
|
+
[CountryCodes.Denmark]: {
|
|
10618
10627
|
pattern: /^(DK-)?[0-9]{4}$/
|
|
10619
10628
|
},
|
|
10620
|
-
|
|
10621
|
-
|
|
10622
|
-
|
|
10623
|
-
|
|
10624
|
-
|
|
10625
|
-
|
|
10626
|
-
|
|
10627
|
-
pattern: /^([A-Za-z][A-Ha-hK-Yk-y]?[0-9][A-Za-z0-9]? ?[0-9][A-Za-z]{2}|[Gg][Ii][Rr] ?0[Aa]{2})$/
|
|
10629
|
+
[CountryCodes.Estonia]: createPatternByDigits(5),
|
|
10630
|
+
[CountryCodes.Finland]: createPatternByDigits(5),
|
|
10631
|
+
[CountryCodes.France]: createPatternByDigits(5),
|
|
10632
|
+
[CountryCodes.Georgia]: createPatternByDigits(4),
|
|
10633
|
+
[CountryCodes.Germany]: createPatternByDigits(5),
|
|
10634
|
+
[CountryCodes.Gibraltar]: {
|
|
10635
|
+
pattern: /^GX11[ -]?1AA$/
|
|
10628
10636
|
},
|
|
10629
|
-
|
|
10630
|
-
GR: {
|
|
10637
|
+
[CountryCodes.Greece]: {
|
|
10631
10638
|
pattern: /^\d{3}\s{0,1}\d{2}$/
|
|
10632
10639
|
},
|
|
10633
|
-
|
|
10634
|
-
|
|
10635
|
-
|
|
10636
|
-
HU: createPatternByDigits(4),
|
|
10637
|
-
IE: {
|
|
10640
|
+
[CountryCodes.Hungary]: createPatternByDigits(4),
|
|
10641
|
+
[CountryCodes.Iceland]: createPatternByDigits(3),
|
|
10642
|
+
[CountryCodes.Ireland]: {
|
|
10638
10643
|
pattern: /(?:^[AC-FHKNPRTV-Y][0-9]{2}|D6W)[ -]?[0-9AC-FHKNPRTV-Y]{4}/
|
|
10639
10644
|
},
|
|
10640
|
-
|
|
10641
|
-
|
|
10642
|
-
|
|
10643
|
-
LT: {
|
|
10644
|
-
pattern: /^(LT-)?[0-9]{4,5}$/
|
|
10645
|
+
[CountryCodes.Italy]: createPatternByDigits(5),
|
|
10646
|
+
[CountryCodes.Japan]: {
|
|
10647
|
+
pattern: /^\d{3}[-]\d{4}$/
|
|
10645
10648
|
},
|
|
10646
|
-
|
|
10647
|
-
LV: {
|
|
10649
|
+
[CountryCodes.Latvia]: {
|
|
10648
10650
|
pattern: /^(LV-)?[0-9]{4}$/
|
|
10649
10651
|
},
|
|
10650
|
-
|
|
10651
|
-
|
|
10652
|
+
[CountryCodes.Liechtenstein]: createPatternByDigits(4),
|
|
10653
|
+
[CountryCodes.Lithuania]: {
|
|
10654
|
+
pattern: /^(LT-)?[0-9]{4,5}$/
|
|
10652
10655
|
},
|
|
10653
|
-
|
|
10656
|
+
[CountryCodes.Luxembourg]: createPatternByDigits(4),
|
|
10657
|
+
[CountryCodes.Malaysia]: createPatternByDigits(5),
|
|
10658
|
+
[CountryCodes.Malta]: {
|
|
10654
10659
|
pattern: /^[A-Za-z]{2,3}[ ]?\d{2}(?:\d{2})?$/
|
|
10655
10660
|
},
|
|
10656
|
-
|
|
10657
|
-
|
|
10658
|
-
|
|
10661
|
+
[CountryCodes.Monaco]: {
|
|
10662
|
+
pattern: /^980\d{2}$/
|
|
10663
|
+
},
|
|
10664
|
+
[CountryCodes.Netherlands]: {
|
|
10659
10665
|
pattern: /(?:NL-)?(?:[1-9]\d{3} ?(?:[A-EGHJ-NPRTVWXZ][A-EGHJ-NPRSTVWXZ]|S[BCEGHJ-NPRTVWXZ]))/
|
|
10660
10666
|
},
|
|
10661
|
-
|
|
10662
|
-
|
|
10667
|
+
[CountryCodes.NewZealand]: createPatternByDigits(4),
|
|
10668
|
+
[CountryCodes.Norway]: createPatternByDigits(4),
|
|
10669
|
+
[CountryCodes.Poland]: {
|
|
10663
10670
|
pattern: /^\d{2}[-]\d{3}$/
|
|
10664
10671
|
},
|
|
10665
|
-
|
|
10672
|
+
[CountryCodes.Portugal]: {
|
|
10666
10673
|
pattern: /^([1-9]\d{3})([- ]?(\d{3})? *)$/
|
|
10667
10674
|
},
|
|
10668
|
-
|
|
10669
|
-
|
|
10675
|
+
[CountryCodes.PuertoRico]: createPatternByDigits(5),
|
|
10676
|
+
[CountryCodes.Romania]: createPatternByDigits(6),
|
|
10677
|
+
[CountryCodes.Slovakia]: {
|
|
10678
|
+
pattern: /^(SK-)?[0-9]{5}$/
|
|
10679
|
+
},
|
|
10680
|
+
[CountryCodes.Slovenia]: {
|
|
10670
10681
|
pattern: /^(SI-)?[0-9]{4}$/
|
|
10671
10682
|
},
|
|
10672
|
-
|
|
10673
|
-
|
|
10674
|
-
|
|
10675
|
-
pattern: /^(SK-)?[0-9]{5}$/
|
|
10683
|
+
[CountryCodes.Singapore]: createPatternByDigits(6),
|
|
10684
|
+
[CountryCodes.Spain]: {
|
|
10685
|
+
pattern: /(?:0[1-9]|[1-4]\d|5[0-2])\d{3}/
|
|
10676
10686
|
},
|
|
10677
|
-
|
|
10678
|
-
|
|
10687
|
+
[CountryCodes.Sweden]: createPatternByDigits(5),
|
|
10688
|
+
[CountryCodes.Switzerland]: {
|
|
10689
|
+
pattern: /[1-9]\d{3}/
|
|
10679
10690
|
},
|
|
10680
|
-
|
|
10691
|
+
[CountryCodes.UnitedKingdom]: {
|
|
10692
|
+
pattern: /^([A-Za-z][A-Ha-hK-Yk-y]?[0-9][A-Za-z0-9]? ?[0-9][A-Za-z]{2}|[Gg][Ii][Rr] ?0[Aa]{2})$/
|
|
10693
|
+
},
|
|
10694
|
+
[CountryCodes.UnitedStates]: {
|
|
10681
10695
|
pattern: /^(\d{5})([-]?(\d{4})? *)$/
|
|
10682
10696
|
}
|
|
10683
10697
|
};
|
|
@@ -14471,9 +14485,10 @@ function IdentityAuComponent(props) {
|
|
|
14471
14485
|
maskedFields: props.maskedFields
|
|
14472
14486
|
});
|
|
14473
14487
|
p(() => {
|
|
14488
|
+
console.log("triggerValidation");
|
|
14474
14489
|
if (data.typeOfIdentity)
|
|
14475
14490
|
triggerValidation(["idNumber"]);
|
|
14476
|
-
}, [
|
|
14491
|
+
}, [data.typeOfIdentity]);
|
|
14477
14492
|
const {
|
|
14478
14493
|
sliceData,
|
|
14479
14494
|
updateStateSlice
|
|
@@ -15856,6 +15871,33 @@ const currencyByCountry = {
|
|
|
15856
15871
|
[CountryCodes.UnitedKingdom]: [Currency.GBP, Currency.EUR],
|
|
15857
15872
|
[CountryCodes.UnitedStates]: [Currency.USD]
|
|
15858
15873
|
};
|
|
15874
|
+
const bankVerificationValidationRules = {
|
|
15875
|
+
verifiedAccountHolder: {
|
|
15876
|
+
modes: ["blur"],
|
|
15877
|
+
validate: (verifiedAccountHolder) => !isEmpty(verifiedAccountHolder),
|
|
15878
|
+
errorMessage: "fieldIsRequired"
|
|
15879
|
+
},
|
|
15880
|
+
verifiedBankCountry: {
|
|
15881
|
+
modes: ["blur"],
|
|
15882
|
+
validate: (verifiedBankCountry) => !isEmpty(verifiedBankCountry),
|
|
15883
|
+
errorMessage: "fieldIsRequired"
|
|
15884
|
+
},
|
|
15885
|
+
verifiedBankName: {
|
|
15886
|
+
modes: ["blur"],
|
|
15887
|
+
validate: (verifiedBankName) => !isEmpty(verifiedBankName),
|
|
15888
|
+
errorMessage: "fieldIsRequired"
|
|
15889
|
+
},
|
|
15890
|
+
verifiedCurrencyCode: {
|
|
15891
|
+
modes: ["blur"],
|
|
15892
|
+
validate: (verifiedCurrencyCode) => !isEmpty(verifiedCurrencyCode),
|
|
15893
|
+
errorMessage: "fieldIsRequired"
|
|
15894
|
+
},
|
|
15895
|
+
verifiedBankAccountNumber: {
|
|
15896
|
+
modes: ["blur"],
|
|
15897
|
+
validate: (verifiedBankAccountNumber) => !isEmpty(verifiedBankAccountNumber),
|
|
15898
|
+
errorMessage: "fieldIsRequired"
|
|
15899
|
+
}
|
|
15900
|
+
};
|
|
15859
15901
|
const BankVerificationWidget$1 = "";
|
|
15860
15902
|
class AdyenKycSdkError extends Error {
|
|
15861
15903
|
constructor(message, sourceError) {
|
|
@@ -15893,11 +15935,10 @@ const removeElementSiblings = (element) => {
|
|
|
15893
15935
|
child = child.nextSibling;
|
|
15894
15936
|
}
|
|
15895
15937
|
};
|
|
15896
|
-
const vendorIdentifiers = ["Tink", "PayWithMyBank"];
|
|
15897
|
-
const [TINK_VENDOR, TRUSTLY_VENDOR] = vendorIdentifiers;
|
|
15898
15938
|
const RELEVANT_MESSAGE_TYPES = ["account_verification_report_id", "error"];
|
|
15899
15939
|
const TERMINAL_DATA_PROPS = ["accounts", "error", "reference"];
|
|
15900
15940
|
const MOUNT_TIMEOUT = 10 * 1e3;
|
|
15941
|
+
const TINK_VENDOR = "Tink";
|
|
15901
15942
|
const logger$7 = createLogger("iframeWidget");
|
|
15902
15943
|
const isObjectData = (data) => typeof data === "object" && !Array.isArray(data) && data !== null;
|
|
15903
15944
|
const isTerminalMessageData = (data) => Object.entries(data).some(([prop]) => TERMINAL_DATA_PROPS.includes(prop));
|
|
@@ -16191,7 +16232,7 @@ const usePreferredVendorForCountry = (country2, getBankVerificationVendors) => {
|
|
|
16191
16232
|
const getPreferredVendor = async () => {
|
|
16192
16233
|
const vendors = await getBankVerificationVendors(country2);
|
|
16193
16234
|
const preferredVendor2 = vendors[0];
|
|
16194
|
-
setPreferredVendor(
|
|
16235
|
+
setPreferredVendor(preferredVendor2.name ? preferredVendor2 : null);
|
|
16195
16236
|
};
|
|
16196
16237
|
getPreferredVendor().catch(logger$6.error);
|
|
16197
16238
|
}, [country2, getBankVerificationVendors]);
|
|
@@ -16279,7 +16320,11 @@ function BankVerification(props) {
|
|
|
16279
16320
|
getBankVerificationVendors,
|
|
16280
16321
|
setBankVerificationError,
|
|
16281
16322
|
onBack,
|
|
16282
|
-
hideDropinLayout
|
|
16323
|
+
hideDropinLayout,
|
|
16324
|
+
setBankInfoValidated,
|
|
16325
|
+
hideOnHomeButton,
|
|
16326
|
+
bankInfoValidated,
|
|
16327
|
+
formIsActive
|
|
16283
16328
|
} = props;
|
|
16284
16329
|
const {
|
|
16285
16330
|
i18n
|
|
@@ -16302,7 +16347,7 @@ function BankVerification(props) {
|
|
|
16302
16347
|
...props,
|
|
16303
16348
|
schema,
|
|
16304
16349
|
defaultData: props.data,
|
|
16305
|
-
rules:
|
|
16350
|
+
rules: bankVerificationValidationRules,
|
|
16306
16351
|
fieldProblems: props == null ? void 0 : props.fieldValidationErrors
|
|
16307
16352
|
});
|
|
16308
16353
|
const retrieveBankAccountInfo = async ({
|
|
@@ -16316,9 +16361,9 @@ function BankVerification(props) {
|
|
|
16316
16361
|
handleChangeFor("verifiedBankCountry")(props.country);
|
|
16317
16362
|
handleChangeFor("verifiedAccountHolder")(props.data.verifiedAccountHolder);
|
|
16318
16363
|
handleChangeFor("verifiedCurrencyCode")(props.data.verifiedCurrencyCode ?? ((_a = currencyByCountry[props.country]) == null ? void 0 : _a[0]));
|
|
16319
|
-
|
|
16364
|
+
setBankInfoValidated(true);
|
|
16320
16365
|
hideDropinLayout(false);
|
|
16321
|
-
|
|
16366
|
+
hideOnHomeButton(true);
|
|
16322
16367
|
triggerValidation();
|
|
16323
16368
|
await ((_b = props.refreshLegalEntity) == null ? void 0 : _b.call(props));
|
|
16324
16369
|
};
|
|
@@ -16337,14 +16382,14 @@ function BankVerification(props) {
|
|
|
16337
16382
|
});
|
|
16338
16383
|
}, [data, valid, errors, isValid]);
|
|
16339
16384
|
p(() => {
|
|
16340
|
-
hideDropinLayout(
|
|
16385
|
+
hideDropinLayout(formIsActive && !bankInfoValidated);
|
|
16341
16386
|
return () => hideDropinLayout(false);
|
|
16342
|
-
}, [
|
|
16387
|
+
}, [bankInfoValidated, formIsActive]);
|
|
16343
16388
|
return o(Fragment, {
|
|
16344
16389
|
children: [o(StateContextSetter, {
|
|
16345
16390
|
owner: ACCOUNT_VERIFICATION,
|
|
16346
16391
|
stateRef
|
|
16347
|
-
}),
|
|
16392
|
+
}), bankInfoValidated && o(Fragment, {
|
|
16348
16393
|
children: [o(FormHeader, {
|
|
16349
16394
|
heading: props.heading
|
|
16350
16395
|
}), o("div", {
|
|
@@ -16359,7 +16404,7 @@ function BankVerification(props) {
|
|
|
16359
16404
|
children: [" ", i18n.get("youSuccessfullyVerifiedAccount")]
|
|
16360
16405
|
})]
|
|
16361
16406
|
})]
|
|
16362
|
-
}), typeof getBankVerificationVendors === "function" &&
|
|
16407
|
+
}), typeof getBankVerificationVendors === "function" && formIsActive && !bankInfoValidated && o("div", {
|
|
16363
16408
|
className: "adyen-kyc-bank-verification-container",
|
|
16364
16409
|
children: o(InstantBankVerification, {
|
|
16365
16410
|
getBankVerificationVendors,
|
|
@@ -17381,6 +17426,13 @@ const BankDocumentRequirements = ({
|
|
|
17381
17426
|
})]
|
|
17382
17427
|
});
|
|
17383
17428
|
};
|
|
17429
|
+
const payoutBankStatementValidationRules = {
|
|
17430
|
+
description: {
|
|
17431
|
+
modes: ["blur"],
|
|
17432
|
+
validate: (description2) => description2 ? bankStatementDescriptionPattern.test(description2) : true,
|
|
17433
|
+
errorMessage: "invalidFormatBankStatementDescription"
|
|
17434
|
+
}
|
|
17435
|
+
};
|
|
17384
17436
|
const CHARACTERS_LIMIT$1 = 200;
|
|
17385
17437
|
const bankStatementFields = ["bankStatementDocument", "description"];
|
|
17386
17438
|
function PayoutBankStatementComponent(props) {
|
|
@@ -17403,7 +17455,7 @@ function PayoutBankStatementComponent(props) {
|
|
|
17403
17455
|
isOptional: isBankStatementOptional
|
|
17404
17456
|
}), [isBankStatementOptional]);
|
|
17405
17457
|
const rules2 = F$1(() => ({
|
|
17406
|
-
...props.validators,
|
|
17458
|
+
...props.validators || payoutBankStatementValidationRules,
|
|
17407
17459
|
bankStatementDocument: fileValidationRules(bankStatementValidationOptions)
|
|
17408
17460
|
}), [bankStatementValidationOptions, props.validators]);
|
|
17409
17461
|
const {
|
|
@@ -17420,7 +17472,7 @@ function PayoutBankStatementComponent(props) {
|
|
|
17420
17472
|
defaultData: props.data,
|
|
17421
17473
|
rules: rules2,
|
|
17422
17474
|
fieldProblems: props == null ? void 0 : props.fieldValidationErrors,
|
|
17423
|
-
shouldValidate:
|
|
17475
|
+
shouldValidate: props == null ? void 0 : props.shouldValidate
|
|
17424
17476
|
});
|
|
17425
17477
|
const alreadyUploadedDocuments = F$1(() => {
|
|
17426
17478
|
var _a2;
|
|
@@ -17861,12 +17913,17 @@ function PayoutDetailsComponent(props) {
|
|
|
17861
17913
|
activeForm,
|
|
17862
17914
|
taskType,
|
|
17863
17915
|
legalEntityResponse,
|
|
17864
|
-
handleGetBankVerificationVendors
|
|
17916
|
+
handleGetBankVerificationVendors,
|
|
17917
|
+
setHideDropinLayout,
|
|
17918
|
+
setHideOnHomeButton,
|
|
17919
|
+
setSkipSubmit,
|
|
17920
|
+
setHideBackButton,
|
|
17921
|
+
setSubmitButtonLabel
|
|
17865
17922
|
} = props;
|
|
17866
17923
|
const [instantVerificationError, setInstantVerificationError] = useInstantVerificationErrorNotification(1e4);
|
|
17867
17924
|
const verificationMethodFormProps = getFormProps(props, payoutSteps.payoutVerificationMethod.formId);
|
|
17868
17925
|
const accountVerificationFormProps = getFormProps(props, payoutSteps.payoutAccountVerification.formId);
|
|
17869
|
-
const payoutAccountFormProps = getFormProps(props, payoutSteps.payoutAccountDetails(
|
|
17926
|
+
const payoutAccountFormProps = getFormProps(props, payoutSteps.payoutAccountDetails(taskType).formId);
|
|
17870
17927
|
const payoutBankStatementFormProps = getFormProps(props, payoutSteps.payoutAccountDocuments.formId);
|
|
17871
17928
|
const taskHeading = i18n.get(taskHeadings[taskType]);
|
|
17872
17929
|
const isBankStatementDocumentOptional = formUtilities(payoutBankStatementFormProps, i18n).isOptionalField("bankStatementDocument");
|
|
@@ -17875,16 +17932,15 @@ function PayoutDetailsComponent(props) {
|
|
|
17875
17932
|
const resetData = useResetGlobalData();
|
|
17876
17933
|
const verifyInstantly = ((_a = data.payoutVerificationMethod) == null ? void 0 : _a.payoutVerificationMethod) === "instantVerification";
|
|
17877
17934
|
const bankCountry2 = (_b = data.payoutVerificationMethod) == null ? void 0 : _b.bankCountry;
|
|
17878
|
-
p(() => props.evaluateConfiguration(data), [data.payoutVerificationMethod]);
|
|
17879
17935
|
p(() => resetData(), [resetData]);
|
|
17880
17936
|
p(() => {
|
|
17881
17937
|
if (activeForm.formId === summaryStep.formId && verifyInstantly) {
|
|
17882
|
-
|
|
17883
|
-
|
|
17884
|
-
|
|
17885
|
-
|
|
17938
|
+
setSkipSubmit(true);
|
|
17939
|
+
setHideOnHomeButton(true);
|
|
17940
|
+
setHideBackButton(true);
|
|
17941
|
+
setSubmitButtonLabel("continue");
|
|
17886
17942
|
}
|
|
17887
|
-
}, [
|
|
17943
|
+
}, [activeForm]);
|
|
17888
17944
|
const [bankInfoValidated, setBankInfoValidated] = h(false);
|
|
17889
17945
|
return o("div", {
|
|
17890
17946
|
className: "adyen-kyc-payout",
|
|
@@ -17912,11 +17968,10 @@ function PayoutDetailsComponent(props) {
|
|
|
17912
17968
|
id: payoutSteps.payoutAccountVerification.formId,
|
|
17913
17969
|
country: bankCountry2,
|
|
17914
17970
|
onBack: props.onBack,
|
|
17915
|
-
|
|
17916
|
-
hideDropinLayout: (hideStatus) => props.setHideDropinLayout(hideStatus),
|
|
17971
|
+
hideDropinLayout: setHideDropinLayout,
|
|
17917
17972
|
getBankVerificationVendors: handleGetBankVerificationVendors,
|
|
17918
17973
|
setBankVerificationError: setInstantVerificationError,
|
|
17919
|
-
hideOnHomeButton:
|
|
17974
|
+
hideOnHomeButton: setHideOnHomeButton,
|
|
17920
17975
|
bankInfoValidated,
|
|
17921
17976
|
setBankInfoValidated,
|
|
17922
17977
|
formIsActive: activeForm.formId === payoutSteps.payoutAccountVerification.formId,
|
|
@@ -18528,6 +18583,7 @@ const remediationActionMappings = {
|
|
|
18528
18583
|
}]
|
|
18529
18584
|
};
|
|
18530
18585
|
const dataMissingRemediationsToFieldsMap = {
|
|
18586
|
+
"1_501": [DocumentType.REGISTRATION_DOCUMENT],
|
|
18531
18587
|
"2_158": ["vatNumber", "exemptedFromVat", "vatAbsenceReason"]
|
|
18532
18588
|
};
|
|
18533
18589
|
var EntityType = /* @__PURE__ */ ((EntityType2) => {
|
|
@@ -19046,7 +19102,9 @@ const useFormComposer = ({
|
|
|
19046
19102
|
forms,
|
|
19047
19103
|
formRef,
|
|
19048
19104
|
submitButtonLabel,
|
|
19049
|
-
onSubmit
|
|
19105
|
+
onSubmit,
|
|
19106
|
+
skipSubmit,
|
|
19107
|
+
onSkipSubmit
|
|
19050
19108
|
}) => {
|
|
19051
19109
|
const {
|
|
19052
19110
|
i18n
|
|
@@ -19101,6 +19159,10 @@ const useFormComposer = ({
|
|
|
19101
19159
|
return;
|
|
19102
19160
|
}
|
|
19103
19161
|
if (isFormSummaryStep(activeForm)) {
|
|
19162
|
+
if (skipSubmit && onSkipSubmit) {
|
|
19163
|
+
onSkipSubmit();
|
|
19164
|
+
return;
|
|
19165
|
+
}
|
|
19104
19166
|
onSubmit();
|
|
19105
19167
|
return;
|
|
19106
19168
|
}
|
|
@@ -19952,8 +20014,9 @@ const mapField = (lePath, dropinTask) => {
|
|
|
19952
20014
|
case TaskTypes.PAYOUT:
|
|
19953
20015
|
case TaskTypes.PAYIN:
|
|
19954
20016
|
return remediationPayoutApiKeyMapping[lePath];
|
|
20017
|
+
default:
|
|
20018
|
+
return null;
|
|
19955
20019
|
}
|
|
19956
|
-
return null;
|
|
19957
20020
|
};
|
|
19958
20021
|
const getRequiredForms = (forms, requiredFields, optionalFields) => {
|
|
19959
20022
|
const requiredForms = Object.values(forms).filter(({
|
|
@@ -20254,16 +20317,13 @@ const FormWrapper = ({
|
|
|
20254
20317
|
hasVerificationErrors: Object.keys((problems == null ? void 0 : problems.verificationErrors) ?? {}).length > 0
|
|
20255
20318
|
})
|
|
20256
20319
|
});
|
|
20257
|
-
if (hideDropinLayout) {
|
|
20258
|
-
return multiStepForm;
|
|
20259
|
-
}
|
|
20260
20320
|
return o(DropinLayout, {
|
|
20261
20321
|
content: o(Fragment, {
|
|
20262
20322
|
children: [sidebar, multiStepForm]
|
|
20263
20323
|
})
|
|
20264
20324
|
});
|
|
20265
20325
|
};
|
|
20266
|
-
const parseConfiguration$
|
|
20326
|
+
const parseConfiguration$2 = ({
|
|
20267
20327
|
country: country2,
|
|
20268
20328
|
matchingScenario
|
|
20269
20329
|
}) => parseCompanyScenarios(matchingScenario == null ? void 0 : matchingScenario[LegalEntityType.ORGANIZATION], country2);
|
|
@@ -20356,7 +20416,7 @@ function CompanyDropinComponent({
|
|
|
20356
20416
|
fieldConfigurations,
|
|
20357
20417
|
requiredFields
|
|
20358
20418
|
} = useScenarioConfiguration({
|
|
20359
|
-
parseConfiguration: parseConfiguration$
|
|
20419
|
+
parseConfiguration: parseConfiguration$2,
|
|
20360
20420
|
getConfigurationData,
|
|
20361
20421
|
setLoadingStatus,
|
|
20362
20422
|
country: country2
|
|
@@ -22170,7 +22230,7 @@ function Toast({
|
|
|
22170
22230
|
})]
|
|
22171
22231
|
});
|
|
22172
22232
|
}
|
|
22173
|
-
const parseConfiguration = ({
|
|
22233
|
+
const parseConfiguration$1 = ({
|
|
22174
22234
|
country: country2,
|
|
22175
22235
|
matchingScenario
|
|
22176
22236
|
}) => parseIndividualScenarios(matchingScenario == null ? void 0 : matchingScenario[LegalEntityType.INDIVIDUAL], country2);
|
|
@@ -22247,7 +22307,7 @@ function IndividualDropinComponent({
|
|
|
22247
22307
|
const {
|
|
22248
22308
|
fieldConfigurations
|
|
22249
22309
|
} = useScenarioConfiguration({
|
|
22250
|
-
parseConfiguration,
|
|
22310
|
+
parseConfiguration: parseConfiguration$1,
|
|
22251
22311
|
getConfigurationData,
|
|
22252
22312
|
setLoadingStatus,
|
|
22253
22313
|
country: country2
|
|
@@ -22622,934 +22682,447 @@ function IndividualDropinComponent({
|
|
|
22622
22682
|
})
|
|
22623
22683
|
});
|
|
22624
22684
|
}
|
|
22625
|
-
|
|
22626
|
-
|
|
22627
|
-
|
|
22628
|
-
|
|
22629
|
-
|
|
22630
|
-
|
|
22631
|
-
|
|
22632
|
-
|
|
22633
|
-
|
|
22634
|
-
|
|
22635
|
-
|
|
22636
|
-
|
|
22637
|
-
|
|
22638
|
-
|
|
22639
|
-
|
|
22685
|
+
const isInstantVerificationAvailable = ({
|
|
22686
|
+
country: country2,
|
|
22687
|
+
verificationVendorsCallback,
|
|
22688
|
+
bankVerificationVendors
|
|
22689
|
+
}) => Boolean(verificationVendorsCallback && (bankVerificationVendors == null ? void 0 : bankVerificationVendors[country2]));
|
|
22690
|
+
const rules = ({
|
|
22691
|
+
data,
|
|
22692
|
+
requiredFields
|
|
22693
|
+
}) => ({
|
|
22694
|
+
whenUsingManualVerification: () => {
|
|
22695
|
+
var _a;
|
|
22696
|
+
if (!data.payoutVerificationMethod)
|
|
22697
|
+
return;
|
|
22698
|
+
if (((_a = data == null ? void 0 : data.payoutVerificationMethod) == null ? void 0 : _a.payoutVerificationMethod) === "manualVerification") {
|
|
22699
|
+
return "REQUIRED";
|
|
22700
|
+
}
|
|
22701
|
+
},
|
|
22702
|
+
whenUsingInstantVerification: () => {
|
|
22703
|
+
var _a;
|
|
22704
|
+
if (!data.payoutVerificationMethod) {
|
|
22705
|
+
return "REQUIRED";
|
|
22706
|
+
}
|
|
22707
|
+
if (((_a = data == null ? void 0 : data.payoutVerificationMethod) == null ? void 0 : _a.payoutVerificationMethod) === "instantVerification") {
|
|
22708
|
+
return "REQUIRED";
|
|
22709
|
+
}
|
|
22710
|
+
},
|
|
22711
|
+
verifiedBankAccountNumber: () => {
|
|
22712
|
+
var _a;
|
|
22713
|
+
if (((_a = data == null ? void 0 : data.payoutVerificationMethod) == null ? void 0 : _a.payoutVerificationMethod) === "instantVerification") {
|
|
22714
|
+
return "REQUIRED";
|
|
22715
|
+
}
|
|
22716
|
+
},
|
|
22717
|
+
bankStatementRequirement: () => {
|
|
22718
|
+
var _a;
|
|
22719
|
+
if (((_a = data == null ? void 0 : data.payoutVerificationMethod) == null ? void 0 : _a.payoutVerificationMethod) === "manualVerification") {
|
|
22720
|
+
return requiredFields == null ? void 0 : requiredFields.bankStatementRequirement;
|
|
22721
|
+
}
|
|
22722
|
+
},
|
|
22723
|
+
// "bankStatement description" field is always "optional" and it's coupled with bank statement document.
|
|
22724
|
+
bankStatementDescription: () => {
|
|
22725
|
+
var _a;
|
|
22726
|
+
if (((_a = data == null ? void 0 : data.payoutVerificationMethod) == null ? void 0 : _a.payoutVerificationMethod) === "manualVerification" && !!(requiredFields == null ? void 0 : requiredFields.bankStatementRequirement)) {
|
|
22727
|
+
return "OPTIONAL";
|
|
22728
|
+
}
|
|
22729
|
+
}
|
|
22730
|
+
});
|
|
22731
|
+
const getRegistrationCountry = (legalEntityResponse) => {
|
|
22732
|
+
var _a, _b;
|
|
22733
|
+
if (legalEntityResponse.type === LegalEntityType.INDIVIDUAL) {
|
|
22734
|
+
return (_a = legalEntityResponse.individual) == null ? void 0 : _a.residentialAddress.country;
|
|
22735
|
+
}
|
|
22736
|
+
if (legalEntityResponse.type === LegalEntityType.ORGANIZATION) {
|
|
22737
|
+
return (_b = legalEntityResponse.organization) == null ? void 0 : _b.registeredAddress.country;
|
|
22738
|
+
}
|
|
22640
22739
|
};
|
|
22641
|
-
|
|
22642
|
-
|
|
22643
|
-
|
|
22644
|
-
|
|
22645
|
-
|
|
22740
|
+
const labels$1 = () => ({
|
|
22741
|
+
verifiedAccountHolder: () => "accountHolder",
|
|
22742
|
+
verifiedBankCountry: () => "bankCountry",
|
|
22743
|
+
verifiedBankName: () => "bankName",
|
|
22744
|
+
verifiedCurrencyCode: () => "currencyCode",
|
|
22745
|
+
verifiedBankAccountNumber: () => "bankAccountNumber"
|
|
22746
|
+
});
|
|
22747
|
+
const parseConfiguration = ({
|
|
22748
|
+
requiredFields,
|
|
22749
|
+
country: country2,
|
|
22750
|
+
bankVerificationAvailable
|
|
22751
|
+
}) => parsePayoutScenarios({
|
|
22752
|
+
requiredFields: requiredFields == null ? void 0 : requiredFields.fields,
|
|
22753
|
+
country: country2,
|
|
22754
|
+
bankVerificationAvailable
|
|
22755
|
+
});
|
|
22756
|
+
function PayoutDetailsDropinComponent({
|
|
22757
|
+
transferInstrument,
|
|
22758
|
+
setTransferInstrument,
|
|
22759
|
+
handleCreateDocument,
|
|
22760
|
+
handleGetDocument,
|
|
22761
|
+
handleUpdateDocument,
|
|
22762
|
+
handleUpdateTransferInstrument,
|
|
22763
|
+
handleCreateTransferInstrument,
|
|
22764
|
+
handleGetBankVerificationVendors,
|
|
22765
|
+
legalEntityResponse,
|
|
22766
|
+
trackingConfig,
|
|
22767
|
+
accountHolder: accountHolder2,
|
|
22768
|
+
country: country2,
|
|
22769
|
+
problems: propProblems,
|
|
22770
|
+
onSubmit: externalOnSubmit,
|
|
22771
|
+
onChange,
|
|
22772
|
+
taskType,
|
|
22773
|
+
taskName,
|
|
22774
|
+
eventEmitter,
|
|
22775
|
+
capabilities,
|
|
22776
|
+
handleHomeClick,
|
|
22777
|
+
homeButtonLabel,
|
|
22778
|
+
refreshLegalEntity,
|
|
22779
|
+
navigateBackToTaskList
|
|
22780
|
+
}) {
|
|
22781
|
+
var _a, _b, _c;
|
|
22782
|
+
const {
|
|
22783
|
+
i18n
|
|
22784
|
+
} = useCoreContext();
|
|
22785
|
+
const {
|
|
22786
|
+
showToast,
|
|
22787
|
+
clearToasts
|
|
22788
|
+
} = useToastContext();
|
|
22789
|
+
const {
|
|
22790
|
+
isSettingEnabled
|
|
22791
|
+
} = useSettingsContext();
|
|
22792
|
+
const {
|
|
22793
|
+
getConfiguration: getConfiguration2,
|
|
22794
|
+
getPayoutAccountFormat: getPayoutAccountFormat2
|
|
22795
|
+
} = useKycExternalApi();
|
|
22796
|
+
const defaultPayoutCountry = getRegistrationCountry(legalEntityResponse) ?? country2;
|
|
22797
|
+
const [bankAccountCountry2, setBankAccountCountry] = h(defaultPayoutCountry);
|
|
22798
|
+
const existingPayoutDetails = transferInstrument ? mapTransferInstrumentToPayoutAccount(transferInstrument) : void 0;
|
|
22799
|
+
const [documents2, setDocuments] = h();
|
|
22800
|
+
const fallbackCurrency = (_a = currencyByCountry[defaultPayoutCountry]) == null ? void 0 : _a[0];
|
|
22801
|
+
const accountHolderName = accountHolder2 || getLegalEntityNameBasedOnType(legalEntityResponse);
|
|
22802
|
+
const instantVerificationEnabled = Boolean(!transferInstrument && handleGetBankVerificationVendors);
|
|
22803
|
+
const prefilledData = {
|
|
22804
|
+
payoutAccountDetails: {
|
|
22805
|
+
accountHolder: accountHolderName,
|
|
22806
|
+
currency: fallbackCurrency,
|
|
22807
|
+
...existingPayoutDetails == null ? void 0 : existingPayoutDetails.payoutAccountDetails
|
|
22808
|
+
},
|
|
22809
|
+
payoutVerificationMethod: {
|
|
22810
|
+
payoutVerificationMethod: transferInstrument ? isInstantVerifiedAccount(transferInstrument) ? "instantVerification" : "manualVerification" : instantVerificationEnabled ? "instantVerification" : void 0,
|
|
22811
|
+
bankCountry: defaultPayoutCountry,
|
|
22812
|
+
...existingPayoutDetails == null ? void 0 : existingPayoutDetails.payoutVerificationMethod
|
|
22813
|
+
},
|
|
22814
|
+
payoutAccountVerification: {
|
|
22815
|
+
verifiedAccountHolder: accountHolderName,
|
|
22816
|
+
verifiedBankCountry: defaultPayoutCountry,
|
|
22817
|
+
...existingPayoutDetails == null ? void 0 : existingPayoutDetails.payoutAccountVerification
|
|
22818
|
+
}
|
|
22646
22819
|
};
|
|
22647
|
-
|
|
22648
|
-
|
|
22649
|
-
|
|
22650
|
-
|
|
22651
|
-
|
|
22652
|
-
|
|
22653
|
-
|
|
22654
|
-
|
|
22655
|
-
|
|
22656
|
-
|
|
22657
|
-
|
|
22658
|
-
|
|
22659
|
-
|
|
22660
|
-
|
|
22661
|
-
|
|
22662
|
-
|
|
22663
|
-
|
|
22664
|
-
|
|
22665
|
-
|
|
22666
|
-
|
|
22667
|
-
|
|
22668
|
-
|
|
22669
|
-
|
|
22670
|
-
|
|
22671
|
-
|
|
22672
|
-
|
|
22673
|
-
|
|
22674
|
-
|
|
22675
|
-
|
|
22676
|
-
|
|
22677
|
-
|
|
22678
|
-
|
|
22679
|
-
|
|
22680
|
-
|
|
22681
|
-
|
|
22682
|
-
|
|
22683
|
-
|
|
22684
|
-
|
|
22685
|
-
|
|
22686
|
-
|
|
22687
|
-
|
|
22688
|
-
|
|
22689
|
-
|
|
22690
|
-
|
|
22691
|
-
|
|
22692
|
-
|
|
22693
|
-
|
|
22694
|
-
|
|
22695
|
-
|
|
22696
|
-
|
|
22697
|
-
|
|
22698
|
-
|
|
22699
|
-
|
|
22820
|
+
const documentUtils = documentApiUtils(handleCreateDocument, handleGetDocument, handleUpdateDocument);
|
|
22821
|
+
const [hideDropinLayout, setHideDropinLayout] = h(false);
|
|
22822
|
+
const [submitButtonLabel, setSubmitButtonLabel] = h();
|
|
22823
|
+
const [skipSubmit, setSkipSubmit] = h(false);
|
|
22824
|
+
const [hideHomeButton, setHideHomeButton] = h(false);
|
|
22825
|
+
const [hideBackButton, setHideBackButton] = h(false);
|
|
22826
|
+
const [loadingStatus, setLoadingStatus] = h("success");
|
|
22827
|
+
const [data, setData] = h(prefilledData);
|
|
22828
|
+
const [problems, setProblems] = h(propProblems || ((_c = (_b = getCapabilityProblems(legalEntityResponse)) == null ? void 0 : _b.BankAccount) == null ? void 0 : _c[transferInstrument == null ? void 0 : transferInstrument.id]));
|
|
22829
|
+
const baseTrackingPayload = getBaseTrackingPayload({
|
|
22830
|
+
trackingConfig,
|
|
22831
|
+
task: taskType
|
|
22832
|
+
});
|
|
22833
|
+
p(() => {
|
|
22834
|
+
userEvents.addPageView("Payout dropin");
|
|
22835
|
+
userEvents.addEvent("Started payout task", {
|
|
22836
|
+
segmentation: {
|
|
22837
|
+
...baseTrackingPayload
|
|
22838
|
+
}
|
|
22839
|
+
});
|
|
22840
|
+
}, []);
|
|
22841
|
+
const getConfigurationData = T$1(() => getConfiguration2({
|
|
22842
|
+
legalEntityType: legalEntityResponse.type,
|
|
22843
|
+
capabilities,
|
|
22844
|
+
country: bankAccountCountry2 ?? defaultPayoutCountry
|
|
22845
|
+
}), [bankAccountCountry2, capabilities]);
|
|
22846
|
+
const getPayoutAccountFormatData = T$1(() => getPayoutAccountFormat2(bankAccountCountry2 ?? defaultPayoutCountry), [bankAccountCountry2]);
|
|
22847
|
+
const {
|
|
22848
|
+
fieldConfigurations,
|
|
22849
|
+
requiredFields,
|
|
22850
|
+
bankVerificationVendors
|
|
22851
|
+
} = useScenarioConfiguration({
|
|
22852
|
+
parseConfiguration,
|
|
22853
|
+
getConfigurationData,
|
|
22854
|
+
getPayoutAccountFormatData,
|
|
22855
|
+
instantVerificationEnabled,
|
|
22856
|
+
setLoadingStatus,
|
|
22857
|
+
country: bankAccountCountry2 ?? defaultPayoutCountry
|
|
22858
|
+
});
|
|
22859
|
+
const fieldsFromCustomRules = F$1(() => rules({
|
|
22860
|
+
data,
|
|
22861
|
+
country: bankAccountCountry2 ?? defaultPayoutCountry,
|
|
22862
|
+
taskType,
|
|
22863
|
+
requiredFields
|
|
22864
|
+
}), [bankAccountCountry2, data, taskType]);
|
|
22865
|
+
const fieldsFormCustomLabels = F$1(() => labels$1 ? labels$1() : {}, [data, bankAccountCountry2]);
|
|
22866
|
+
const payoutDetailsSteps = F$1(() => {
|
|
22867
|
+
var _a2, _b2;
|
|
22868
|
+
return getAppropriatePayoutDetailsSteps(taskType, Boolean((_a2 = prefilledData == null ? void 0 : prefilledData.payoutAccountDetails) == null ? void 0 : _a2.transferInstrumentId), !transferInstrument && isInstantVerificationAvailable({
|
|
22869
|
+
country: (_b2 = prefilledData == null ? void 0 : prefilledData.payoutVerificationMethod) == null ? void 0 : _b2.bankCountry,
|
|
22870
|
+
bankVerificationVendors,
|
|
22871
|
+
verificationVendorsCallback: handleGetBankVerificationVendors
|
|
22872
|
+
}), isSettingEnabled("allowIntraRegionCrossBorderPayout"));
|
|
22873
|
+
}, [bankVerificationVendors]);
|
|
22874
|
+
const derivedProps = F$1(() => getPropsFromConfigurations(fieldConfigurations, payoutDetailsSteps, (problems == null ? void 0 : problems.remediationActions) ? Object.values(problems == null ? void 0 : problems.remediationActions) : [], (problems == null ? void 0 : problems.missingData) ?? [], [], fieldsFromCustomRules, fieldsFormCustomLabels), [fieldConfigurations, fieldsFromCustomRules, problems == null ? void 0 : problems.remediationActions]);
|
|
22875
|
+
const {
|
|
22876
|
+
state: {
|
|
22877
|
+
currentState
|
|
22878
|
+
}
|
|
22879
|
+
} = useStateContext();
|
|
22880
|
+
const formValidity = currentState.validityByForm;
|
|
22881
|
+
p(() => {
|
|
22882
|
+
var _a2, _b2;
|
|
22883
|
+
setData({
|
|
22884
|
+
...currentState.data
|
|
22885
|
+
});
|
|
22886
|
+
setBankAccountCountry((_b2 = (_a2 = currentState == null ? void 0 : currentState.data) == null ? void 0 : _a2.payoutVerificationMethod) == null ? void 0 : _b2.bankCountry);
|
|
22887
|
+
onChange == null ? void 0 : onChange(currentState);
|
|
22888
|
+
}, [currentState, onChange]);
|
|
22889
|
+
const forms = F$1(() => {
|
|
22890
|
+
const requiredForms = getRequiredForms(payoutDetailsSteps, derivedProps == null ? void 0 : derivedProps.requiredFields, derivedProps == null ? void 0 : derivedProps.optionalFields);
|
|
22891
|
+
return addValidityToForms(requiredForms, formValidity, problems);
|
|
22892
|
+
}, [derivedProps, formValidity, problems]);
|
|
22893
|
+
p(() => {
|
|
22894
|
+
var _a2;
|
|
22895
|
+
const documentIds = ((_a2 = transferInstrument == null ? void 0 : transferInstrument.documentDetails) == null ? void 0 : _a2.map((documentReference) => documentReference.id)) || [];
|
|
22896
|
+
if (documentIds.length) {
|
|
22897
|
+
documentUtils.fetchDocuments(documentIds, transferInstrument == null ? void 0 : transferInstrument.id).then(() => {
|
|
22898
|
+
setDocuments(mapApiDocumentToPayoutDocuments(transferInstrument == null ? void 0 : transferInstrument.id));
|
|
22899
|
+
}).catch(() => {
|
|
22900
|
+
showToast({
|
|
22901
|
+
label: i18n.get("failedToFetchRelevantDocuments"),
|
|
22902
|
+
type: ToastType.ERROR
|
|
22903
|
+
});
|
|
22904
|
+
});
|
|
22905
|
+
}
|
|
22906
|
+
}, []);
|
|
22907
|
+
const submitDocuments = async ({
|
|
22908
|
+
forms: forms2,
|
|
22909
|
+
transferInstrument: transferInstrument2,
|
|
22910
|
+
dataSubmitted
|
|
22911
|
+
}) => {
|
|
22912
|
+
if (isDocumentsRequired2(forms2)) {
|
|
22913
|
+
const documentToUpload = await mapPayoutDocumentsToApiDocuments(dataSubmitted, transferInstrument2.id);
|
|
22914
|
+
if (documentToUpload) {
|
|
22915
|
+
try {
|
|
22916
|
+
const documents22 = await documentUtils.uploadDocuments([documentToUpload], transferInstrument2.id);
|
|
22917
|
+
documents22.forEach((document2) => {
|
|
22918
|
+
var _a2;
|
|
22919
|
+
userEvents.addEvent("Saved document", {
|
|
22920
|
+
segmentation: {
|
|
22921
|
+
...baseTrackingPayload,
|
|
22922
|
+
documentType: document2.type,
|
|
22923
|
+
fileExtention: (_a2 = document2.attachments) == null ? void 0 : _a2.map((item) => getFileExtention(item.pageName))
|
|
22924
|
+
}
|
|
22925
|
+
});
|
|
22700
22926
|
});
|
|
22701
|
-
|
|
22702
|
-
|
|
22703
|
-
|
|
22704
|
-
|
|
22705
|
-
|
|
22706
|
-
|
|
22707
|
-
return {
|
|
22708
|
-
data: {
|
|
22709
|
-
...acc.data,
|
|
22710
|
-
[fieldKey]: dataObjByFormId[fieldKey] ?? allDataObjByFormId[fieldKey]
|
|
22711
|
-
},
|
|
22712
|
-
valid: {
|
|
22713
|
-
...acc.valid,
|
|
22714
|
-
[fieldKey]: validObjByFormId[fieldKey]
|
|
22715
|
-
},
|
|
22716
|
-
errors: {
|
|
22717
|
-
...acc.errors,
|
|
22718
|
-
[fieldKey]: errorsObjByFormId[fieldKey]
|
|
22719
|
-
},
|
|
22720
|
-
fieldProblems: {
|
|
22721
|
-
...acc.fieldProblems,
|
|
22722
|
-
[fieldKey]: fieldProblemsObjByFormId[fieldKey]
|
|
22927
|
+
} catch (e2) {
|
|
22928
|
+
setProblems({
|
|
22929
|
+
...problems,
|
|
22930
|
+
validationErrors: {
|
|
22931
|
+
payoutAccountDocuments: {
|
|
22932
|
+
bankStatementDocument: true
|
|
22723
22933
|
}
|
|
22724
|
-
}
|
|
22725
|
-
}, {
|
|
22726
|
-
data: {},
|
|
22727
|
-
valid: {},
|
|
22728
|
-
errors: {},
|
|
22729
|
-
fieldProblems: {}
|
|
22934
|
+
}
|
|
22730
22935
|
});
|
|
22731
|
-
|
|
22732
|
-
|
|
22733
|
-
mergedState.errors[dataStoreId] = processedBySchema.errors;
|
|
22734
|
-
mergedState.fieldProblems[dataStoreId] = processedBySchema.fieldProblems;
|
|
22936
|
+
setTransferInstrument(transferInstrument2);
|
|
22937
|
+
throw new Error(i18n.get("remediationMessage_1_704"));
|
|
22735
22938
|
}
|
|
22736
|
-
mergedState.validityByForm = {
|
|
22737
|
-
...mergedState.validityByForm,
|
|
22738
|
-
[dataStoreId]: Object.values(mergedState.valid[dataStoreId]).every((isValid) => isValid)
|
|
22739
|
-
};
|
|
22740
|
-
mergedState.hasDataChanged = {
|
|
22741
|
-
...state2.hasDataChanged,
|
|
22742
|
-
[dataStoreId]: {
|
|
22743
|
-
hasDataChanged: hasDataChanged((_b = state2.initialData) == null ? void 0 : _b[dataStoreId], (_c = mergedState.data) == null ? void 0 : _c[dataStoreId])
|
|
22744
|
-
}
|
|
22745
|
-
};
|
|
22746
|
-
mergedState.hasAnyDataChanged = Object.values(mergedState.hasDataChanged).some(({
|
|
22747
|
-
hasDataChanged: hasDataChanged2
|
|
22748
|
-
}) => hasDataChanged2);
|
|
22749
|
-
mergedState.allValid = Object.values(mergedState.validityByForm).every((isValid) => isValid);
|
|
22750
|
-
mergedState.isValid = !activeForms.length ? mergedState.allValid : activeForms.every((item) => mergedState.validityByForm[item]);
|
|
22751
|
-
mergedState.initialData = structuredClone(state2.initialData);
|
|
22752
|
-
return {
|
|
22753
|
-
currentState: mergedState,
|
|
22754
|
-
prevState: state2,
|
|
22755
|
-
changeInitiatedBy: dataStoreId
|
|
22756
|
-
};
|
|
22757
|
-
}
|
|
22758
|
-
case "resetState": {
|
|
22759
|
-
const dataStoreId = ((_d = action.value) == null ? void 0 : _d.dataStoreId) ?? ((_e = action.value) == null ? void 0 : _e.caller);
|
|
22760
|
-
return {
|
|
22761
|
-
currentState: INITIAL_STATE,
|
|
22762
|
-
prevState: currState,
|
|
22763
|
-
changeInitiatedBy: dataStoreId
|
|
22764
|
-
};
|
|
22765
|
-
}
|
|
22766
|
-
default: {
|
|
22767
|
-
throw new Error(`Unhandled action type: ${action.type}`);
|
|
22768
22939
|
}
|
|
22769
22940
|
}
|
|
22770
|
-
}
|
|
22771
|
-
return {
|
|
22772
|
-
reducer: reducer2,
|
|
22773
|
-
setCurrentForms
|
|
22774
22941
|
};
|
|
22775
|
-
|
|
22776
|
-
|
|
22777
|
-
|
|
22778
|
-
|
|
22779
|
-
}
|
|
22780
|
-
|
|
22781
|
-
currentState: {
|
|
22782
|
-
data: defaultData,
|
|
22783
|
-
allData: defaultData,
|
|
22784
|
-
valid: {},
|
|
22785
|
-
errors: {},
|
|
22786
|
-
fieldProblems: {},
|
|
22787
|
-
validityByForm: {},
|
|
22788
|
-
initialData: defaultData
|
|
22789
|
-
},
|
|
22790
|
-
prevState: {},
|
|
22791
|
-
changeInitiatedBy: null
|
|
22942
|
+
const omitMaskedFieldsIfUnchanged = (maskedFields, dataSubmitted, savedData) => {
|
|
22943
|
+
maskedFields.forEach((maskedField) => {
|
|
22944
|
+
if (dataSubmitted[maskedField] === (savedData == null ? void 0 : savedData[maskedField])) {
|
|
22945
|
+
delete dataSubmitted[maskedField];
|
|
22946
|
+
}
|
|
22947
|
+
});
|
|
22792
22948
|
};
|
|
22793
|
-
const
|
|
22794
|
-
|
|
22795
|
-
|
|
22796
|
-
|
|
22797
|
-
|
|
22798
|
-
|
|
22799
|
-
|
|
22800
|
-
var _a;
|
|
22801
|
-
return ((_a = state2 == null ? void 0 : state2.currentState) == null ? void 0 : _a.data) ?? {};
|
|
22802
|
-
},
|
|
22803
|
-
getState: () => state2 == null ? void 0 : state2.currentState
|
|
22804
|
-
}), [reducerObj, state2]);
|
|
22805
|
-
return o(StateContext.Provider, {
|
|
22806
|
-
value: contextValue,
|
|
22807
|
-
children
|
|
22808
|
-
});
|
|
22809
|
-
}
|
|
22810
|
-
const isInstantVerificationAvailable = ({
|
|
22811
|
-
country: country2,
|
|
22812
|
-
verificationVendorsCallback,
|
|
22813
|
-
bankVerificationVendors
|
|
22814
|
-
}) => Boolean(verificationVendorsCallback && (bankVerificationVendors == null ? void 0 : bankVerificationVendors[country2]));
|
|
22815
|
-
const rules = ({
|
|
22816
|
-
data,
|
|
22817
|
-
requiredFields
|
|
22818
|
-
}) => ({
|
|
22819
|
-
whenUsingManualVerification: () => {
|
|
22820
|
-
var _a;
|
|
22821
|
-
if (!data.payoutVerificationMethod)
|
|
22822
|
-
return;
|
|
22823
|
-
if (((_a = data == null ? void 0 : data.payoutVerificationMethod) == null ? void 0 : _a.payoutVerificationMethod) === "manualVerification") {
|
|
22824
|
-
return "REQUIRED";
|
|
22825
|
-
}
|
|
22826
|
-
},
|
|
22827
|
-
whenUsingInstantVerification: () => {
|
|
22828
|
-
var _a;
|
|
22829
|
-
if (!data.payoutVerificationMethod) {
|
|
22830
|
-
return "REQUIRED";
|
|
22831
|
-
}
|
|
22832
|
-
if (((_a = data == null ? void 0 : data.payoutVerificationMethod) == null ? void 0 : _a.payoutVerificationMethod) === "instantVerification") {
|
|
22833
|
-
return "REQUIRED";
|
|
22834
|
-
}
|
|
22835
|
-
},
|
|
22836
|
-
verifiedBankAccountNumber: () => {
|
|
22837
|
-
var _a;
|
|
22838
|
-
if (((_a = data == null ? void 0 : data.payoutVerificationMethod) == null ? void 0 : _a.payoutVerificationMethod) === "instantVerification") {
|
|
22839
|
-
return "REQUIRED";
|
|
22840
|
-
}
|
|
22841
|
-
},
|
|
22842
|
-
bankStatementRequirement: () => {
|
|
22843
|
-
var _a;
|
|
22844
|
-
if (((_a = data == null ? void 0 : data.payoutVerificationMethod) == null ? void 0 : _a.payoutVerificationMethod) === "manualVerification") {
|
|
22845
|
-
return requiredFields == null ? void 0 : requiredFields.bankStatementRequirement;
|
|
22949
|
+
const onSubmit = async () => {
|
|
22950
|
+
var _a2;
|
|
22951
|
+
setLoadingStatus("loading");
|
|
22952
|
+
const dataSubmitted = data;
|
|
22953
|
+
dataSubmitted.payoutAccountDetails.currency = dataSubmitted.payoutAccountDetails.currency ?? fallbackCurrency;
|
|
22954
|
+
if (defaultPayoutCountry === CountryCodes.Sweden && "iban" in dataSubmitted.payoutAccountDetails) {
|
|
22955
|
+
dataSubmitted.payoutAccountDetails.currency = Currency.EUR;
|
|
22846
22956
|
}
|
|
22847
|
-
|
|
22848
|
-
|
|
22849
|
-
|
|
22850
|
-
|
|
22851
|
-
|
|
22852
|
-
|
|
22853
|
-
}
|
|
22854
|
-
}
|
|
22855
|
-
});
|
|
22856
|
-
const getOpeningStep = (forms, remediationActions) => {
|
|
22857
|
-
var _a;
|
|
22858
|
-
if (remediationActions && Object.keys(remediationActions).length > 0) {
|
|
22859
|
-
const allRemediationActions = Object.values(remediationActions).flat().filter((rem) => {
|
|
22860
|
-
var _a2;
|
|
22861
|
-
return ((_a2 = rem.forms) == null ? void 0 : _a2.length) > 0;
|
|
22862
|
-
});
|
|
22863
|
-
if (allRemediationActions.length === 1 && ((_a = allRemediationActions[0]) == null ? void 0 : _a.forms.length) === 1) {
|
|
22864
|
-
const form = forms.find((form2) => {
|
|
22865
|
-
var _a2;
|
|
22866
|
-
return (form2 == null ? void 0 : form2.formId) === ((_a2 = allRemediationActions[0]) == null ? void 0 : _a2.forms[0]);
|
|
22867
|
-
});
|
|
22868
|
-
if (form)
|
|
22869
|
-
return form;
|
|
22870
|
-
}
|
|
22871
|
-
return forms[forms.length - 1];
|
|
22872
|
-
}
|
|
22873
|
-
return forms[0];
|
|
22874
|
-
};
|
|
22875
|
-
function withFormComposer(WrappedComponent, {
|
|
22876
|
-
getComponentForms,
|
|
22877
|
-
parseConfiguration: parseConfiguration2,
|
|
22878
|
-
rules: rules2,
|
|
22879
|
-
labels: labels2,
|
|
22880
|
-
defaultTaskName,
|
|
22881
|
-
getConfigFor = "contextCountry"
|
|
22882
|
-
}) {
|
|
22883
|
-
const WithFormComposer = (props) => {
|
|
22884
|
-
var _a, _b, _c, _d, _e;
|
|
22885
|
-
const {
|
|
22886
|
-
i18n,
|
|
22887
|
-
loadingContext,
|
|
22888
|
-
clientKey,
|
|
22889
|
-
contextCountry: initialContextCountry,
|
|
22890
|
-
setContextCountry: setInitialContextCountry,
|
|
22891
|
-
isReview
|
|
22892
|
-
} = useCoreContext();
|
|
22893
|
-
const {
|
|
22894
|
-
isSettingEnabled
|
|
22895
|
-
} = useSettingsContext();
|
|
22896
|
-
const {
|
|
22897
|
-
getData,
|
|
22898
|
-
getState
|
|
22899
|
-
} = useStateContext();
|
|
22900
|
-
const {
|
|
22901
|
-
getOmittedKeys: getSummaryOmittedKeys = null,
|
|
22902
|
-
formatData: formatDataForSummary = null,
|
|
22903
|
-
omittedForms
|
|
22904
|
-
} = props.summary || {};
|
|
22905
|
-
const taskName = props.taskName ?? defaultTaskName;
|
|
22906
|
-
const [hideDropinLayout, setHideDropinLayout] = h(false);
|
|
22907
|
-
const [hideNavigation, setHideNavigation] = h(false);
|
|
22908
|
-
const [hideFooter, setHideFooter] = h(false);
|
|
22909
|
-
const [hideOnHomeButton, setHideOnHomeButton] = h(false);
|
|
22910
|
-
const [hideBackButton, setHideBackButton] = h(false);
|
|
22911
|
-
const [submitButtonLabel, setSubmitButtonLabel] = h(null);
|
|
22912
|
-
const [skipSubmitAndGoTaskList, setSkipSubmitAndGoTaskList] = h(false);
|
|
22913
|
-
const [customFormNavigationHandlers, setCustomFormNavigationHandlers] = h({});
|
|
22914
|
-
const [shouldValidate, setShouldValidate] = h(false);
|
|
22915
|
-
const [formValidity, setFormValidity] = h({});
|
|
22916
|
-
const formRef = _$1(null);
|
|
22917
|
-
const [loadingStatus, setLoadingStatus] = h("success");
|
|
22918
|
-
const [derivedProps, setDerivedProps] = h(props);
|
|
22919
|
-
const [contextCountry, setContextCountry] = h(props.country || initialContextCountry);
|
|
22920
|
-
const {
|
|
22921
|
-
sliceData: payoutMethodData
|
|
22922
|
-
} = useGlobalDataSlice("payoutVerificationMethod");
|
|
22923
|
-
const configCountry = (getConfigFor === "bankCountry" ? payoutMethodData == null ? void 0 : payoutMethodData.bankCountry : contextCountry) ?? contextCountry;
|
|
22924
|
-
p(() => {
|
|
22925
|
-
loadDocumentGuidance(loadingContext);
|
|
22926
|
-
}, [loadingContext]);
|
|
22927
|
-
const getConfigurationData = T$1(() => getConfiguration({
|
|
22928
|
-
loadingContext,
|
|
22929
|
-
clientKey
|
|
22930
|
-
}, {
|
|
22931
|
-
legalEntityType: props.legalEntityType,
|
|
22932
|
-
capabilities: props.capabilities,
|
|
22933
|
-
// for payout forms, we need to get config for the selected bankCountry, not necessarily the same as the residency/registration country
|
|
22934
|
-
country: configCountry
|
|
22935
|
-
}), [clientKey, configCountry, loadingContext, props.capabilities, props.legalEntityType]);
|
|
22936
|
-
const getPayoutAccountFormatData = T$1(() => getPayoutAccountFormat({
|
|
22937
|
-
loadingContext,
|
|
22938
|
-
clientKey
|
|
22939
|
-
}, configCountry), [clientKey, configCountry, loadingContext]);
|
|
22940
|
-
const {
|
|
22941
|
-
fieldConfigurations,
|
|
22942
|
-
requiredFields,
|
|
22943
|
-
bankVerificationVendors
|
|
22944
|
-
} = useScenarioConfiguration({
|
|
22945
|
-
getConfigurationData,
|
|
22946
|
-
getPayoutAccountFormatData,
|
|
22947
|
-
parseConfiguration: parseConfiguration2,
|
|
22948
|
-
country: configCountry,
|
|
22949
|
-
instantVerificationEnabled: derivedProps.instantVerificationEnabled && derivedProps.handleGetBankVerificationVendors,
|
|
22950
|
-
setLoadingStatus
|
|
22951
|
-
});
|
|
22952
|
-
const isFormStepVisible = (formId) => {
|
|
22953
|
-
if (derivedProps.requiredFields || derivedProps.optionalFields) {
|
|
22954
|
-
return !!derivedProps.requiredFields[formId] || !!derivedProps.optionalFields[formId];
|
|
22957
|
+
const event = {
|
|
22958
|
+
segmentation: {
|
|
22959
|
+
...baseTrackingPayload,
|
|
22960
|
+
documentType: DocumentType.BANK_STATEMENT,
|
|
22961
|
+
bankCountry: dataSubmitted.payoutVerificationMethod.bankCountry,
|
|
22962
|
+
bankCurrency: dataSubmitted.payoutAccountDetails.currency
|
|
22955
22963
|
}
|
|
22956
|
-
return true;
|
|
22957
22964
|
};
|
|
22958
|
-
|
|
22959
|
-
|
|
22960
|
-
|
|
22961
|
-
|
|
22962
|
-
|
|
22963
|
-
|
|
22964
|
-
const
|
|
22965
|
-
|
|
22966
|
-
|
|
22967
|
-
|
|
22968
|
-
|
|
22969
|
-
|
|
22970
|
-
p(() => {
|
|
22971
|
-
var _a2;
|
|
22972
|
-
if (hasAlreadyNavigatedForm)
|
|
22973
|
-
return;
|
|
22974
|
-
const openingStep = getOpeningStep(allowedForms, (_a2 = props == null ? void 0 : props.problems) == null ? void 0 : _a2.remediationActions);
|
|
22975
|
-
if (activeForm !== openingStep) {
|
|
22976
|
-
setActiveForm(openingStep);
|
|
22965
|
+
userEvents.addEvent("Provided payout details", event);
|
|
22966
|
+
omitMaskedFieldsIfUnchanged(maskedPayoutFields, dataSubmitted.payoutAccountDetails, existingPayoutDetails == null ? void 0 : existingPayoutDetails.payoutAccountDetails);
|
|
22967
|
+
let transferInstrument2 = mapPayoutAccountToTransferInstrument({
|
|
22968
|
+
data: dataSubmitted,
|
|
22969
|
+
legalEntity: legalEntityResponse
|
|
22970
|
+
});
|
|
22971
|
+
const transferInstrumentId = (_a2 = existingPayoutDetails == null ? void 0 : existingPayoutDetails.payoutAccountDetails) == null ? void 0 : _a2.transferInstrumentId;
|
|
22972
|
+
try {
|
|
22973
|
+
if (!transferInstrumentId) {
|
|
22974
|
+
transferInstrument2 = await handleCreateTransferInstrument(transferInstrument2);
|
|
22975
|
+
} else {
|
|
22976
|
+
transferInstrument2 = await handleUpdateTransferInstrument(drop("id").from(transferInstrument2), transferInstrumentId);
|
|
22977
22977
|
}
|
|
22978
|
-
|
|
22979
|
-
|
|
22980
|
-
|
|
22981
|
-
|
|
22982
|
-
|
|
22983
|
-
|
|
22984
|
-
|
|
22985
|
-
|
|
22986
|
-
|
|
22987
|
-
|
|
22988
|
-
|
|
22989
|
-
|
|
22990
|
-
|
|
22991
|
-
|
|
22992
|
-
|
|
22993
|
-
|
|
22994
|
-
|
|
22995
|
-
|
|
22996
|
-
|
|
22997
|
-
|
|
22998
|
-
|
|
22999
|
-
|
|
23000
|
-
|
|
23001
|
-
|
|
23002
|
-
|
|
23003
|
-
|
|
23004
|
-
|
|
23005
|
-
|
|
23006
|
-
|
|
23007
|
-
|
|
22978
|
+
userEvents.addEvent("Saved payout details", event);
|
|
22979
|
+
try {
|
|
22980
|
+
await submitDocuments({
|
|
22981
|
+
forms,
|
|
22982
|
+
transferInstrument: transferInstrument2,
|
|
22983
|
+
dataSubmitted
|
|
22984
|
+
});
|
|
22985
|
+
setLoadingStatus("success");
|
|
22986
|
+
clearToasts();
|
|
22987
|
+
externalOnSubmit == null ? void 0 : externalOnSubmit(dataSubmitted);
|
|
22988
|
+
} catch (e2) {
|
|
22989
|
+
setLoadingStatus("success");
|
|
22990
|
+
showToast({
|
|
22991
|
+
label: e2.message,
|
|
22992
|
+
type: ToastType.ERROR
|
|
22993
|
+
});
|
|
22994
|
+
}
|
|
22995
|
+
} catch (e2) {
|
|
22996
|
+
if (isValidationError(e2)) {
|
|
22997
|
+
const validationErrors = processValidationErrors(e2, taskType);
|
|
22998
|
+
setProblems({
|
|
22999
|
+
...problems,
|
|
23000
|
+
validationErrors
|
|
23001
|
+
});
|
|
23002
|
+
} else if (isMaintenanceModeError(e2)) {
|
|
23003
|
+
showToast({
|
|
23004
|
+
label: i18n.get("failedToUpdateDetails"),
|
|
23005
|
+
subLabel: i18n.get("maintenanceModeMessage"),
|
|
23006
|
+
type: ToastType.ERROR,
|
|
23007
|
+
duration: "indefinite"
|
|
23008
|
+
});
|
|
23009
|
+
} else {
|
|
23010
|
+
showToast({
|
|
23011
|
+
label: i18n.get("failedToUpdateDetails"),
|
|
23012
|
+
type: ToastType.ERROR
|
|
23013
|
+
});
|
|
23014
|
+
}
|
|
23015
|
+
setLoadingStatus("success");
|
|
23016
|
+
userEvents.addEvent("Encountered error payout details", {
|
|
23008
23017
|
segmentation: {
|
|
23009
|
-
...
|
|
23010
|
-
|
|
23011
|
-
|
|
23012
|
-
|
|
23013
|
-
to: toForm.formId,
|
|
23014
|
-
toLabel: i18n.get(toForm.formName)
|
|
23018
|
+
...baseTrackingPayload,
|
|
23019
|
+
errorCode: e2.errorCode,
|
|
23020
|
+
errorMessage: e2.title,
|
|
23021
|
+
errorType: "BE"
|
|
23015
23022
|
}
|
|
23016
23023
|
});
|
|
23017
|
-
}
|
|
23018
|
-
|
|
23019
|
-
|
|
23020
|
-
|
|
23021
|
-
|
|
23022
|
-
|
|
23024
|
+
}
|
|
23025
|
+
};
|
|
23026
|
+
const isDocumentsRequired2 = (forms2) => forms2.some((form) => form.formId === payoutDetailsSteps.payoutAccountDocuments.formId);
|
|
23027
|
+
const formatFileSummaryData2 = (documents22) => {
|
|
23028
|
+
var _a2, _b2;
|
|
23029
|
+
return {
|
|
23030
|
+
...(documents22 == null ? void 0 : documents22.bankStatementDocument) && {
|
|
23031
|
+
bankStatementDocument: {
|
|
23032
|
+
fileName: (_b2 = (_a2 = documents22.bankStatementDocument) == null ? void 0 : _a2[0]) == null ? void 0 : _b2.name
|
|
23023
23033
|
}
|
|
23024
|
-
});
|
|
23025
|
-
};
|
|
23026
|
-
const gotoFormByFormIndex = (nextFormIndex) => {
|
|
23027
|
-
if (formRef.current.verifyForm) {
|
|
23028
|
-
formRef.current.verifyForm(activeForm.formId).then((isVerified) => {
|
|
23029
|
-
if (isVerified) {
|
|
23030
|
-
setHasAlreadyNavigatedForm(true);
|
|
23031
|
-
setActiveForm(allowedForms[nextFormIndex]);
|
|
23032
|
-
}
|
|
23033
|
-
});
|
|
23034
|
-
} else {
|
|
23035
|
-
setHasAlreadyNavigatedForm(true);
|
|
23036
|
-
setActiveForm(allowedForms[nextFormIndex]);
|
|
23037
23034
|
}
|
|
23038
23035
|
};
|
|
23039
|
-
const validateCurrentForm = () => {
|
|
23040
|
-
setShouldValidate(true);
|
|
23041
|
-
};
|
|
23042
|
-
const handleNextClick = () => {
|
|
23043
|
-
var _a2, _b2;
|
|
23044
|
-
if (formRef.current.customNavigationHandler) {
|
|
23045
|
-
formRef.current.customNavigationHandler();
|
|
23046
|
-
return;
|
|
23047
|
-
}
|
|
23048
|
-
if ((_a2 = customFormNavigationHandlers[activeForm.formId]) == null ? void 0 : _a2.onNext) {
|
|
23049
|
-
(_b2 = customFormNavigationHandlers[activeForm.formId]) == null ? void 0 : _b2.onNext();
|
|
23050
|
-
return;
|
|
23051
|
-
}
|
|
23052
|
-
const allFields = (derivedProps == null ? void 0 : derivedProps.allFields) || {};
|
|
23053
|
-
if (isFormSummaryStep(activeForm)) {
|
|
23054
|
-
if (skipSubmitAndGoTaskList) {
|
|
23055
|
-
props.navigateBackToTaskList();
|
|
23056
|
-
} else {
|
|
23057
|
-
props.onSubmit({
|
|
23058
|
-
data: getData(),
|
|
23059
|
-
forms: allowedForms,
|
|
23060
|
-
allFields,
|
|
23061
|
-
setLoadingStatus
|
|
23062
|
-
});
|
|
23063
|
-
}
|
|
23064
|
-
return;
|
|
23065
|
-
}
|
|
23066
|
-
if (formValidity[activeForm.formId]) {
|
|
23067
|
-
if (isFinalStep) {
|
|
23068
|
-
props.onSubmit({
|
|
23069
|
-
data: getData(),
|
|
23070
|
-
forms: allowedForms,
|
|
23071
|
-
allFields,
|
|
23072
|
-
setLoadingStatus
|
|
23073
|
-
});
|
|
23074
|
-
return;
|
|
23075
|
-
}
|
|
23076
|
-
setShouldValidate(false);
|
|
23077
|
-
const toFormIndex = allowedForms.findIndex((form) => form.formId === activeForm.formId) + 1;
|
|
23078
|
-
gotoFormByFormIndex(toFormIndex);
|
|
23079
|
-
const toForm = allowedForms[toFormIndex];
|
|
23080
|
-
trackNavigation2({
|
|
23081
|
-
fromForm: activeForm,
|
|
23082
|
-
toForm,
|
|
23083
|
-
component: "ActionBar"
|
|
23084
|
-
});
|
|
23085
|
-
trackSectionCompletion(activeForm);
|
|
23086
|
-
} else {
|
|
23087
|
-
validateCurrentForm();
|
|
23088
|
-
}
|
|
23089
|
-
};
|
|
23090
|
-
const handleBackClick = () => {
|
|
23091
|
-
const currentFormIndex = allowedForms.findIndex((form) => form.formId === activeForm.formId);
|
|
23092
|
-
if (currentFormIndex) {
|
|
23093
|
-
const fromForm = allowedForms[currentFormIndex];
|
|
23094
|
-
const toForm = allowedForms[currentFormIndex - 1];
|
|
23095
|
-
setActiveForm(toForm);
|
|
23096
|
-
setHasAlreadyNavigatedForm(true);
|
|
23097
|
-
trackNavigation2({
|
|
23098
|
-
fromForm,
|
|
23099
|
-
toForm,
|
|
23100
|
-
component: "ActionBar"
|
|
23101
|
-
});
|
|
23102
|
-
}
|
|
23103
|
-
};
|
|
23104
|
-
const setCustomHandlers = (formId, onNext, onBack) => {
|
|
23105
|
-
setCustomFormNavigationHandlers({
|
|
23106
|
-
...customFormNavigationHandlers,
|
|
23107
|
-
[formId]: {
|
|
23108
|
-
onNext,
|
|
23109
|
-
onBack
|
|
23110
|
-
}
|
|
23111
|
-
});
|
|
23112
|
-
};
|
|
23113
|
-
const nextButtonText = isReview ? isFormSummaryStep(activeForm) ? i18n.get("confirm") : i18n.get("next") : isFinalStep ? i18n.get(submitButtonLabel ?? "submit") : i18n.get("next");
|
|
23114
|
-
p(() => {
|
|
23115
|
-
props.eventEmitter.on("next", handleNextClick);
|
|
23116
|
-
props.eventEmitter.on("back", handleBackClick);
|
|
23117
|
-
props.eventEmitter.on("validate", validateCurrentForm);
|
|
23118
|
-
return () => {
|
|
23119
|
-
props.eventEmitter.off("next", handleNextClick);
|
|
23120
|
-
props.eventEmitter.off("back", handleNextClick);
|
|
23121
|
-
props.eventEmitter.off("validate", validateCurrentForm);
|
|
23122
|
-
};
|
|
23123
|
-
}, [activeForm, allowedForms]);
|
|
23124
|
-
const onCountryChange = (country2) => {
|
|
23125
|
-
setContextCountry(country2);
|
|
23126
|
-
};
|
|
23127
|
-
const onWrappedComponentChange = (state2) => {
|
|
23128
|
-
var _a2;
|
|
23129
|
-
setFormValidity(state2.validityByForm);
|
|
23130
|
-
(_a2 = props.onChange) == null ? void 0 : _a2.call(props, state2);
|
|
23131
|
-
};
|
|
23132
|
-
const handleStateChange = ({
|
|
23133
|
-
currentState
|
|
23134
|
-
}) => {
|
|
23135
|
-
onWrappedComponentChange(currentState);
|
|
23136
|
-
};
|
|
23137
|
-
const handleLeaveDropin = async () => {
|
|
23138
|
-
var _a2;
|
|
23139
|
-
const data = getData();
|
|
23140
|
-
const hasDataChanged2 = getState().hasAnyDataChanged;
|
|
23141
|
-
if (hasDataChanged2 && ((_a2 = props.canSubmit) == null ? void 0 : _a2.call(props, data))) {
|
|
23142
|
-
setInitialContextCountry(contextCountry);
|
|
23143
|
-
const allFields = (derivedProps == null ? void 0 : derivedProps.allFields) || {};
|
|
23144
|
-
await props.onSubmit({
|
|
23145
|
-
data,
|
|
23146
|
-
forms: allowedForms,
|
|
23147
|
-
allFields,
|
|
23148
|
-
setLoadingStatus
|
|
23149
|
-
});
|
|
23150
|
-
} else {
|
|
23151
|
-
props.handleHomeClick();
|
|
23152
|
-
}
|
|
23153
|
-
};
|
|
23154
|
-
const formFooter = !hideDropinLayout && !hideFooter && o(ActionBar, {
|
|
23155
|
-
onNext: handleNextClick,
|
|
23156
|
-
onBack: isFirstStep ? props.handleBackClick : handleBackClick,
|
|
23157
|
-
backButtonLabel: i18n.get("back"),
|
|
23158
|
-
nextButtonLabel: nextButtonText,
|
|
23159
|
-
onHome: handleLeaveDropin,
|
|
23160
|
-
homeButtonLabel: props.homeButtonLabel,
|
|
23161
|
-
hideOnHomeButton,
|
|
23162
|
-
hideBackButton
|
|
23163
|
-
});
|
|
23164
|
-
const wrappedComponent = o("div", {
|
|
23165
|
-
className: "adyen-kyc-form-container",
|
|
23166
|
-
children: o(LoaderWrapper, {
|
|
23167
|
-
status: loadingStatus,
|
|
23168
|
-
formOpacityWhenLoading: 0.3,
|
|
23169
|
-
loaderSize: "large",
|
|
23170
|
-
children: o(FormRouterContextProvider, {
|
|
23171
|
-
setFormIndex: gotoFormByFormIndex,
|
|
23172
|
-
forms: allowedForms,
|
|
23173
|
-
handleGetIdVerificationToken: props.handleGetIdVerificationToken,
|
|
23174
|
-
children: [o(StateContextWatcher, {
|
|
23175
|
-
owner: "FormComposer",
|
|
23176
|
-
onChange: handleStateChange
|
|
23177
|
-
}), o(WrappedComponent, {
|
|
23178
|
-
ref: formRef,
|
|
23179
|
-
forms: allowedForms,
|
|
23180
|
-
activeForm,
|
|
23181
|
-
...derivedProps,
|
|
23182
|
-
data: props.data,
|
|
23183
|
-
onChange: onWrappedComponentChange,
|
|
23184
|
-
evaluateConfiguration: (data) => evaluateConfiguration(fieldConfigurations, configCountry, data, isSettingEnabled, requiredFields),
|
|
23185
|
-
country: contextCountry,
|
|
23186
|
-
onCountryChange,
|
|
23187
|
-
legalEntityId: props.legalEntityId,
|
|
23188
|
-
problems: props == null ? void 0 : props.problems,
|
|
23189
|
-
shouldValidate,
|
|
23190
|
-
onNext: handleNextClick,
|
|
23191
|
-
onBack: handleBackClick,
|
|
23192
|
-
setHideDropinLayout,
|
|
23193
|
-
setHideNavigation,
|
|
23194
|
-
setHideFooter,
|
|
23195
|
-
setCustomFormNavigationHandlers: setCustomHandlers,
|
|
23196
|
-
setHideOnHomeButton,
|
|
23197
|
-
setHideBackButton,
|
|
23198
|
-
setSubmitButtonLabel,
|
|
23199
|
-
setSkipSubmitAndGoTaskList,
|
|
23200
|
-
bankVerificationVendors
|
|
23201
|
-
}), activeForm.formId === summaryStep.formId && o("div", {
|
|
23202
|
-
className: "adyen-kyc-form-wrapper",
|
|
23203
|
-
children: o(Summary, {
|
|
23204
|
-
trackNavigation: trackNavigation2,
|
|
23205
|
-
data: formatDataForSummary ? formatDataForSummary(getData(), allowedForms) : getData(),
|
|
23206
|
-
omittedKeys: getSummaryOmittedKeys ? getSummaryOmittedKeys(getData()) : null,
|
|
23207
|
-
omittedForms,
|
|
23208
|
-
forms: allowedForms,
|
|
23209
|
-
gotoForm: gotoFormByFormIndex,
|
|
23210
|
-
labels: derivedProps.labels,
|
|
23211
|
-
problems: props == null ? void 0 : props.problems
|
|
23212
|
-
})
|
|
23213
|
-
}), formFooter]
|
|
23214
|
-
})
|
|
23215
|
-
})
|
|
23216
|
-
});
|
|
23217
|
-
const allowedFormsWithValidity = addValidityToForms(allowedForms, formValidity, props.problems);
|
|
23218
|
-
const sidebar = !hideDropinLayout && !hideNavigation && o(LoaderWrapper, {
|
|
23219
|
-
status: loadingStatus,
|
|
23220
|
-
formOpacityWhenLoading: 0.3,
|
|
23221
|
-
showSpinner: false,
|
|
23222
|
-
className: "adyen-kyc-dropin__sidebar-wrapper",
|
|
23223
|
-
children: o(FormNavigation, {
|
|
23224
|
-
forms: allowedFormsWithValidity,
|
|
23225
|
-
activeForm: allowedFormsWithValidity.find((form) => form.formId === activeForm.formId),
|
|
23226
|
-
gotoForm: gotoFormByFormIndex,
|
|
23227
|
-
validateForm: validateCurrentForm,
|
|
23228
|
-
taskName,
|
|
23229
|
-
trackNavigation: trackNavigation2,
|
|
23230
|
-
hasVerificationErrors: ((_c = props == null ? void 0 : props.problems) == null ? void 0 : _c.verificationErrors) && ((_e = Object.keys((_d = props == null ? void 0 : props.problems) == null ? void 0 : _d.verificationErrors)) == null ? void 0 : _e.length) > 0
|
|
23231
|
-
})
|
|
23232
|
-
});
|
|
23233
|
-
const content = o(Fragment, {
|
|
23234
|
-
children: [sidebar, wrappedComponent]
|
|
23235
|
-
});
|
|
23236
|
-
if (!props.hideDropinLayout) {
|
|
23237
|
-
return o(DropinLayout, {
|
|
23238
|
-
content
|
|
23239
|
-
});
|
|
23240
|
-
}
|
|
23241
|
-
return wrappedComponent;
|
|
23242
23036
|
};
|
|
23243
|
-
|
|
23244
|
-
}
|
|
23245
|
-
const getRegistrationCountry = (legalEntityResponse) => {
|
|
23246
|
-
var _a, _b;
|
|
23247
|
-
if (legalEntityResponse.type === LegalEntityType.INDIVIDUAL) {
|
|
23248
|
-
return (_a = legalEntityResponse.individual) == null ? void 0 : _a.residentialAddress.country;
|
|
23249
|
-
}
|
|
23250
|
-
if (legalEntityResponse.type === LegalEntityType.ORGANIZATION) {
|
|
23251
|
-
return (_b = legalEntityResponse.organization) == null ? void 0 : _b.registeredAddress.country;
|
|
23252
|
-
}
|
|
23253
|
-
};
|
|
23254
|
-
const labels$1 = () => ({
|
|
23255
|
-
verifiedAccountHolder: () => "accountHolder",
|
|
23256
|
-
verifiedBankCountry: () => "bankCountry",
|
|
23257
|
-
verifiedBankName: () => "bankName",
|
|
23258
|
-
verifiedCurrencyCode: () => "currencyCode",
|
|
23259
|
-
verifiedBankAccountNumber: () => "bankAccountNumber"
|
|
23260
|
-
});
|
|
23261
|
-
const PayoutAccountWithFormComposer = withFormComposer(PayoutDetailsComponent, {
|
|
23262
|
-
getComponentForms: (props, isSettingEnabled) => {
|
|
23263
|
-
var _a, _b, _c, _d;
|
|
23264
|
-
return getAppropriatePayoutDetailsSteps(props.currentTask, Boolean((_b = (_a = props.data) == null ? void 0 : _a.payoutAccountDetails) == null ? void 0 : _b.transferInstrumentId), props.instantVerificationEnabled && isInstantVerificationAvailable({
|
|
23265
|
-
country: (_d = (_c = props.data) == null ? void 0 : _c.payoutVerificationMethod) == null ? void 0 : _d.bankCountry,
|
|
23266
|
-
bankVerificationVendors: props.bankVerificationVendors,
|
|
23267
|
-
verificationVendorsCallback: props.handleGetBankVerificationVendors
|
|
23268
|
-
}), isSettingEnabled("allowIntraRegionCrossBorderPayout"));
|
|
23269
|
-
},
|
|
23270
|
-
parseConfiguration: ({
|
|
23271
|
-
requiredFields,
|
|
23272
|
-
country: country2,
|
|
23273
|
-
bankVerificationAvailable
|
|
23274
|
-
}) => parsePayoutScenarios({
|
|
23275
|
-
requiredFields: requiredFields == null ? void 0 : requiredFields.fields,
|
|
23276
|
-
country: country2,
|
|
23277
|
-
bankVerificationAvailable
|
|
23278
|
-
}),
|
|
23279
|
-
rules,
|
|
23280
|
-
defaultTaskName: "payoutDetails",
|
|
23281
|
-
labels: labels$1,
|
|
23282
|
-
getConfigFor: "bankCountry"
|
|
23283
|
-
});
|
|
23284
|
-
function PayoutDetailsDropinComponent(props) {
|
|
23285
|
-
var _a, _b, _c;
|
|
23286
|
-
const {
|
|
23287
|
-
transferInstrument,
|
|
23288
|
-
setTransferInstrument,
|
|
23289
|
-
handleCreateDocument,
|
|
23290
|
-
handleGetDocument,
|
|
23291
|
-
handleUpdateDocument,
|
|
23292
|
-
handleUpdateTransferInstrument,
|
|
23293
|
-
handleCreateTransferInstrument,
|
|
23294
|
-
legalEntityResponse,
|
|
23295
|
-
trackingConfig,
|
|
23296
|
-
accountHolder: accountHolder2
|
|
23297
|
-
} = props;
|
|
23298
|
-
const [bankAccountCountry2, setBankAccountCountry] = h(getRegistrationCountry(legalEntityResponse));
|
|
23299
|
-
const defaultPayoutCountry = bankAccountCountry2 ?? props.country;
|
|
23300
|
-
const {
|
|
23301
|
-
i18n
|
|
23302
|
-
} = useCoreContext();
|
|
23303
|
-
const {
|
|
23304
|
-
showToast,
|
|
23305
|
-
clearToasts
|
|
23306
|
-
} = useToastContext();
|
|
23307
|
-
const [problems, setProblems] = h(props.problems || ((_b = (_a = getCapabilityProblems(legalEntityResponse)) == null ? void 0 : _a.BankAccount) == null ? void 0 : _b[transferInstrument == null ? void 0 : transferInstrument.id]));
|
|
23308
|
-
const documentUtils = documentApiUtils(handleCreateDocument, handleGetDocument, handleUpdateDocument);
|
|
23309
|
-
const existingPayoutDetails = transferInstrument ? mapTransferInstrumentToPayoutAccount(transferInstrument) : void 0;
|
|
23310
|
-
const fallbackCurrency = (_c = currencyByCountry[defaultPayoutCountry]) == null ? void 0 : _c[0];
|
|
23311
|
-
const accountHolderName = accountHolder2 || getLegalEntityNameBasedOnType(legalEntityResponse);
|
|
23312
|
-
const prefilledData = {
|
|
23313
|
-
payoutAccountDetails: {
|
|
23314
|
-
accountHolder: accountHolderName,
|
|
23315
|
-
currency: fallbackCurrency,
|
|
23316
|
-
...existingPayoutDetails == null ? void 0 : existingPayoutDetails.payoutAccountDetails
|
|
23317
|
-
},
|
|
23318
|
-
payoutVerificationMethod: {
|
|
23319
|
-
payoutVerificationMethod: transferInstrument ? isInstantVerifiedAccount(transferInstrument) ? "instantVerification" : "manualVerification" : void 0,
|
|
23320
|
-
bankCountry: defaultPayoutCountry,
|
|
23321
|
-
...existingPayoutDetails == null ? void 0 : existingPayoutDetails.payoutVerificationMethod
|
|
23322
|
-
},
|
|
23323
|
-
payoutAccountVerification: {
|
|
23324
|
-
verifiedAccountHolder: accountHolderName,
|
|
23325
|
-
verifiedBankCountry: defaultPayoutCountry,
|
|
23326
|
-
...existingPayoutDetails == null ? void 0 : existingPayoutDetails.payoutAccountVerification
|
|
23327
|
-
}
|
|
23328
|
-
};
|
|
23329
|
-
const [data, setData] = h(prefilledData || props.data);
|
|
23330
|
-
const baseTrackingPayload = getBaseTrackingPayload({
|
|
23331
|
-
trackingConfig,
|
|
23332
|
-
task: props.taskType
|
|
23333
|
-
});
|
|
23334
|
-
p(() => {
|
|
23335
|
-
userEvents.addPageView("Payout dropin");
|
|
23336
|
-
userEvents.addEvent("Started payout task", {
|
|
23337
|
-
segmentation: {
|
|
23338
|
-
...baseTrackingPayload
|
|
23339
|
-
}
|
|
23340
|
-
});
|
|
23341
|
-
}, []);
|
|
23342
|
-
p(() => {
|
|
23343
|
-
var _a2;
|
|
23344
|
-
const documentIds = ((_a2 = transferInstrument == null ? void 0 : transferInstrument.documentDetails) == null ? void 0 : _a2.map((documentReference) => documentReference.id)) || [];
|
|
23345
|
-
if (documentIds.length) {
|
|
23346
|
-
documentUtils.fetchDocuments(documentIds, transferInstrument == null ? void 0 : transferInstrument.id).then(() => {
|
|
23347
|
-
const mappedDocuments = mapApiDocumentToPayoutDocuments(transferInstrument == null ? void 0 : transferInstrument.id);
|
|
23348
|
-
setData({
|
|
23349
|
-
...data,
|
|
23350
|
-
payoutAccountDocuments: mappedDocuments
|
|
23351
|
-
});
|
|
23352
|
-
}).catch(() => {
|
|
23353
|
-
showToast({
|
|
23354
|
-
label: i18n.get("failedToFetchRelevantDocuments"),
|
|
23355
|
-
type: ToastType.ERROR
|
|
23356
|
-
});
|
|
23357
|
-
});
|
|
23358
|
-
}
|
|
23359
|
-
}, []);
|
|
23360
|
-
const submitDocuments = async ({
|
|
23361
|
-
forms,
|
|
23362
|
-
transferInstrument: transferInstrument2,
|
|
23363
|
-
dataSubmitted
|
|
23364
|
-
}) => {
|
|
23365
|
-
if (isDocumentsRequired2(forms)) {
|
|
23366
|
-
const documentToUpload = await mapPayoutDocumentsToApiDocuments(dataSubmitted, transferInstrument2.id);
|
|
23367
|
-
if (documentToUpload) {
|
|
23368
|
-
try {
|
|
23369
|
-
const documents2 = await documentUtils.uploadDocuments([documentToUpload], transferInstrument2.id);
|
|
23370
|
-
documents2.forEach((document2) => {
|
|
23371
|
-
var _a2;
|
|
23372
|
-
userEvents.addEvent("Saved document", {
|
|
23373
|
-
segmentation: {
|
|
23374
|
-
...baseTrackingPayload,
|
|
23375
|
-
documentType: document2.type,
|
|
23376
|
-
fileExtention: (_a2 = document2.attachments) == null ? void 0 : _a2.map((item) => getFileExtention(item.pageName))
|
|
23377
|
-
}
|
|
23378
|
-
});
|
|
23379
|
-
});
|
|
23380
|
-
} catch (e2) {
|
|
23381
|
-
setProblems({
|
|
23382
|
-
...problems,
|
|
23383
|
-
validationErrors: {
|
|
23384
|
-
payoutAccountDocuments: {
|
|
23385
|
-
bankStatementDocument: true
|
|
23386
|
-
}
|
|
23387
|
-
}
|
|
23388
|
-
});
|
|
23389
|
-
setTransferInstrument(transferInstrument2);
|
|
23390
|
-
throw new Error(i18n.get("remediationMessage_1_704"));
|
|
23391
|
-
}
|
|
23392
|
-
}
|
|
23393
|
-
}
|
|
23394
|
-
};
|
|
23395
|
-
const omitMaskedFieldsIfUnchanged = (maskedFields, dataSubmitted, savedData) => {
|
|
23396
|
-
maskedFields.forEach((maskedField) => {
|
|
23397
|
-
if (dataSubmitted[maskedField] === (savedData == null ? void 0 : savedData[maskedField])) {
|
|
23398
|
-
delete dataSubmitted[maskedField];
|
|
23399
|
-
}
|
|
23400
|
-
});
|
|
23401
|
-
};
|
|
23402
|
-
const onSubmit = async ({
|
|
23403
|
-
data: dataSubmitted,
|
|
23404
|
-
forms,
|
|
23405
|
-
setLoadingStatus
|
|
23406
|
-
}) => {
|
|
23407
|
-
var _a2, _b2;
|
|
23408
|
-
setLoadingStatus("loading");
|
|
23409
|
-
dataSubmitted.payoutAccountDetails.currency = dataSubmitted.payoutAccountDetails.currency ?? fallbackCurrency;
|
|
23410
|
-
if (defaultPayoutCountry === CountryCodes.Sweden && "iban" in dataSubmitted.payoutAccountDetails) {
|
|
23411
|
-
dataSubmitted.payoutAccountDetails.currency = Currency.EUR;
|
|
23412
|
-
}
|
|
23413
|
-
const event = {
|
|
23414
|
-
segmentation: {
|
|
23415
|
-
...baseTrackingPayload,
|
|
23416
|
-
documentType: DocumentType.BANK_STATEMENT,
|
|
23417
|
-
bankCountry: dataSubmitted.payoutVerificationMethod.bankCountry,
|
|
23418
|
-
bankCurrency: dataSubmitted.payoutAccountDetails.currency
|
|
23419
|
-
}
|
|
23420
|
-
};
|
|
23421
|
-
userEvents.addEvent("Provided payout details", event);
|
|
23422
|
-
omitMaskedFieldsIfUnchanged(maskedPayoutFields, dataSubmitted.payoutAccountDetails, existingPayoutDetails == null ? void 0 : existingPayoutDetails.payoutAccountDetails);
|
|
23423
|
-
let transferInstrument2 = mapPayoutAccountToTransferInstrument({
|
|
23424
|
-
data: dataSubmitted,
|
|
23425
|
-
legalEntity: legalEntityResponse
|
|
23426
|
-
});
|
|
23427
|
-
const transferInstrumentId = (_a2 = existingPayoutDetails == null ? void 0 : existingPayoutDetails.payoutAccountDetails) == null ? void 0 : _a2.transferInstrumentId;
|
|
23428
|
-
try {
|
|
23429
|
-
if (!transferInstrumentId) {
|
|
23430
|
-
transferInstrument2 = await handleCreateTransferInstrument(transferInstrument2);
|
|
23431
|
-
} else {
|
|
23432
|
-
transferInstrument2 = await handleUpdateTransferInstrument(drop("id").from(transferInstrument2), transferInstrumentId);
|
|
23433
|
-
}
|
|
23434
|
-
userEvents.addEvent("Saved payout details", event);
|
|
23435
|
-
try {
|
|
23436
|
-
await submitDocuments({
|
|
23437
|
-
forms,
|
|
23438
|
-
transferInstrument: transferInstrument2,
|
|
23439
|
-
dataSubmitted
|
|
23440
|
-
});
|
|
23441
|
-
setLoadingStatus("success");
|
|
23442
|
-
clearToasts();
|
|
23443
|
-
(_b2 = props.onSubmit) == null ? void 0 : _b2.call(props, dataSubmitted);
|
|
23444
|
-
} catch (e2) {
|
|
23445
|
-
setLoadingStatus("success");
|
|
23446
|
-
showToast({
|
|
23447
|
-
label: e2.message,
|
|
23448
|
-
type: ToastType.ERROR
|
|
23449
|
-
});
|
|
23450
|
-
}
|
|
23451
|
-
} catch (e2) {
|
|
23452
|
-
if (isValidationError(e2)) {
|
|
23453
|
-
const validationErrors = processValidationErrors(e2, props.taskType);
|
|
23454
|
-
setProblems({
|
|
23455
|
-
...problems,
|
|
23456
|
-
validationErrors
|
|
23457
|
-
});
|
|
23458
|
-
} else if (isMaintenanceModeError(e2)) {
|
|
23459
|
-
showToast({
|
|
23460
|
-
label: i18n.get("failedToUpdateDetails"),
|
|
23461
|
-
subLabel: i18n.get("maintenanceModeMessage"),
|
|
23462
|
-
type: ToastType.ERROR,
|
|
23463
|
-
duration: "indefinite"
|
|
23464
|
-
});
|
|
23465
|
-
} else {
|
|
23466
|
-
showToast({
|
|
23467
|
-
label: i18n.get("failedToUpdateDetails"),
|
|
23468
|
-
type: ToastType.ERROR
|
|
23469
|
-
});
|
|
23470
|
-
}
|
|
23471
|
-
setLoadingStatus("success");
|
|
23472
|
-
userEvents.addEvent("Encountered error payout details", {
|
|
23473
|
-
segmentation: {
|
|
23474
|
-
...baseTrackingPayload,
|
|
23475
|
-
errorCode: e2.errorCode,
|
|
23476
|
-
errorMessage: e2.title,
|
|
23477
|
-
errorType: "BE"
|
|
23478
|
-
}
|
|
23479
|
-
});
|
|
23480
|
-
}
|
|
23481
|
-
};
|
|
23482
|
-
const isDocumentsRequired2 = (forms) => forms.some((form) => form.formId === payoutSteps.payoutAccountDocuments.formId);
|
|
23483
|
-
const formatFileSummaryData2 = (documents2) => {
|
|
23484
|
-
var _a2, _b2;
|
|
23485
|
-
return {
|
|
23486
|
-
...(documents2 == null ? void 0 : documents2.bankStatementDocument) && {
|
|
23487
|
-
bankStatementDocument: {
|
|
23488
|
-
fileName: (_b2 = (_a2 = documents2.bankStatementDocument) == null ? void 0 : _a2[0]) == null ? void 0 : _b2.name
|
|
23489
|
-
}
|
|
23490
|
-
}
|
|
23491
|
-
};
|
|
23492
|
-
};
|
|
23493
|
-
const canSubmit2 = (data2) => {
|
|
23037
|
+
const canSubmit2 = () => {
|
|
23494
23038
|
var _a2;
|
|
23495
|
-
if (((_a2 =
|
|
23039
|
+
if (((_a2 = data.payoutVerificationMethod) == null ? void 0 : _a2.payoutVerificationMethod) === "instantVerification") {
|
|
23496
23040
|
return false;
|
|
23497
23041
|
}
|
|
23498
|
-
const bankDetails =
|
|
23499
|
-
return Object.values(bankDetails).every(Boolean);
|
|
23042
|
+
const bankDetails = data.payoutAccountDetails;
|
|
23043
|
+
return !isEmpty(bankDetails) && Object.values(bankDetails).every(Boolean);
|
|
23500
23044
|
};
|
|
23501
23045
|
const datasetUtils = datasetUtilities(i18n.locale);
|
|
23502
|
-
const formatDataForSummary = (
|
|
23046
|
+
const formatDataForSummary = () => {
|
|
23503
23047
|
var _a2;
|
|
23504
|
-
const summaryData = cloneObject(
|
|
23048
|
+
const summaryData = cloneObject(data);
|
|
23505
23049
|
if (((_a2 = summaryData.payoutVerificationMethod) == null ? void 0 : _a2.bankCountry) && summaryData.payoutAccountDetails) {
|
|
23506
23050
|
summaryData.payoutAccountDetails.bankCountry = datasetUtils.getCountryName(summaryData.payoutVerificationMethod.bankCountry);
|
|
23507
23051
|
}
|
|
23508
23052
|
if (summaryData == null ? void 0 : summaryData.payoutAccountDocuments) {
|
|
23509
|
-
summaryData.payoutAccountDocuments.bankStatementDocument = formatFileSummaryData2(
|
|
23053
|
+
summaryData.payoutAccountDocuments.bankStatementDocument = formatFileSummaryData2(data == null ? void 0 : data.payoutAccountDocuments);
|
|
23510
23054
|
}
|
|
23511
23055
|
return summaryData;
|
|
23512
23056
|
};
|
|
23513
|
-
|
|
23514
|
-
|
|
23515
|
-
|
|
23516
|
-
|
|
23517
|
-
|
|
23518
|
-
|
|
23519
|
-
|
|
23520
|
-
|
|
23521
|
-
|
|
23522
|
-
|
|
23523
|
-
|
|
23524
|
-
|
|
23525
|
-
|
|
23526
|
-
|
|
23527
|
-
|
|
23057
|
+
const {
|
|
23058
|
+
handleNextClick,
|
|
23059
|
+
handleBackClick,
|
|
23060
|
+
activeForm,
|
|
23061
|
+
shouldValidate,
|
|
23062
|
+
setShouldValidate,
|
|
23063
|
+
gotoFormByFormIndex,
|
|
23064
|
+
nextButtonLabel
|
|
23065
|
+
} = useFormComposer({
|
|
23066
|
+
problems,
|
|
23067
|
+
baseTrackingPayload,
|
|
23068
|
+
forms,
|
|
23069
|
+
submitButtonLabel,
|
|
23070
|
+
onSubmit,
|
|
23071
|
+
skipSubmit,
|
|
23072
|
+
onSkipSubmit: navigateBackToTaskList
|
|
23073
|
+
});
|
|
23074
|
+
return o(FormWrapper, {
|
|
23075
|
+
taskName: taskName ?? "payoutDetails",
|
|
23076
|
+
activeForm,
|
|
23077
|
+
summary: {
|
|
23078
|
+
data: formatDataForSummary(),
|
|
23079
|
+
omittedKeys: ["transferInstrumentId"],
|
|
23080
|
+
omittedForms: [payoutSteps.payoutVerificationMethod.formId],
|
|
23081
|
+
labels: derivedProps == null ? void 0 : derivedProps.labels
|
|
23082
|
+
},
|
|
23083
|
+
handleBackClick,
|
|
23084
|
+
handleNextClick,
|
|
23085
|
+
handleHomeClick,
|
|
23086
|
+
hideDropinLayout,
|
|
23087
|
+
hideHomeButton,
|
|
23088
|
+
hideBackButton,
|
|
23089
|
+
loadingStatus,
|
|
23090
|
+
forms,
|
|
23091
|
+
onSubmit,
|
|
23092
|
+
baseTrackingPayload,
|
|
23093
|
+
gotoFormByFormIndex,
|
|
23094
|
+
nextButtonLabel,
|
|
23095
|
+
homeButtonLabel,
|
|
23096
|
+
validateForm: () => setShouldValidate(true),
|
|
23097
|
+
canSubmit: canSubmit2() && hasDataChanged(prefilledData, data),
|
|
23098
|
+
problems,
|
|
23099
|
+
children: o(PayoutDetailsComponent, {
|
|
23100
|
+
...derivedProps,
|
|
23101
|
+
capabilities,
|
|
23102
|
+
data: {
|
|
23103
|
+
...prefilledData,
|
|
23104
|
+
payoutAccountDocuments: documents2
|
|
23105
|
+
},
|
|
23528
23106
|
country: defaultPayoutCountry,
|
|
23107
|
+
activeForm,
|
|
23108
|
+
forms,
|
|
23529
23109
|
problems,
|
|
23530
|
-
eventEmitter
|
|
23531
|
-
|
|
23532
|
-
|
|
23533
|
-
|
|
23534
|
-
|
|
23535
|
-
|
|
23536
|
-
|
|
23110
|
+
eventEmitter,
|
|
23111
|
+
onBack: handleBackClick,
|
|
23112
|
+
accountHolder: accountHolder2 ?? getLegalEntityNameBasedOnType(legalEntityResponse),
|
|
23113
|
+
setHideDropinLayout,
|
|
23114
|
+
setSubmitButtonLabel,
|
|
23115
|
+
setHideOnHomeButton: setHideHomeButton,
|
|
23116
|
+
setHideBackButton,
|
|
23117
|
+
setSkipSubmit,
|
|
23118
|
+
onChange,
|
|
23537
23119
|
legalEntityResponse,
|
|
23538
|
-
|
|
23539
|
-
|
|
23540
|
-
|
|
23541
|
-
|
|
23542
|
-
|
|
23543
|
-
|
|
23544
|
-
onSubmit,
|
|
23545
|
-
handleBackClick: props.handleBackClick,
|
|
23546
|
-
handleCreateTransferInstrument: props.handleCreateTransferInstrument,
|
|
23547
|
-
handleUpdateTransferInstrument: props.handleUpdateTransferInstrument,
|
|
23548
|
-
handleGetBankVerificationVendors: props.handleGetBankVerificationVendors,
|
|
23549
|
-
navigateBackToTaskList: props.navigateBackToTaskList,
|
|
23550
|
-
instantVerificationEnabled: !transferInstrument,
|
|
23551
|
-
refreshLegalEntity: props.refreshLegalEntity
|
|
23552
|
-
})]
|
|
23120
|
+
handleGetBankVerificationVendors,
|
|
23121
|
+
instantVerificationEnabled,
|
|
23122
|
+
refreshLegalEntity,
|
|
23123
|
+
shouldValidate,
|
|
23124
|
+
bankVerificationVendors
|
|
23125
|
+
})
|
|
23553
23126
|
});
|
|
23554
23127
|
}
|
|
23555
23128
|
const ContractViewer$1 = "";
|
|
@@ -24260,658 +23833,1233 @@ function TrustRoleAndEntityTypeComponent(props) {
|
|
|
24260
23833
|
} = e2.target;
|
|
24261
23834
|
handleChangeFor("descriptionUndefinedBeneficiary")(value);
|
|
24262
23835
|
};
|
|
24263
|
-
const changeRoles = (roles) => {
|
|
24264
|
-
handleChangeFor("role")(roles);
|
|
24265
|
-
if (roles.includes("undefinedBeneficiary")) {
|
|
24266
|
-
handleChangeFor("entityType")(void 0);
|
|
23836
|
+
const changeRoles = (roles) => {
|
|
23837
|
+
handleChangeFor("role")(roles);
|
|
23838
|
+
if (roles.includes("undefinedBeneficiary")) {
|
|
23839
|
+
handleChangeFor("entityType")(void 0);
|
|
23840
|
+
} else {
|
|
23841
|
+
handleChangeFor("descriptionUndefinedBeneficiary")(void 0);
|
|
23842
|
+
}
|
|
23843
|
+
};
|
|
23844
|
+
const changeSettlorExemptionReasons = (exemptionReasons) => {
|
|
23845
|
+
var _a;
|
|
23846
|
+
if (exemptionReasons.includes("noneOfTheAbove")) {
|
|
23847
|
+
handleChangeFor("settlorExemptionReason")(((_a = data.settlorExemptionReason) == null ? void 0 : _a.includes("noneOfTheAbove")) ? exemptionReasons.filter((reason) => reason !== "noneOfTheAbove") : ["noneOfTheAbove"]);
|
|
23848
|
+
return;
|
|
23849
|
+
}
|
|
23850
|
+
handleChangeFor("settlorExemptionReason")(exemptionReasons);
|
|
23851
|
+
};
|
|
23852
|
+
return o("form", {
|
|
23853
|
+
className: "adyen-kyc-trust__role-and-entity-type adl-u-width-full",
|
|
23854
|
+
children: [o(FormHeader, {
|
|
23855
|
+
heading: i18n.get("roleAndEntityType")
|
|
23856
|
+
}), o(ErrorPanel, {
|
|
23857
|
+
verificationErrors: props == null ? void 0 : props.formVerificationErrors,
|
|
23858
|
+
validationErrors: props == null ? void 0 : props.fieldValidationErrors,
|
|
23859
|
+
formUtils,
|
|
23860
|
+
id: "ariaErrorField"
|
|
23861
|
+
}), o(Field, {
|
|
23862
|
+
name: "role",
|
|
23863
|
+
label: formUtils.getLabel("role", "selectTheApplicableRoles"),
|
|
23864
|
+
classNameModifiers: ["role"],
|
|
23865
|
+
errorMessage: formUtils.getErrorMessage("role", errors, fieldProblems),
|
|
23866
|
+
isValid: valid.role,
|
|
23867
|
+
disabled: availableRoles.length === 0,
|
|
23868
|
+
showErrorIconBottom: true,
|
|
23869
|
+
children: (childProps) => o(MultiSelectList, {
|
|
23870
|
+
...childProps,
|
|
23871
|
+
options: Object.values(TrustMemberTypes),
|
|
23872
|
+
selected: data.role ?? [],
|
|
23873
|
+
onSelect: changeRoles,
|
|
23874
|
+
mapToSelectItem: (role2) => ({
|
|
23875
|
+
...makeSelectItemForTrustRole(role2, i18n),
|
|
23876
|
+
disabled: !availableRoles.includes(role2)
|
|
23877
|
+
})
|
|
23878
|
+
})
|
|
23879
|
+
}), (schema == null ? void 0 : schema.includes("entityType")) && o(Field, {
|
|
23880
|
+
name: "entityType",
|
|
23881
|
+
useLabelElement: false,
|
|
23882
|
+
errorMessage: formUtils.getErrorMessage("entityType", errors, fieldProblems),
|
|
23883
|
+
label: formUtils.getLabel("entityType", "whatTypeOfYourMembersEntity"),
|
|
23884
|
+
classNameModifiers: ["entityType"],
|
|
23885
|
+
disabled: !!(trustMember == null ? void 0 : trustMember.reference),
|
|
23886
|
+
children: (childProps) => o(RadioCardSelect, {
|
|
23887
|
+
...childProps,
|
|
23888
|
+
options: trustMemberLegalEntityTypes,
|
|
23889
|
+
onSelect: handleChangeFor("entityType"),
|
|
23890
|
+
selected: data.entityType,
|
|
23891
|
+
optionId: (option) => leTypeCardDetails[option].id,
|
|
23892
|
+
optionName: (option) => leTypeCardDetails[option].name,
|
|
23893
|
+
optionDescription: (option) => leTypeCardDetails[option].description,
|
|
23894
|
+
"aria-required": true,
|
|
23895
|
+
"aria-label": formUtils.getLabel("entityType", "whatTypeOfYourMembersEntity"),
|
|
23896
|
+
"aria-invalid": !valid.entityType
|
|
23897
|
+
})
|
|
23898
|
+
}), (schema == null ? void 0 : schema.includes("descriptionUndefinedBeneficiary")) && o(Field, {
|
|
23899
|
+
name: "descriptionUndefinedBeneficiary",
|
|
23900
|
+
label: formUtils.getLabel("description"),
|
|
23901
|
+
isValid: valid.descriptionUndefinedBeneficiary,
|
|
23902
|
+
errorMessage: formUtils.getErrorMessage("descriptionUndefinedBeneficiary", errors, fieldProblems),
|
|
23903
|
+
children: (childProps) => o(TextArea, {
|
|
23904
|
+
...childProps,
|
|
23905
|
+
name: "descriptionUndefinedBeneficiary",
|
|
23906
|
+
value: data.descriptionUndefinedBeneficiary,
|
|
23907
|
+
classNameModifiers: ["descriptionUndefinedBeneficiary"],
|
|
23908
|
+
maxLength: CHARACTERS_LIMIT,
|
|
23909
|
+
onInput: onInputDescription,
|
|
23910
|
+
helper: i18n.get("describeWhoIsABeneficiaryInYourTrust"),
|
|
23911
|
+
"aria-required": true,
|
|
23912
|
+
"aria-label": formUtils.getLabel("descriptionUndefinedBeneficiary"),
|
|
23913
|
+
"aria-invalid": !valid.descriptionUndefinedBeneficiary
|
|
23914
|
+
})
|
|
23915
|
+
}), (schema == null ? void 0 : schema.includes("settlorExemptionReason")) && o(Field, {
|
|
23916
|
+
name: "settlorExemptionReason",
|
|
23917
|
+
label: formUtils.getLabel("settlorExemptionReason", "whichOfTheseApplyToTheSettlor"),
|
|
23918
|
+
isValid: valid.settlorExemptionReason,
|
|
23919
|
+
errorMessage: formUtils.getErrorMessage("settlorExemptionReason", errors, fieldProblems),
|
|
23920
|
+
showErrorIconBottom: true,
|
|
23921
|
+
children: (childProps) => o(MultiSelectList, {
|
|
23922
|
+
...childProps,
|
|
23923
|
+
options: settlorExemptionReasonWithNoneOfTheAbove,
|
|
23924
|
+
selected: data.settlorExemptionReason ?? [],
|
|
23925
|
+
onSelect: changeSettlorExemptionReasons,
|
|
23926
|
+
mapToSelectItem: (reason) => ({
|
|
23927
|
+
id: reason,
|
|
23928
|
+
name: i18n.get(reason)
|
|
23929
|
+
})
|
|
23930
|
+
})
|
|
23931
|
+
})]
|
|
23932
|
+
});
|
|
23933
|
+
}
|
|
23934
|
+
const summary = {
|
|
23935
|
+
formId: "summary",
|
|
23936
|
+
formName: "summary"
|
|
23937
|
+
};
|
|
23938
|
+
const roleAndTypeForms = {
|
|
23939
|
+
roleAndEntityType: {
|
|
23940
|
+
formId: "roleAndEntityType",
|
|
23941
|
+
formName: "roleAndEntityType",
|
|
23942
|
+
fields: ["role", "entityType"]
|
|
23943
|
+
},
|
|
23944
|
+
memberDetails: {
|
|
23945
|
+
formId: "memberDetails",
|
|
23946
|
+
formName: "memberDetails"
|
|
23947
|
+
},
|
|
23948
|
+
summary
|
|
23949
|
+
};
|
|
23950
|
+
const undefinedBeneficiaryForms = {
|
|
23951
|
+
roleAndEntityType: {
|
|
23952
|
+
formId: "roleAndEntityType",
|
|
23953
|
+
formName: "roleAndEntityType",
|
|
23954
|
+
fields: ["role", "entityType", "descriptionUndefinedBeneficiary"]
|
|
23955
|
+
},
|
|
23956
|
+
summary
|
|
23957
|
+
};
|
|
23958
|
+
const exemptSettlorForms = {
|
|
23959
|
+
roleAndEntityType: {
|
|
23960
|
+
formId: "roleAndEntityType",
|
|
23961
|
+
formName: "roleAndEntityType",
|
|
23962
|
+
fields: ["role", "entityType", "settlorExemptionReason"]
|
|
23963
|
+
},
|
|
23964
|
+
summary
|
|
23965
|
+
};
|
|
23966
|
+
const logger$3 = createLogger("RoleAndTypeDropin");
|
|
23967
|
+
function RoleAndTypeDropinComponent(props) {
|
|
23968
|
+
var _a, _b;
|
|
23969
|
+
const {
|
|
23970
|
+
i18n
|
|
23971
|
+
} = useCoreContext();
|
|
23972
|
+
const {
|
|
23973
|
+
showToast
|
|
23974
|
+
} = useToastContext();
|
|
23975
|
+
const [trustMember, setTrustMember] = h(props.trustMember);
|
|
23976
|
+
const [shouldValidate, setShouldValidate] = h(false);
|
|
23977
|
+
const roleAndEntityTypeFormID = "roleAndEntityType";
|
|
23978
|
+
const [formList, setFormList] = h([...Object.values(roleAndTypeForms)]);
|
|
23979
|
+
const [formValidity, setFormValidity] = h({
|
|
23980
|
+
[roleAndEntityTypeFormID]: false
|
|
23981
|
+
});
|
|
23982
|
+
const taskName = "trustMembers";
|
|
23983
|
+
const [activeForm, setActiveForm] = h(formList[0]);
|
|
23984
|
+
const isSummaryStep = activeForm.formId === summaryStep.formId;
|
|
23985
|
+
const trustMemberCase = ((_a = trustMember == null ? void 0 : trustMember.settlorExemptionReason) == null ? void 0 : _a.length) ? "exemptSettlor" : ((_b = trustMember == null ? void 0 : trustMember.types) == null ? void 0 : _b.includes(TrustMemberTypes.UNDEFINED_BENEFICIARY)) ? "undefinedBeneficiary" : "fullEntity";
|
|
23986
|
+
const navigateToTrustMember = () => {
|
|
23987
|
+
const trustMemberAssociation = {
|
|
23988
|
+
...props.trustMember,
|
|
23989
|
+
legalEntityType: trustMember == null ? void 0 : trustMember.legalEntityType,
|
|
23990
|
+
types: trustMember == null ? void 0 : trustMember.types
|
|
23991
|
+
};
|
|
23992
|
+
props.navigateNext(trustMemberAssociation);
|
|
23993
|
+
};
|
|
23994
|
+
const submitExemptSettlor = async (exemptSettlor, trustLE) => {
|
|
23995
|
+
var _a2;
|
|
23996
|
+
const existingTrustMembers = getOwnTrustMembers(trustLE);
|
|
23997
|
+
const existingSettlor = existingTrustMembers.find((member) => member.type === "settlor");
|
|
23998
|
+
const updatedAssociations = [...(trustLE.entityAssociations ?? []).filter((association) => association !== existingSettlor), exemptSettlor];
|
|
23999
|
+
const updatedTrustLE = {
|
|
24000
|
+
...trustLE,
|
|
24001
|
+
entityAssociations: updatedAssociations
|
|
24002
|
+
};
|
|
24003
|
+
try {
|
|
24004
|
+
await ((_a2 = props.handleUpdateLegalEntity) == null ? void 0 : _a2.call(props, updatedTrustLE, trustLE.id));
|
|
24005
|
+
showToast({
|
|
24006
|
+
label: i18n.get("successfullyUpdatedDetails"),
|
|
24007
|
+
type: ToastType.SUCCESS
|
|
24008
|
+
});
|
|
24009
|
+
props.onSubmit(updatedTrustLE);
|
|
24010
|
+
} catch (e2) {
|
|
24011
|
+
logger$3.error(e2);
|
|
24012
|
+
showToast({
|
|
24013
|
+
label: i18n.get("failedToUpdateDetails"),
|
|
24014
|
+
type: ToastType.ERROR
|
|
24015
|
+
});
|
|
24016
|
+
}
|
|
24017
|
+
};
|
|
24018
|
+
const submitUndefinedBeneficiary = async () => {
|
|
24019
|
+
var _a2, _b2, _c;
|
|
24020
|
+
if (((_a2 = props.trustMember) == null ? void 0 : _a2.descriptionUndefinedBeneficiary) === (trustMember == null ? void 0 : trustMember.descriptionUndefinedBeneficiary)) {
|
|
24021
|
+
props.onSubmit(props.trust);
|
|
24022
|
+
return;
|
|
24023
|
+
}
|
|
24024
|
+
const existingUndefinedBeneficiaryInfo = (((_b2 = props.trust.trust) == null ? void 0 : _b2.undefinedBeneficiaryInfo) ?? []).filter((ub) => ub.reference !== (trustMember == null ? void 0 : trustMember.reference));
|
|
24025
|
+
const updatedTrust = {
|
|
24026
|
+
trust: {
|
|
24027
|
+
undefinedBeneficiaryInfo: [{
|
|
24028
|
+
...(trustMember == null ? void 0 : trustMember.reference) && {
|
|
24029
|
+
reference: trustMember == null ? void 0 : trustMember.reference
|
|
24030
|
+
},
|
|
24031
|
+
description: (trustMember == null ? void 0 : trustMember.descriptionUndefinedBeneficiary) || ""
|
|
24032
|
+
}, ...existingUndefinedBeneficiaryInfo]
|
|
24033
|
+
}
|
|
24034
|
+
};
|
|
24035
|
+
try {
|
|
24036
|
+
await ((_c = props.handleUpdateLegalEntity) == null ? void 0 : _c.call(props, updatedTrust, props.trust.id));
|
|
24037
|
+
showToast({
|
|
24038
|
+
label: i18n.get("successfullyUpdatedDetails"),
|
|
24039
|
+
type: ToastType.SUCCESS
|
|
24040
|
+
});
|
|
24041
|
+
props.onSubmit(updatedTrust);
|
|
24042
|
+
} catch (e2) {
|
|
24043
|
+
logger$3.error(e2);
|
|
24044
|
+
showToast({
|
|
24045
|
+
label: i18n.get("failedToUpdateDetails"),
|
|
24046
|
+
type: ToastType.ERROR
|
|
24047
|
+
});
|
|
24048
|
+
}
|
|
24049
|
+
};
|
|
24050
|
+
const formatRolesForSummary = (roles) => roles.map((role2) => i18n.get(getTrustMemberName(role2))).join(", ");
|
|
24051
|
+
const formatSettlorExemptionReasonsForSummary = (reasons) => reasons.map((reason) => i18n.get(reason)).join(", ");
|
|
24052
|
+
const summaryData = {
|
|
24053
|
+
roleAndEntityType: {
|
|
24054
|
+
role: formatRolesForSummary((trustMember == null ? void 0 : trustMember.types) ?? []),
|
|
24055
|
+
entityType: (trustMember == null ? void 0 : trustMember.legalEntityType) ? i18n.get(trustMember == null ? void 0 : trustMember.legalEntityType) : void 0,
|
|
24056
|
+
descriptionUndefinedBeneficiary: trustMember == null ? void 0 : trustMember.descriptionUndefinedBeneficiary,
|
|
24057
|
+
otherInformation: formatSettlorExemptionReasonsForSummary((trustMember == null ? void 0 : trustMember.settlorExemptionReason) ?? [])
|
|
24058
|
+
}
|
|
24059
|
+
};
|
|
24060
|
+
const onNavigateToNextStep = () => {
|
|
24061
|
+
if (isSummaryStep) {
|
|
24062
|
+
switch (trustMemberCase) {
|
|
24063
|
+
case "exemptSettlor":
|
|
24064
|
+
if (!trustMember)
|
|
24065
|
+
return;
|
|
24066
|
+
submitExemptSettlor(trustMember, props.trust).catch(logger$3.error);
|
|
24067
|
+
break;
|
|
24068
|
+
case "undefinedBeneficiary":
|
|
24069
|
+
submitUndefinedBeneficiary().catch(logger$3.error);
|
|
24070
|
+
break;
|
|
24071
|
+
default:
|
|
24072
|
+
return;
|
|
24073
|
+
}
|
|
24074
|
+
}
|
|
24075
|
+
if (!formValidity[roleAndEntityTypeFormID]) {
|
|
24076
|
+
setShouldValidate(true);
|
|
24077
|
+
return;
|
|
24078
|
+
}
|
|
24079
|
+
if (trustMemberCase === "fullEntity") {
|
|
24080
|
+
navigateToTrustMember();
|
|
24081
|
+
} else {
|
|
24082
|
+
setActiveForm(summary);
|
|
24083
|
+
}
|
|
24084
|
+
};
|
|
24085
|
+
const onTrustMemberChange = ({
|
|
24086
|
+
data,
|
|
24087
|
+
isValid = false,
|
|
24088
|
+
dataStoreId = void 0
|
|
24089
|
+
}) => {
|
|
24090
|
+
if (dataStoreId) {
|
|
24091
|
+
setFormValidity({
|
|
24092
|
+
...formValidity,
|
|
24093
|
+
[dataStoreId]: isValid
|
|
24094
|
+
});
|
|
24095
|
+
}
|
|
24096
|
+
if ((data == null ? void 0 : data.role) && data.role.includes(TrustMemberTypes.UNDEFINED_BENEFICIARY)) {
|
|
24097
|
+
setFormList([...Object.values(undefinedBeneficiaryForms)]);
|
|
24098
|
+
} else if (isExemptSettlor(data)) {
|
|
24099
|
+
setFormList([...Object.values(exemptSettlorForms)]);
|
|
24267
24100
|
} else {
|
|
24268
|
-
|
|
24101
|
+
setFormList([...Object.values(roleAndTypeForms)]);
|
|
24269
24102
|
}
|
|
24103
|
+
setTrustMember({
|
|
24104
|
+
...props.trustMember,
|
|
24105
|
+
...data.role ? {
|
|
24106
|
+
types: data.role
|
|
24107
|
+
} : {},
|
|
24108
|
+
legalEntityType: data.entityType,
|
|
24109
|
+
...data.descriptionUndefinedBeneficiary ? {
|
|
24110
|
+
descriptionUndefinedBeneficiary: data.descriptionUndefinedBeneficiary
|
|
24111
|
+
} : {},
|
|
24112
|
+
...isExemptSettlor(data) ? {
|
|
24113
|
+
settlorExemptionReason: data.settlorExemptionReason.filter((reason) => reason !== "noneOfTheAbove")
|
|
24114
|
+
} : {}
|
|
24115
|
+
});
|
|
24270
24116
|
};
|
|
24271
|
-
const
|
|
24272
|
-
var
|
|
24273
|
-
if (
|
|
24274
|
-
handleChangeFor("settlorExemptionReason")(((_a = data.settlorExemptionReason) == null ? void 0 : _a.includes("noneOfTheAbove")) ? exemptionReasons.filter((reason) => reason !== "noneOfTheAbove") : ["noneOfTheAbove"]);
|
|
24117
|
+
const saveRolesAndNavigate = async () => {
|
|
24118
|
+
var _a2, _b2, _c;
|
|
24119
|
+
if (!trustMember) {
|
|
24275
24120
|
return;
|
|
24276
24121
|
}
|
|
24277
|
-
|
|
24122
|
+
const {
|
|
24123
|
+
reference
|
|
24124
|
+
} = trustMember;
|
|
24125
|
+
if (reference && hasRolesChanged(trustMember.types, (_a2 = props.trustMember) == null ? void 0 : _a2.types) && props.trust.id) {
|
|
24126
|
+
const existingTrustAssociations = getOwnEntityAssociations(props.trust);
|
|
24127
|
+
const updatedTrustAssociations = {
|
|
24128
|
+
entityAssociations: [...((_b2 = trustMember.types) == null ? void 0 : _b2.map((role2) => ({
|
|
24129
|
+
type: role2,
|
|
24130
|
+
reference
|
|
24131
|
+
}))) || [], ...existingTrustAssociations.filter((ea) => ea.legalEntityId !== trustMember.reference) || []]
|
|
24132
|
+
};
|
|
24133
|
+
await ((_c = props.handleUpdateLegalEntity) == null ? void 0 : _c.call(props, updatedTrustAssociations, props.trust.id));
|
|
24134
|
+
}
|
|
24135
|
+
props.navigateBack();
|
|
24278
24136
|
};
|
|
24279
|
-
|
|
24280
|
-
|
|
24281
|
-
|
|
24282
|
-
|
|
24283
|
-
|
|
24284
|
-
|
|
24285
|
-
|
|
24286
|
-
|
|
24287
|
-
|
|
24288
|
-
|
|
24289
|
-
|
|
24290
|
-
|
|
24291
|
-
|
|
24292
|
-
|
|
24293
|
-
|
|
24294
|
-
|
|
24295
|
-
|
|
24296
|
-
children:
|
|
24297
|
-
|
|
24298
|
-
|
|
24299
|
-
|
|
24300
|
-
|
|
24301
|
-
|
|
24302
|
-
|
|
24303
|
-
disabled: !availableRoles.includes(role2)
|
|
24137
|
+
const hasRolesChanged = (newRoles = [], existingRoles = []) => newRoles.length !== existingRoles.length || !newRoles.every((newRole) => existingRoles.includes(newRole));
|
|
24138
|
+
const formsWithValidity = Object.values(formList).map((form) => ({
|
|
24139
|
+
formId: form.formId,
|
|
24140
|
+
formName: form.formName,
|
|
24141
|
+
isValid: formValidity[form.formId]
|
|
24142
|
+
}));
|
|
24143
|
+
const gotoFormByFormIndex = (formIndex) => {
|
|
24144
|
+
setActiveForm(formList[formIndex]);
|
|
24145
|
+
};
|
|
24146
|
+
const content = o(Fragment, {
|
|
24147
|
+
children: [o(FormNavigation, {
|
|
24148
|
+
forms: formsWithValidity,
|
|
24149
|
+
activeForm: formsWithValidity.find((form) => form.formId === activeForm.formId),
|
|
24150
|
+
taskName,
|
|
24151
|
+
gotoForm: noop
|
|
24152
|
+
}), o("div", {
|
|
24153
|
+
className: "adyen-kyc-form-container",
|
|
24154
|
+
children: [o("div", {
|
|
24155
|
+
className: activeForm.formId !== "roleAndEntityType" ? "adyen-kyc-form-wrapper adyen-kyc-form-wrapper--hidden" : "adyen-kyc-form-wrapper",
|
|
24156
|
+
children: o(TrustRoleAndEntityTypeComponent, {
|
|
24157
|
+
id: roleAndEntityTypeFormID,
|
|
24158
|
+
trustMember: props.trustMember,
|
|
24159
|
+
onChange: onTrustMemberChange,
|
|
24160
|
+
shouldValidate
|
|
24304
24161
|
})
|
|
24305
|
-
})
|
|
24306
|
-
|
|
24307
|
-
|
|
24308
|
-
|
|
24309
|
-
|
|
24310
|
-
|
|
24311
|
-
classNameModifiers: ["entityType"],
|
|
24312
|
-
disabled: !!(trustMember == null ? void 0 : trustMember.reference),
|
|
24313
|
-
children: (childProps) => o(RadioCardSelect, {
|
|
24314
|
-
...childProps,
|
|
24315
|
-
options: trustMemberLegalEntityTypes,
|
|
24316
|
-
onSelect: handleChangeFor("entityType"),
|
|
24317
|
-
selected: data.entityType,
|
|
24318
|
-
optionId: (option) => leTypeCardDetails[option].id,
|
|
24319
|
-
optionName: (option) => leTypeCardDetails[option].name,
|
|
24320
|
-
optionDescription: (option) => leTypeCardDetails[option].description,
|
|
24321
|
-
"aria-required": true,
|
|
24322
|
-
"aria-label": formUtils.getLabel("entityType", "whatTypeOfYourMembersEntity"),
|
|
24323
|
-
"aria-invalid": !valid.entityType
|
|
24324
|
-
})
|
|
24325
|
-
}), (schema == null ? void 0 : schema.includes("descriptionUndefinedBeneficiary")) && o(Field, {
|
|
24326
|
-
name: "descriptionUndefinedBeneficiary",
|
|
24327
|
-
label: formUtils.getLabel("description"),
|
|
24328
|
-
isValid: valid.descriptionUndefinedBeneficiary,
|
|
24329
|
-
errorMessage: formUtils.getErrorMessage("descriptionUndefinedBeneficiary", errors, fieldProblems),
|
|
24330
|
-
children: (childProps) => o(TextArea, {
|
|
24331
|
-
...childProps,
|
|
24332
|
-
name: "descriptionUndefinedBeneficiary",
|
|
24333
|
-
value: data.descriptionUndefinedBeneficiary,
|
|
24334
|
-
classNameModifiers: ["descriptionUndefinedBeneficiary"],
|
|
24335
|
-
maxLength: CHARACTERS_LIMIT,
|
|
24336
|
-
onInput: onInputDescription,
|
|
24337
|
-
helper: i18n.get("describeWhoIsABeneficiaryInYourTrust"),
|
|
24338
|
-
"aria-required": true,
|
|
24339
|
-
"aria-label": formUtils.getLabel("descriptionUndefinedBeneficiary"),
|
|
24340
|
-
"aria-invalid": !valid.descriptionUndefinedBeneficiary
|
|
24341
|
-
})
|
|
24342
|
-
}), (schema == null ? void 0 : schema.includes("settlorExemptionReason")) && o(Field, {
|
|
24343
|
-
name: "settlorExemptionReason",
|
|
24344
|
-
label: formUtils.getLabel("settlorExemptionReason", "whichOfTheseApplyToTheSettlor"),
|
|
24345
|
-
isValid: valid.settlorExemptionReason,
|
|
24346
|
-
errorMessage: formUtils.getErrorMessage("settlorExemptionReason", errors, fieldProblems),
|
|
24347
|
-
showErrorIconBottom: true,
|
|
24348
|
-
children: (childProps) => o(MultiSelectList, {
|
|
24349
|
-
...childProps,
|
|
24350
|
-
options: settlorExemptionReasonWithNoneOfTheAbove,
|
|
24351
|
-
selected: data.settlorExemptionReason ?? [],
|
|
24352
|
-
onSelect: changeSettlorExemptionReasons,
|
|
24353
|
-
mapToSelectItem: (reason) => ({
|
|
24354
|
-
id: reason,
|
|
24355
|
-
name: i18n.get(reason)
|
|
24162
|
+
}), isSummaryStep && o("div", {
|
|
24163
|
+
className: "adyen-kyc-form-wrapper",
|
|
24164
|
+
children: o(Summary, {
|
|
24165
|
+
data: summaryData,
|
|
24166
|
+
forms: [undefinedBeneficiaryForms.roleAndEntityType],
|
|
24167
|
+
gotoForm: gotoFormByFormIndex
|
|
24356
24168
|
})
|
|
24357
|
-
})
|
|
24169
|
+
}), o(ActionBar, {
|
|
24170
|
+
onNext: onNavigateToNextStep,
|
|
24171
|
+
onHome: saveRolesAndNavigate,
|
|
24172
|
+
nextButtonLabel: isSummaryStep ? i18n.get("submit") : i18n.get("next"),
|
|
24173
|
+
homeButtonLabel: i18n.get("saveAndGoToOverview")
|
|
24174
|
+
})]
|
|
24358
24175
|
})]
|
|
24359
24176
|
});
|
|
24177
|
+
return o(DropinLayout, {
|
|
24178
|
+
content
|
|
24179
|
+
});
|
|
24360
24180
|
}
|
|
24361
|
-
const
|
|
24362
|
-
|
|
24363
|
-
|
|
24364
|
-
|
|
24365
|
-
|
|
24366
|
-
roleAndEntityType: {
|
|
24367
|
-
formId: "roleAndEntityType",
|
|
24368
|
-
formName: "roleAndEntityType",
|
|
24369
|
-
fields: ["role", "entityType"]
|
|
24370
|
-
},
|
|
24371
|
-
memberDetails: {
|
|
24372
|
-
formId: "memberDetails",
|
|
24373
|
-
formName: "memberDetails"
|
|
24181
|
+
const serviceAgreementValidationRules = {
|
|
24182
|
+
signer: {
|
|
24183
|
+
modes: ["blur"],
|
|
24184
|
+
validate: (signer2) => !!signer2,
|
|
24185
|
+
errorMessage: "fieldIsRequired"
|
|
24374
24186
|
},
|
|
24375
|
-
|
|
24187
|
+
acceptServiceAgreement: {
|
|
24188
|
+
modes: ["blur"],
|
|
24189
|
+
validate: (acceptServiceAgreement) => !!acceptServiceAgreement,
|
|
24190
|
+
errorMessage: "fieldIsRequired"
|
|
24191
|
+
}
|
|
24376
24192
|
};
|
|
24377
|
-
const
|
|
24378
|
-
|
|
24379
|
-
|
|
24380
|
-
|
|
24381
|
-
|
|
24382
|
-
|
|
24383
|
-
|
|
24193
|
+
const logger$2 = createLogger("useServiceAgreement");
|
|
24194
|
+
const FALLBACK_LANGUAGE_CODE = "en";
|
|
24195
|
+
const useServiceAgreement = ({
|
|
24196
|
+
handleGetServiceAgreement,
|
|
24197
|
+
handleServiceAgreementIsNotAvailableInThatLanguage,
|
|
24198
|
+
legalEntityId,
|
|
24199
|
+
serviceAgreementType,
|
|
24200
|
+
language
|
|
24201
|
+
}) => {
|
|
24202
|
+
const [serviceAgreement, setServiceAgreement] = h();
|
|
24203
|
+
const [loading2, setLoading] = h("loading");
|
|
24204
|
+
const [agreementLanguage, setAgreementLanguage] = h(language);
|
|
24205
|
+
p(() => {
|
|
24206
|
+
if (agreementLanguage !== language) {
|
|
24207
|
+
setAgreementLanguage(language);
|
|
24208
|
+
}
|
|
24209
|
+
}, [language]);
|
|
24210
|
+
p(() => {
|
|
24211
|
+
const requestServiceAgreement = async () => {
|
|
24212
|
+
setLoading("loading");
|
|
24213
|
+
try {
|
|
24214
|
+
const {
|
|
24215
|
+
termsOfServiceDocumentId,
|
|
24216
|
+
document: document2
|
|
24217
|
+
} = await handleGetServiceAgreement(legalEntityId, {
|
|
24218
|
+
type: serviceAgreementType,
|
|
24219
|
+
language: agreementLanguage
|
|
24220
|
+
});
|
|
24221
|
+
if (!document2) {
|
|
24222
|
+
logger$2.log('"document" field was missing in response');
|
|
24223
|
+
return;
|
|
24224
|
+
}
|
|
24225
|
+
const contract = JSON.parse(decodeURIComponent(escape(window.atob(document2))));
|
|
24226
|
+
setServiceAgreement({
|
|
24227
|
+
id: termsOfServiceDocumentId,
|
|
24228
|
+
contract
|
|
24229
|
+
});
|
|
24230
|
+
setLoading("success");
|
|
24231
|
+
} catch (err) {
|
|
24232
|
+
if (agreementLanguage !== FALLBACK_LANGUAGE_CODE) {
|
|
24233
|
+
handleServiceAgreementIsNotAvailableInThatLanguage();
|
|
24234
|
+
setAgreementLanguage(FALLBACK_LANGUAGE_CODE);
|
|
24235
|
+
return;
|
|
24236
|
+
}
|
|
24237
|
+
throw err;
|
|
24238
|
+
}
|
|
24239
|
+
};
|
|
24240
|
+
requestServiceAgreement().catch(logger$2.error);
|
|
24241
|
+
}, [handleGetServiceAgreement, handleServiceAgreementIsNotAvailableInThatLanguage, agreementLanguage, legalEntityId, serviceAgreementType]);
|
|
24242
|
+
return {
|
|
24243
|
+
loading: loading2,
|
|
24244
|
+
serviceAgreement
|
|
24245
|
+
};
|
|
24384
24246
|
};
|
|
24385
|
-
const
|
|
24386
|
-
|
|
24387
|
-
|
|
24388
|
-
|
|
24389
|
-
|
|
24390
|
-
|
|
24391
|
-
|
|
24247
|
+
const serviceAgreementTypesTranslationMapping = {
|
|
24248
|
+
adyenForPlatformsManage: "paymentProcessingTerms",
|
|
24249
|
+
adyenIssuing: "accountHolderTerms",
|
|
24250
|
+
adyenForPlatformsAdvanced: "paymentProcessingTerms",
|
|
24251
|
+
adyenCapital: "capitalUserTerms",
|
|
24252
|
+
adyenAccount: "businessAccountTerms",
|
|
24253
|
+
adyenCard: "cardUserTerms",
|
|
24254
|
+
adyenFranchisee: "franchiseesTAndCs"
|
|
24392
24255
|
};
|
|
24393
|
-
|
|
24394
|
-
|
|
24395
|
-
|
|
24256
|
+
function ServiceAgreementDropinComponent({
|
|
24257
|
+
legalEntity,
|
|
24258
|
+
handleGetServiceAgreement,
|
|
24259
|
+
handleHomeClick,
|
|
24260
|
+
handleSign,
|
|
24261
|
+
taskType,
|
|
24262
|
+
serviceAgreementTypes,
|
|
24263
|
+
serviceAgreementAcceptanceInfos,
|
|
24264
|
+
trackingConfig
|
|
24265
|
+
}) {
|
|
24266
|
+
var _a, _b, _c, _d;
|
|
24396
24267
|
const {
|
|
24397
24268
|
i18n
|
|
24398
24269
|
} = useCoreContext();
|
|
24399
24270
|
const {
|
|
24400
24271
|
showToast
|
|
24401
24272
|
} = useToastContext();
|
|
24402
|
-
const
|
|
24403
|
-
|
|
24404
|
-
|
|
24405
|
-
|
|
24406
|
-
const [formValidity, setFormValidity] = h({
|
|
24407
|
-
[roleAndEntityTypeFormID]: false
|
|
24273
|
+
const baseTrackingPayload = getBaseTrackingPayload({
|
|
24274
|
+
trackingConfig,
|
|
24275
|
+
legalEntity,
|
|
24276
|
+
task: taskType
|
|
24408
24277
|
});
|
|
24409
|
-
const
|
|
24410
|
-
const
|
|
24411
|
-
|
|
24412
|
-
|
|
24413
|
-
|
|
24414
|
-
|
|
24415
|
-
|
|
24416
|
-
|
|
24417
|
-
|
|
24418
|
-
|
|
24419
|
-
|
|
24420
|
-
|
|
24421
|
-
const
|
|
24422
|
-
|
|
24423
|
-
|
|
24424
|
-
|
|
24425
|
-
|
|
24426
|
-
|
|
24427
|
-
|
|
24428
|
-
|
|
24429
|
-
|
|
24430
|
-
|
|
24431
|
-
|
|
24432
|
-
|
|
24433
|
-
|
|
24434
|
-
|
|
24435
|
-
|
|
24436
|
-
|
|
24437
|
-
|
|
24438
|
-
|
|
24439
|
-
|
|
24440
|
-
|
|
24441
|
-
|
|
24442
|
-
|
|
24443
|
-
|
|
24444
|
-
|
|
24445
|
-
|
|
24446
|
-
|
|
24447
|
-
|
|
24448
|
-
|
|
24278
|
+
const [loadingStatus, setLoadingStatus] = h();
|
|
24279
|
+
const formsToBeSigned = serviceAgreementTypes.map((serviceAgreementType) => ({
|
|
24280
|
+
formId: serviceAgreementType,
|
|
24281
|
+
formName: serviceAgreementTypesTranslationMapping[serviceAgreementType],
|
|
24282
|
+
isValid: false
|
|
24283
|
+
}));
|
|
24284
|
+
const signedForms = serviceAgreementAcceptanceInfos.map((serviceAgreementAcceptanceInfo) => ({
|
|
24285
|
+
formId: serviceAgreementAcceptanceInfo.type,
|
|
24286
|
+
formName: serviceAgreementTypesTranslationMapping[serviceAgreementAcceptanceInfo.type],
|
|
24287
|
+
isValid: true
|
|
24288
|
+
}));
|
|
24289
|
+
const forms = [...formsToBeSigned, ...signedForms];
|
|
24290
|
+
const [activeForm, setActiveForm] = h(forms[0]);
|
|
24291
|
+
const canSign = serviceAgreementTypes.includes(activeForm.formId);
|
|
24292
|
+
const handleServiceAgreementIsNotAvailableInThatLanguage = T$1(() => {
|
|
24293
|
+
showToast({
|
|
24294
|
+
label: i18n.get("failedToGetServiceAgreementInSelectedLanguageFallbackToEn"),
|
|
24295
|
+
type: ToastType.ERROR
|
|
24296
|
+
});
|
|
24297
|
+
}, [i18n, showToast]);
|
|
24298
|
+
const {
|
|
24299
|
+
loading: contractLoadingStatus,
|
|
24300
|
+
serviceAgreement
|
|
24301
|
+
} = useServiceAgreement({
|
|
24302
|
+
handleGetServiceAgreement,
|
|
24303
|
+
handleServiceAgreementIsNotAvailableInThatLanguage,
|
|
24304
|
+
legalEntityId: legalEntity.id,
|
|
24305
|
+
serviceAgreementType: activeForm.formId,
|
|
24306
|
+
language: i18n.languageCode
|
|
24307
|
+
});
|
|
24308
|
+
const {
|
|
24309
|
+
handleChangeFor,
|
|
24310
|
+
triggerValidation,
|
|
24311
|
+
data,
|
|
24312
|
+
valid,
|
|
24313
|
+
isValid,
|
|
24314
|
+
errors
|
|
24315
|
+
} = useForm({
|
|
24316
|
+
schema: ["signer", "acceptServiceAgreement"],
|
|
24317
|
+
rules: serviceAgreementValidationRules
|
|
24318
|
+
});
|
|
24319
|
+
const signers = legalEntity.type === LegalEntityType.ORGANIZATION ? getOwnSignatories(legalEntity).map(({
|
|
24320
|
+
legalEntityId: id2,
|
|
24321
|
+
name
|
|
24322
|
+
}) => ({
|
|
24323
|
+
id: id2 ?? "",
|
|
24324
|
+
name: name ?? ""
|
|
24325
|
+
})) : [{
|
|
24326
|
+
id: legalEntity == null ? void 0 : legalEntity.id,
|
|
24327
|
+
name: `${(_a = legalEntity == null ? void 0 : legalEntity.individual) == null ? void 0 : _a.name.firstName} ${(_b = legalEntity == null ? void 0 : legalEntity.individual) == null ? void 0 : _b.name.lastName}`
|
|
24328
|
+
}];
|
|
24329
|
+
const handleSignClick = async () => {
|
|
24330
|
+
userEvents.addEvent("Clicked ToS signing", {
|
|
24331
|
+
segmentation: {
|
|
24332
|
+
...baseTrackingPayload
|
|
24333
|
+
}
|
|
24334
|
+
});
|
|
24335
|
+
if (loadingStatus === "loading" || !serviceAgreement || !data.signer)
|
|
24449
24336
|
return;
|
|
24450
|
-
|
|
24451
|
-
|
|
24452
|
-
|
|
24453
|
-
|
|
24454
|
-
|
|
24455
|
-
|
|
24456
|
-
|
|
24457
|
-
|
|
24458
|
-
|
|
24459
|
-
|
|
24337
|
+
triggerValidation();
|
|
24338
|
+
if (isValid) {
|
|
24339
|
+
try {
|
|
24340
|
+
setLoadingStatus("loading");
|
|
24341
|
+
await handleSign(legalEntity.id, serviceAgreement.id, {
|
|
24342
|
+
acceptedBy: data.signer
|
|
24343
|
+
});
|
|
24344
|
+
setLoadingStatus("success");
|
|
24345
|
+
showToast({
|
|
24346
|
+
label: i18n.get("serviceAgreementSignedSuccessfully"),
|
|
24347
|
+
type: ToastType.SUCCESS
|
|
24348
|
+
});
|
|
24349
|
+
userEvents.addEvent("Succeeded ToS signing", {
|
|
24350
|
+
segmentation: {
|
|
24351
|
+
...baseTrackingPayload
|
|
24352
|
+
}
|
|
24353
|
+
});
|
|
24354
|
+
} catch {
|
|
24355
|
+
setLoadingStatus("success");
|
|
24356
|
+
showToast({
|
|
24357
|
+
label: i18n.get("serviceAgreementSignFailed"),
|
|
24358
|
+
type: ToastType.ERROR
|
|
24359
|
+
});
|
|
24360
|
+
userEvents.addEvent("Failed ToS signing", {
|
|
24361
|
+
segmentation: {
|
|
24362
|
+
...baseTrackingPayload
|
|
24363
|
+
}
|
|
24364
|
+
});
|
|
24460
24365
|
}
|
|
24461
|
-
}
|
|
24462
|
-
|
|
24463
|
-
|
|
24464
|
-
|
|
24465
|
-
|
|
24466
|
-
|
|
24467
|
-
});
|
|
24468
|
-
props.onSubmit(updatedTrust);
|
|
24469
|
-
} catch (e2) {
|
|
24470
|
-
logger$3.error(e2);
|
|
24471
|
-
showToast({
|
|
24472
|
-
label: i18n.get("failedToUpdateDetails"),
|
|
24473
|
-
type: ToastType.ERROR
|
|
24366
|
+
} else {
|
|
24367
|
+
userEvents.addEvent("Encountered ToS validation error", {
|
|
24368
|
+
segmentation: {
|
|
24369
|
+
...baseTrackingPayload,
|
|
24370
|
+
fields: Object.entries(valid).filter(([, value]) => !value).map(([key]) => key)
|
|
24371
|
+
}
|
|
24474
24372
|
});
|
|
24475
24373
|
}
|
|
24476
24374
|
};
|
|
24477
|
-
const
|
|
24478
|
-
|
|
24479
|
-
|
|
24480
|
-
|
|
24481
|
-
role: formatRolesForSummary((trustMember == null ? void 0 : trustMember.types) ?? []),
|
|
24482
|
-
entityType: (trustMember == null ? void 0 : trustMember.legalEntityType) ? i18n.get(trustMember == null ? void 0 : trustMember.legalEntityType) : void 0,
|
|
24483
|
-
descriptionUndefinedBeneficiary: trustMember == null ? void 0 : trustMember.descriptionUndefinedBeneficiary,
|
|
24484
|
-
otherInformation: formatSettlorExemptionReasonsForSummary((trustMember == null ? void 0 : trustMember.settlorExemptionReason) ?? [])
|
|
24485
|
-
}
|
|
24486
|
-
};
|
|
24487
|
-
const onNavigateToNextStep = () => {
|
|
24488
|
-
if (isSummaryStep) {
|
|
24489
|
-
switch (trustMemberCase) {
|
|
24490
|
-
case "exemptSettlor":
|
|
24491
|
-
if (!trustMember)
|
|
24492
|
-
return;
|
|
24493
|
-
submitExemptSettlor(trustMember, props.trust).catch(logger$3.error);
|
|
24494
|
-
break;
|
|
24495
|
-
case "undefinedBeneficiary":
|
|
24496
|
-
submitUndefinedBeneficiary().catch(logger$3.error);
|
|
24497
|
-
break;
|
|
24375
|
+
const goHome = () => {
|
|
24376
|
+
userEvents.addEvent("Returned to task overview from ToS", {
|
|
24377
|
+
segmentation: {
|
|
24378
|
+
...baseTrackingPayload
|
|
24498
24379
|
}
|
|
24499
|
-
|
|
24500
|
-
|
|
24501
|
-
|
|
24502
|
-
|
|
24503
|
-
|
|
24504
|
-
|
|
24505
|
-
|
|
24506
|
-
|
|
24507
|
-
|
|
24508
|
-
|
|
24509
|
-
}
|
|
24380
|
+
});
|
|
24381
|
+
handleHomeClick();
|
|
24382
|
+
};
|
|
24383
|
+
const handleExpandSection = (title) => {
|
|
24384
|
+
userEvents.addEvent("Expanded ToS section", {
|
|
24385
|
+
segmentation: {
|
|
24386
|
+
...baseTrackingPayload,
|
|
24387
|
+
statementExtended: title
|
|
24388
|
+
}
|
|
24389
|
+
});
|
|
24510
24390
|
};
|
|
24511
|
-
|
|
24512
|
-
|
|
24513
|
-
|
|
24514
|
-
dataStoreId = void 0
|
|
24515
|
-
}) => {
|
|
24516
|
-
if (dataStoreId) {
|
|
24517
|
-
setFormValidity({
|
|
24518
|
-
...formValidity,
|
|
24519
|
-
[dataStoreId]: isValid
|
|
24520
|
-
});
|
|
24521
|
-
}
|
|
24522
|
-
if ((data == null ? void 0 : data.role) && data.role.includes(TrustMemberTypes.UNDEFINED_BENEFICIARY)) {
|
|
24523
|
-
setFormList([...Object.values(undefinedBeneficiaryForms)]);
|
|
24524
|
-
} else if (isExemptSettlor(data)) {
|
|
24525
|
-
setFormList([...Object.values(exemptSettlorForms)]);
|
|
24391
|
+
p(() => {
|
|
24392
|
+
if (forms.length) {
|
|
24393
|
+
setActiveForm(forms[0]);
|
|
24526
24394
|
} else {
|
|
24527
|
-
|
|
24395
|
+
goHome();
|
|
24528
24396
|
}
|
|
24529
|
-
|
|
24530
|
-
|
|
24531
|
-
|
|
24532
|
-
|
|
24533
|
-
|
|
24534
|
-
|
|
24535
|
-
|
|
24536
|
-
descriptionUndefinedBeneficiary: data.descriptionUndefinedBeneficiary
|
|
24537
|
-
} : {},
|
|
24538
|
-
...isExemptSettlor(data) ? {
|
|
24539
|
-
settlorExemptionReason: data.settlorExemptionReason.filter((reason) => reason !== "noneOfTheAbove")
|
|
24540
|
-
} : {}
|
|
24397
|
+
}, [serviceAgreementTypes]);
|
|
24398
|
+
p(() => {
|
|
24399
|
+
userEvents.addPageView("ToS dropin");
|
|
24400
|
+
userEvents.addEvent("Started ToS task", {
|
|
24401
|
+
segmentation: {
|
|
24402
|
+
...baseTrackingPayload
|
|
24403
|
+
}
|
|
24541
24404
|
});
|
|
24405
|
+
}, []);
|
|
24406
|
+
const gotoForm = (index) => {
|
|
24407
|
+
setActiveForm(forms[index]);
|
|
24542
24408
|
};
|
|
24543
|
-
const
|
|
24544
|
-
|
|
24545
|
-
|
|
24546
|
-
|
|
24547
|
-
|
|
24548
|
-
|
|
24549
|
-
|
|
24550
|
-
|
|
24551
|
-
|
|
24552
|
-
|
|
24553
|
-
|
|
24554
|
-
|
|
24555
|
-
|
|
24556
|
-
|
|
24557
|
-
|
|
24558
|
-
|
|
24559
|
-
|
|
24409
|
+
const sidebar = o(LoaderWrapper, {
|
|
24410
|
+
status: loadingStatus,
|
|
24411
|
+
formOpacityWhenLoading: 0.3,
|
|
24412
|
+
showSpinner: false,
|
|
24413
|
+
className: "adyen-kyc-dropin__sidebar-wrapper",
|
|
24414
|
+
children: [!!formsToBeSigned.length && o(FormNavigation, {
|
|
24415
|
+
forms: formsToBeSigned,
|
|
24416
|
+
activeForm,
|
|
24417
|
+
gotoForm,
|
|
24418
|
+
taskName: "signServiceAgreement",
|
|
24419
|
+
className: "adl-u-margin-bottom-24"
|
|
24420
|
+
}), !!signedForms.length && o(FormNavigation, {
|
|
24421
|
+
forms: signedForms,
|
|
24422
|
+
activeForm,
|
|
24423
|
+
gotoForm: (index) => gotoForm(formsToBeSigned.length + index),
|
|
24424
|
+
taskName: "signedDocuments"
|
|
24425
|
+
})]
|
|
24426
|
+
});
|
|
24427
|
+
const content = o(LoaderWrapper, {
|
|
24428
|
+
status: loadingStatus,
|
|
24429
|
+
formOpacityWhenLoading: 0.3,
|
|
24430
|
+
showSpinner: false,
|
|
24431
|
+
className: "adyen-kyc-form-container",
|
|
24432
|
+
children: [o(LoaderWrapper, {
|
|
24433
|
+
status: contractLoadingStatus,
|
|
24434
|
+
formOpacityWhenLoading: 0.3,
|
|
24435
|
+
showSpinner: false,
|
|
24436
|
+
children: serviceAgreement && o(ContractViewer, {
|
|
24437
|
+
contract: serviceAgreement.contract,
|
|
24438
|
+
onExpandSection: handleExpandSection
|
|
24439
|
+
})
|
|
24440
|
+
}), canSign && o(Fragment, {
|
|
24441
|
+
children: [o(Field, {
|
|
24442
|
+
name: "signer",
|
|
24443
|
+
label: i18n.get("signer"),
|
|
24444
|
+
classNameModifiers: ["col-50"],
|
|
24445
|
+
className: "adl-u-margin-y-32",
|
|
24446
|
+
errorMessage: i18n.get((_c = errors.signer) == null ? void 0 : _c.errorMessage),
|
|
24447
|
+
isValid: valid.signer,
|
|
24448
|
+
children: (childProps) => o(Select, {
|
|
24449
|
+
...childProps,
|
|
24450
|
+
onChange: handleChangeFor("signer", "blur"),
|
|
24451
|
+
name: "signer",
|
|
24452
|
+
placeholder: i18n.get("selectSigner"),
|
|
24453
|
+
selected: data.signer,
|
|
24454
|
+
items: signers
|
|
24455
|
+
})
|
|
24456
|
+
}), o(Field, {
|
|
24457
|
+
name: "acceptServiceAgreement",
|
|
24458
|
+
errorMessage: i18n.get((_d = errors.acceptServiceAgreement) == null ? void 0 : _d.errorMessage),
|
|
24459
|
+
isValid: valid.acceptServiceAgreement,
|
|
24460
|
+
children: (childProps) => o(Checkbox, {
|
|
24461
|
+
...childProps,
|
|
24462
|
+
label: i18n.get("iHaveReadAndIAcceptTheseTerms"),
|
|
24463
|
+
checked: data.acceptServiceAgreement ?? false,
|
|
24464
|
+
name: "acceptServiceAgreement",
|
|
24465
|
+
onChange: handleChangeFor("acceptServiceAgreement")
|
|
24466
|
+
})
|
|
24467
|
+
})]
|
|
24468
|
+
}), o(ActionBar, {
|
|
24469
|
+
onHome: goHome,
|
|
24470
|
+
homeButtonLabel: i18n.get("goToOverview"),
|
|
24471
|
+
onNext: canSign ? handleSignClick : void 0,
|
|
24472
|
+
nextButtonLabel: canSign ? i18n.get("sign") : void 0
|
|
24473
|
+
})]
|
|
24474
|
+
});
|
|
24475
|
+
return o(DropinLayout, {
|
|
24476
|
+
content: o(Fragment, {
|
|
24477
|
+
children: [sidebar, content]
|
|
24478
|
+
})
|
|
24479
|
+
});
|
|
24480
|
+
}
|
|
24481
|
+
function removeObjectPropsWithEmptyValues(obj) {
|
|
24482
|
+
Object.keys(obj).forEach((key) => {
|
|
24483
|
+
if (obj[key] === null || isEmpty(obj[key]))
|
|
24484
|
+
delete obj[key];
|
|
24485
|
+
});
|
|
24486
|
+
return obj;
|
|
24487
|
+
}
|
|
24488
|
+
const INITIAL_STATE = {
|
|
24489
|
+
data: {},
|
|
24490
|
+
allData: {},
|
|
24491
|
+
initialData: {},
|
|
24492
|
+
errors: {},
|
|
24493
|
+
valid: {},
|
|
24494
|
+
fieldProblems: {},
|
|
24495
|
+
isValid: false
|
|
24496
|
+
};
|
|
24497
|
+
function StateReducer() {
|
|
24498
|
+
const [schemas, setSchemas] = h({});
|
|
24499
|
+
const [activeForms, setActiveForms] = h([]);
|
|
24500
|
+
const setCurrentForms = (forms) => {
|
|
24501
|
+
setActiveForms(forms);
|
|
24502
|
+
};
|
|
24503
|
+
function reducer2({
|
|
24504
|
+
currentState: currState
|
|
24505
|
+
}, action) {
|
|
24506
|
+
var _a, _b, _c, _d, _e;
|
|
24507
|
+
switch (action.type) {
|
|
24508
|
+
case "addToState": {
|
|
24509
|
+
const state2 = structuredClone(currState);
|
|
24510
|
+
const dataStoreId = action.value.dataStoreId ?? action.value.caller;
|
|
24511
|
+
const schema = action.value.schema || null;
|
|
24512
|
+
const schemaHasChanged = schema && ((_a = schemas == null ? void 0 : schemas[dataStoreId]) == null ? void 0 : _a.toString()) !== schema.toString();
|
|
24513
|
+
const mergedState = {
|
|
24514
|
+
...state2,
|
|
24515
|
+
data: {
|
|
24516
|
+
...state2.data,
|
|
24517
|
+
[dataStoreId]: {
|
|
24518
|
+
...state2.data[dataStoreId],
|
|
24519
|
+
...action.value.data
|
|
24520
|
+
}
|
|
24521
|
+
},
|
|
24522
|
+
// Add data in allData state prop in case we will need them later
|
|
24523
|
+
allData: {
|
|
24524
|
+
...state2.allData,
|
|
24525
|
+
[dataStoreId]: {
|
|
24526
|
+
...state2.allData[dataStoreId],
|
|
24527
|
+
...removeObjectPropsWithEmptyValues(action.value.data)
|
|
24528
|
+
}
|
|
24529
|
+
},
|
|
24530
|
+
errors: {
|
|
24531
|
+
...state2.errors,
|
|
24532
|
+
[dataStoreId]: {
|
|
24533
|
+
...state2.errors[dataStoreId],
|
|
24534
|
+
...action.value.errors
|
|
24535
|
+
}
|
|
24536
|
+
},
|
|
24537
|
+
valid: {
|
|
24538
|
+
...state2.valid,
|
|
24539
|
+
[dataStoreId]: {
|
|
24540
|
+
...state2.valid[dataStoreId],
|
|
24541
|
+
...action.value.valid
|
|
24542
|
+
}
|
|
24543
|
+
},
|
|
24544
|
+
fieldProblems: {
|
|
24545
|
+
...state2.fieldProblems,
|
|
24546
|
+
[dataStoreId]: {
|
|
24547
|
+
...state2.fieldProblems[dataStoreId],
|
|
24548
|
+
...action.value.fieldProblems
|
|
24549
|
+
}
|
|
24550
|
+
}
|
|
24551
|
+
};
|
|
24552
|
+
if (schemaHasChanged) {
|
|
24553
|
+
setSchemas({
|
|
24554
|
+
...schemas,
|
|
24555
|
+
[dataStoreId]: schema
|
|
24556
|
+
});
|
|
24557
|
+
const processedBySchema = schema.reduce((acc, fieldKey) => {
|
|
24558
|
+
const dataObjByFormId = mergedState.data[dataStoreId];
|
|
24559
|
+
const allDataObjByFormId = mergedState.allData[dataStoreId];
|
|
24560
|
+
const validObjByFormId = mergedState.valid[dataStoreId];
|
|
24561
|
+
const errorsObjByFormId = mergedState.errors[dataStoreId];
|
|
24562
|
+
const fieldProblemsObjByFormId = mergedState.fieldProblems[dataStoreId];
|
|
24563
|
+
return {
|
|
24564
|
+
data: {
|
|
24565
|
+
...acc.data,
|
|
24566
|
+
[fieldKey]: dataObjByFormId[fieldKey] ?? allDataObjByFormId[fieldKey]
|
|
24567
|
+
},
|
|
24568
|
+
valid: {
|
|
24569
|
+
...acc.valid,
|
|
24570
|
+
[fieldKey]: validObjByFormId[fieldKey]
|
|
24571
|
+
},
|
|
24572
|
+
errors: {
|
|
24573
|
+
...acc.errors,
|
|
24574
|
+
[fieldKey]: errorsObjByFormId[fieldKey]
|
|
24575
|
+
},
|
|
24576
|
+
fieldProblems: {
|
|
24577
|
+
...acc.fieldProblems,
|
|
24578
|
+
[fieldKey]: fieldProblemsObjByFormId[fieldKey]
|
|
24579
|
+
}
|
|
24580
|
+
};
|
|
24581
|
+
}, {
|
|
24582
|
+
data: {},
|
|
24583
|
+
valid: {},
|
|
24584
|
+
errors: {},
|
|
24585
|
+
fieldProblems: {}
|
|
24586
|
+
});
|
|
24587
|
+
mergedState.data[dataStoreId] = processedBySchema.data;
|
|
24588
|
+
mergedState.valid[dataStoreId] = processedBySchema.valid;
|
|
24589
|
+
mergedState.errors[dataStoreId] = processedBySchema.errors;
|
|
24590
|
+
mergedState.fieldProblems[dataStoreId] = processedBySchema.fieldProblems;
|
|
24591
|
+
}
|
|
24592
|
+
mergedState.validityByForm = {
|
|
24593
|
+
...mergedState.validityByForm,
|
|
24594
|
+
[dataStoreId]: Object.values(mergedState.valid[dataStoreId]).every((isValid) => isValid)
|
|
24595
|
+
};
|
|
24596
|
+
mergedState.hasDataChanged = {
|
|
24597
|
+
...state2.hasDataChanged,
|
|
24598
|
+
[dataStoreId]: {
|
|
24599
|
+
hasDataChanged: hasDataChanged((_b = state2.initialData) == null ? void 0 : _b[dataStoreId], (_c = mergedState.data) == null ? void 0 : _c[dataStoreId])
|
|
24600
|
+
}
|
|
24601
|
+
};
|
|
24602
|
+
mergedState.hasAnyDataChanged = Object.values(mergedState.hasDataChanged).some(({
|
|
24603
|
+
hasDataChanged: hasDataChanged2
|
|
24604
|
+
}) => hasDataChanged2);
|
|
24605
|
+
mergedState.allValid = Object.values(mergedState.validityByForm).every((isValid) => isValid);
|
|
24606
|
+
mergedState.isValid = !activeForms.length ? mergedState.allValid : activeForms.every((item) => mergedState.validityByForm[item]);
|
|
24607
|
+
mergedState.initialData = structuredClone(state2.initialData);
|
|
24608
|
+
return {
|
|
24609
|
+
currentState: mergedState,
|
|
24610
|
+
prevState: state2,
|
|
24611
|
+
changeInitiatedBy: dataStoreId
|
|
24612
|
+
};
|
|
24613
|
+
}
|
|
24614
|
+
case "resetState": {
|
|
24615
|
+
const dataStoreId = ((_d = action.value) == null ? void 0 : _d.dataStoreId) ?? ((_e = action.value) == null ? void 0 : _e.caller);
|
|
24616
|
+
return {
|
|
24617
|
+
currentState: INITIAL_STATE,
|
|
24618
|
+
prevState: currState,
|
|
24619
|
+
changeInitiatedBy: dataStoreId
|
|
24620
|
+
};
|
|
24621
|
+
}
|
|
24622
|
+
default: {
|
|
24623
|
+
throw new Error(`Unhandled action type: ${action.type}`);
|
|
24624
|
+
}
|
|
24560
24625
|
}
|
|
24561
|
-
|
|
24626
|
+
}
|
|
24627
|
+
return {
|
|
24628
|
+
reducer: reducer2,
|
|
24629
|
+
setCurrentForms
|
|
24562
24630
|
};
|
|
24563
|
-
|
|
24564
|
-
|
|
24565
|
-
|
|
24566
|
-
|
|
24567
|
-
|
|
24568
|
-
|
|
24569
|
-
|
|
24570
|
-
|
|
24631
|
+
}
|
|
24632
|
+
function StateProvider({
|
|
24633
|
+
defaultData = {},
|
|
24634
|
+
children
|
|
24635
|
+
}) {
|
|
24636
|
+
const defaultState = {
|
|
24637
|
+
currentState: {
|
|
24638
|
+
data: defaultData,
|
|
24639
|
+
allData: defaultData,
|
|
24640
|
+
valid: {},
|
|
24641
|
+
errors: {},
|
|
24642
|
+
fieldProblems: {},
|
|
24643
|
+
validityByForm: {},
|
|
24644
|
+
initialData: defaultData
|
|
24645
|
+
},
|
|
24646
|
+
prevState: {},
|
|
24647
|
+
changeInitiatedBy: null
|
|
24571
24648
|
};
|
|
24572
|
-
const
|
|
24573
|
-
|
|
24574
|
-
|
|
24575
|
-
|
|
24576
|
-
|
|
24577
|
-
|
|
24578
|
-
|
|
24579
|
-
|
|
24580
|
-
|
|
24581
|
-
|
|
24582
|
-
|
|
24583
|
-
|
|
24584
|
-
|
|
24585
|
-
|
|
24586
|
-
|
|
24587
|
-
})
|
|
24588
|
-
}), isSummaryStep && o("div", {
|
|
24589
|
-
className: "adyen-kyc-form-wrapper",
|
|
24590
|
-
children: o(Summary, {
|
|
24591
|
-
data: summaryData,
|
|
24592
|
-
forms: [undefinedBeneficiaryForms.roleAndEntityType],
|
|
24593
|
-
gotoForm: gotoFormByFormIndex
|
|
24594
|
-
})
|
|
24595
|
-
}), o(ActionBar, {
|
|
24596
|
-
onNext: onNavigateToNextStep,
|
|
24597
|
-
onHome: saveRolesAndNavigate,
|
|
24598
|
-
nextButtonLabel: isSummaryStep ? i18n.get("submit") : i18n.get("next"),
|
|
24599
|
-
homeButtonLabel: i18n.get("saveAndGoToOverview")
|
|
24600
|
-
})]
|
|
24601
|
-
})]
|
|
24602
|
-
});
|
|
24603
|
-
return o(DropinLayout, {
|
|
24604
|
-
content
|
|
24649
|
+
const reducerObj = StateReducer();
|
|
24650
|
+
const [state2, dispatch] = s(reducerObj.reducer, defaultState);
|
|
24651
|
+
const contextValue = F$1(() => ({
|
|
24652
|
+
state: state2,
|
|
24653
|
+
dispatch,
|
|
24654
|
+
setActiveForms: reducerObj.setCurrentForms,
|
|
24655
|
+
getData: () => {
|
|
24656
|
+
var _a;
|
|
24657
|
+
return ((_a = state2 == null ? void 0 : state2.currentState) == null ? void 0 : _a.data) ?? {};
|
|
24658
|
+
},
|
|
24659
|
+
getState: () => state2 == null ? void 0 : state2.currentState
|
|
24660
|
+
}), [reducerObj, state2]);
|
|
24661
|
+
return o(StateContext.Provider, {
|
|
24662
|
+
value: contextValue,
|
|
24663
|
+
children
|
|
24605
24664
|
});
|
|
24606
24665
|
}
|
|
24607
|
-
const
|
|
24608
|
-
|
|
24609
|
-
|
|
24610
|
-
|
|
24611
|
-
|
|
24612
|
-
|
|
24613
|
-
acceptServiceAgreement: {
|
|
24614
|
-
modes: ["blur"],
|
|
24615
|
-
validate: (acceptServiceAgreement) => !!acceptServiceAgreement,
|
|
24616
|
-
errorMessage: "fieldIsRequired"
|
|
24666
|
+
const labels = (data, country2) => ({
|
|
24667
|
+
registrationNumber: () => {
|
|
24668
|
+
var _a;
|
|
24669
|
+
if (country2 === CountryCodes.Monaco && ((_a = data == null ? void 0 : data.solePropNameAndCountry) == null ? void 0 : _a.companyCountry) === CountryCodes.Monaco) {
|
|
24670
|
+
return "mcRegistrationNumberSoleProp";
|
|
24671
|
+
}
|
|
24617
24672
|
}
|
|
24618
|
-
};
|
|
24619
|
-
const
|
|
24620
|
-
|
|
24621
|
-
|
|
24622
|
-
|
|
24623
|
-
|
|
24624
|
-
|
|
24625
|
-
|
|
24626
|
-
|
|
24627
|
-
|
|
24628
|
-
|
|
24629
|
-
|
|
24630
|
-
|
|
24631
|
-
|
|
24632
|
-
|
|
24633
|
-
setAgreementLanguage(language);
|
|
24673
|
+
});
|
|
24674
|
+
const getOpeningStep = (forms, remediationActions) => {
|
|
24675
|
+
var _a;
|
|
24676
|
+
if (remediationActions && Object.keys(remediationActions).length > 0) {
|
|
24677
|
+
const allRemediationActions = Object.values(remediationActions).flat().filter((rem) => {
|
|
24678
|
+
var _a2;
|
|
24679
|
+
return ((_a2 = rem.forms) == null ? void 0 : _a2.length) > 0;
|
|
24680
|
+
});
|
|
24681
|
+
if (allRemediationActions.length === 1 && ((_a = allRemediationActions[0]) == null ? void 0 : _a.forms.length) === 1) {
|
|
24682
|
+
const form = forms.find((form2) => {
|
|
24683
|
+
var _a2;
|
|
24684
|
+
return (form2 == null ? void 0 : form2.formId) === ((_a2 = allRemediationActions[0]) == null ? void 0 : _a2.forms[0]);
|
|
24685
|
+
});
|
|
24686
|
+
if (form)
|
|
24687
|
+
return form;
|
|
24634
24688
|
}
|
|
24635
|
-
|
|
24636
|
-
|
|
24637
|
-
|
|
24638
|
-
|
|
24639
|
-
|
|
24640
|
-
|
|
24641
|
-
|
|
24642
|
-
|
|
24643
|
-
|
|
24644
|
-
|
|
24645
|
-
|
|
24646
|
-
|
|
24647
|
-
|
|
24648
|
-
|
|
24649
|
-
|
|
24650
|
-
|
|
24651
|
-
|
|
24652
|
-
|
|
24653
|
-
|
|
24654
|
-
|
|
24655
|
-
|
|
24656
|
-
|
|
24657
|
-
|
|
24658
|
-
|
|
24659
|
-
|
|
24660
|
-
|
|
24661
|
-
|
|
24662
|
-
|
|
24663
|
-
|
|
24689
|
+
return forms[forms.length - 1];
|
|
24690
|
+
}
|
|
24691
|
+
return forms[0];
|
|
24692
|
+
};
|
|
24693
|
+
function withFormComposer(WrappedComponent, {
|
|
24694
|
+
getComponentForms,
|
|
24695
|
+
parseConfiguration: parseConfiguration2,
|
|
24696
|
+
rules: rules2,
|
|
24697
|
+
labels: labels2,
|
|
24698
|
+
defaultTaskName,
|
|
24699
|
+
getConfigFor = "contextCountry"
|
|
24700
|
+
}) {
|
|
24701
|
+
const WithFormComposer = (props) => {
|
|
24702
|
+
var _a, _b, _c, _d, _e;
|
|
24703
|
+
const {
|
|
24704
|
+
i18n,
|
|
24705
|
+
loadingContext,
|
|
24706
|
+
clientKey,
|
|
24707
|
+
contextCountry: initialContextCountry,
|
|
24708
|
+
setContextCountry: setInitialContextCountry,
|
|
24709
|
+
isReview
|
|
24710
|
+
} = useCoreContext();
|
|
24711
|
+
const {
|
|
24712
|
+
isSettingEnabled
|
|
24713
|
+
} = useSettingsContext();
|
|
24714
|
+
const {
|
|
24715
|
+
getData,
|
|
24716
|
+
getState
|
|
24717
|
+
} = useStateContext();
|
|
24718
|
+
const {
|
|
24719
|
+
getOmittedKeys: getSummaryOmittedKeys = null,
|
|
24720
|
+
formatData: formatDataForSummary = null,
|
|
24721
|
+
omittedForms
|
|
24722
|
+
} = props.summary || {};
|
|
24723
|
+
const taskName = props.taskName ?? defaultTaskName;
|
|
24724
|
+
const [hideDropinLayout, setHideDropinLayout] = h(false);
|
|
24725
|
+
const [hideNavigation, setHideNavigation] = h(false);
|
|
24726
|
+
const [hideFooter, setHideFooter] = h(false);
|
|
24727
|
+
const [hideOnHomeButton, setHideOnHomeButton] = h(false);
|
|
24728
|
+
const [hideBackButton, setHideBackButton] = h(false);
|
|
24729
|
+
const [submitButtonLabel, setSubmitButtonLabel] = h(null);
|
|
24730
|
+
const [skipSubmitAndGoTaskList, setSkipSubmitAndGoTaskList] = h(false);
|
|
24731
|
+
const [customFormNavigationHandlers, setCustomFormNavigationHandlers] = h({});
|
|
24732
|
+
const [shouldValidate, setShouldValidate] = h(false);
|
|
24733
|
+
const [formValidity, setFormValidity] = h({});
|
|
24734
|
+
const formRef = _$1(null);
|
|
24735
|
+
const [loadingStatus, setLoadingStatus] = h("success");
|
|
24736
|
+
const [derivedProps, setDerivedProps] = h(props);
|
|
24737
|
+
const [contextCountry, setContextCountry] = h(props.country || initialContextCountry);
|
|
24738
|
+
const {
|
|
24739
|
+
sliceData: payoutMethodData
|
|
24740
|
+
} = useGlobalDataSlice("payoutVerificationMethod");
|
|
24741
|
+
const configCountry = (getConfigFor === "bankCountry" ? payoutMethodData == null ? void 0 : payoutMethodData.bankCountry : contextCountry) ?? contextCountry;
|
|
24742
|
+
p(() => {
|
|
24743
|
+
loadDocumentGuidance(loadingContext);
|
|
24744
|
+
}, [loadingContext]);
|
|
24745
|
+
const getConfigurationData = T$1(() => getConfiguration({
|
|
24746
|
+
loadingContext,
|
|
24747
|
+
clientKey
|
|
24748
|
+
}, {
|
|
24749
|
+
legalEntityType: props.legalEntityType,
|
|
24750
|
+
capabilities: props.capabilities,
|
|
24751
|
+
// for payout forms, we need to get config for the selected bankCountry, not necessarily the same as the residency/registration country
|
|
24752
|
+
country: configCountry
|
|
24753
|
+
}), [clientKey, configCountry, loadingContext, props.capabilities, props.legalEntityType]);
|
|
24754
|
+
const getPayoutAccountFormatData = T$1(() => getPayoutAccountFormat({
|
|
24755
|
+
loadingContext,
|
|
24756
|
+
clientKey
|
|
24757
|
+
}, configCountry), [clientKey, configCountry, loadingContext]);
|
|
24758
|
+
const {
|
|
24759
|
+
fieldConfigurations,
|
|
24760
|
+
requiredFields,
|
|
24761
|
+
bankVerificationVendors
|
|
24762
|
+
} = useScenarioConfiguration({
|
|
24763
|
+
getConfigurationData,
|
|
24764
|
+
getPayoutAccountFormatData,
|
|
24765
|
+
parseConfiguration: parseConfiguration2,
|
|
24766
|
+
country: configCountry,
|
|
24767
|
+
instantVerificationEnabled: derivedProps.instantVerificationEnabled && derivedProps.handleGetBankVerificationVendors,
|
|
24768
|
+
setLoadingStatus
|
|
24769
|
+
});
|
|
24770
|
+
const isFormStepVisible = (formId) => {
|
|
24771
|
+
if (derivedProps.requiredFields || derivedProps.optionalFields) {
|
|
24772
|
+
return !!derivedProps.requiredFields[formId] || !!derivedProps.optionalFields[formId];
|
|
24664
24773
|
}
|
|
24774
|
+
return true;
|
|
24665
24775
|
};
|
|
24666
|
-
|
|
24667
|
-
|
|
24668
|
-
|
|
24669
|
-
|
|
24670
|
-
|
|
24671
|
-
|
|
24672
|
-
|
|
24673
|
-
const
|
|
24674
|
-
|
|
24675
|
-
|
|
24676
|
-
|
|
24677
|
-
|
|
24678
|
-
|
|
24679
|
-
|
|
24680
|
-
|
|
24681
|
-
|
|
24682
|
-
|
|
24683
|
-
|
|
24684
|
-
|
|
24685
|
-
handleHomeClick,
|
|
24686
|
-
handleSign,
|
|
24687
|
-
taskType,
|
|
24688
|
-
serviceAgreementTypes,
|
|
24689
|
-
serviceAgreementAcceptanceInfos,
|
|
24690
|
-
trackingConfig
|
|
24691
|
-
}) {
|
|
24692
|
-
var _a, _b, _c, _d;
|
|
24693
|
-
const {
|
|
24694
|
-
i18n
|
|
24695
|
-
} = useCoreContext();
|
|
24696
|
-
const {
|
|
24697
|
-
showToast
|
|
24698
|
-
} = useToastContext();
|
|
24699
|
-
const baseTrackingPayload = getBaseTrackingPayload({
|
|
24700
|
-
trackingConfig,
|
|
24701
|
-
legalEntity,
|
|
24702
|
-
task: taskType
|
|
24703
|
-
});
|
|
24704
|
-
const [loadingStatus, setLoadingStatus] = h();
|
|
24705
|
-
const formsToBeSigned = serviceAgreementTypes.map((serviceAgreementType) => ({
|
|
24706
|
-
formId: serviceAgreementType,
|
|
24707
|
-
formName: serviceAgreementTypesTranslationMapping[serviceAgreementType],
|
|
24708
|
-
isValid: false
|
|
24709
|
-
}));
|
|
24710
|
-
const signedForms = serviceAgreementAcceptanceInfos.map((serviceAgreementAcceptanceInfo) => ({
|
|
24711
|
-
formId: serviceAgreementAcceptanceInfo.type,
|
|
24712
|
-
formName: serviceAgreementTypesTranslationMapping[serviceAgreementAcceptanceInfo.type],
|
|
24713
|
-
isValid: true
|
|
24714
|
-
}));
|
|
24715
|
-
const forms = [...formsToBeSigned, ...signedForms];
|
|
24716
|
-
const [activeForm, setActiveForm] = h(forms[0]);
|
|
24717
|
-
const canSign = serviceAgreementTypes.includes(activeForm.formId);
|
|
24718
|
-
const handleServiceAgreementIsNotAvailableInThatLanguage = T$1(() => {
|
|
24719
|
-
showToast({
|
|
24720
|
-
label: i18n.get("failedToGetServiceAgreementInSelectedLanguageFallbackToEn"),
|
|
24721
|
-
type: ToastType.ERROR
|
|
24722
|
-
});
|
|
24723
|
-
}, [i18n, showToast]);
|
|
24724
|
-
const {
|
|
24725
|
-
loading: contractLoadingStatus,
|
|
24726
|
-
serviceAgreement
|
|
24727
|
-
} = useServiceAgreement({
|
|
24728
|
-
handleGetServiceAgreement,
|
|
24729
|
-
handleServiceAgreementIsNotAvailableInThatLanguage,
|
|
24730
|
-
legalEntityId: legalEntity.id,
|
|
24731
|
-
serviceAgreementType: activeForm.formId,
|
|
24732
|
-
language: i18n.languageCode
|
|
24733
|
-
});
|
|
24734
|
-
const {
|
|
24735
|
-
handleChangeFor,
|
|
24736
|
-
triggerValidation,
|
|
24737
|
-
data,
|
|
24738
|
-
valid,
|
|
24739
|
-
isValid,
|
|
24740
|
-
errors
|
|
24741
|
-
} = useForm({
|
|
24742
|
-
schema: ["signer", "acceptServiceAgreement"],
|
|
24743
|
-
rules: serviceAgreementValidationRules
|
|
24744
|
-
});
|
|
24745
|
-
const signers = legalEntity.type === LegalEntityType.ORGANIZATION ? getOwnSignatories(legalEntity).map(({
|
|
24746
|
-
legalEntityId: id2,
|
|
24747
|
-
name
|
|
24748
|
-
}) => ({
|
|
24749
|
-
id: id2 ?? "",
|
|
24750
|
-
name: name ?? ""
|
|
24751
|
-
})) : [{
|
|
24752
|
-
id: legalEntity == null ? void 0 : legalEntity.id,
|
|
24753
|
-
name: `${(_a = legalEntity == null ? void 0 : legalEntity.individual) == null ? void 0 : _a.name.firstName} ${(_b = legalEntity == null ? void 0 : legalEntity.individual) == null ? void 0 : _b.name.lastName}`
|
|
24754
|
-
}];
|
|
24755
|
-
const handleSignClick = async () => {
|
|
24756
|
-
userEvents.addEvent("Clicked ToS signing", {
|
|
24757
|
-
segmentation: {
|
|
24758
|
-
...baseTrackingPayload
|
|
24776
|
+
const isFormSummaryStep = (form) => form.formId === summaryStep.formId;
|
|
24777
|
+
const componentForms = F$1(() => getComponentForms({
|
|
24778
|
+
...props,
|
|
24779
|
+
bankVerificationVendors
|
|
24780
|
+
}, isSettingEnabled), [bankVerificationVendors, isSettingEnabled, props]);
|
|
24781
|
+
const componentFormsWithSummary = [...Object.values(componentForms), summaryStep];
|
|
24782
|
+
const allowedForms = componentFormsWithSummary.filter((form) => isFormStepVisible(form.formId) || isFormSummaryStep(form));
|
|
24783
|
+
const [activeForm, setActiveForm] = h(getOpeningStep(allowedForms, (_a = props == null ? void 0 : props.problems) == null ? void 0 : _a.remediationActions));
|
|
24784
|
+
const [hasAlreadyNavigatedForm, setHasAlreadyNavigatedForm] = h(false);
|
|
24785
|
+
const getFormIndex = (formId) => allowedForms.findIndex((form) => form.formId === formId);
|
|
24786
|
+
const isFinalStep = getFormIndex(activeForm.formId) === allowedForms.length - 1;
|
|
24787
|
+
const isFirstStep = getFormIndex(activeForm.formId) === 0;
|
|
24788
|
+
p(() => {
|
|
24789
|
+
var _a2;
|
|
24790
|
+
if (hasAlreadyNavigatedForm)
|
|
24791
|
+
return;
|
|
24792
|
+
const openingStep = getOpeningStep(allowedForms, (_a2 = props == null ? void 0 : props.problems) == null ? void 0 : _a2.remediationActions);
|
|
24793
|
+
if (activeForm !== openingStep) {
|
|
24794
|
+
setActiveForm(openingStep);
|
|
24759
24795
|
}
|
|
24760
|
-
});
|
|
24761
|
-
|
|
24762
|
-
|
|
24763
|
-
|
|
24764
|
-
|
|
24765
|
-
|
|
24766
|
-
|
|
24767
|
-
|
|
24768
|
-
|
|
24769
|
-
|
|
24770
|
-
|
|
24771
|
-
|
|
24772
|
-
|
|
24773
|
-
|
|
24774
|
-
|
|
24775
|
-
|
|
24776
|
-
|
|
24777
|
-
|
|
24796
|
+
}, [activeForm, allowedForms, (_b = props == null ? void 0 : props.problems) == null ? void 0 : _b.remediationActions, hasAlreadyNavigatedForm]);
|
|
24797
|
+
const evaluateConfiguration = T$1((scenarioConfiguration, country2, formData, isSettingEnabled2, requiredFields2) => {
|
|
24798
|
+
var _a2, _b2, _c2;
|
|
24799
|
+
const fieldsFromCustomRules = rules2 ? rules2({
|
|
24800
|
+
data: formData,
|
|
24801
|
+
country: country2,
|
|
24802
|
+
taskType: props.taskType,
|
|
24803
|
+
isSettingEnabled: isSettingEnabled2,
|
|
24804
|
+
requiredFields: requiredFields2
|
|
24805
|
+
}) : {};
|
|
24806
|
+
const fieldsFormCustomLabels = labels2 ? labels2(formData, country2) : {};
|
|
24807
|
+
const scenarioProps = getPropsFromConfigurations(scenarioConfiguration, componentForms, ((_a2 = props == null ? void 0 : props.problems) == null ? void 0 : _a2.remediationActions) ? Object.values((_b2 = props == null ? void 0 : props.problems) == null ? void 0 : _b2.remediationActions) : [], ((_c2 = props.problems) == null ? void 0 : _c2.missingData) ?? [], props.legalEntityResponse ? getFieldsWithExistingData(props.legalEntityResponse) : [], fieldsFromCustomRules, fieldsFormCustomLabels);
|
|
24808
|
+
setShouldValidate(false);
|
|
24809
|
+
setDerivedProps({
|
|
24810
|
+
...props,
|
|
24811
|
+
...scenarioProps,
|
|
24812
|
+
country: configCountry
|
|
24813
|
+
});
|
|
24814
|
+
}, [componentForms, configCountry, props]);
|
|
24815
|
+
p(() => {
|
|
24816
|
+
if (!fieldConfigurations)
|
|
24817
|
+
return;
|
|
24818
|
+
evaluateConfiguration(fieldConfigurations, configCountry, getData(), isSettingEnabled, requiredFields);
|
|
24819
|
+
}, [fieldConfigurations, configCountry, evaluateConfiguration, getData, isSettingEnabled, requiredFields]);
|
|
24820
|
+
const trackNavigation2 = ({
|
|
24821
|
+
fromForm,
|
|
24822
|
+
toForm,
|
|
24823
|
+
component
|
|
24824
|
+
}) => {
|
|
24825
|
+
userEvents.addEvent("Navigated form", {
|
|
24826
|
+
segmentation: {
|
|
24827
|
+
...props == null ? void 0 : props.baseTrackingPayload,
|
|
24828
|
+
component,
|
|
24829
|
+
from: fromForm.formId,
|
|
24830
|
+
fromLabel: i18n.get(fromForm.formName),
|
|
24831
|
+
to: toForm.formId,
|
|
24832
|
+
toLabel: i18n.get(toForm.formName)
|
|
24833
|
+
}
|
|
24834
|
+
});
|
|
24835
|
+
};
|
|
24836
|
+
const trackSectionCompletion = (form) => {
|
|
24837
|
+
userEvents.addEvent("Completed form section", {
|
|
24838
|
+
segmentation: {
|
|
24839
|
+
...props == null ? void 0 : props.baseTrackingPayload,
|
|
24840
|
+
sectionName: form.formId
|
|
24841
|
+
}
|
|
24842
|
+
});
|
|
24843
|
+
};
|
|
24844
|
+
const gotoFormByFormIndex = (nextFormIndex) => {
|
|
24845
|
+
if (formRef.current.verifyForm) {
|
|
24846
|
+
formRef.current.verifyForm(activeForm.formId).then((isVerified) => {
|
|
24847
|
+
if (isVerified) {
|
|
24848
|
+
setHasAlreadyNavigatedForm(true);
|
|
24849
|
+
setActiveForm(allowedForms[nextFormIndex]);
|
|
24778
24850
|
}
|
|
24779
24851
|
});
|
|
24780
|
-
}
|
|
24781
|
-
|
|
24782
|
-
|
|
24783
|
-
|
|
24784
|
-
|
|
24852
|
+
} else {
|
|
24853
|
+
setHasAlreadyNavigatedForm(true);
|
|
24854
|
+
setActiveForm(allowedForms[nextFormIndex]);
|
|
24855
|
+
}
|
|
24856
|
+
};
|
|
24857
|
+
const validateCurrentForm = () => {
|
|
24858
|
+
setShouldValidate(true);
|
|
24859
|
+
};
|
|
24860
|
+
const handleNextClick = () => {
|
|
24861
|
+
var _a2, _b2;
|
|
24862
|
+
if (formRef.current.customNavigationHandler) {
|
|
24863
|
+
formRef.current.customNavigationHandler();
|
|
24864
|
+
return;
|
|
24865
|
+
}
|
|
24866
|
+
if ((_a2 = customFormNavigationHandlers[activeForm.formId]) == null ? void 0 : _a2.onNext) {
|
|
24867
|
+
(_b2 = customFormNavigationHandlers[activeForm.formId]) == null ? void 0 : _b2.onNext();
|
|
24868
|
+
return;
|
|
24869
|
+
}
|
|
24870
|
+
const allFields = (derivedProps == null ? void 0 : derivedProps.allFields) || {};
|
|
24871
|
+
if (isFormSummaryStep(activeForm)) {
|
|
24872
|
+
if (skipSubmitAndGoTaskList) {
|
|
24873
|
+
props.navigateBackToTaskList();
|
|
24874
|
+
} else {
|
|
24875
|
+
props.onSubmit({
|
|
24876
|
+
data: getData(),
|
|
24877
|
+
forms: allowedForms,
|
|
24878
|
+
allFields,
|
|
24879
|
+
setLoadingStatus
|
|
24880
|
+
});
|
|
24881
|
+
}
|
|
24882
|
+
return;
|
|
24883
|
+
}
|
|
24884
|
+
if (formValidity[activeForm.formId]) {
|
|
24885
|
+
if (isFinalStep) {
|
|
24886
|
+
props.onSubmit({
|
|
24887
|
+
data: getData(),
|
|
24888
|
+
forms: allowedForms,
|
|
24889
|
+
allFields,
|
|
24890
|
+
setLoadingStatus
|
|
24891
|
+
});
|
|
24892
|
+
return;
|
|
24893
|
+
}
|
|
24894
|
+
setShouldValidate(false);
|
|
24895
|
+
const toFormIndex = allowedForms.findIndex((form) => form.formId === activeForm.formId) + 1;
|
|
24896
|
+
gotoFormByFormIndex(toFormIndex);
|
|
24897
|
+
const toForm = allowedForms[toFormIndex];
|
|
24898
|
+
trackNavigation2({
|
|
24899
|
+
fromForm: activeForm,
|
|
24900
|
+
toForm,
|
|
24901
|
+
component: "ActionBar"
|
|
24785
24902
|
});
|
|
24786
|
-
|
|
24787
|
-
|
|
24788
|
-
|
|
24789
|
-
|
|
24903
|
+
trackSectionCompletion(activeForm);
|
|
24904
|
+
} else {
|
|
24905
|
+
validateCurrentForm();
|
|
24906
|
+
}
|
|
24907
|
+
};
|
|
24908
|
+
const handleBackClick = () => {
|
|
24909
|
+
const currentFormIndex = allowedForms.findIndex((form) => form.formId === activeForm.formId);
|
|
24910
|
+
if (currentFormIndex) {
|
|
24911
|
+
const fromForm = allowedForms[currentFormIndex];
|
|
24912
|
+
const toForm = allowedForms[currentFormIndex - 1];
|
|
24913
|
+
setActiveForm(toForm);
|
|
24914
|
+
setHasAlreadyNavigatedForm(true);
|
|
24915
|
+
trackNavigation2({
|
|
24916
|
+
fromForm,
|
|
24917
|
+
toForm,
|
|
24918
|
+
component: "ActionBar"
|
|
24790
24919
|
});
|
|
24791
24920
|
}
|
|
24792
|
-
}
|
|
24793
|
-
|
|
24794
|
-
|
|
24795
|
-
|
|
24796
|
-
|
|
24921
|
+
};
|
|
24922
|
+
const setCustomHandlers = (formId, onNext, onBack) => {
|
|
24923
|
+
setCustomFormNavigationHandlers({
|
|
24924
|
+
...customFormNavigationHandlers,
|
|
24925
|
+
[formId]: {
|
|
24926
|
+
onNext,
|
|
24927
|
+
onBack
|
|
24797
24928
|
}
|
|
24798
24929
|
});
|
|
24799
|
-
}
|
|
24800
|
-
|
|
24801
|
-
|
|
24802
|
-
|
|
24803
|
-
|
|
24804
|
-
|
|
24805
|
-
|
|
24806
|
-
|
|
24807
|
-
|
|
24808
|
-
|
|
24809
|
-
|
|
24810
|
-
|
|
24811
|
-
|
|
24812
|
-
|
|
24813
|
-
|
|
24930
|
+
};
|
|
24931
|
+
const nextButtonText = isReview ? isFormSummaryStep(activeForm) ? i18n.get("confirm") : i18n.get("next") : isFinalStep ? i18n.get(submitButtonLabel ?? "submit") : i18n.get("next");
|
|
24932
|
+
p(() => {
|
|
24933
|
+
props.eventEmitter.on("next", handleNextClick);
|
|
24934
|
+
props.eventEmitter.on("back", handleBackClick);
|
|
24935
|
+
props.eventEmitter.on("validate", validateCurrentForm);
|
|
24936
|
+
return () => {
|
|
24937
|
+
props.eventEmitter.off("next", handleNextClick);
|
|
24938
|
+
props.eventEmitter.off("back", handleNextClick);
|
|
24939
|
+
props.eventEmitter.off("validate", validateCurrentForm);
|
|
24940
|
+
};
|
|
24941
|
+
}, [activeForm, allowedForms]);
|
|
24942
|
+
const onCountryChange = (country2) => {
|
|
24943
|
+
setContextCountry(country2);
|
|
24944
|
+
};
|
|
24945
|
+
const onWrappedComponentChange = (state2) => {
|
|
24946
|
+
var _a2;
|
|
24947
|
+
setFormValidity(state2.validityByForm);
|
|
24948
|
+
(_a2 = props.onChange) == null ? void 0 : _a2.call(props, state2);
|
|
24949
|
+
};
|
|
24950
|
+
const handleStateChange = ({
|
|
24951
|
+
currentState
|
|
24952
|
+
}) => {
|
|
24953
|
+
onWrappedComponentChange(currentState);
|
|
24954
|
+
};
|
|
24955
|
+
const handleLeaveDropin = async () => {
|
|
24956
|
+
var _a2;
|
|
24957
|
+
const data = getData();
|
|
24958
|
+
const hasDataChanged2 = getState().hasAnyDataChanged;
|
|
24959
|
+
if (hasDataChanged2 && ((_a2 = props.canSubmit) == null ? void 0 : _a2.call(props, data))) {
|
|
24960
|
+
setInitialContextCountry(contextCountry);
|
|
24961
|
+
const allFields = (derivedProps == null ? void 0 : derivedProps.allFields) || {};
|
|
24962
|
+
await props.onSubmit({
|
|
24963
|
+
data,
|
|
24964
|
+
forms: allowedForms,
|
|
24965
|
+
allFields,
|
|
24966
|
+
setLoadingStatus
|
|
24967
|
+
});
|
|
24968
|
+
} else {
|
|
24969
|
+
props.handleHomeClick();
|
|
24814
24970
|
}
|
|
24971
|
+
};
|
|
24972
|
+
const formFooter = !hideDropinLayout && !hideFooter && o(ActionBar, {
|
|
24973
|
+
onNext: handleNextClick,
|
|
24974
|
+
onBack: isFirstStep ? props.handleBackClick : handleBackClick,
|
|
24975
|
+
backButtonLabel: i18n.get("back"),
|
|
24976
|
+
nextButtonLabel: nextButtonText,
|
|
24977
|
+
onHome: handleLeaveDropin,
|
|
24978
|
+
homeButtonLabel: props.homeButtonLabel,
|
|
24979
|
+
hideOnHomeButton,
|
|
24980
|
+
hideBackButton
|
|
24815
24981
|
});
|
|
24816
|
-
|
|
24817
|
-
|
|
24818
|
-
|
|
24819
|
-
|
|
24820
|
-
|
|
24821
|
-
|
|
24822
|
-
|
|
24823
|
-
|
|
24824
|
-
|
|
24825
|
-
|
|
24826
|
-
|
|
24827
|
-
|
|
24828
|
-
|
|
24829
|
-
|
|
24982
|
+
const wrappedComponent = o("div", {
|
|
24983
|
+
className: "adyen-kyc-form-container",
|
|
24984
|
+
children: o(LoaderWrapper, {
|
|
24985
|
+
status: loadingStatus,
|
|
24986
|
+
formOpacityWhenLoading: 0.3,
|
|
24987
|
+
loaderSize: "large",
|
|
24988
|
+
children: o(FormRouterContextProvider, {
|
|
24989
|
+
setFormIndex: gotoFormByFormIndex,
|
|
24990
|
+
forms: allowedForms,
|
|
24991
|
+
handleGetIdVerificationToken: props.handleGetIdVerificationToken,
|
|
24992
|
+
children: [o(StateContextWatcher, {
|
|
24993
|
+
owner: "FormComposer",
|
|
24994
|
+
onChange: handleStateChange
|
|
24995
|
+
}), o(WrappedComponent, {
|
|
24996
|
+
ref: formRef,
|
|
24997
|
+
forms: allowedForms,
|
|
24998
|
+
activeForm,
|
|
24999
|
+
...derivedProps,
|
|
25000
|
+
data: props.data,
|
|
25001
|
+
onChange: onWrappedComponentChange,
|
|
25002
|
+
evaluateConfiguration: (data) => evaluateConfiguration(fieldConfigurations, configCountry, data, isSettingEnabled, requiredFields),
|
|
25003
|
+
country: contextCountry,
|
|
25004
|
+
onCountryChange,
|
|
25005
|
+
legalEntityId: props.legalEntityId,
|
|
25006
|
+
problems: props == null ? void 0 : props.problems,
|
|
25007
|
+
shouldValidate,
|
|
25008
|
+
onNext: handleNextClick,
|
|
25009
|
+
onBack: handleBackClick,
|
|
25010
|
+
setHideDropinLayout,
|
|
25011
|
+
setHideNavigation,
|
|
25012
|
+
setHideFooter,
|
|
25013
|
+
setCustomFormNavigationHandlers: setCustomHandlers,
|
|
25014
|
+
setHideOnHomeButton,
|
|
25015
|
+
setHideBackButton,
|
|
25016
|
+
setSubmitButtonLabel,
|
|
25017
|
+
setSkipSubmitAndGoTaskList,
|
|
25018
|
+
bankVerificationVendors
|
|
25019
|
+
}), activeForm.formId === summaryStep.formId && o("div", {
|
|
25020
|
+
className: "adyen-kyc-form-wrapper",
|
|
25021
|
+
children: o(Summary, {
|
|
25022
|
+
trackNavigation: trackNavigation2,
|
|
25023
|
+
data: formatDataForSummary ? formatDataForSummary(getData(), allowedForms) : getData(),
|
|
25024
|
+
omittedKeys: getSummaryOmittedKeys ? getSummaryOmittedKeys(getData()) : null,
|
|
25025
|
+
omittedForms,
|
|
25026
|
+
forms: allowedForms,
|
|
25027
|
+
gotoForm: gotoFormByFormIndex,
|
|
25028
|
+
labels: derivedProps.labels,
|
|
25029
|
+
problems: props == null ? void 0 : props.problems
|
|
25030
|
+
})
|
|
25031
|
+
}), formFooter]
|
|
25032
|
+
})
|
|
25033
|
+
})
|
|
24830
25034
|
});
|
|
24831
|
-
|
|
24832
|
-
|
|
24833
|
-
|
|
24834
|
-
};
|
|
24835
|
-
const sidebar = o(LoaderWrapper, {
|
|
24836
|
-
status: loadingStatus,
|
|
24837
|
-
formOpacityWhenLoading: 0.3,
|
|
24838
|
-
showSpinner: false,
|
|
24839
|
-
className: "adyen-kyc-dropin__sidebar-wrapper",
|
|
24840
|
-
children: [!!formsToBeSigned.length && o(FormNavigation, {
|
|
24841
|
-
forms: formsToBeSigned,
|
|
24842
|
-
activeForm,
|
|
24843
|
-
gotoForm,
|
|
24844
|
-
taskName: "signServiceAgreement",
|
|
24845
|
-
className: "adl-u-margin-bottom-24"
|
|
24846
|
-
}), !!signedForms.length && o(FormNavigation, {
|
|
24847
|
-
forms: signedForms,
|
|
24848
|
-
activeForm,
|
|
24849
|
-
gotoForm: (index) => gotoForm(formsToBeSigned.length + index),
|
|
24850
|
-
taskName: "signedDocuments"
|
|
24851
|
-
})]
|
|
24852
|
-
});
|
|
24853
|
-
const content = o(LoaderWrapper, {
|
|
24854
|
-
status: loadingStatus,
|
|
24855
|
-
formOpacityWhenLoading: 0.3,
|
|
24856
|
-
showSpinner: false,
|
|
24857
|
-
className: "adyen-kyc-form-container",
|
|
24858
|
-
children: [o(LoaderWrapper, {
|
|
24859
|
-
status: contractLoadingStatus,
|
|
25035
|
+
const allowedFormsWithValidity = addValidityToForms(allowedForms, formValidity, props.problems);
|
|
25036
|
+
const sidebar = !hideDropinLayout && !hideNavigation && o(LoaderWrapper, {
|
|
25037
|
+
status: loadingStatus,
|
|
24860
25038
|
formOpacityWhenLoading: 0.3,
|
|
24861
25039
|
showSpinner: false,
|
|
24862
|
-
|
|
24863
|
-
|
|
24864
|
-
|
|
25040
|
+
className: "adyen-kyc-dropin__sidebar-wrapper",
|
|
25041
|
+
children: o(FormNavigation, {
|
|
25042
|
+
forms: allowedFormsWithValidity,
|
|
25043
|
+
activeForm: allowedFormsWithValidity.find((form) => form.formId === activeForm.formId),
|
|
25044
|
+
gotoForm: gotoFormByFormIndex,
|
|
25045
|
+
validateForm: validateCurrentForm,
|
|
25046
|
+
taskName,
|
|
25047
|
+
trackNavigation: trackNavigation2,
|
|
25048
|
+
hasVerificationErrors: ((_c = props == null ? void 0 : props.problems) == null ? void 0 : _c.verificationErrors) && ((_e = Object.keys((_d = props == null ? void 0 : props.problems) == null ? void 0 : _d.verificationErrors)) == null ? void 0 : _e.length) > 0
|
|
24865
25049
|
})
|
|
24866
|
-
})
|
|
24867
|
-
|
|
24868
|
-
|
|
24869
|
-
|
|
24870
|
-
|
|
24871
|
-
|
|
24872
|
-
|
|
24873
|
-
|
|
24874
|
-
children: (childProps) => o(Select, {
|
|
24875
|
-
...childProps,
|
|
24876
|
-
onChange: handleChangeFor("signer", "blur"),
|
|
24877
|
-
name: "signer",
|
|
24878
|
-
placeholder: i18n.get("selectSigner"),
|
|
24879
|
-
selected: data.signer,
|
|
24880
|
-
items: signers
|
|
24881
|
-
})
|
|
24882
|
-
}), o(Field, {
|
|
24883
|
-
name: "acceptServiceAgreement",
|
|
24884
|
-
errorMessage: i18n.get((_d = errors.acceptServiceAgreement) == null ? void 0 : _d.errorMessage),
|
|
24885
|
-
isValid: valid.acceptServiceAgreement,
|
|
24886
|
-
children: (childProps) => o(Checkbox, {
|
|
24887
|
-
...childProps,
|
|
24888
|
-
label: i18n.get("iHaveReadAndIAcceptTheseTerms"),
|
|
24889
|
-
checked: data.acceptServiceAgreement ?? false,
|
|
24890
|
-
name: "acceptServiceAgreement",
|
|
24891
|
-
onChange: handleChangeFor("acceptServiceAgreement")
|
|
24892
|
-
})
|
|
24893
|
-
})]
|
|
24894
|
-
}), o(ActionBar, {
|
|
24895
|
-
onHome: goHome,
|
|
24896
|
-
homeButtonLabel: i18n.get("goToOverview"),
|
|
24897
|
-
onNext: canSign ? handleSignClick : void 0,
|
|
24898
|
-
nextButtonLabel: canSign ? i18n.get("sign") : void 0
|
|
24899
|
-
})]
|
|
24900
|
-
});
|
|
24901
|
-
return o(DropinLayout, {
|
|
24902
|
-
content: o(Fragment, {
|
|
24903
|
-
children: [sidebar, content]
|
|
24904
|
-
})
|
|
24905
|
-
});
|
|
24906
|
-
}
|
|
24907
|
-
const labels = (data, country2) => ({
|
|
24908
|
-
registrationNumber: () => {
|
|
24909
|
-
var _a;
|
|
24910
|
-
if (country2 === CountryCodes.Monaco && ((_a = data == null ? void 0 : data.solePropNameAndCountry) == null ? void 0 : _a.companyCountry) === CountryCodes.Monaco) {
|
|
24911
|
-
return "mcRegistrationNumberSoleProp";
|
|
25050
|
+
});
|
|
25051
|
+
const content = o(Fragment, {
|
|
25052
|
+
children: [sidebar, wrappedComponent]
|
|
25053
|
+
});
|
|
25054
|
+
if (!props.hideDropinLayout) {
|
|
25055
|
+
return o(DropinLayout, {
|
|
25056
|
+
content
|
|
25057
|
+
});
|
|
24912
25058
|
}
|
|
24913
|
-
|
|
24914
|
-
}
|
|
25059
|
+
return wrappedComponent;
|
|
25060
|
+
};
|
|
25061
|
+
return WithFormComposer;
|
|
25062
|
+
}
|
|
24915
25063
|
const SolePropWithFormComposer = withFormComposer(SolePropComponent, {
|
|
24916
25064
|
getComponentForms: () => solePropForms,
|
|
24917
25065
|
// TODO: change trust to soleprop once the configurations for soleprops are added in backend.
|