@adyen/kyc-components 2.2.6 → 2.3.0

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.
@@ -6760,6 +6760,13 @@ const Select = ({
6760
6760
  return o("div", {
6761
6761
  className: cx(["adyen-kyc-dropdown", styles$2["adyen-kyc-dropdown"], className, ...classNameModifiers.map((m2) => `adyen-kyc-dropdown--${m2}`)]),
6762
6762
  ref: selectContainerRef,
6763
+ onClick: (e2) => {
6764
+ e2.stopPropagation();
6765
+ if (filterInputRef.current) {
6766
+ filterInputRef.current.focus();
6767
+ }
6768
+ },
6769
+ role: "presentation",
6763
6770
  children: [o(SelectButton, {
6764
6771
  id: uniqueId2 ?? null,
6765
6772
  active,
@@ -10596,88 +10603,92 @@ const createPatternByDigits = (digits) => ({
10596
10603
  pattern: new RegExp(`\\d{${digits}}`)
10597
10604
  });
10598
10605
  const postalCodePatterns = {
10599
- AT: createPatternByDigits(4),
10600
- AU: createPatternByDigits(4),
10601
- BE: {
10606
+ [CountryCodes.Australia]: createPatternByDigits(4),
10607
+ [CountryCodes.Austria]: createPatternByDigits(4),
10608
+ [CountryCodes.Belgium]: {
10602
10609
  pattern: /(?:(?:[1-9])(?:\d{3}))/
10603
10610
  },
10604
- BG: createPatternByDigits(4),
10605
- BR: createPatternByDigits(8),
10606
- CA: {
10611
+ [CountryCodes.Brazil]: createPatternByDigits(8),
10612
+ [CountryCodes.Bulgaria]: createPatternByDigits(4),
10613
+ [CountryCodes.Canada]: {
10607
10614
  pattern: /(?:[ABCEGHJ-NPRSTVXY]\d[A-Z][ -]?\d[A-Z]\d)/
10608
10615
  },
10609
- CH: {
10610
- pattern: /[1-9]\d{3}/
10616
+ [CountryCodes.Croatia]: {
10617
+ pattern: /^([1-5])[0-9]{4}$/
10611
10618
  },
10612
- CY: createPatternByDigits(4),
10613
- CZ: {
10619
+ [CountryCodes.Cyprus]: createPatternByDigits(4),
10620
+ [CountryCodes.CzechRepublic]: {
10614
10621
  pattern: /\d{3}\s?\d{2}/
10615
10622
  },
10616
- DE: createPatternByDigits(5),
10617
- DK: {
10623
+ [CountryCodes.Denmark]: {
10618
10624
  pattern: /^(DK-)?[0-9]{4}$/
10619
10625
  },
10620
- EE: createPatternByDigits(5),
10621
- ES: {
10622
- pattern: /(?:0[1-9]|[1-4]\d|5[0-2])\d{3}/
10623
- },
10624
- FI: createPatternByDigits(5),
10625
- FR: createPatternByDigits(5),
10626
- GB: {
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})$/
10626
+ [CountryCodes.Estonia]: createPatternByDigits(5),
10627
+ [CountryCodes.Finland]: createPatternByDigits(5),
10628
+ [CountryCodes.France]: createPatternByDigits(5),
10629
+ [CountryCodes.Georgia]: createPatternByDigits(4),
10630
+ [CountryCodes.Germany]: createPatternByDigits(5),
10631
+ [CountryCodes.Gibraltar]: {
10632
+ pattern: /^GX11[ -]?1AA$/
10628
10633
  },
10629
- GE: createPatternByDigits(4),
10630
- GR: {
10634
+ [CountryCodes.Greece]: {
10631
10635
  pattern: /^\d{3}\s{0,1}\d{2}$/
10632
10636
  },
10633
- HR: {
10634
- pattern: /^([1-5])[0-9]{4}$/
10635
- },
10636
- HU: createPatternByDigits(4),
10637
- IE: {
10637
+ [CountryCodes.Hungary]: createPatternByDigits(4),
10638
+ [CountryCodes.Iceland]: createPatternByDigits(3),
10639
+ [CountryCodes.Ireland]: {
10638
10640
  pattern: /(?:^[AC-FHKNPRTV-Y][0-9]{2}|D6W)[ -]?[0-9AC-FHKNPRTV-Y]{4}/
10639
10641
  },
10640
- IS: createPatternByDigits(3),
10641
- IT: createPatternByDigits(5),
10642
- LI: createPatternByDigits(4),
10643
- LT: {
10644
- pattern: /^(LT-)?[0-9]{4,5}$/
10642
+ [CountryCodes.Italy]: createPatternByDigits(5),
10643
+ [CountryCodes.Japan]: {
10644
+ pattern: /^\d{3}[-]\d{4}$/
10645
10645
  },
10646
- LU: createPatternByDigits(4),
10647
- LV: {
10646
+ [CountryCodes.Latvia]: {
10648
10647
  pattern: /^(LV-)?[0-9]{4}$/
10649
10648
  },
10650
- MC: {
10651
- pattern: /^980\d{2}$/
10649
+ [CountryCodes.Liechtenstein]: createPatternByDigits(4),
10650
+ [CountryCodes.Lithuania]: {
10651
+ pattern: /^(LT-)?[0-9]{4,5}$/
10652
10652
  },
10653
- MT: {
10653
+ [CountryCodes.Luxembourg]: createPatternByDigits(4),
10654
+ [CountryCodes.Malaysia]: createPatternByDigits(5),
10655
+ [CountryCodes.Malta]: {
10654
10656
  pattern: /^[A-Za-z]{2,3}[ ]?\d{2}(?:\d{2})?$/
10655
10657
  },
10656
- MY: createPatternByDigits(5),
10657
- NZ: createPatternByDigits(4),
10658
- NL: {
10658
+ [CountryCodes.Monaco]: {
10659
+ pattern: /^980\d{2}$/
10660
+ },
10661
+ [CountryCodes.Netherlands]: {
10659
10662
  pattern: /(?:NL-)?(?:[1-9]\d{3} ?(?:[A-EGHJ-NPRTVWXZ][A-EGHJ-NPRSTVWXZ]|S[BCEGHJ-NPRTVWXZ]))/
10660
10663
  },
10661
- NO: createPatternByDigits(4),
10662
- PL: {
10664
+ [CountryCodes.NewZealand]: createPatternByDigits(4),
10665
+ [CountryCodes.Norway]: createPatternByDigits(4),
10666
+ [CountryCodes.Poland]: {
10663
10667
  pattern: /^\d{2}[-]\d{3}$/
10664
10668
  },
10665
- PT: {
10669
+ [CountryCodes.Portugal]: {
10666
10670
  pattern: /^([1-9]\d{3})([- ]?(\d{3})? *)$/
10667
10671
  },
10668
- RO: createPatternByDigits(6),
10669
- SI: {
10672
+ [CountryCodes.PuertoRico]: createPatternByDigits(5),
10673
+ [CountryCodes.Romania]: createPatternByDigits(6),
10674
+ [CountryCodes.Slovakia]: {
10675
+ pattern: /^(SK-)?[0-9]{5}$/
10676
+ },
10677
+ [CountryCodes.Slovenia]: {
10670
10678
  pattern: /^(SI-)?[0-9]{4}$/
10671
10679
  },
10672
- SE: createPatternByDigits(5),
10673
- SG: createPatternByDigits(6),
10674
- SK: {
10675
- pattern: /^(SK-)?[0-9]{5}$/
10680
+ [CountryCodes.Singapore]: createPatternByDigits(6),
10681
+ [CountryCodes.Spain]: {
10682
+ pattern: /(?:0[1-9]|[1-4]\d|5[0-2])\d{3}/
10676
10683
  },
10677
- JP: {
10678
- pattern: /^\d{3}[-]\d{4}$/
10684
+ [CountryCodes.Sweden]: createPatternByDigits(5),
10685
+ [CountryCodes.Switzerland]: {
10686
+ pattern: /[1-9]\d{3}/
10679
10687
  },
10680
- US: {
10688
+ [CountryCodes.UnitedKingdom]: {
10689
+ 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})$/
10690
+ },
10691
+ [CountryCodes.UnitedStates]: {
10681
10692
  pattern: /^(\d{5})([-]?(\d{4})? *)$/
10682
10693
  }
10683
10694
  };
@@ -14471,9 +14482,10 @@ function IdentityAuComponent(props) {
14471
14482
  maskedFields: props.maskedFields
14472
14483
  });
14473
14484
  p(() => {
14485
+ console.log("triggerValidation");
14474
14486
  if (data.typeOfIdentity)
14475
14487
  triggerValidation(["idNumber"]);
14476
- }, [triggerValidation, data.typeOfIdentity]);
14488
+ }, [data.typeOfIdentity]);
14477
14489
  const {
14478
14490
  sliceData,
14479
14491
  updateStateSlice
@@ -15856,6 +15868,33 @@ const currencyByCountry = {
15856
15868
  [CountryCodes.UnitedKingdom]: [Currency.GBP, Currency.EUR],
15857
15869
  [CountryCodes.UnitedStates]: [Currency.USD]
15858
15870
  };
15871
+ const bankVerificationValidationRules = {
15872
+ verifiedAccountHolder: {
15873
+ modes: ["blur"],
15874
+ validate: (verifiedAccountHolder) => !isEmpty(verifiedAccountHolder),
15875
+ errorMessage: "fieldIsRequired"
15876
+ },
15877
+ verifiedBankCountry: {
15878
+ modes: ["blur"],
15879
+ validate: (verifiedBankCountry) => !isEmpty(verifiedBankCountry),
15880
+ errorMessage: "fieldIsRequired"
15881
+ },
15882
+ verifiedBankName: {
15883
+ modes: ["blur"],
15884
+ validate: (verifiedBankName) => !isEmpty(verifiedBankName),
15885
+ errorMessage: "fieldIsRequired"
15886
+ },
15887
+ verifiedCurrencyCode: {
15888
+ modes: ["blur"],
15889
+ validate: (verifiedCurrencyCode) => !isEmpty(verifiedCurrencyCode),
15890
+ errorMessage: "fieldIsRequired"
15891
+ },
15892
+ verifiedBankAccountNumber: {
15893
+ modes: ["blur"],
15894
+ validate: (verifiedBankAccountNumber) => !isEmpty(verifiedBankAccountNumber),
15895
+ errorMessage: "fieldIsRequired"
15896
+ }
15897
+ };
15859
15898
  const BankVerificationWidget$1 = "";
15860
15899
  class AdyenKycSdkError extends Error {
15861
15900
  constructor(message, sourceError) {
@@ -15893,11 +15932,10 @@ const removeElementSiblings = (element) => {
15893
15932
  child = child.nextSibling;
15894
15933
  }
15895
15934
  };
15896
- const vendorIdentifiers = ["Tink", "PayWithMyBank"];
15897
- const [TINK_VENDOR, TRUSTLY_VENDOR] = vendorIdentifiers;
15898
15935
  const RELEVANT_MESSAGE_TYPES = ["account_verification_report_id", "error"];
15899
15936
  const TERMINAL_DATA_PROPS = ["accounts", "error", "reference"];
15900
15937
  const MOUNT_TIMEOUT = 10 * 1e3;
15938
+ const TINK_VENDOR = "Tink";
15901
15939
  const logger$7 = createLogger("iframeWidget");
15902
15940
  const isObjectData = (data) => typeof data === "object" && !Array.isArray(data) && data !== null;
15903
15941
  const isTerminalMessageData = (data) => Object.entries(data).some(([prop]) => TERMINAL_DATA_PROPS.includes(prop));
@@ -16191,7 +16229,7 @@ const usePreferredVendorForCountry = (country2, getBankVerificationVendors) => {
16191
16229
  const getPreferredVendor = async () => {
16192
16230
  const vendors = await getBankVerificationVendors(country2);
16193
16231
  const preferredVendor2 = vendors[0];
16194
- setPreferredVendor(vendorIdentifiers.includes(preferredVendor2.name) ? preferredVendor2 : null);
16232
+ setPreferredVendor(preferredVendor2.name ? preferredVendor2 : null);
16195
16233
  };
16196
16234
  getPreferredVendor().catch(logger$6.error);
16197
16235
  }, [country2, getBankVerificationVendors]);
@@ -16279,7 +16317,11 @@ function BankVerification(props) {
16279
16317
  getBankVerificationVendors,
16280
16318
  setBankVerificationError,
16281
16319
  onBack,
16282
- hideDropinLayout
16320
+ hideDropinLayout,
16321
+ setBankInfoValidated,
16322
+ hideOnHomeButton,
16323
+ bankInfoValidated,
16324
+ formIsActive
16283
16325
  } = props;
16284
16326
  const {
16285
16327
  i18n
@@ -16302,7 +16344,7 @@ function BankVerification(props) {
16302
16344
  ...props,
16303
16345
  schema,
16304
16346
  defaultData: props.data,
16305
- rules: props.validators,
16347
+ rules: bankVerificationValidationRules,
16306
16348
  fieldProblems: props == null ? void 0 : props.fieldValidationErrors
16307
16349
  });
16308
16350
  const retrieveBankAccountInfo = async ({
@@ -16316,9 +16358,9 @@ function BankVerification(props) {
16316
16358
  handleChangeFor("verifiedBankCountry")(props.country);
16317
16359
  handleChangeFor("verifiedAccountHolder")(props.data.verifiedAccountHolder);
16318
16360
  handleChangeFor("verifiedCurrencyCode")(props.data.verifiedCurrencyCode ?? ((_a = currencyByCountry[props.country]) == null ? void 0 : _a[0]));
16319
- props.setBankInfoValidated(true);
16361
+ setBankInfoValidated(true);
16320
16362
  hideDropinLayout(false);
16321
- props.hideOnHomeButton();
16363
+ hideOnHomeButton(true);
16322
16364
  triggerValidation();
16323
16365
  await ((_b = props.refreshLegalEntity) == null ? void 0 : _b.call(props));
16324
16366
  };
@@ -16337,14 +16379,14 @@ function BankVerification(props) {
16337
16379
  });
16338
16380
  }, [data, valid, errors, isValid]);
16339
16381
  p(() => {
16340
- hideDropinLayout(props.formIsActive && !props.bankInfoValidated);
16382
+ hideDropinLayout(formIsActive && !bankInfoValidated);
16341
16383
  return () => hideDropinLayout(false);
16342
- }, [props.bankInfoValidated, props.formIsActive]);
16384
+ }, [bankInfoValidated, formIsActive]);
16343
16385
  return o(Fragment, {
16344
16386
  children: [o(StateContextSetter, {
16345
16387
  owner: ACCOUNT_VERIFICATION,
16346
16388
  stateRef
16347
- }), props.bankInfoValidated && o(Fragment, {
16389
+ }), bankInfoValidated && o(Fragment, {
16348
16390
  children: [o(FormHeader, {
16349
16391
  heading: props.heading
16350
16392
  }), o("div", {
@@ -16359,7 +16401,7 @@ function BankVerification(props) {
16359
16401
  children: [" ", i18n.get("youSuccessfullyVerifiedAccount")]
16360
16402
  })]
16361
16403
  })]
16362
- }), typeof getBankVerificationVendors === "function" && props.formIsActive && !props.bankInfoValidated && o("div", {
16404
+ }), typeof getBankVerificationVendors === "function" && formIsActive && !bankInfoValidated && o("div", {
16363
16405
  className: "adyen-kyc-bank-verification-container",
16364
16406
  children: o(InstantBankVerification, {
16365
16407
  getBankVerificationVendors,
@@ -17420,7 +17462,7 @@ function PayoutBankStatementComponent(props) {
17420
17462
  defaultData: props.data,
17421
17463
  rules: rules2,
17422
17464
  fieldProblems: props == null ? void 0 : props.fieldValidationErrors,
17423
- shouldValidate: true
17465
+ shouldValidate: props == null ? void 0 : props.shouldValidate
17424
17466
  });
17425
17467
  const alreadyUploadedDocuments = F$1(() => {
17426
17468
  var _a2;
@@ -17861,12 +17903,17 @@ function PayoutDetailsComponent(props) {
17861
17903
  activeForm,
17862
17904
  taskType,
17863
17905
  legalEntityResponse,
17864
- handleGetBankVerificationVendors
17906
+ handleGetBankVerificationVendors,
17907
+ setHideDropinLayout,
17908
+ setHideOnHomeButton,
17909
+ setSkipSubmit,
17910
+ setHideBackButton,
17911
+ setSubmitButtonLabel
17865
17912
  } = props;
17866
17913
  const [instantVerificationError, setInstantVerificationError] = useInstantVerificationErrorNotification(1e4);
17867
17914
  const verificationMethodFormProps = getFormProps(props, payoutSteps.payoutVerificationMethod.formId);
17868
17915
  const accountVerificationFormProps = getFormProps(props, payoutSteps.payoutAccountVerification.formId);
17869
- const payoutAccountFormProps = getFormProps(props, payoutSteps.payoutAccountDetails(props.taskType).formId);
17916
+ const payoutAccountFormProps = getFormProps(props, payoutSteps.payoutAccountDetails(taskType).formId);
17870
17917
  const payoutBankStatementFormProps = getFormProps(props, payoutSteps.payoutAccountDocuments.formId);
17871
17918
  const taskHeading = i18n.get(taskHeadings[taskType]);
17872
17919
  const isBankStatementDocumentOptional = formUtilities(payoutBankStatementFormProps, i18n).isOptionalField("bankStatementDocument");
@@ -17875,16 +17922,15 @@ function PayoutDetailsComponent(props) {
17875
17922
  const resetData = useResetGlobalData();
17876
17923
  const verifyInstantly = ((_a = data.payoutVerificationMethod) == null ? void 0 : _a.payoutVerificationMethod) === "instantVerification";
17877
17924
  const bankCountry2 = (_b = data.payoutVerificationMethod) == null ? void 0 : _b.bankCountry;
17878
- p(() => props.evaluateConfiguration(data), [data.payoutVerificationMethod]);
17879
17925
  p(() => resetData(), [resetData]);
17880
17926
  p(() => {
17881
17927
  if (activeForm.formId === summaryStep.formId && verifyInstantly) {
17882
- props.setSkipSubmitAndGoTaskList(true);
17883
- props.setHideOnHomeButton(true);
17884
- props.setHideBackButton(true);
17885
- props.setSubmitButtonLabel("continue");
17928
+ setSkipSubmit(true);
17929
+ setHideOnHomeButton(true);
17930
+ setHideBackButton(true);
17931
+ setSubmitButtonLabel("continue");
17886
17932
  }
17887
- }, [props.activeForm]);
17933
+ }, [activeForm]);
17888
17934
  const [bankInfoValidated, setBankInfoValidated] = h(false);
17889
17935
  return o("div", {
17890
17936
  className: "adyen-kyc-payout",
@@ -17912,11 +17958,10 @@ function PayoutDetailsComponent(props) {
17912
17958
  id: payoutSteps.payoutAccountVerification.formId,
17913
17959
  country: bankCountry2,
17914
17960
  onBack: props.onBack,
17915
- onNext: props.onNext,
17916
- hideDropinLayout: (hideStatus) => props.setHideDropinLayout(hideStatus),
17961
+ hideDropinLayout: setHideDropinLayout,
17917
17962
  getBankVerificationVendors: handleGetBankVerificationVendors,
17918
17963
  setBankVerificationError: setInstantVerificationError,
17919
- hideOnHomeButton: () => props.setHideOnHomeButton(true),
17964
+ hideOnHomeButton: setHideOnHomeButton,
17920
17965
  bankInfoValidated,
17921
17966
  setBankInfoValidated,
17922
17967
  formIsActive: activeForm.formId === payoutSteps.payoutAccountVerification.formId,
@@ -19046,7 +19091,9 @@ const useFormComposer = ({
19046
19091
  forms,
19047
19092
  formRef,
19048
19093
  submitButtonLabel,
19049
- onSubmit
19094
+ onSubmit,
19095
+ skipSubmit,
19096
+ onSkipSubmit
19050
19097
  }) => {
19051
19098
  const {
19052
19099
  i18n
@@ -19101,6 +19148,10 @@ const useFormComposer = ({
19101
19148
  return;
19102
19149
  }
19103
19150
  if (isFormSummaryStep(activeForm)) {
19151
+ if (skipSubmit && onSkipSubmit) {
19152
+ onSkipSubmit();
19153
+ return;
19154
+ }
19104
19155
  onSubmit();
19105
19156
  return;
19106
19157
  }
@@ -20254,16 +20305,13 @@ const FormWrapper = ({
20254
20305
  hasVerificationErrors: Object.keys((problems == null ? void 0 : problems.verificationErrors) ?? {}).length > 0
20255
20306
  })
20256
20307
  });
20257
- if (hideDropinLayout) {
20258
- return multiStepForm;
20259
- }
20260
20308
  return o(DropinLayout, {
20261
20309
  content: o(Fragment, {
20262
20310
  children: [sidebar, multiStepForm]
20263
20311
  })
20264
20312
  });
20265
20313
  };
20266
- const parseConfiguration$1 = ({
20314
+ const parseConfiguration$2 = ({
20267
20315
  country: country2,
20268
20316
  matchingScenario
20269
20317
  }) => parseCompanyScenarios(matchingScenario == null ? void 0 : matchingScenario[LegalEntityType.ORGANIZATION], country2);
@@ -20356,7 +20404,7 @@ function CompanyDropinComponent({
20356
20404
  fieldConfigurations,
20357
20405
  requiredFields
20358
20406
  } = useScenarioConfiguration({
20359
- parseConfiguration: parseConfiguration$1,
20407
+ parseConfiguration: parseConfiguration$2,
20360
20408
  getConfigurationData,
20361
20409
  setLoadingStatus,
20362
20410
  country: country2
@@ -22170,7 +22218,7 @@ function Toast({
22170
22218
  })]
22171
22219
  });
22172
22220
  }
22173
- const parseConfiguration = ({
22221
+ const parseConfiguration$1 = ({
22174
22222
  country: country2,
22175
22223
  matchingScenario
22176
22224
  }) => parseIndividualScenarios(matchingScenario == null ? void 0 : matchingScenario[LegalEntityType.INDIVIDUAL], country2);
@@ -22247,7 +22295,7 @@ function IndividualDropinComponent({
22247
22295
  const {
22248
22296
  fieldConfigurations
22249
22297
  } = useScenarioConfiguration({
22250
- parseConfiguration,
22298
+ parseConfiguration: parseConfiguration$1,
22251
22299
  getConfigurationData,
22252
22300
  setLoadingStatus,
22253
22301
  country: country2
@@ -22622,934 +22670,447 @@ function IndividualDropinComponent({
22622
22670
  })
22623
22671
  });
22624
22672
  }
22625
- function removeObjectPropsWithEmptyValues(obj) {
22626
- Object.keys(obj).forEach((key) => {
22627
- if (obj[key] === null || isEmpty(obj[key]))
22628
- delete obj[key];
22629
- });
22630
- return obj;
22631
- }
22632
- const INITIAL_STATE = {
22633
- data: {},
22634
- allData: {},
22635
- initialData: {},
22636
- errors: {},
22637
- valid: {},
22638
- fieldProblems: {},
22639
- isValid: false
22673
+ const isInstantVerificationAvailable = ({
22674
+ country: country2,
22675
+ verificationVendorsCallback,
22676
+ bankVerificationVendors
22677
+ }) => Boolean(verificationVendorsCallback && (bankVerificationVendors == null ? void 0 : bankVerificationVendors[country2]));
22678
+ const rules = ({
22679
+ data,
22680
+ requiredFields
22681
+ }) => ({
22682
+ whenUsingManualVerification: () => {
22683
+ var _a;
22684
+ if (!data.payoutVerificationMethod)
22685
+ return;
22686
+ if (((_a = data == null ? void 0 : data.payoutVerificationMethod) == null ? void 0 : _a.payoutVerificationMethod) === "manualVerification") {
22687
+ return "REQUIRED";
22688
+ }
22689
+ },
22690
+ whenUsingInstantVerification: () => {
22691
+ var _a;
22692
+ if (!data.payoutVerificationMethod) {
22693
+ return "REQUIRED";
22694
+ }
22695
+ if (((_a = data == null ? void 0 : data.payoutVerificationMethod) == null ? void 0 : _a.payoutVerificationMethod) === "instantVerification") {
22696
+ return "REQUIRED";
22697
+ }
22698
+ },
22699
+ verifiedBankAccountNumber: () => {
22700
+ var _a;
22701
+ if (((_a = data == null ? void 0 : data.payoutVerificationMethod) == null ? void 0 : _a.payoutVerificationMethod) === "instantVerification") {
22702
+ return "REQUIRED";
22703
+ }
22704
+ },
22705
+ bankStatementRequirement: () => {
22706
+ var _a;
22707
+ if (((_a = data == null ? void 0 : data.payoutVerificationMethod) == null ? void 0 : _a.payoutVerificationMethod) === "manualVerification") {
22708
+ return requiredFields == null ? void 0 : requiredFields.bankStatementRequirement;
22709
+ }
22710
+ },
22711
+ // "bankStatement description" field is always "optional" and it's coupled with bank statement document.
22712
+ bankStatementDescription: () => {
22713
+ var _a;
22714
+ if (((_a = data == null ? void 0 : data.payoutVerificationMethod) == null ? void 0 : _a.payoutVerificationMethod) === "manualVerification" && !!(requiredFields == null ? void 0 : requiredFields.bankStatementRequirement)) {
22715
+ return "OPTIONAL";
22716
+ }
22717
+ }
22718
+ });
22719
+ const getRegistrationCountry = (legalEntityResponse) => {
22720
+ var _a, _b;
22721
+ if (legalEntityResponse.type === LegalEntityType.INDIVIDUAL) {
22722
+ return (_a = legalEntityResponse.individual) == null ? void 0 : _a.residentialAddress.country;
22723
+ }
22724
+ if (legalEntityResponse.type === LegalEntityType.ORGANIZATION) {
22725
+ return (_b = legalEntityResponse.organization) == null ? void 0 : _b.registeredAddress.country;
22726
+ }
22640
22727
  };
22641
- function StateReducer() {
22642
- const [schemas, setSchemas] = h({});
22643
- const [activeForms, setActiveForms] = h([]);
22644
- const setCurrentForms = (forms) => {
22645
- setActiveForms(forms);
22728
+ const labels$1 = () => ({
22729
+ verifiedAccountHolder: () => "accountHolder",
22730
+ verifiedBankCountry: () => "bankCountry",
22731
+ verifiedBankName: () => "bankName",
22732
+ verifiedCurrencyCode: () => "currencyCode",
22733
+ verifiedBankAccountNumber: () => "bankAccountNumber"
22734
+ });
22735
+ const parseConfiguration = ({
22736
+ requiredFields,
22737
+ country: country2,
22738
+ bankVerificationAvailable
22739
+ }) => parsePayoutScenarios({
22740
+ requiredFields: requiredFields == null ? void 0 : requiredFields.fields,
22741
+ country: country2,
22742
+ bankVerificationAvailable
22743
+ });
22744
+ function PayoutDetailsDropinComponent({
22745
+ transferInstrument,
22746
+ setTransferInstrument,
22747
+ handleCreateDocument,
22748
+ handleGetDocument,
22749
+ handleUpdateDocument,
22750
+ handleUpdateTransferInstrument,
22751
+ handleCreateTransferInstrument,
22752
+ handleGetBankVerificationVendors,
22753
+ legalEntityResponse,
22754
+ trackingConfig,
22755
+ accountHolder: accountHolder2,
22756
+ country: country2,
22757
+ problems: propProblems,
22758
+ onSubmit: externalOnSubmit,
22759
+ onChange,
22760
+ taskType,
22761
+ taskName,
22762
+ eventEmitter,
22763
+ capabilities,
22764
+ handleHomeClick,
22765
+ homeButtonLabel,
22766
+ refreshLegalEntity,
22767
+ navigateBackToTaskList
22768
+ }) {
22769
+ var _a, _b, _c;
22770
+ const {
22771
+ i18n
22772
+ } = useCoreContext();
22773
+ const {
22774
+ showToast,
22775
+ clearToasts
22776
+ } = useToastContext();
22777
+ const {
22778
+ isSettingEnabled
22779
+ } = useSettingsContext();
22780
+ const {
22781
+ getConfiguration: getConfiguration2,
22782
+ getPayoutAccountFormat: getPayoutAccountFormat2
22783
+ } = useKycExternalApi();
22784
+ const defaultPayoutCountry = getRegistrationCountry(legalEntityResponse) ?? country2;
22785
+ const [bankAccountCountry2, setBankAccountCountry] = h(defaultPayoutCountry);
22786
+ const existingPayoutDetails = transferInstrument ? mapTransferInstrumentToPayoutAccount(transferInstrument) : void 0;
22787
+ const [documents2, setDocuments] = h();
22788
+ const fallbackCurrency = (_a = currencyByCountry[defaultPayoutCountry]) == null ? void 0 : _a[0];
22789
+ const accountHolderName = accountHolder2 || getLegalEntityNameBasedOnType(legalEntityResponse);
22790
+ const instantVerificationEnabled = Boolean(!transferInstrument && handleGetBankVerificationVendors);
22791
+ const prefilledData = {
22792
+ payoutAccountDetails: {
22793
+ accountHolder: accountHolderName,
22794
+ currency: fallbackCurrency,
22795
+ ...existingPayoutDetails == null ? void 0 : existingPayoutDetails.payoutAccountDetails
22796
+ },
22797
+ payoutVerificationMethod: {
22798
+ payoutVerificationMethod: transferInstrument ? isInstantVerifiedAccount(transferInstrument) ? "instantVerification" : "manualVerification" : instantVerificationEnabled ? "instantVerification" : void 0,
22799
+ bankCountry: defaultPayoutCountry,
22800
+ ...existingPayoutDetails == null ? void 0 : existingPayoutDetails.payoutVerificationMethod
22801
+ },
22802
+ payoutAccountVerification: {
22803
+ verifiedAccountHolder: accountHolderName,
22804
+ verifiedBankCountry: defaultPayoutCountry,
22805
+ ...existingPayoutDetails == null ? void 0 : existingPayoutDetails.payoutAccountVerification
22806
+ }
22646
22807
  };
22647
- function reducer2({
22648
- currentState: currState
22649
- }, action) {
22650
- var _a, _b, _c, _d, _e;
22651
- switch (action.type) {
22652
- case "addToState": {
22653
- const state2 = structuredClone(currState);
22654
- const dataStoreId = action.value.dataStoreId ?? action.value.caller;
22655
- const schema = action.value.schema || null;
22656
- const schemaHasChanged = schema && ((_a = schemas == null ? void 0 : schemas[dataStoreId]) == null ? void 0 : _a.toString()) !== schema.toString();
22657
- const mergedState = {
22658
- ...state2,
22659
- data: {
22660
- ...state2.data,
22661
- [dataStoreId]: {
22662
- ...state2.data[dataStoreId],
22663
- ...action.value.data
22664
- }
22665
- },
22666
- // Add data in allData state prop in case we will need them later
22667
- allData: {
22668
- ...state2.allData,
22669
- [dataStoreId]: {
22670
- ...state2.allData[dataStoreId],
22671
- ...removeObjectPropsWithEmptyValues(action.value.data)
22672
- }
22673
- },
22674
- errors: {
22675
- ...state2.errors,
22676
- [dataStoreId]: {
22677
- ...state2.errors[dataStoreId],
22678
- ...action.value.errors
22679
- }
22680
- },
22681
- valid: {
22682
- ...state2.valid,
22683
- [dataStoreId]: {
22684
- ...state2.valid[dataStoreId],
22685
- ...action.value.valid
22686
- }
22687
- },
22688
- fieldProblems: {
22689
- ...state2.fieldProblems,
22690
- [dataStoreId]: {
22691
- ...state2.fieldProblems[dataStoreId],
22692
- ...action.value.fieldProblems
22693
- }
22694
- }
22695
- };
22696
- if (schemaHasChanged) {
22697
- setSchemas({
22698
- ...schemas,
22699
- [dataStoreId]: schema
22808
+ const documentUtils = documentApiUtils(handleCreateDocument, handleGetDocument, handleUpdateDocument);
22809
+ const [hideDropinLayout, setHideDropinLayout] = h(false);
22810
+ const [submitButtonLabel, setSubmitButtonLabel] = h();
22811
+ const [skipSubmit, setSkipSubmit] = h(false);
22812
+ const [hideHomeButton, setHideHomeButton] = h(false);
22813
+ const [hideBackButton, setHideBackButton] = h(false);
22814
+ const [loadingStatus, setLoadingStatus] = h("success");
22815
+ const [data, setData] = h(prefilledData);
22816
+ const [problems, setProblems] = h(propProblems || ((_c = (_b = getCapabilityProblems(legalEntityResponse)) == null ? void 0 : _b.BankAccount) == null ? void 0 : _c[transferInstrument == null ? void 0 : transferInstrument.id]));
22817
+ const baseTrackingPayload = getBaseTrackingPayload({
22818
+ trackingConfig,
22819
+ task: taskType
22820
+ });
22821
+ p(() => {
22822
+ userEvents.addPageView("Payout dropin");
22823
+ userEvents.addEvent("Started payout task", {
22824
+ segmentation: {
22825
+ ...baseTrackingPayload
22826
+ }
22827
+ });
22828
+ }, []);
22829
+ const getConfigurationData = T$1(() => getConfiguration2({
22830
+ legalEntityType: legalEntityResponse.type,
22831
+ capabilities,
22832
+ country: bankAccountCountry2 ?? defaultPayoutCountry
22833
+ }), [bankAccountCountry2, capabilities]);
22834
+ const getPayoutAccountFormatData = T$1(() => getPayoutAccountFormat2(bankAccountCountry2 ?? defaultPayoutCountry), [bankAccountCountry2]);
22835
+ const {
22836
+ fieldConfigurations,
22837
+ requiredFields,
22838
+ bankVerificationVendors
22839
+ } = useScenarioConfiguration({
22840
+ parseConfiguration,
22841
+ getConfigurationData,
22842
+ getPayoutAccountFormatData,
22843
+ instantVerificationEnabled,
22844
+ setLoadingStatus,
22845
+ country: bankAccountCountry2 ?? defaultPayoutCountry
22846
+ });
22847
+ const fieldsFromCustomRules = F$1(() => rules({
22848
+ data,
22849
+ country: bankAccountCountry2 ?? defaultPayoutCountry,
22850
+ taskType,
22851
+ requiredFields
22852
+ }), [bankAccountCountry2, data, taskType]);
22853
+ const fieldsFormCustomLabels = F$1(() => labels$1 ? labels$1() : {}, [data, bankAccountCountry2]);
22854
+ const payoutDetailsSteps = F$1(() => {
22855
+ var _a2, _b2;
22856
+ return getAppropriatePayoutDetailsSteps(taskType, Boolean((_a2 = prefilledData == null ? void 0 : prefilledData.payoutAccountDetails) == null ? void 0 : _a2.transferInstrumentId), !transferInstrument && isInstantVerificationAvailable({
22857
+ country: (_b2 = prefilledData == null ? void 0 : prefilledData.payoutVerificationMethod) == null ? void 0 : _b2.bankCountry,
22858
+ bankVerificationVendors,
22859
+ verificationVendorsCallback: handleGetBankVerificationVendors
22860
+ }), isSettingEnabled("allowIntraRegionCrossBorderPayout"));
22861
+ }, [bankVerificationVendors]);
22862
+ 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]);
22863
+ const {
22864
+ state: {
22865
+ currentState
22866
+ }
22867
+ } = useStateContext();
22868
+ const formValidity = currentState.validityByForm;
22869
+ p(() => {
22870
+ var _a2, _b2;
22871
+ setData({
22872
+ ...currentState.data
22873
+ });
22874
+ setBankAccountCountry((_b2 = (_a2 = currentState == null ? void 0 : currentState.data) == null ? void 0 : _a2.payoutVerificationMethod) == null ? void 0 : _b2.bankCountry);
22875
+ onChange == null ? void 0 : onChange(currentState);
22876
+ }, [currentState, onChange]);
22877
+ const forms = F$1(() => {
22878
+ const requiredForms = getRequiredForms(payoutDetailsSteps, derivedProps == null ? void 0 : derivedProps.requiredFields, derivedProps == null ? void 0 : derivedProps.optionalFields);
22879
+ return addValidityToForms(requiredForms, formValidity, problems);
22880
+ }, [derivedProps, formValidity, problems]);
22881
+ p(() => {
22882
+ var _a2;
22883
+ const documentIds = ((_a2 = transferInstrument == null ? void 0 : transferInstrument.documentDetails) == null ? void 0 : _a2.map((documentReference) => documentReference.id)) || [];
22884
+ if (documentIds.length) {
22885
+ documentUtils.fetchDocuments(documentIds, transferInstrument == null ? void 0 : transferInstrument.id).then(() => {
22886
+ setDocuments(mapApiDocumentToPayoutDocuments(transferInstrument == null ? void 0 : transferInstrument.id));
22887
+ }).catch(() => {
22888
+ showToast({
22889
+ label: i18n.get("failedToFetchRelevantDocuments"),
22890
+ type: ToastType.ERROR
22891
+ });
22892
+ });
22893
+ }
22894
+ }, []);
22895
+ const submitDocuments = async ({
22896
+ forms: forms2,
22897
+ transferInstrument: transferInstrument2,
22898
+ dataSubmitted
22899
+ }) => {
22900
+ if (isDocumentsRequired2(forms2)) {
22901
+ const documentToUpload = await mapPayoutDocumentsToApiDocuments(dataSubmitted, transferInstrument2.id);
22902
+ if (documentToUpload) {
22903
+ try {
22904
+ const documents22 = await documentUtils.uploadDocuments([documentToUpload], transferInstrument2.id);
22905
+ documents22.forEach((document2) => {
22906
+ var _a2;
22907
+ userEvents.addEvent("Saved document", {
22908
+ segmentation: {
22909
+ ...baseTrackingPayload,
22910
+ documentType: document2.type,
22911
+ fileExtention: (_a2 = document2.attachments) == null ? void 0 : _a2.map((item) => getFileExtention(item.pageName))
22912
+ }
22913
+ });
22700
22914
  });
22701
- const processedBySchema = schema.reduce((acc, fieldKey) => {
22702
- const dataObjByFormId = mergedState.data[dataStoreId];
22703
- const allDataObjByFormId = mergedState.allData[dataStoreId];
22704
- const validObjByFormId = mergedState.valid[dataStoreId];
22705
- const errorsObjByFormId = mergedState.errors[dataStoreId];
22706
- const fieldProblemsObjByFormId = mergedState.fieldProblems[dataStoreId];
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]
22915
+ } catch (e2) {
22916
+ setProblems({
22917
+ ...problems,
22918
+ validationErrors: {
22919
+ payoutAccountDocuments: {
22920
+ bankStatementDocument: true
22723
22921
  }
22724
- };
22725
- }, {
22726
- data: {},
22727
- valid: {},
22728
- errors: {},
22729
- fieldProblems: {}
22922
+ }
22730
22923
  });
22731
- mergedState.data[dataStoreId] = processedBySchema.data;
22732
- mergedState.valid[dataStoreId] = processedBySchema.valid;
22733
- mergedState.errors[dataStoreId] = processedBySchema.errors;
22734
- mergedState.fieldProblems[dataStoreId] = processedBySchema.fieldProblems;
22924
+ setTransferInstrument(transferInstrument2);
22925
+ throw new Error(i18n.get("remediationMessage_1_704"));
22735
22926
  }
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
22927
  }
22769
22928
  }
22770
- }
22771
- return {
22772
- reducer: reducer2,
22773
- setCurrentForms
22774
22929
  };
22775
- }
22776
- function StateProvider({
22777
- defaultData = {},
22778
- children
22779
- }) {
22780
- const defaultState = {
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
22930
+ const omitMaskedFieldsIfUnchanged = (maskedFields, dataSubmitted, savedData) => {
22931
+ maskedFields.forEach((maskedField) => {
22932
+ if (dataSubmitted[maskedField] === (savedData == null ? void 0 : savedData[maskedField])) {
22933
+ delete dataSubmitted[maskedField];
22934
+ }
22935
+ });
22792
22936
  };
22793
- const reducerObj = StateReducer();
22794
- const [state2, dispatch] = s(reducerObj.reducer, defaultState);
22795
- const contextValue = F$1(() => ({
22796
- state: state2,
22797
- dispatch,
22798
- setActiveForms: reducerObj.setCurrentForms,
22799
- getData: () => {
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;
22846
- }
22847
- },
22848
- // "bankStatement description" field is always "optional" and it's coupled with bank statement document.
22849
- bankStatementDescription: () => {
22850
- var _a;
22851
- if (((_a = data == null ? void 0 : data.payoutVerificationMethod) == null ? void 0 : _a.payoutVerificationMethod) === "manualVerification" && !!(requiredFields == null ? void 0 : requiredFields.bankStatementRequirement)) {
22852
- return "OPTIONAL";
22937
+ const onSubmit = async () => {
22938
+ var _a2;
22939
+ setLoadingStatus("loading");
22940
+ const dataSubmitted = data;
22941
+ dataSubmitted.payoutAccountDetails.currency = dataSubmitted.payoutAccountDetails.currency ?? fallbackCurrency;
22942
+ if (defaultPayoutCountry === CountryCodes.Sweden && "iban" in dataSubmitted.payoutAccountDetails) {
22943
+ dataSubmitted.payoutAccountDetails.currency = Currency.EUR;
22853
22944
  }
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];
22945
+ const event = {
22946
+ segmentation: {
22947
+ ...baseTrackingPayload,
22948
+ documentType: DocumentType.BANK_STATEMENT,
22949
+ bankCountry: dataSubmitted.payoutVerificationMethod.bankCountry,
22950
+ bankCurrency: dataSubmitted.payoutAccountDetails.currency
22955
22951
  }
22956
- return true;
22957
22952
  };
22958
- const isFormSummaryStep = (form) => form.formId === summaryStep.formId;
22959
- const componentForms = F$1(() => getComponentForms({
22960
- ...props,
22961
- bankVerificationVendors
22962
- }, isSettingEnabled), [bankVerificationVendors, isSettingEnabled, props]);
22963
- const componentFormsWithSummary = [...Object.values(componentForms), summaryStep];
22964
- const allowedForms = componentFormsWithSummary.filter((form) => isFormStepVisible(form.formId) || isFormSummaryStep(form));
22965
- const [activeForm, setActiveForm] = h(getOpeningStep(allowedForms, (_a = props == null ? void 0 : props.problems) == null ? void 0 : _a.remediationActions));
22966
- const [hasAlreadyNavigatedForm, setHasAlreadyNavigatedForm] = h(false);
22967
- const getFormIndex = (formId) => allowedForms.findIndex((form) => form.formId === formId);
22968
- const isFinalStep = getFormIndex(activeForm.formId) === allowedForms.length - 1;
22969
- const isFirstStep = getFormIndex(activeForm.formId) === 0;
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);
22953
+ userEvents.addEvent("Provided payout details", event);
22954
+ omitMaskedFieldsIfUnchanged(maskedPayoutFields, dataSubmitted.payoutAccountDetails, existingPayoutDetails == null ? void 0 : existingPayoutDetails.payoutAccountDetails);
22955
+ let transferInstrument2 = mapPayoutAccountToTransferInstrument({
22956
+ data: dataSubmitted,
22957
+ legalEntity: legalEntityResponse
22958
+ });
22959
+ const transferInstrumentId = (_a2 = existingPayoutDetails == null ? void 0 : existingPayoutDetails.payoutAccountDetails) == null ? void 0 : _a2.transferInstrumentId;
22960
+ try {
22961
+ if (!transferInstrumentId) {
22962
+ transferInstrument2 = await handleCreateTransferInstrument(transferInstrument2);
22963
+ } else {
22964
+ transferInstrument2 = await handleUpdateTransferInstrument(drop("id").from(transferInstrument2), transferInstrumentId);
22977
22965
  }
22978
- }, [activeForm, allowedForms, (_b = props == null ? void 0 : props.problems) == null ? void 0 : _b.remediationActions, hasAlreadyNavigatedForm]);
22979
- const evaluateConfiguration = T$1((scenarioConfiguration, country2, formData, isSettingEnabled2, requiredFields2) => {
22980
- var _a2, _b2, _c2;
22981
- const fieldsFromCustomRules = rules2 ? rules2({
22982
- data: formData,
22983
- country: country2,
22984
- taskType: props.taskType,
22985
- isSettingEnabled: isSettingEnabled2,
22986
- requiredFields: requiredFields2
22987
- }) : {};
22988
- const fieldsFormCustomLabels = labels2 ? labels2(formData, country2) : {};
22989
- 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);
22990
- setShouldValidate(false);
22991
- setDerivedProps({
22992
- ...props,
22993
- ...scenarioProps,
22994
- country: configCountry
22995
- });
22996
- }, [componentForms, configCountry, props]);
22997
- p(() => {
22998
- if (!fieldConfigurations)
22999
- return;
23000
- evaluateConfiguration(fieldConfigurations, configCountry, getData(), isSettingEnabled, requiredFields);
23001
- }, [fieldConfigurations, configCountry, evaluateConfiguration, getData, isSettingEnabled, requiredFields]);
23002
- const trackNavigation2 = ({
23003
- fromForm,
23004
- toForm,
23005
- component
23006
- }) => {
23007
- userEvents.addEvent("Navigated form", {
22966
+ userEvents.addEvent("Saved payout details", event);
22967
+ try {
22968
+ await submitDocuments({
22969
+ forms,
22970
+ transferInstrument: transferInstrument2,
22971
+ dataSubmitted
22972
+ });
22973
+ setLoadingStatus("success");
22974
+ clearToasts();
22975
+ externalOnSubmit == null ? void 0 : externalOnSubmit(dataSubmitted);
22976
+ } catch (e2) {
22977
+ setLoadingStatus("success");
22978
+ showToast({
22979
+ label: e2.message,
22980
+ type: ToastType.ERROR
22981
+ });
22982
+ }
22983
+ } catch (e2) {
22984
+ if (isValidationError(e2)) {
22985
+ const validationErrors = processValidationErrors(e2, taskType);
22986
+ setProblems({
22987
+ ...problems,
22988
+ validationErrors
22989
+ });
22990
+ } else if (isMaintenanceModeError(e2)) {
22991
+ showToast({
22992
+ label: i18n.get("failedToUpdateDetails"),
22993
+ subLabel: i18n.get("maintenanceModeMessage"),
22994
+ type: ToastType.ERROR,
22995
+ duration: "indefinite"
22996
+ });
22997
+ } else {
22998
+ showToast({
22999
+ label: i18n.get("failedToUpdateDetails"),
23000
+ type: ToastType.ERROR
23001
+ });
23002
+ }
23003
+ setLoadingStatus("success");
23004
+ userEvents.addEvent("Encountered error payout details", {
23008
23005
  segmentation: {
23009
- ...props == null ? void 0 : props.baseTrackingPayload,
23010
- component,
23011
- from: fromForm.formId,
23012
- fromLabel: i18n.get(fromForm.formName),
23013
- to: toForm.formId,
23014
- toLabel: i18n.get(toForm.formName)
23006
+ ...baseTrackingPayload,
23007
+ errorCode: e2.errorCode,
23008
+ errorMessage: e2.title,
23009
+ errorType: "BE"
23015
23010
  }
23016
23011
  });
23017
- };
23018
- const trackSectionCompletion = (form) => {
23019
- userEvents.addEvent("Completed form section", {
23020
- segmentation: {
23021
- ...props == null ? void 0 : props.baseTrackingPayload,
23022
- sectionName: form.formId
23012
+ }
23013
+ };
23014
+ const isDocumentsRequired2 = (forms2) => forms2.some((form) => form.formId === payoutDetailsSteps.payoutAccountDocuments.formId);
23015
+ const formatFileSummaryData2 = (documents22) => {
23016
+ var _a2, _b2;
23017
+ return {
23018
+ ...(documents22 == null ? void 0 : documents22.bankStatementDocument) && {
23019
+ bankStatementDocument: {
23020
+ fileName: (_b2 = (_a2 = documents22.bankStatementDocument) == null ? void 0 : _a2[0]) == null ? void 0 : _b2.name
23023
23021
  }
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
23022
  }
23038
23023
  };
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
- };
23243
- return WithFormComposer;
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
23024
  };
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) => {
23025
+ const canSubmit2 = () => {
23494
23026
  var _a2;
23495
- if (((_a2 = data2.payoutVerificationMethod) == null ? void 0 : _a2.payoutVerificationMethod) === "instantVerification") {
23027
+ if (((_a2 = data.payoutVerificationMethod) == null ? void 0 : _a2.payoutVerificationMethod) === "instantVerification") {
23496
23028
  return false;
23497
23029
  }
23498
- const bankDetails = data2.payoutAccountDetails;
23499
- return Object.values(bankDetails).every(Boolean);
23030
+ const bankDetails = data.payoutAccountDetails;
23031
+ return !isEmpty(bankDetails) && Object.values(bankDetails).every(Boolean);
23500
23032
  };
23501
23033
  const datasetUtils = datasetUtilities(i18n.locale);
23502
- const formatDataForSummary = (data2) => {
23034
+ const formatDataForSummary = () => {
23503
23035
  var _a2;
23504
- const summaryData = cloneObject(data2);
23036
+ const summaryData = cloneObject(data);
23505
23037
  if (((_a2 = summaryData.payoutVerificationMethod) == null ? void 0 : _a2.bankCountry) && summaryData.payoutAccountDetails) {
23506
23038
  summaryData.payoutAccountDetails.bankCountry = datasetUtils.getCountryName(summaryData.payoutVerificationMethod.bankCountry);
23507
23039
  }
23508
23040
  if (summaryData == null ? void 0 : summaryData.payoutAccountDocuments) {
23509
- summaryData.payoutAccountDocuments.bankStatementDocument = formatFileSummaryData2(data2 == null ? void 0 : data2.payoutAccountDocuments);
23041
+ summaryData.payoutAccountDocuments.bankStatementDocument = formatFileSummaryData2(data == null ? void 0 : data.payoutAccountDocuments);
23510
23042
  }
23511
23043
  return summaryData;
23512
23044
  };
23513
- return o(StateProvider, {
23514
- defaultData: data,
23515
- children: [o(StateContextWatcher, {
23516
- onChange: ({
23517
- currentState
23518
- }) => {
23519
- var _a2, _b2;
23520
- return setBankAccountCountry((_b2 = (_a2 = currentState == null ? void 0 : currentState.data) == null ? void 0 : _a2.payoutVerificationMethod) == null ? void 0 : _b2.bankCountry);
23521
- }
23522
- }), o(PayoutAccountWithFormComposer, {
23523
- baseTrackingPayload,
23524
- taskType: props.taskType,
23525
- taskName: props.taskName,
23526
- capabilities: props.capabilities,
23527
- data,
23045
+ const {
23046
+ handleNextClick,
23047
+ handleBackClick,
23048
+ activeForm,
23049
+ shouldValidate,
23050
+ setShouldValidate,
23051
+ gotoFormByFormIndex,
23052
+ nextButtonLabel
23053
+ } = useFormComposer({
23054
+ problems,
23055
+ baseTrackingPayload,
23056
+ forms,
23057
+ submitButtonLabel,
23058
+ onSubmit,
23059
+ skipSubmit,
23060
+ onSkipSubmit: navigateBackToTaskList
23061
+ });
23062
+ return o(FormWrapper, {
23063
+ taskName: taskName ?? "payoutDetails",
23064
+ activeForm,
23065
+ summary: {
23066
+ data: formatDataForSummary(),
23067
+ omittedKeys: ["transferInstrumentId"],
23068
+ omittedForms: [payoutSteps.payoutVerificationMethod.formId],
23069
+ labels: derivedProps == null ? void 0 : derivedProps.labels
23070
+ },
23071
+ handleBackClick,
23072
+ handleNextClick,
23073
+ handleHomeClick,
23074
+ hideDropinLayout,
23075
+ hideHomeButton,
23076
+ hideBackButton,
23077
+ loadingStatus,
23078
+ forms,
23079
+ onSubmit,
23080
+ baseTrackingPayload,
23081
+ gotoFormByFormIndex,
23082
+ nextButtonLabel,
23083
+ homeButtonLabel,
23084
+ validateForm: () => setShouldValidate(true),
23085
+ canSubmit: canSubmit2() && hasDataChanged(prefilledData, data),
23086
+ problems,
23087
+ children: o(PayoutDetailsComponent, {
23088
+ ...derivedProps,
23089
+ capabilities,
23090
+ data: {
23091
+ ...prefilledData,
23092
+ payoutAccountDocuments: documents2
23093
+ },
23528
23094
  country: defaultPayoutCountry,
23095
+ activeForm,
23096
+ forms,
23529
23097
  problems,
23530
- eventEmitter: props.eventEmitter,
23531
- accountHolder: props.accountHolder ?? getLegalEntityNameBasedOnType(props.legalEntityResponse),
23532
- hideDropinLayout: props.hideDropinLayout,
23533
- onChange: props.onChange,
23534
- handleHomeClick: props.handleHomeClick,
23535
- homeButtonLabel: props.homeButtonLabel,
23536
- legalEntityType: legalEntityResponse.type,
23098
+ eventEmitter,
23099
+ onBack: handleBackClick,
23100
+ accountHolder: accountHolder2 ?? getLegalEntityNameBasedOnType(legalEntityResponse),
23101
+ setHideDropinLayout,
23102
+ setSubmitButtonLabel,
23103
+ setHideOnHomeButton: setHideHomeButton,
23104
+ setHideBackButton,
23105
+ setSkipSubmit,
23106
+ onChange,
23537
23107
  legalEntityResponse,
23538
- summary: {
23539
- formatData: formatDataForSummary,
23540
- getOmittedKeys: () => ["transferInstrumentId"],
23541
- omittedForms: [payoutSteps.payoutVerificationMethod.formId]
23542
- },
23543
- canSubmit: canSubmit2,
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
- })]
23108
+ handleGetBankVerificationVendors,
23109
+ instantVerificationEnabled,
23110
+ refreshLegalEntity,
23111
+ shouldValidate,
23112
+ bankVerificationVendors
23113
+ })
23553
23114
  });
23554
23115
  }
23555
23116
  const ContractViewer$1 = "";
@@ -24260,658 +23821,1232 @@ function TrustRoleAndEntityTypeComponent(props) {
24260
23821
  } = e2.target;
24261
23822
  handleChangeFor("descriptionUndefinedBeneficiary")(value);
24262
23823
  };
24263
- const changeRoles = (roles) => {
24264
- handleChangeFor("role")(roles);
24265
- if (roles.includes("undefinedBeneficiary")) {
24266
- handleChangeFor("entityType")(void 0);
23824
+ const changeRoles = (roles) => {
23825
+ handleChangeFor("role")(roles);
23826
+ if (roles.includes("undefinedBeneficiary")) {
23827
+ handleChangeFor("entityType")(void 0);
23828
+ } else {
23829
+ handleChangeFor("descriptionUndefinedBeneficiary")(void 0);
23830
+ }
23831
+ };
23832
+ const changeSettlorExemptionReasons = (exemptionReasons) => {
23833
+ var _a;
23834
+ if (exemptionReasons.includes("noneOfTheAbove")) {
23835
+ handleChangeFor("settlorExemptionReason")(((_a = data.settlorExemptionReason) == null ? void 0 : _a.includes("noneOfTheAbove")) ? exemptionReasons.filter((reason) => reason !== "noneOfTheAbove") : ["noneOfTheAbove"]);
23836
+ return;
23837
+ }
23838
+ handleChangeFor("settlorExemptionReason")(exemptionReasons);
23839
+ };
23840
+ return o("form", {
23841
+ className: "adyen-kyc-trust__role-and-entity-type adl-u-width-full",
23842
+ children: [o(FormHeader, {
23843
+ heading: i18n.get("roleAndEntityType")
23844
+ }), o(ErrorPanel, {
23845
+ verificationErrors: props == null ? void 0 : props.formVerificationErrors,
23846
+ validationErrors: props == null ? void 0 : props.fieldValidationErrors,
23847
+ formUtils,
23848
+ id: "ariaErrorField"
23849
+ }), o(Field, {
23850
+ name: "role",
23851
+ label: formUtils.getLabel("role", "selectTheApplicableRoles"),
23852
+ classNameModifiers: ["role"],
23853
+ errorMessage: formUtils.getErrorMessage("role", errors, fieldProblems),
23854
+ isValid: valid.role,
23855
+ disabled: availableRoles.length === 0,
23856
+ showErrorIconBottom: true,
23857
+ children: (childProps) => o(MultiSelectList, {
23858
+ ...childProps,
23859
+ options: Object.values(TrustMemberTypes),
23860
+ selected: data.role ?? [],
23861
+ onSelect: changeRoles,
23862
+ mapToSelectItem: (role2) => ({
23863
+ ...makeSelectItemForTrustRole(role2, i18n),
23864
+ disabled: !availableRoles.includes(role2)
23865
+ })
23866
+ })
23867
+ }), (schema == null ? void 0 : schema.includes("entityType")) && o(Field, {
23868
+ name: "entityType",
23869
+ useLabelElement: false,
23870
+ errorMessage: formUtils.getErrorMessage("entityType", errors, fieldProblems),
23871
+ label: formUtils.getLabel("entityType", "whatTypeOfYourMembersEntity"),
23872
+ classNameModifiers: ["entityType"],
23873
+ disabled: !!(trustMember == null ? void 0 : trustMember.reference),
23874
+ children: (childProps) => o(RadioCardSelect, {
23875
+ ...childProps,
23876
+ options: trustMemberLegalEntityTypes,
23877
+ onSelect: handleChangeFor("entityType"),
23878
+ selected: data.entityType,
23879
+ optionId: (option) => leTypeCardDetails[option].id,
23880
+ optionName: (option) => leTypeCardDetails[option].name,
23881
+ optionDescription: (option) => leTypeCardDetails[option].description,
23882
+ "aria-required": true,
23883
+ "aria-label": formUtils.getLabel("entityType", "whatTypeOfYourMembersEntity"),
23884
+ "aria-invalid": !valid.entityType
23885
+ })
23886
+ }), (schema == null ? void 0 : schema.includes("descriptionUndefinedBeneficiary")) && o(Field, {
23887
+ name: "descriptionUndefinedBeneficiary",
23888
+ label: formUtils.getLabel("description"),
23889
+ isValid: valid.descriptionUndefinedBeneficiary,
23890
+ errorMessage: formUtils.getErrorMessage("descriptionUndefinedBeneficiary", errors, fieldProblems),
23891
+ children: (childProps) => o(TextArea, {
23892
+ ...childProps,
23893
+ name: "descriptionUndefinedBeneficiary",
23894
+ value: data.descriptionUndefinedBeneficiary,
23895
+ classNameModifiers: ["descriptionUndefinedBeneficiary"],
23896
+ maxLength: CHARACTERS_LIMIT,
23897
+ onInput: onInputDescription,
23898
+ helper: i18n.get("describeWhoIsABeneficiaryInYourTrust"),
23899
+ "aria-required": true,
23900
+ "aria-label": formUtils.getLabel("descriptionUndefinedBeneficiary"),
23901
+ "aria-invalid": !valid.descriptionUndefinedBeneficiary
23902
+ })
23903
+ }), (schema == null ? void 0 : schema.includes("settlorExemptionReason")) && o(Field, {
23904
+ name: "settlorExemptionReason",
23905
+ label: formUtils.getLabel("settlorExemptionReason", "whichOfTheseApplyToTheSettlor"),
23906
+ isValid: valid.settlorExemptionReason,
23907
+ errorMessage: formUtils.getErrorMessage("settlorExemptionReason", errors, fieldProblems),
23908
+ showErrorIconBottom: true,
23909
+ children: (childProps) => o(MultiSelectList, {
23910
+ ...childProps,
23911
+ options: settlorExemptionReasonWithNoneOfTheAbove,
23912
+ selected: data.settlorExemptionReason ?? [],
23913
+ onSelect: changeSettlorExemptionReasons,
23914
+ mapToSelectItem: (reason) => ({
23915
+ id: reason,
23916
+ name: i18n.get(reason)
23917
+ })
23918
+ })
23919
+ })]
23920
+ });
23921
+ }
23922
+ const summary = {
23923
+ formId: "summary",
23924
+ formName: "summary"
23925
+ };
23926
+ const roleAndTypeForms = {
23927
+ roleAndEntityType: {
23928
+ formId: "roleAndEntityType",
23929
+ formName: "roleAndEntityType",
23930
+ fields: ["role", "entityType"]
23931
+ },
23932
+ memberDetails: {
23933
+ formId: "memberDetails",
23934
+ formName: "memberDetails"
23935
+ },
23936
+ summary
23937
+ };
23938
+ const undefinedBeneficiaryForms = {
23939
+ roleAndEntityType: {
23940
+ formId: "roleAndEntityType",
23941
+ formName: "roleAndEntityType",
23942
+ fields: ["role", "entityType", "descriptionUndefinedBeneficiary"]
23943
+ },
23944
+ summary
23945
+ };
23946
+ const exemptSettlorForms = {
23947
+ roleAndEntityType: {
23948
+ formId: "roleAndEntityType",
23949
+ formName: "roleAndEntityType",
23950
+ fields: ["role", "entityType", "settlorExemptionReason"]
23951
+ },
23952
+ summary
23953
+ };
23954
+ const logger$3 = createLogger("RoleAndTypeDropin");
23955
+ function RoleAndTypeDropinComponent(props) {
23956
+ var _a, _b;
23957
+ const {
23958
+ i18n
23959
+ } = useCoreContext();
23960
+ const {
23961
+ showToast
23962
+ } = useToastContext();
23963
+ const [trustMember, setTrustMember] = h(props.trustMember);
23964
+ const [shouldValidate, setShouldValidate] = h(false);
23965
+ const roleAndEntityTypeFormID = "roleAndEntityType";
23966
+ const [formList, setFormList] = h([...Object.values(roleAndTypeForms)]);
23967
+ const [formValidity, setFormValidity] = h({
23968
+ [roleAndEntityTypeFormID]: false
23969
+ });
23970
+ const taskName = "trustMembers";
23971
+ const [activeForm, setActiveForm] = h(formList[0]);
23972
+ const isSummaryStep = activeForm.formId === summaryStep.formId;
23973
+ 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";
23974
+ const navigateToTrustMember = () => {
23975
+ const trustMemberAssociation = {
23976
+ ...props.trustMember,
23977
+ legalEntityType: trustMember == null ? void 0 : trustMember.legalEntityType,
23978
+ types: trustMember == null ? void 0 : trustMember.types
23979
+ };
23980
+ props.navigateNext(trustMemberAssociation);
23981
+ };
23982
+ const submitExemptSettlor = async (exemptSettlor, trustLE) => {
23983
+ var _a2;
23984
+ const existingTrustMembers = getOwnTrustMembers(trustLE);
23985
+ const existingSettlor = existingTrustMembers.find((member) => member.type === "settlor");
23986
+ const updatedAssociations = [...(trustLE.entityAssociations ?? []).filter((association) => association !== existingSettlor), exemptSettlor];
23987
+ const updatedTrustLE = {
23988
+ ...trustLE,
23989
+ entityAssociations: updatedAssociations
23990
+ };
23991
+ try {
23992
+ await ((_a2 = props.handleUpdateLegalEntity) == null ? void 0 : _a2.call(props, updatedTrustLE, trustLE.id));
23993
+ showToast({
23994
+ label: i18n.get("successfullyUpdatedDetails"),
23995
+ type: ToastType.SUCCESS
23996
+ });
23997
+ props.onSubmit(updatedTrustLE);
23998
+ } catch (e2) {
23999
+ logger$3.error(e2);
24000
+ showToast({
24001
+ label: i18n.get("failedToUpdateDetails"),
24002
+ type: ToastType.ERROR
24003
+ });
24004
+ }
24005
+ };
24006
+ const submitUndefinedBeneficiary = async () => {
24007
+ var _a2, _b2, _c;
24008
+ if (((_a2 = props.trustMember) == null ? void 0 : _a2.descriptionUndefinedBeneficiary) === (trustMember == null ? void 0 : trustMember.descriptionUndefinedBeneficiary)) {
24009
+ props.onSubmit(props.trust);
24010
+ return;
24011
+ }
24012
+ const existingUndefinedBeneficiaryInfo = (((_b2 = props.trust.trust) == null ? void 0 : _b2.undefinedBeneficiaryInfo) ?? []).filter((ub) => ub.reference !== (trustMember == null ? void 0 : trustMember.reference));
24013
+ const updatedTrust = {
24014
+ trust: {
24015
+ undefinedBeneficiaryInfo: [{
24016
+ ...(trustMember == null ? void 0 : trustMember.reference) && {
24017
+ reference: trustMember == null ? void 0 : trustMember.reference
24018
+ },
24019
+ description: (trustMember == null ? void 0 : trustMember.descriptionUndefinedBeneficiary) || ""
24020
+ }, ...existingUndefinedBeneficiaryInfo]
24021
+ }
24022
+ };
24023
+ try {
24024
+ await ((_c = props.handleUpdateLegalEntity) == null ? void 0 : _c.call(props, updatedTrust, props.trust.id));
24025
+ showToast({
24026
+ label: i18n.get("successfullyUpdatedDetails"),
24027
+ type: ToastType.SUCCESS
24028
+ });
24029
+ props.onSubmit(updatedTrust);
24030
+ } catch (e2) {
24031
+ logger$3.error(e2);
24032
+ showToast({
24033
+ label: i18n.get("failedToUpdateDetails"),
24034
+ type: ToastType.ERROR
24035
+ });
24036
+ }
24037
+ };
24038
+ const formatRolesForSummary = (roles) => roles.map((role2) => i18n.get(getTrustMemberName(role2))).join(", ");
24039
+ const formatSettlorExemptionReasonsForSummary = (reasons) => reasons.map((reason) => i18n.get(reason)).join(", ");
24040
+ const summaryData = {
24041
+ roleAndEntityType: {
24042
+ role: formatRolesForSummary((trustMember == null ? void 0 : trustMember.types) ?? []),
24043
+ entityType: (trustMember == null ? void 0 : trustMember.legalEntityType) ? i18n.get(trustMember == null ? void 0 : trustMember.legalEntityType) : void 0,
24044
+ descriptionUndefinedBeneficiary: trustMember == null ? void 0 : trustMember.descriptionUndefinedBeneficiary,
24045
+ otherInformation: formatSettlorExemptionReasonsForSummary((trustMember == null ? void 0 : trustMember.settlorExemptionReason) ?? [])
24046
+ }
24047
+ };
24048
+ const onNavigateToNextStep = () => {
24049
+ if (isSummaryStep) {
24050
+ switch (trustMemberCase) {
24051
+ case "exemptSettlor":
24052
+ if (!trustMember)
24053
+ return;
24054
+ submitExemptSettlor(trustMember, props.trust).catch(logger$3.error);
24055
+ break;
24056
+ case "undefinedBeneficiary":
24057
+ submitUndefinedBeneficiary().catch(logger$3.error);
24058
+ break;
24059
+ }
24060
+ return;
24061
+ }
24062
+ if (!formValidity[roleAndEntityTypeFormID]) {
24063
+ setShouldValidate(true);
24064
+ return;
24065
+ }
24066
+ if (trustMemberCase === "fullEntity") {
24067
+ navigateToTrustMember();
24068
+ } else {
24069
+ setActiveForm(summary);
24070
+ }
24071
+ };
24072
+ const onTrustMemberChange = ({
24073
+ data,
24074
+ isValid = false,
24075
+ dataStoreId = void 0
24076
+ }) => {
24077
+ if (dataStoreId) {
24078
+ setFormValidity({
24079
+ ...formValidity,
24080
+ [dataStoreId]: isValid
24081
+ });
24082
+ }
24083
+ if ((data == null ? void 0 : data.role) && data.role.includes(TrustMemberTypes.UNDEFINED_BENEFICIARY)) {
24084
+ setFormList([...Object.values(undefinedBeneficiaryForms)]);
24085
+ } else if (isExemptSettlor(data)) {
24086
+ setFormList([...Object.values(exemptSettlorForms)]);
24267
24087
  } else {
24268
- handleChangeFor("descriptionUndefinedBeneficiary")(void 0);
24088
+ setFormList([...Object.values(roleAndTypeForms)]);
24269
24089
  }
24090
+ setTrustMember({
24091
+ ...props.trustMember,
24092
+ ...data.role ? {
24093
+ types: data.role
24094
+ } : {},
24095
+ legalEntityType: data.entityType,
24096
+ ...data.descriptionUndefinedBeneficiary ? {
24097
+ descriptionUndefinedBeneficiary: data.descriptionUndefinedBeneficiary
24098
+ } : {},
24099
+ ...isExemptSettlor(data) ? {
24100
+ settlorExemptionReason: data.settlorExemptionReason.filter((reason) => reason !== "noneOfTheAbove")
24101
+ } : {}
24102
+ });
24270
24103
  };
24271
- const changeSettlorExemptionReasons = (exemptionReasons) => {
24272
- var _a;
24273
- if (exemptionReasons.includes("noneOfTheAbove")) {
24274
- handleChangeFor("settlorExemptionReason")(((_a = data.settlorExemptionReason) == null ? void 0 : _a.includes("noneOfTheAbove")) ? exemptionReasons.filter((reason) => reason !== "noneOfTheAbove") : ["noneOfTheAbove"]);
24104
+ const saveRolesAndNavigate = async () => {
24105
+ var _a2, _b2, _c;
24106
+ if (!trustMember) {
24275
24107
  return;
24276
24108
  }
24277
- handleChangeFor("settlorExemptionReason")(exemptionReasons);
24109
+ const {
24110
+ reference
24111
+ } = trustMember;
24112
+ if (reference && hasRolesChanged(trustMember.types, (_a2 = props.trustMember) == null ? void 0 : _a2.types) && props.trust.id) {
24113
+ const existingTrustAssociations = getOwnEntityAssociations(props.trust);
24114
+ const updatedTrustAssociations = {
24115
+ entityAssociations: [...((_b2 = trustMember.types) == null ? void 0 : _b2.map((role2) => ({
24116
+ type: role2,
24117
+ reference
24118
+ }))) || [], ...existingTrustAssociations.filter((ea) => ea.legalEntityId !== trustMember.reference) || []]
24119
+ };
24120
+ await ((_c = props.handleUpdateLegalEntity) == null ? void 0 : _c.call(props, updatedTrustAssociations, props.trust.id));
24121
+ }
24122
+ props.navigateBack();
24278
24123
  };
24279
- return o("form", {
24280
- className: "adyen-kyc-trust__role-and-entity-type adl-u-width-full",
24281
- children: [o(FormHeader, {
24282
- heading: i18n.get("roleAndEntityType")
24283
- }), o(ErrorPanel, {
24284
- verificationErrors: props == null ? void 0 : props.formVerificationErrors,
24285
- validationErrors: props == null ? void 0 : props.fieldValidationErrors,
24286
- formUtils,
24287
- id: "ariaErrorField"
24288
- }), o(Field, {
24289
- name: "role",
24290
- label: formUtils.getLabel("role", "selectTheApplicableRoles"),
24291
- classNameModifiers: ["role"],
24292
- errorMessage: formUtils.getErrorMessage("role", errors, fieldProblems),
24293
- isValid: valid.role,
24294
- disabled: availableRoles.length === 0,
24295
- showErrorIconBottom: true,
24296
- children: (childProps) => o(MultiSelectList, {
24297
- ...childProps,
24298
- options: Object.values(TrustMemberTypes),
24299
- selected: data.role ?? [],
24300
- onSelect: changeRoles,
24301
- mapToSelectItem: (role2) => ({
24302
- ...makeSelectItemForTrustRole(role2, i18n),
24303
- disabled: !availableRoles.includes(role2)
24124
+ const hasRolesChanged = (newRoles = [], existingRoles = []) => newRoles.length !== existingRoles.length || !newRoles.every((newRole) => existingRoles.includes(newRole));
24125
+ const formsWithValidity = Object.values(formList).map((form) => ({
24126
+ formId: form.formId,
24127
+ formName: form.formName,
24128
+ isValid: formValidity[form.formId]
24129
+ }));
24130
+ const gotoFormByFormIndex = (formIndex) => {
24131
+ setActiveForm(formList[formIndex]);
24132
+ };
24133
+ const content = o(Fragment, {
24134
+ children: [o(FormNavigation, {
24135
+ forms: formsWithValidity,
24136
+ activeForm: formsWithValidity.find((form) => form.formId === activeForm.formId),
24137
+ taskName,
24138
+ gotoForm: noop
24139
+ }), o("div", {
24140
+ className: "adyen-kyc-form-container",
24141
+ children: [o("div", {
24142
+ className: activeForm.formId !== "roleAndEntityType" ? "adyen-kyc-form-wrapper adyen-kyc-form-wrapper--hidden" : "adyen-kyc-form-wrapper",
24143
+ children: o(TrustRoleAndEntityTypeComponent, {
24144
+ id: roleAndEntityTypeFormID,
24145
+ trustMember: props.trustMember,
24146
+ onChange: onTrustMemberChange,
24147
+ shouldValidate
24304
24148
  })
24305
- })
24306
- }), (schema == null ? void 0 : schema.includes("entityType")) && o(Field, {
24307
- name: "entityType",
24308
- useLabelElement: false,
24309
- errorMessage: formUtils.getErrorMessage("entityType", errors, fieldProblems),
24310
- label: formUtils.getLabel("entityType", "whatTypeOfYourMembersEntity"),
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)
24149
+ }), isSummaryStep && o("div", {
24150
+ className: "adyen-kyc-form-wrapper",
24151
+ children: o(Summary, {
24152
+ data: summaryData,
24153
+ forms: [undefinedBeneficiaryForms.roleAndEntityType],
24154
+ gotoForm: gotoFormByFormIndex
24356
24155
  })
24357
- })
24156
+ }), o(ActionBar, {
24157
+ onNext: onNavigateToNextStep,
24158
+ onHome: saveRolesAndNavigate,
24159
+ nextButtonLabel: isSummaryStep ? i18n.get("submit") : i18n.get("next"),
24160
+ homeButtonLabel: i18n.get("saveAndGoToOverview")
24161
+ })]
24358
24162
  })]
24359
24163
  });
24164
+ return o(DropinLayout, {
24165
+ content
24166
+ });
24360
24167
  }
24361
- const summary = {
24362
- formId: "summary",
24363
- formName: "summary"
24364
- };
24365
- const roleAndTypeForms = {
24366
- roleAndEntityType: {
24367
- formId: "roleAndEntityType",
24368
- formName: "roleAndEntityType",
24369
- fields: ["role", "entityType"]
24370
- },
24371
- memberDetails: {
24372
- formId: "memberDetails",
24373
- formName: "memberDetails"
24168
+ const serviceAgreementValidationRules = {
24169
+ signer: {
24170
+ modes: ["blur"],
24171
+ validate: (signer2) => !!signer2,
24172
+ errorMessage: "fieldIsRequired"
24374
24173
  },
24375
- summary
24174
+ acceptServiceAgreement: {
24175
+ modes: ["blur"],
24176
+ validate: (acceptServiceAgreement) => !!acceptServiceAgreement,
24177
+ errorMessage: "fieldIsRequired"
24178
+ }
24376
24179
  };
24377
- const undefinedBeneficiaryForms = {
24378
- roleAndEntityType: {
24379
- formId: "roleAndEntityType",
24380
- formName: "roleAndEntityType",
24381
- fields: ["role", "entityType", "descriptionUndefinedBeneficiary"]
24382
- },
24383
- summary
24180
+ const logger$2 = createLogger("useServiceAgreement");
24181
+ const FALLBACK_LANGUAGE_CODE = "en";
24182
+ const useServiceAgreement = ({
24183
+ handleGetServiceAgreement,
24184
+ handleServiceAgreementIsNotAvailableInThatLanguage,
24185
+ legalEntityId,
24186
+ serviceAgreementType,
24187
+ language
24188
+ }) => {
24189
+ const [serviceAgreement, setServiceAgreement] = h();
24190
+ const [loading2, setLoading] = h("loading");
24191
+ const [agreementLanguage, setAgreementLanguage] = h(language);
24192
+ p(() => {
24193
+ if (agreementLanguage !== language) {
24194
+ setAgreementLanguage(language);
24195
+ }
24196
+ }, [language]);
24197
+ p(() => {
24198
+ const requestServiceAgreement = async () => {
24199
+ setLoading("loading");
24200
+ try {
24201
+ const {
24202
+ termsOfServiceDocumentId,
24203
+ document: document2
24204
+ } = await handleGetServiceAgreement(legalEntityId, {
24205
+ type: serviceAgreementType,
24206
+ language: agreementLanguage
24207
+ });
24208
+ if (!document2) {
24209
+ logger$2.log('"document" field was missing in response');
24210
+ return;
24211
+ }
24212
+ const contract = JSON.parse(decodeURIComponent(escape(window.atob(document2))));
24213
+ setServiceAgreement({
24214
+ id: termsOfServiceDocumentId,
24215
+ contract
24216
+ });
24217
+ setLoading("success");
24218
+ } catch (err) {
24219
+ if (agreementLanguage !== FALLBACK_LANGUAGE_CODE) {
24220
+ handleServiceAgreementIsNotAvailableInThatLanguage();
24221
+ setAgreementLanguage(FALLBACK_LANGUAGE_CODE);
24222
+ return;
24223
+ }
24224
+ throw err;
24225
+ }
24226
+ };
24227
+ requestServiceAgreement().catch(logger$2.error);
24228
+ }, [handleGetServiceAgreement, handleServiceAgreementIsNotAvailableInThatLanguage, agreementLanguage, legalEntityId, serviceAgreementType]);
24229
+ return {
24230
+ loading: loading2,
24231
+ serviceAgreement
24232
+ };
24384
24233
  };
24385
- const exemptSettlorForms = {
24386
- roleAndEntityType: {
24387
- formId: "roleAndEntityType",
24388
- formName: "roleAndEntityType",
24389
- fields: ["role", "entityType", "settlorExemptionReason"]
24390
- },
24391
- summary
24234
+ const serviceAgreementTypesTranslationMapping = {
24235
+ adyenForPlatformsManage: "paymentProcessingTerms",
24236
+ adyenIssuing: "accountHolderTerms",
24237
+ adyenForPlatformsAdvanced: "paymentProcessingTerms",
24238
+ adyenCapital: "capitalUserTerms",
24239
+ adyenAccount: "businessAccountTerms",
24240
+ adyenCard: "cardUserTerms",
24241
+ adyenFranchisee: "franchiseesTAndCs"
24392
24242
  };
24393
- const logger$3 = createLogger("RoleAndTypeDropin");
24394
- function RoleAndTypeDropinComponent(props) {
24395
- var _a, _b;
24243
+ function ServiceAgreementDropinComponent({
24244
+ legalEntity,
24245
+ handleGetServiceAgreement,
24246
+ handleHomeClick,
24247
+ handleSign,
24248
+ taskType,
24249
+ serviceAgreementTypes,
24250
+ serviceAgreementAcceptanceInfos,
24251
+ trackingConfig
24252
+ }) {
24253
+ var _a, _b, _c, _d;
24396
24254
  const {
24397
24255
  i18n
24398
24256
  } = useCoreContext();
24399
24257
  const {
24400
24258
  showToast
24401
24259
  } = useToastContext();
24402
- const [trustMember, setTrustMember] = h(props.trustMember);
24403
- const [shouldValidate, setShouldValidate] = h(false);
24404
- const roleAndEntityTypeFormID = "roleAndEntityType";
24405
- const [formList, setFormList] = h([...Object.values(roleAndTypeForms)]);
24406
- const [formValidity, setFormValidity] = h({
24407
- [roleAndEntityTypeFormID]: false
24260
+ const baseTrackingPayload = getBaseTrackingPayload({
24261
+ trackingConfig,
24262
+ legalEntity,
24263
+ task: taskType
24408
24264
  });
24409
- const taskName = "trustMembers";
24410
- const [activeForm, setActiveForm] = h(formList[0]);
24411
- const isSummaryStep = activeForm.formId === summaryStep.formId;
24412
- 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";
24413
- const navigateToTrustMember = () => {
24414
- const trustMemberAssociation = {
24415
- ...props.trustMember,
24416
- legalEntityType: trustMember == null ? void 0 : trustMember.legalEntityType,
24417
- types: trustMember == null ? void 0 : trustMember.types
24418
- };
24419
- props.navigateNext(trustMemberAssociation);
24420
- };
24421
- const submitExemptSettlor = async (exemptSettlor, trustLE) => {
24422
- var _a2;
24423
- const existingTrustMembers = getOwnTrustMembers(trustLE);
24424
- const existingSettlor = existingTrustMembers.find((member) => member.type === "settlor");
24425
- const updatedAssociations = [...(trustLE.entityAssociations ?? []).filter((association) => association !== existingSettlor), exemptSettlor];
24426
- const updatedTrustLE = {
24427
- ...trustLE,
24428
- entityAssociations: updatedAssociations
24429
- };
24430
- try {
24431
- await ((_a2 = props.handleUpdateLegalEntity) == null ? void 0 : _a2.call(props, updatedTrustLE, trustLE.id));
24432
- showToast({
24433
- label: i18n.get("successfullyUpdatedDetails"),
24434
- type: ToastType.SUCCESS
24435
- });
24436
- props.onSubmit(updatedTrustLE);
24437
- } catch (e2) {
24438
- logger$3.error(e2);
24439
- showToast({
24440
- label: i18n.get("failedToUpdateDetails"),
24441
- type: ToastType.ERROR
24442
- });
24443
- }
24444
- };
24445
- const submitUndefinedBeneficiary = async () => {
24446
- var _a2, _b2, _c;
24447
- if (((_a2 = props.trustMember) == null ? void 0 : _a2.descriptionUndefinedBeneficiary) === (trustMember == null ? void 0 : trustMember.descriptionUndefinedBeneficiary)) {
24448
- props.onSubmit(props.trust);
24265
+ const [loadingStatus, setLoadingStatus] = h();
24266
+ const formsToBeSigned = serviceAgreementTypes.map((serviceAgreementType) => ({
24267
+ formId: serviceAgreementType,
24268
+ formName: serviceAgreementTypesTranslationMapping[serviceAgreementType],
24269
+ isValid: false
24270
+ }));
24271
+ const signedForms = serviceAgreementAcceptanceInfos.map((serviceAgreementAcceptanceInfo) => ({
24272
+ formId: serviceAgreementAcceptanceInfo.type,
24273
+ formName: serviceAgreementTypesTranslationMapping[serviceAgreementAcceptanceInfo.type],
24274
+ isValid: true
24275
+ }));
24276
+ const forms = [...formsToBeSigned, ...signedForms];
24277
+ const [activeForm, setActiveForm] = h(forms[0]);
24278
+ const canSign = serviceAgreementTypes.includes(activeForm.formId);
24279
+ const handleServiceAgreementIsNotAvailableInThatLanguage = T$1(() => {
24280
+ showToast({
24281
+ label: i18n.get("failedToGetServiceAgreementInSelectedLanguageFallbackToEn"),
24282
+ type: ToastType.ERROR
24283
+ });
24284
+ }, [i18n, showToast]);
24285
+ const {
24286
+ loading: contractLoadingStatus,
24287
+ serviceAgreement
24288
+ } = useServiceAgreement({
24289
+ handleGetServiceAgreement,
24290
+ handleServiceAgreementIsNotAvailableInThatLanguage,
24291
+ legalEntityId: legalEntity.id,
24292
+ serviceAgreementType: activeForm.formId,
24293
+ language: i18n.languageCode
24294
+ });
24295
+ const {
24296
+ handleChangeFor,
24297
+ triggerValidation,
24298
+ data,
24299
+ valid,
24300
+ isValid,
24301
+ errors
24302
+ } = useForm({
24303
+ schema: ["signer", "acceptServiceAgreement"],
24304
+ rules: serviceAgreementValidationRules
24305
+ });
24306
+ const signers = legalEntity.type === LegalEntityType.ORGANIZATION ? getOwnSignatories(legalEntity).map(({
24307
+ legalEntityId: id2,
24308
+ name
24309
+ }) => ({
24310
+ id: id2 ?? "",
24311
+ name: name ?? ""
24312
+ })) : [{
24313
+ id: legalEntity == null ? void 0 : legalEntity.id,
24314
+ 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}`
24315
+ }];
24316
+ const handleSignClick = async () => {
24317
+ userEvents.addEvent("Clicked ToS signing", {
24318
+ segmentation: {
24319
+ ...baseTrackingPayload
24320
+ }
24321
+ });
24322
+ if (loadingStatus === "loading" || !serviceAgreement || !data.signer)
24449
24323
  return;
24450
- }
24451
- const existingUndefinedBeneficiaryInfo = (((_b2 = props.trust.trust) == null ? void 0 : _b2.undefinedBeneficiaryInfo) ?? []).filter((ub) => ub.reference !== (trustMember == null ? void 0 : trustMember.reference));
24452
- const updatedTrust = {
24453
- trust: {
24454
- undefinedBeneficiaryInfo: [{
24455
- ...(trustMember == null ? void 0 : trustMember.reference) && {
24456
- reference: trustMember == null ? void 0 : trustMember.reference
24457
- },
24458
- description: (trustMember == null ? void 0 : trustMember.descriptionUndefinedBeneficiary) || ""
24459
- }, ...existingUndefinedBeneficiaryInfo]
24324
+ triggerValidation();
24325
+ if (isValid) {
24326
+ try {
24327
+ setLoadingStatus("loading");
24328
+ await handleSign(legalEntity.id, serviceAgreement.id, {
24329
+ acceptedBy: data.signer
24330
+ });
24331
+ setLoadingStatus("success");
24332
+ showToast({
24333
+ label: i18n.get("serviceAgreementSignedSuccessfully"),
24334
+ type: ToastType.SUCCESS
24335
+ });
24336
+ userEvents.addEvent("Succeeded ToS signing", {
24337
+ segmentation: {
24338
+ ...baseTrackingPayload
24339
+ }
24340
+ });
24341
+ } catch {
24342
+ setLoadingStatus("success");
24343
+ showToast({
24344
+ label: i18n.get("serviceAgreementSignFailed"),
24345
+ type: ToastType.ERROR
24346
+ });
24347
+ userEvents.addEvent("Failed ToS signing", {
24348
+ segmentation: {
24349
+ ...baseTrackingPayload
24350
+ }
24351
+ });
24460
24352
  }
24461
- };
24462
- try {
24463
- await ((_c = props.handleUpdateLegalEntity) == null ? void 0 : _c.call(props, updatedTrust, props.trust.id));
24464
- showToast({
24465
- label: i18n.get("successfullyUpdatedDetails"),
24466
- type: ToastType.SUCCESS
24467
- });
24468
- props.onSubmit(updatedTrust);
24469
- } catch (e2) {
24470
- logger$3.error(e2);
24471
- showToast({
24472
- label: i18n.get("failedToUpdateDetails"),
24473
- type: ToastType.ERROR
24353
+ } else {
24354
+ userEvents.addEvent("Encountered ToS validation error", {
24355
+ segmentation: {
24356
+ ...baseTrackingPayload,
24357
+ fields: Object.entries(valid).filter(([, value]) => !value).map(([key]) => key)
24358
+ }
24474
24359
  });
24475
24360
  }
24476
24361
  };
24477
- const formatRolesForSummary = (roles) => roles.map((role2) => i18n.get(getTrustMemberName(role2))).join(", ");
24478
- const formatSettlorExemptionReasonsForSummary = (reasons) => reasons.map((reason) => i18n.get(reason)).join(", ");
24479
- const summaryData = {
24480
- roleAndEntityType: {
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;
24362
+ const goHome = () => {
24363
+ userEvents.addEvent("Returned to task overview from ToS", {
24364
+ segmentation: {
24365
+ ...baseTrackingPayload
24498
24366
  }
24499
- return;
24500
- }
24501
- if (!formValidity[roleAndEntityTypeFormID]) {
24502
- setShouldValidate(true);
24503
- return;
24504
- }
24505
- if (trustMemberCase === "fullEntity") {
24506
- navigateToTrustMember();
24507
- } else {
24508
- setActiveForm(summary);
24509
- }
24367
+ });
24368
+ handleHomeClick();
24369
+ };
24370
+ const handleExpandSection = (title) => {
24371
+ userEvents.addEvent("Expanded ToS section", {
24372
+ segmentation: {
24373
+ ...baseTrackingPayload,
24374
+ statementExtended: title
24375
+ }
24376
+ });
24510
24377
  };
24511
- const onTrustMemberChange = ({
24512
- data,
24513
- isValid = false,
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)]);
24378
+ p(() => {
24379
+ if (forms.length) {
24380
+ setActiveForm(forms[0]);
24526
24381
  } else {
24527
- setFormList([...Object.values(roleAndTypeForms)]);
24382
+ goHome();
24528
24383
  }
24529
- setTrustMember({
24530
- ...props.trustMember,
24531
- ...data.role ? {
24532
- types: data.role
24533
- } : {},
24534
- legalEntityType: data.entityType,
24535
- ...data.descriptionUndefinedBeneficiary ? {
24536
- descriptionUndefinedBeneficiary: data.descriptionUndefinedBeneficiary
24537
- } : {},
24538
- ...isExemptSettlor(data) ? {
24539
- settlorExemptionReason: data.settlorExemptionReason.filter((reason) => reason !== "noneOfTheAbove")
24540
- } : {}
24384
+ }, [serviceAgreementTypes]);
24385
+ p(() => {
24386
+ userEvents.addPageView("ToS dropin");
24387
+ userEvents.addEvent("Started ToS task", {
24388
+ segmentation: {
24389
+ ...baseTrackingPayload
24390
+ }
24541
24391
  });
24392
+ }, []);
24393
+ const gotoForm = (index) => {
24394
+ setActiveForm(forms[index]);
24542
24395
  };
24543
- const saveRolesAndNavigate = async () => {
24544
- var _a2, _b2, _c;
24545
- if (!trustMember) {
24546
- return;
24547
- }
24548
- const {
24549
- reference
24550
- } = trustMember;
24551
- if (reference && hasRolesChanged(trustMember.types, (_a2 = props.trustMember) == null ? void 0 : _a2.types) && props.trust.id) {
24552
- const existingTrustAssociations = getOwnEntityAssociations(props.trust);
24553
- const updatedTrustAssociations = {
24554
- entityAssociations: [...((_b2 = trustMember.types) == null ? void 0 : _b2.map((role2) => ({
24555
- type: role2,
24556
- reference
24557
- }))) || [], ...existingTrustAssociations.filter((ea) => ea.legalEntityId !== trustMember.reference) || []]
24558
- };
24559
- await ((_c = props.handleUpdateLegalEntity) == null ? void 0 : _c.call(props, updatedTrustAssociations, props.trust.id));
24396
+ const sidebar = o(LoaderWrapper, {
24397
+ status: loadingStatus,
24398
+ formOpacityWhenLoading: 0.3,
24399
+ showSpinner: false,
24400
+ className: "adyen-kyc-dropin__sidebar-wrapper",
24401
+ children: [!!formsToBeSigned.length && o(FormNavigation, {
24402
+ forms: formsToBeSigned,
24403
+ activeForm,
24404
+ gotoForm,
24405
+ taskName: "signServiceAgreement",
24406
+ className: "adl-u-margin-bottom-24"
24407
+ }), !!signedForms.length && o(FormNavigation, {
24408
+ forms: signedForms,
24409
+ activeForm,
24410
+ gotoForm: (index) => gotoForm(formsToBeSigned.length + index),
24411
+ taskName: "signedDocuments"
24412
+ })]
24413
+ });
24414
+ const content = o(LoaderWrapper, {
24415
+ status: loadingStatus,
24416
+ formOpacityWhenLoading: 0.3,
24417
+ showSpinner: false,
24418
+ className: "adyen-kyc-form-container",
24419
+ children: [o(LoaderWrapper, {
24420
+ status: contractLoadingStatus,
24421
+ formOpacityWhenLoading: 0.3,
24422
+ showSpinner: false,
24423
+ children: serviceAgreement && o(ContractViewer, {
24424
+ contract: serviceAgreement.contract,
24425
+ onExpandSection: handleExpandSection
24426
+ })
24427
+ }), canSign && o(Fragment, {
24428
+ children: [o(Field, {
24429
+ name: "signer",
24430
+ label: i18n.get("signer"),
24431
+ classNameModifiers: ["col-50"],
24432
+ className: "adl-u-margin-y-32",
24433
+ errorMessage: i18n.get((_c = errors.signer) == null ? void 0 : _c.errorMessage),
24434
+ isValid: valid.signer,
24435
+ children: (childProps) => o(Select, {
24436
+ ...childProps,
24437
+ onChange: handleChangeFor("signer", "blur"),
24438
+ name: "signer",
24439
+ placeholder: i18n.get("selectSigner"),
24440
+ selected: data.signer,
24441
+ items: signers
24442
+ })
24443
+ }), o(Field, {
24444
+ name: "acceptServiceAgreement",
24445
+ errorMessage: i18n.get((_d = errors.acceptServiceAgreement) == null ? void 0 : _d.errorMessage),
24446
+ isValid: valid.acceptServiceAgreement,
24447
+ children: (childProps) => o(Checkbox, {
24448
+ ...childProps,
24449
+ label: i18n.get("iHaveReadAndIAcceptTheseTerms"),
24450
+ checked: data.acceptServiceAgreement ?? false,
24451
+ name: "acceptServiceAgreement",
24452
+ onChange: handleChangeFor("acceptServiceAgreement")
24453
+ })
24454
+ })]
24455
+ }), o(ActionBar, {
24456
+ onHome: goHome,
24457
+ homeButtonLabel: i18n.get("goToOverview"),
24458
+ onNext: canSign ? handleSignClick : void 0,
24459
+ nextButtonLabel: canSign ? i18n.get("sign") : void 0
24460
+ })]
24461
+ });
24462
+ return o(DropinLayout, {
24463
+ content: o(Fragment, {
24464
+ children: [sidebar, content]
24465
+ })
24466
+ });
24467
+ }
24468
+ function removeObjectPropsWithEmptyValues(obj) {
24469
+ Object.keys(obj).forEach((key) => {
24470
+ if (obj[key] === null || isEmpty(obj[key]))
24471
+ delete obj[key];
24472
+ });
24473
+ return obj;
24474
+ }
24475
+ const INITIAL_STATE = {
24476
+ data: {},
24477
+ allData: {},
24478
+ initialData: {},
24479
+ errors: {},
24480
+ valid: {},
24481
+ fieldProblems: {},
24482
+ isValid: false
24483
+ };
24484
+ function StateReducer() {
24485
+ const [schemas, setSchemas] = h({});
24486
+ const [activeForms, setActiveForms] = h([]);
24487
+ const setCurrentForms = (forms) => {
24488
+ setActiveForms(forms);
24489
+ };
24490
+ function reducer2({
24491
+ currentState: currState
24492
+ }, action) {
24493
+ var _a, _b, _c, _d, _e;
24494
+ switch (action.type) {
24495
+ case "addToState": {
24496
+ const state2 = structuredClone(currState);
24497
+ const dataStoreId = action.value.dataStoreId ?? action.value.caller;
24498
+ const schema = action.value.schema || null;
24499
+ const schemaHasChanged = schema && ((_a = schemas == null ? void 0 : schemas[dataStoreId]) == null ? void 0 : _a.toString()) !== schema.toString();
24500
+ const mergedState = {
24501
+ ...state2,
24502
+ data: {
24503
+ ...state2.data,
24504
+ [dataStoreId]: {
24505
+ ...state2.data[dataStoreId],
24506
+ ...action.value.data
24507
+ }
24508
+ },
24509
+ // Add data in allData state prop in case we will need them later
24510
+ allData: {
24511
+ ...state2.allData,
24512
+ [dataStoreId]: {
24513
+ ...state2.allData[dataStoreId],
24514
+ ...removeObjectPropsWithEmptyValues(action.value.data)
24515
+ }
24516
+ },
24517
+ errors: {
24518
+ ...state2.errors,
24519
+ [dataStoreId]: {
24520
+ ...state2.errors[dataStoreId],
24521
+ ...action.value.errors
24522
+ }
24523
+ },
24524
+ valid: {
24525
+ ...state2.valid,
24526
+ [dataStoreId]: {
24527
+ ...state2.valid[dataStoreId],
24528
+ ...action.value.valid
24529
+ }
24530
+ },
24531
+ fieldProblems: {
24532
+ ...state2.fieldProblems,
24533
+ [dataStoreId]: {
24534
+ ...state2.fieldProblems[dataStoreId],
24535
+ ...action.value.fieldProblems
24536
+ }
24537
+ }
24538
+ };
24539
+ if (schemaHasChanged) {
24540
+ setSchemas({
24541
+ ...schemas,
24542
+ [dataStoreId]: schema
24543
+ });
24544
+ const processedBySchema = schema.reduce((acc, fieldKey) => {
24545
+ const dataObjByFormId = mergedState.data[dataStoreId];
24546
+ const allDataObjByFormId = mergedState.allData[dataStoreId];
24547
+ const validObjByFormId = mergedState.valid[dataStoreId];
24548
+ const errorsObjByFormId = mergedState.errors[dataStoreId];
24549
+ const fieldProblemsObjByFormId = mergedState.fieldProblems[dataStoreId];
24550
+ return {
24551
+ data: {
24552
+ ...acc.data,
24553
+ [fieldKey]: dataObjByFormId[fieldKey] ?? allDataObjByFormId[fieldKey]
24554
+ },
24555
+ valid: {
24556
+ ...acc.valid,
24557
+ [fieldKey]: validObjByFormId[fieldKey]
24558
+ },
24559
+ errors: {
24560
+ ...acc.errors,
24561
+ [fieldKey]: errorsObjByFormId[fieldKey]
24562
+ },
24563
+ fieldProblems: {
24564
+ ...acc.fieldProblems,
24565
+ [fieldKey]: fieldProblemsObjByFormId[fieldKey]
24566
+ }
24567
+ };
24568
+ }, {
24569
+ data: {},
24570
+ valid: {},
24571
+ errors: {},
24572
+ fieldProblems: {}
24573
+ });
24574
+ mergedState.data[dataStoreId] = processedBySchema.data;
24575
+ mergedState.valid[dataStoreId] = processedBySchema.valid;
24576
+ mergedState.errors[dataStoreId] = processedBySchema.errors;
24577
+ mergedState.fieldProblems[dataStoreId] = processedBySchema.fieldProblems;
24578
+ }
24579
+ mergedState.validityByForm = {
24580
+ ...mergedState.validityByForm,
24581
+ [dataStoreId]: Object.values(mergedState.valid[dataStoreId]).every((isValid) => isValid)
24582
+ };
24583
+ mergedState.hasDataChanged = {
24584
+ ...state2.hasDataChanged,
24585
+ [dataStoreId]: {
24586
+ hasDataChanged: hasDataChanged((_b = state2.initialData) == null ? void 0 : _b[dataStoreId], (_c = mergedState.data) == null ? void 0 : _c[dataStoreId])
24587
+ }
24588
+ };
24589
+ mergedState.hasAnyDataChanged = Object.values(mergedState.hasDataChanged).some(({
24590
+ hasDataChanged: hasDataChanged2
24591
+ }) => hasDataChanged2);
24592
+ mergedState.allValid = Object.values(mergedState.validityByForm).every((isValid) => isValid);
24593
+ mergedState.isValid = !activeForms.length ? mergedState.allValid : activeForms.every((item) => mergedState.validityByForm[item]);
24594
+ mergedState.initialData = structuredClone(state2.initialData);
24595
+ return {
24596
+ currentState: mergedState,
24597
+ prevState: state2,
24598
+ changeInitiatedBy: dataStoreId
24599
+ };
24600
+ }
24601
+ case "resetState": {
24602
+ const dataStoreId = ((_d = action.value) == null ? void 0 : _d.dataStoreId) ?? ((_e = action.value) == null ? void 0 : _e.caller);
24603
+ return {
24604
+ currentState: INITIAL_STATE,
24605
+ prevState: currState,
24606
+ changeInitiatedBy: dataStoreId
24607
+ };
24608
+ }
24609
+ default: {
24610
+ throw new Error(`Unhandled action type: ${action.type}`);
24611
+ }
24560
24612
  }
24561
- props.navigateBack();
24613
+ }
24614
+ return {
24615
+ reducer: reducer2,
24616
+ setCurrentForms
24562
24617
  };
24563
- const hasRolesChanged = (newRoles = [], existingRoles = []) => newRoles.length !== existingRoles.length || !newRoles.every((newRole) => existingRoles.includes(newRole));
24564
- const formsWithValidity = Object.values(formList).map((form) => ({
24565
- formId: form.formId,
24566
- formName: form.formName,
24567
- isValid: formValidity[form.formId]
24568
- }));
24569
- const gotoFormByFormIndex = (formIndex) => {
24570
- setActiveForm(formList[formIndex]);
24618
+ }
24619
+ function StateProvider({
24620
+ defaultData = {},
24621
+ children
24622
+ }) {
24623
+ const defaultState = {
24624
+ currentState: {
24625
+ data: defaultData,
24626
+ allData: defaultData,
24627
+ valid: {},
24628
+ errors: {},
24629
+ fieldProblems: {},
24630
+ validityByForm: {},
24631
+ initialData: defaultData
24632
+ },
24633
+ prevState: {},
24634
+ changeInitiatedBy: null
24571
24635
  };
24572
- const content = o(Fragment, {
24573
- children: [o(FormNavigation, {
24574
- forms: formsWithValidity,
24575
- activeForm: formsWithValidity.find((form) => form.formId === activeForm.formId),
24576
- taskName,
24577
- gotoForm: noop
24578
- }), o("div", {
24579
- className: "adyen-kyc-form-container",
24580
- children: [o("div", {
24581
- className: activeForm.formId !== "roleAndEntityType" ? "adyen-kyc-form-wrapper adyen-kyc-form-wrapper--hidden" : "adyen-kyc-form-wrapper",
24582
- children: o(TrustRoleAndEntityTypeComponent, {
24583
- id: roleAndEntityTypeFormID,
24584
- trustMember: props.trustMember,
24585
- onChange: onTrustMemberChange,
24586
- shouldValidate
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
24636
+ const reducerObj = StateReducer();
24637
+ const [state2, dispatch] = s(reducerObj.reducer, defaultState);
24638
+ const contextValue = F$1(() => ({
24639
+ state: state2,
24640
+ dispatch,
24641
+ setActiveForms: reducerObj.setCurrentForms,
24642
+ getData: () => {
24643
+ var _a;
24644
+ return ((_a = state2 == null ? void 0 : state2.currentState) == null ? void 0 : _a.data) ?? {};
24645
+ },
24646
+ getState: () => state2 == null ? void 0 : state2.currentState
24647
+ }), [reducerObj, state2]);
24648
+ return o(StateContext.Provider, {
24649
+ value: contextValue,
24650
+ children
24605
24651
  });
24606
24652
  }
24607
- const serviceAgreementValidationRules = {
24608
- signer: {
24609
- modes: ["blur"],
24610
- validate: (signer2) => !!signer2,
24611
- errorMessage: "fieldIsRequired"
24612
- },
24613
- acceptServiceAgreement: {
24614
- modes: ["blur"],
24615
- validate: (acceptServiceAgreement) => !!acceptServiceAgreement,
24616
- errorMessage: "fieldIsRequired"
24653
+ const labels = (data, country2) => ({
24654
+ registrationNumber: () => {
24655
+ var _a;
24656
+ if (country2 === CountryCodes.Monaco && ((_a = data == null ? void 0 : data.solePropNameAndCountry) == null ? void 0 : _a.companyCountry) === CountryCodes.Monaco) {
24657
+ return "mcRegistrationNumberSoleProp";
24658
+ }
24617
24659
  }
24618
- };
24619
- const logger$2 = createLogger("useServiceAgreement");
24620
- const FALLBACK_LANGUAGE_CODE = "en";
24621
- const useServiceAgreement = ({
24622
- handleGetServiceAgreement,
24623
- handleServiceAgreementIsNotAvailableInThatLanguage,
24624
- legalEntityId,
24625
- serviceAgreementType,
24626
- language
24627
- }) => {
24628
- const [serviceAgreement, setServiceAgreement] = h();
24629
- const [loading2, setLoading] = h("loading");
24630
- const [agreementLanguage, setAgreementLanguage] = h(language);
24631
- p(() => {
24632
- if (agreementLanguage !== language) {
24633
- setAgreementLanguage(language);
24660
+ });
24661
+ const getOpeningStep = (forms, remediationActions) => {
24662
+ var _a;
24663
+ if (remediationActions && Object.keys(remediationActions).length > 0) {
24664
+ const allRemediationActions = Object.values(remediationActions).flat().filter((rem) => {
24665
+ var _a2;
24666
+ return ((_a2 = rem.forms) == null ? void 0 : _a2.length) > 0;
24667
+ });
24668
+ if (allRemediationActions.length === 1 && ((_a = allRemediationActions[0]) == null ? void 0 : _a.forms.length) === 1) {
24669
+ const form = forms.find((form2) => {
24670
+ var _a2;
24671
+ return (form2 == null ? void 0 : form2.formId) === ((_a2 = allRemediationActions[0]) == null ? void 0 : _a2.forms[0]);
24672
+ });
24673
+ if (form)
24674
+ return form;
24634
24675
  }
24635
- }, [language]);
24636
- p(() => {
24637
- const requestServiceAgreement = async () => {
24638
- setLoading("loading");
24639
- try {
24640
- const {
24641
- termsOfServiceDocumentId,
24642
- document: document2
24643
- } = await handleGetServiceAgreement(legalEntityId, {
24644
- type: serviceAgreementType,
24645
- language: agreementLanguage
24646
- });
24647
- if (!document2) {
24648
- logger$2.log('"document" field was missing in response');
24649
- return;
24650
- }
24651
- const contract = JSON.parse(decodeURIComponent(escape(window.atob(document2))));
24652
- setServiceAgreement({
24653
- id: termsOfServiceDocumentId,
24654
- contract
24655
- });
24656
- setLoading("success");
24657
- } catch (err) {
24658
- if (agreementLanguage !== FALLBACK_LANGUAGE_CODE) {
24659
- handleServiceAgreementIsNotAvailableInThatLanguage();
24660
- setAgreementLanguage(FALLBACK_LANGUAGE_CODE);
24661
- return;
24662
- }
24663
- throw err;
24676
+ return forms[forms.length - 1];
24677
+ }
24678
+ return forms[0];
24679
+ };
24680
+ function withFormComposer(WrappedComponent, {
24681
+ getComponentForms,
24682
+ parseConfiguration: parseConfiguration2,
24683
+ rules: rules2,
24684
+ labels: labels2,
24685
+ defaultTaskName,
24686
+ getConfigFor = "contextCountry"
24687
+ }) {
24688
+ const WithFormComposer = (props) => {
24689
+ var _a, _b, _c, _d, _e;
24690
+ const {
24691
+ i18n,
24692
+ loadingContext,
24693
+ clientKey,
24694
+ contextCountry: initialContextCountry,
24695
+ setContextCountry: setInitialContextCountry,
24696
+ isReview
24697
+ } = useCoreContext();
24698
+ const {
24699
+ isSettingEnabled
24700
+ } = useSettingsContext();
24701
+ const {
24702
+ getData,
24703
+ getState
24704
+ } = useStateContext();
24705
+ const {
24706
+ getOmittedKeys: getSummaryOmittedKeys = null,
24707
+ formatData: formatDataForSummary = null,
24708
+ omittedForms
24709
+ } = props.summary || {};
24710
+ const taskName = props.taskName ?? defaultTaskName;
24711
+ const [hideDropinLayout, setHideDropinLayout] = h(false);
24712
+ const [hideNavigation, setHideNavigation] = h(false);
24713
+ const [hideFooter, setHideFooter] = h(false);
24714
+ const [hideOnHomeButton, setHideOnHomeButton] = h(false);
24715
+ const [hideBackButton, setHideBackButton] = h(false);
24716
+ const [submitButtonLabel, setSubmitButtonLabel] = h(null);
24717
+ const [skipSubmitAndGoTaskList, setSkipSubmitAndGoTaskList] = h(false);
24718
+ const [customFormNavigationHandlers, setCustomFormNavigationHandlers] = h({});
24719
+ const [shouldValidate, setShouldValidate] = h(false);
24720
+ const [formValidity, setFormValidity] = h({});
24721
+ const formRef = _$1(null);
24722
+ const [loadingStatus, setLoadingStatus] = h("success");
24723
+ const [derivedProps, setDerivedProps] = h(props);
24724
+ const [contextCountry, setContextCountry] = h(props.country || initialContextCountry);
24725
+ const {
24726
+ sliceData: payoutMethodData
24727
+ } = useGlobalDataSlice("payoutVerificationMethod");
24728
+ const configCountry = (getConfigFor === "bankCountry" ? payoutMethodData == null ? void 0 : payoutMethodData.bankCountry : contextCountry) ?? contextCountry;
24729
+ p(() => {
24730
+ loadDocumentGuidance(loadingContext);
24731
+ }, [loadingContext]);
24732
+ const getConfigurationData = T$1(() => getConfiguration({
24733
+ loadingContext,
24734
+ clientKey
24735
+ }, {
24736
+ legalEntityType: props.legalEntityType,
24737
+ capabilities: props.capabilities,
24738
+ // for payout forms, we need to get config for the selected bankCountry, not necessarily the same as the residency/registration country
24739
+ country: configCountry
24740
+ }), [clientKey, configCountry, loadingContext, props.capabilities, props.legalEntityType]);
24741
+ const getPayoutAccountFormatData = T$1(() => getPayoutAccountFormat({
24742
+ loadingContext,
24743
+ clientKey
24744
+ }, configCountry), [clientKey, configCountry, loadingContext]);
24745
+ const {
24746
+ fieldConfigurations,
24747
+ requiredFields,
24748
+ bankVerificationVendors
24749
+ } = useScenarioConfiguration({
24750
+ getConfigurationData,
24751
+ getPayoutAccountFormatData,
24752
+ parseConfiguration: parseConfiguration2,
24753
+ country: configCountry,
24754
+ instantVerificationEnabled: derivedProps.instantVerificationEnabled && derivedProps.handleGetBankVerificationVendors,
24755
+ setLoadingStatus
24756
+ });
24757
+ const isFormStepVisible = (formId) => {
24758
+ if (derivedProps.requiredFields || derivedProps.optionalFields) {
24759
+ return !!derivedProps.requiredFields[formId] || !!derivedProps.optionalFields[formId];
24664
24760
  }
24761
+ return true;
24665
24762
  };
24666
- requestServiceAgreement().catch(logger$2.error);
24667
- }, [handleGetServiceAgreement, handleServiceAgreementIsNotAvailableInThatLanguage, agreementLanguage, legalEntityId, serviceAgreementType]);
24668
- return {
24669
- loading: loading2,
24670
- serviceAgreement
24671
- };
24672
- };
24673
- const serviceAgreementTypesTranslationMapping = {
24674
- adyenForPlatformsManage: "paymentProcessingTerms",
24675
- adyenIssuing: "accountHolderTerms",
24676
- adyenForPlatformsAdvanced: "paymentProcessingTerms",
24677
- adyenCapital: "capitalUserTerms",
24678
- adyenAccount: "businessAccountTerms",
24679
- adyenCard: "cardUserTerms",
24680
- adyenFranchisee: "franchiseesTAndCs"
24681
- };
24682
- function ServiceAgreementDropinComponent({
24683
- legalEntity,
24684
- handleGetServiceAgreement,
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
24763
+ const isFormSummaryStep = (form) => form.formId === summaryStep.formId;
24764
+ const componentForms = F$1(() => getComponentForms({
24765
+ ...props,
24766
+ bankVerificationVendors
24767
+ }, isSettingEnabled), [bankVerificationVendors, isSettingEnabled, props]);
24768
+ const componentFormsWithSummary = [...Object.values(componentForms), summaryStep];
24769
+ const allowedForms = componentFormsWithSummary.filter((form) => isFormStepVisible(form.formId) || isFormSummaryStep(form));
24770
+ const [activeForm, setActiveForm] = h(getOpeningStep(allowedForms, (_a = props == null ? void 0 : props.problems) == null ? void 0 : _a.remediationActions));
24771
+ const [hasAlreadyNavigatedForm, setHasAlreadyNavigatedForm] = h(false);
24772
+ const getFormIndex = (formId) => allowedForms.findIndex((form) => form.formId === formId);
24773
+ const isFinalStep = getFormIndex(activeForm.formId) === allowedForms.length - 1;
24774
+ const isFirstStep = getFormIndex(activeForm.formId) === 0;
24775
+ p(() => {
24776
+ var _a2;
24777
+ if (hasAlreadyNavigatedForm)
24778
+ return;
24779
+ const openingStep = getOpeningStep(allowedForms, (_a2 = props == null ? void 0 : props.problems) == null ? void 0 : _a2.remediationActions);
24780
+ if (activeForm !== openingStep) {
24781
+ setActiveForm(openingStep);
24759
24782
  }
24760
- });
24761
- if (loadingStatus === "loading" || !serviceAgreement || !data.signer)
24762
- return;
24763
- triggerValidation();
24764
- if (isValid) {
24765
- try {
24766
- setLoadingStatus("loading");
24767
- await handleSign(legalEntity.id, serviceAgreement.id, {
24768
- acceptedBy: data.signer
24769
- });
24770
- setLoadingStatus("success");
24771
- showToast({
24772
- label: i18n.get("serviceAgreementSignedSuccessfully"),
24773
- type: ToastType.SUCCESS
24774
- });
24775
- userEvents.addEvent("Succeeded ToS signing", {
24776
- segmentation: {
24777
- ...baseTrackingPayload
24783
+ }, [activeForm, allowedForms, (_b = props == null ? void 0 : props.problems) == null ? void 0 : _b.remediationActions, hasAlreadyNavigatedForm]);
24784
+ const evaluateConfiguration = T$1((scenarioConfiguration, country2, formData, isSettingEnabled2, requiredFields2) => {
24785
+ var _a2, _b2, _c2;
24786
+ const fieldsFromCustomRules = rules2 ? rules2({
24787
+ data: formData,
24788
+ country: country2,
24789
+ taskType: props.taskType,
24790
+ isSettingEnabled: isSettingEnabled2,
24791
+ requiredFields: requiredFields2
24792
+ }) : {};
24793
+ const fieldsFormCustomLabels = labels2 ? labels2(formData, country2) : {};
24794
+ 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);
24795
+ setShouldValidate(false);
24796
+ setDerivedProps({
24797
+ ...props,
24798
+ ...scenarioProps,
24799
+ country: configCountry
24800
+ });
24801
+ }, [componentForms, configCountry, props]);
24802
+ p(() => {
24803
+ if (!fieldConfigurations)
24804
+ return;
24805
+ evaluateConfiguration(fieldConfigurations, configCountry, getData(), isSettingEnabled, requiredFields);
24806
+ }, [fieldConfigurations, configCountry, evaluateConfiguration, getData, isSettingEnabled, requiredFields]);
24807
+ const trackNavigation2 = ({
24808
+ fromForm,
24809
+ toForm,
24810
+ component
24811
+ }) => {
24812
+ userEvents.addEvent("Navigated form", {
24813
+ segmentation: {
24814
+ ...props == null ? void 0 : props.baseTrackingPayload,
24815
+ component,
24816
+ from: fromForm.formId,
24817
+ fromLabel: i18n.get(fromForm.formName),
24818
+ to: toForm.formId,
24819
+ toLabel: i18n.get(toForm.formName)
24820
+ }
24821
+ });
24822
+ };
24823
+ const trackSectionCompletion = (form) => {
24824
+ userEvents.addEvent("Completed form section", {
24825
+ segmentation: {
24826
+ ...props == null ? void 0 : props.baseTrackingPayload,
24827
+ sectionName: form.formId
24828
+ }
24829
+ });
24830
+ };
24831
+ const gotoFormByFormIndex = (nextFormIndex) => {
24832
+ if (formRef.current.verifyForm) {
24833
+ formRef.current.verifyForm(activeForm.formId).then((isVerified) => {
24834
+ if (isVerified) {
24835
+ setHasAlreadyNavigatedForm(true);
24836
+ setActiveForm(allowedForms[nextFormIndex]);
24778
24837
  }
24779
24838
  });
24780
- } catch {
24781
- setLoadingStatus("success");
24782
- showToast({
24783
- label: i18n.get("serviceAgreementSignFailed"),
24784
- type: ToastType.ERROR
24839
+ } else {
24840
+ setHasAlreadyNavigatedForm(true);
24841
+ setActiveForm(allowedForms[nextFormIndex]);
24842
+ }
24843
+ };
24844
+ const validateCurrentForm = () => {
24845
+ setShouldValidate(true);
24846
+ };
24847
+ const handleNextClick = () => {
24848
+ var _a2, _b2;
24849
+ if (formRef.current.customNavigationHandler) {
24850
+ formRef.current.customNavigationHandler();
24851
+ return;
24852
+ }
24853
+ if ((_a2 = customFormNavigationHandlers[activeForm.formId]) == null ? void 0 : _a2.onNext) {
24854
+ (_b2 = customFormNavigationHandlers[activeForm.formId]) == null ? void 0 : _b2.onNext();
24855
+ return;
24856
+ }
24857
+ const allFields = (derivedProps == null ? void 0 : derivedProps.allFields) || {};
24858
+ if (isFormSummaryStep(activeForm)) {
24859
+ if (skipSubmitAndGoTaskList) {
24860
+ props.navigateBackToTaskList();
24861
+ } else {
24862
+ props.onSubmit({
24863
+ data: getData(),
24864
+ forms: allowedForms,
24865
+ allFields,
24866
+ setLoadingStatus
24867
+ });
24868
+ }
24869
+ return;
24870
+ }
24871
+ if (formValidity[activeForm.formId]) {
24872
+ if (isFinalStep) {
24873
+ props.onSubmit({
24874
+ data: getData(),
24875
+ forms: allowedForms,
24876
+ allFields,
24877
+ setLoadingStatus
24878
+ });
24879
+ return;
24880
+ }
24881
+ setShouldValidate(false);
24882
+ const toFormIndex = allowedForms.findIndex((form) => form.formId === activeForm.formId) + 1;
24883
+ gotoFormByFormIndex(toFormIndex);
24884
+ const toForm = allowedForms[toFormIndex];
24885
+ trackNavigation2({
24886
+ fromForm: activeForm,
24887
+ toForm,
24888
+ component: "ActionBar"
24785
24889
  });
24786
- userEvents.addEvent("Failed ToS signing", {
24787
- segmentation: {
24788
- ...baseTrackingPayload
24789
- }
24890
+ trackSectionCompletion(activeForm);
24891
+ } else {
24892
+ validateCurrentForm();
24893
+ }
24894
+ };
24895
+ const handleBackClick = () => {
24896
+ const currentFormIndex = allowedForms.findIndex((form) => form.formId === activeForm.formId);
24897
+ if (currentFormIndex) {
24898
+ const fromForm = allowedForms[currentFormIndex];
24899
+ const toForm = allowedForms[currentFormIndex - 1];
24900
+ setActiveForm(toForm);
24901
+ setHasAlreadyNavigatedForm(true);
24902
+ trackNavigation2({
24903
+ fromForm,
24904
+ toForm,
24905
+ component: "ActionBar"
24790
24906
  });
24791
24907
  }
24792
- } else {
24793
- userEvents.addEvent("Encountered ToS validation error", {
24794
- segmentation: {
24795
- ...baseTrackingPayload,
24796
- fields: Object.entries(valid).filter(([, value]) => !value).map(([key]) => key)
24908
+ };
24909
+ const setCustomHandlers = (formId, onNext, onBack) => {
24910
+ setCustomFormNavigationHandlers({
24911
+ ...customFormNavigationHandlers,
24912
+ [formId]: {
24913
+ onNext,
24914
+ onBack
24797
24915
  }
24798
24916
  });
24799
- }
24800
- };
24801
- const goHome = () => {
24802
- userEvents.addEvent("Returned to task overview from ToS", {
24803
- segmentation: {
24804
- ...baseTrackingPayload
24805
- }
24806
- });
24807
- handleHomeClick();
24808
- };
24809
- const handleExpandSection = (title) => {
24810
- userEvents.addEvent("Expanded ToS section", {
24811
- segmentation: {
24812
- ...baseTrackingPayload,
24813
- statementExtended: title
24917
+ };
24918
+ const nextButtonText = isReview ? isFormSummaryStep(activeForm) ? i18n.get("confirm") : i18n.get("next") : isFinalStep ? i18n.get(submitButtonLabel ?? "submit") : i18n.get("next");
24919
+ p(() => {
24920
+ props.eventEmitter.on("next", handleNextClick);
24921
+ props.eventEmitter.on("back", handleBackClick);
24922
+ props.eventEmitter.on("validate", validateCurrentForm);
24923
+ return () => {
24924
+ props.eventEmitter.off("next", handleNextClick);
24925
+ props.eventEmitter.off("back", handleNextClick);
24926
+ props.eventEmitter.off("validate", validateCurrentForm);
24927
+ };
24928
+ }, [activeForm, allowedForms]);
24929
+ const onCountryChange = (country2) => {
24930
+ setContextCountry(country2);
24931
+ };
24932
+ const onWrappedComponentChange = (state2) => {
24933
+ var _a2;
24934
+ setFormValidity(state2.validityByForm);
24935
+ (_a2 = props.onChange) == null ? void 0 : _a2.call(props, state2);
24936
+ };
24937
+ const handleStateChange = ({
24938
+ currentState
24939
+ }) => {
24940
+ onWrappedComponentChange(currentState);
24941
+ };
24942
+ const handleLeaveDropin = async () => {
24943
+ var _a2;
24944
+ const data = getData();
24945
+ const hasDataChanged2 = getState().hasAnyDataChanged;
24946
+ if (hasDataChanged2 && ((_a2 = props.canSubmit) == null ? void 0 : _a2.call(props, data))) {
24947
+ setInitialContextCountry(contextCountry);
24948
+ const allFields = (derivedProps == null ? void 0 : derivedProps.allFields) || {};
24949
+ await props.onSubmit({
24950
+ data,
24951
+ forms: allowedForms,
24952
+ allFields,
24953
+ setLoadingStatus
24954
+ });
24955
+ } else {
24956
+ props.handleHomeClick();
24814
24957
  }
24958
+ };
24959
+ const formFooter = !hideDropinLayout && !hideFooter && o(ActionBar, {
24960
+ onNext: handleNextClick,
24961
+ onBack: isFirstStep ? props.handleBackClick : handleBackClick,
24962
+ backButtonLabel: i18n.get("back"),
24963
+ nextButtonLabel: nextButtonText,
24964
+ onHome: handleLeaveDropin,
24965
+ homeButtonLabel: props.homeButtonLabel,
24966
+ hideOnHomeButton,
24967
+ hideBackButton
24815
24968
  });
24816
- };
24817
- p(() => {
24818
- if (forms.length) {
24819
- setActiveForm(forms[0]);
24820
- } else {
24821
- goHome();
24822
- }
24823
- }, [serviceAgreementTypes]);
24824
- p(() => {
24825
- userEvents.addPageView("ToS dropin");
24826
- userEvents.addEvent("Started ToS task", {
24827
- segmentation: {
24828
- ...baseTrackingPayload
24829
- }
24969
+ const wrappedComponent = o("div", {
24970
+ className: "adyen-kyc-form-container",
24971
+ children: o(LoaderWrapper, {
24972
+ status: loadingStatus,
24973
+ formOpacityWhenLoading: 0.3,
24974
+ loaderSize: "large",
24975
+ children: o(FormRouterContextProvider, {
24976
+ setFormIndex: gotoFormByFormIndex,
24977
+ forms: allowedForms,
24978
+ handleGetIdVerificationToken: props.handleGetIdVerificationToken,
24979
+ children: [o(StateContextWatcher, {
24980
+ owner: "FormComposer",
24981
+ onChange: handleStateChange
24982
+ }), o(WrappedComponent, {
24983
+ ref: formRef,
24984
+ forms: allowedForms,
24985
+ activeForm,
24986
+ ...derivedProps,
24987
+ data: props.data,
24988
+ onChange: onWrappedComponentChange,
24989
+ evaluateConfiguration: (data) => evaluateConfiguration(fieldConfigurations, configCountry, data, isSettingEnabled, requiredFields),
24990
+ country: contextCountry,
24991
+ onCountryChange,
24992
+ legalEntityId: props.legalEntityId,
24993
+ problems: props == null ? void 0 : props.problems,
24994
+ shouldValidate,
24995
+ onNext: handleNextClick,
24996
+ onBack: handleBackClick,
24997
+ setHideDropinLayout,
24998
+ setHideNavigation,
24999
+ setHideFooter,
25000
+ setCustomFormNavigationHandlers: setCustomHandlers,
25001
+ setHideOnHomeButton,
25002
+ setHideBackButton,
25003
+ setSubmitButtonLabel,
25004
+ setSkipSubmitAndGoTaskList,
25005
+ bankVerificationVendors
25006
+ }), activeForm.formId === summaryStep.formId && o("div", {
25007
+ className: "adyen-kyc-form-wrapper",
25008
+ children: o(Summary, {
25009
+ trackNavigation: trackNavigation2,
25010
+ data: formatDataForSummary ? formatDataForSummary(getData(), allowedForms) : getData(),
25011
+ omittedKeys: getSummaryOmittedKeys ? getSummaryOmittedKeys(getData()) : null,
25012
+ omittedForms,
25013
+ forms: allowedForms,
25014
+ gotoForm: gotoFormByFormIndex,
25015
+ labels: derivedProps.labels,
25016
+ problems: props == null ? void 0 : props.problems
25017
+ })
25018
+ }), formFooter]
25019
+ })
25020
+ })
24830
25021
  });
24831
- }, []);
24832
- const gotoForm = (index) => {
24833
- setActiveForm(forms[index]);
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,
25022
+ const allowedFormsWithValidity = addValidityToForms(allowedForms, formValidity, props.problems);
25023
+ const sidebar = !hideDropinLayout && !hideNavigation && o(LoaderWrapper, {
25024
+ status: loadingStatus,
24860
25025
  formOpacityWhenLoading: 0.3,
24861
25026
  showSpinner: false,
24862
- children: serviceAgreement && o(ContractViewer, {
24863
- contract: serviceAgreement.contract,
24864
- onExpandSection: handleExpandSection
25027
+ className: "adyen-kyc-dropin__sidebar-wrapper",
25028
+ children: o(FormNavigation, {
25029
+ forms: allowedFormsWithValidity,
25030
+ activeForm: allowedFormsWithValidity.find((form) => form.formId === activeForm.formId),
25031
+ gotoForm: gotoFormByFormIndex,
25032
+ validateForm: validateCurrentForm,
25033
+ taskName,
25034
+ trackNavigation: trackNavigation2,
25035
+ 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
25036
  })
24866
- }), canSign && o(Fragment, {
24867
- children: [o(Field, {
24868
- name: "signer",
24869
- label: i18n.get("signer"),
24870
- classNameModifiers: ["col-50"],
24871
- className: "adl-u-margin-y-32",
24872
- errorMessage: i18n.get((_c = errors.signer) == null ? void 0 : _c.errorMessage),
24873
- isValid: valid.signer,
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";
25037
+ });
25038
+ const content = o(Fragment, {
25039
+ children: [sidebar, wrappedComponent]
25040
+ });
25041
+ if (!props.hideDropinLayout) {
25042
+ return o(DropinLayout, {
25043
+ content
25044
+ });
24912
25045
  }
24913
- }
24914
- });
25046
+ return wrappedComponent;
25047
+ };
25048
+ return WithFormComposer;
25049
+ }
24915
25050
  const SolePropWithFormComposer = withFormComposer(SolePropComponent, {
24916
25051
  getComponentForms: () => solePropForms,
24917
25052
  // TODO: change trust to soleprop once the configurations for soleprops are added in backend.