@adyen/kyc-components 2.41.1 → 2.41.2

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.
@@ -10201,7 +10201,10 @@ const entityTypeToCorrespondingAccountHolderOption = {
10201
10201
  [LegalEntityType.SOLE_PROPRIETORSHIP]: "mySoleProprietorName",
10202
10202
  [LegalEntityType.TRUST]: "aTrust"
10203
10203
  };
10204
- const getDefaultAccountHolderType = (legalEntityResponse, isTypeChanging = false) => {
10204
+ const getDefaultAccountHolderType = (legalEntityResponse, isTypeChanging = false, accountHolder2) => {
10205
+ if (accountHolder2) {
10206
+ return accountHolder2;
10207
+ }
10205
10208
  if (!(legalEntityResponse == null ? void 0 : legalEntityResponse.type))
10206
10209
  return void 0;
10207
10210
  if (hasOwnEntityAssociationOfType(LegalEntityType.SOLE_PROPRIETORSHIP, legalEntityResponse.entityAssociations, legalEntityResponse.id)) {
@@ -10454,6 +10457,7 @@ const companyTypeValidationRules = {
10454
10457
  };
10455
10458
  const companyTypeFields = ["entityType", ...accountHolderFields];
10456
10459
  function CompanyTypeComponent(props) {
10460
+ var _a;
10457
10461
  const {
10458
10462
  i18n
10459
10463
  } = useI18nContext();
@@ -10484,8 +10488,8 @@ function CompanyTypeComponent(props) {
10484
10488
  const formUtils = formUtilities(props, i18n);
10485
10489
  const accountHolderProps = getFieldProps(props, accountHolderFields);
10486
10490
  useEffect(() => {
10487
- var _a, _b;
10488
- (_b = (_a = stateRef.current) == null ? void 0 : _a.setState) == null ? void 0 : _b.call(_a, {
10491
+ var _a2, _b;
10492
+ (_b = (_a2 = stateRef.current) == null ? void 0 : _a2.setState) == null ? void 0 : _b.call(_a2, {
10489
10493
  type: "addToState",
10490
10494
  value: {
10491
10495
  data,
@@ -10498,7 +10502,7 @@ function CompanyTypeComponent(props) {
10498
10502
  }
10499
10503
  });
10500
10504
  }, [data, valid, errors, isValid]);
10501
- const companyTypeOptions = isNewEntryFlowEnabled ? companyTypes.filter((companyType2) => companyType2.id !== CompanyTypesValue.INCORPORATED_PARTNERSHIP && companyType2.id !== CompanyTypesValue.INCORPORATED_ASSOCIATION) : companyTypes;
10505
+ const companyTypeOptions = isNewEntryFlowEnabled && ((_a = props.data) == null ? void 0 : _a.accountHolder) !== "aTrust" ? companyTypes.filter((companyType2) => companyType2.id !== CompanyTypesValue.INCORPORATED_PARTNERSHIP && companyType2.id !== CompanyTypesValue.INCORPORATED_ASSOCIATION) : companyTypes;
10502
10506
  const companyTypeExamples2 = useCompanyTypeExamples(country2);
10503
10507
  return jsxs(Fragment, {
10504
10508
  children: [jsx(StateContextSetter, {
@@ -13461,7 +13465,7 @@ const mapIndividualToLegalEntity = (data) => {
13461
13465
  }
13462
13466
  return requestObj;
13463
13467
  };
13464
- const mapLegalEntityToCompany = (legalEntity, isChangingType) => {
13468
+ const mapLegalEntityToCompany = (legalEntity, isChangingType, accountHolder2) => {
13465
13469
  var _a, _b, _c, _d;
13466
13470
  let companyCompData;
13467
13471
  if (legalEntity == null ? void 0 : legalEntity.organization) {
@@ -13506,7 +13510,7 @@ const mapLegalEntityToCompany = (legalEntity, isChangingType) => {
13506
13510
  ...companyCompData,
13507
13511
  companyType: {
13508
13512
  ...companyCompData == null ? void 0 : companyCompData.companyType,
13509
- accountHolder: getDefaultAccountHolderType(legalEntity, isChangingType)
13513
+ accountHolder: getDefaultAccountHolderType(legalEntity, isChangingType, accountHolder2)
13510
13514
  }
13511
13515
  };
13512
13516
  return companyCompData;
@@ -22622,23 +22626,35 @@ const mapLegalArrangementOptionToCompanyTypesValue = (legalArrangement) => {
22622
22626
  case "associationIncorporated":
22623
22627
  return CompanyTypesValue.INCORPORATED_ASSOCIATION;
22624
22628
  default:
22629
+ return void 0;
22630
+ }
22631
+ };
22632
+ const determineOrganizationTypeToUpdate = (defaultLegalArrangement, targetLegalArrangement, currentCompanyTypeValue) => {
22633
+ if (targetLegalArrangement === "aTrust") {
22634
+ return;
22635
+ }
22636
+ if (!targetLegalArrangement) {
22637
+ const isUnavailableTypesInCompany = currentCompanyTypeValue === CompanyTypesValue.INCORPORATED_ASSOCIATION || currentCompanyTypeValue === CompanyTypesValue.INCORPORATED_PARTNERSHIP;
22638
+ if (isUnavailableTypesInCompany) {
22625
22639
  return "";
22640
+ }
22626
22641
  }
22642
+ return mapLegalArrangementOptionToCompanyTypesValue(targetLegalArrangement);
22627
22643
  };
22628
22644
  const getDefaultLegalArrangementOrSuborganizationType = (legalEntityResponse, accountHolder2) => {
22629
22645
  var _a;
22630
22646
  const entityAssociations = legalEntityResponse == null ? void 0 : legalEntityResponse.entityAssociations;
22631
22647
  const suborganizationType = (_a = legalEntityResponse == null ? void 0 : legalEntityResponse.organization) == null ? void 0 : _a.type;
22648
+ const hasTrust = hasOwnEntityAssociationOfType(LegalEntityType.TRUST, entityAssociations, legalEntityResponse == null ? void 0 : legalEntityResponse.id);
22649
+ if (hasTrust || accountHolder2 === "aTrust") {
22650
+ return "aTrust";
22651
+ }
22632
22652
  if (suborganizationType === CompanyTypesValue.INCORPORATED_PARTNERSHIP) {
22633
22653
  return "partnershipIncorporated";
22634
22654
  }
22635
22655
  if (suborganizationType === CompanyTypesValue.INCORPORATED_ASSOCIATION) {
22636
22656
  return "associationIncorporated";
22637
22657
  }
22638
- const hasTrust = hasOwnEntityAssociationOfType(LegalEntityType.TRUST, entityAssociations, legalEntityResponse == null ? void 0 : legalEntityResponse.id);
22639
- if (hasTrust || accountHolder2 === "aTrust") {
22640
- return "aTrust";
22641
- }
22642
22658
  return void 0;
22643
22659
  };
22644
22660
  const getTargetLegalEntityType = (businessType, legalArrangement, trusteeType, currentLegalEntityType) => {
@@ -22648,11 +22664,12 @@ const getTargetLegalEntityType = (businessType, legalArrangement, trusteeType, c
22648
22664
  if (businessType === "legalArrangement" && legalArrangement === "aTrust" && trusteeType === "individual" || businessType === "individual" || businessType === "soleProprietorship") {
22649
22665
  return LegalEntityType.INDIVIDUAL;
22650
22666
  }
22651
- if (legalArrangement === "partnershipIncorporated") {
22667
+ if (legalArrangement && isLegalArrangementOrganizationSubtype(legalArrangement)) {
22652
22668
  return LegalEntityType.ORGANIZATION;
22653
22669
  }
22654
22670
  return currentLegalEntityType;
22655
22671
  };
22672
+ const isLegalArrangementOrganizationSubtype = (legalArrangementOption) => legalArrangementOption === "partnershipIncorporated" || legalArrangementOption === "associationIncorporated";
22656
22673
  var ToastType = /* @__PURE__ */ ((ToastType2) => {
22657
22674
  ToastType2["LOADING"] = "loading";
22658
22675
  ToastType2["SUCCESS"] = "success";
@@ -22962,7 +22979,8 @@ function CompanyDropinComponent({
22962
22979
  handleUpdateLegalEntity,
22963
22980
  handleHomeClick,
22964
22981
  onTypeSwitch,
22965
- onChange
22982
+ onChange,
22983
+ accountHolder: accountHolder2
22966
22984
  }) {
22967
22985
  var _a, _b;
22968
22986
  const {
@@ -22979,7 +22997,8 @@ function CompanyDropinComponent({
22979
22997
  i18n,
22980
22998
  setLocale
22981
22999
  } = useI18nContext();
22982
- const dataFromResponse = mapLegalEntityToCompany(legalEntityResponse, isTargetLegalEntityType);
23000
+ const isNewEntryFlowEnabled = useEnableNewEntryFlow();
23001
+ const dataFromResponse = mapLegalEntityToCompany(legalEntityResponse, isTargetLegalEntityType, isNewEntryFlowEnabled ? accountHolder2 : void 0);
22983
23002
  const {
22984
23003
  getConfiguration: getConfiguration2
22985
23004
  } = useConfigurationApi();
@@ -23035,7 +23054,7 @@ function CompanyDropinComponent({
23035
23054
  });
23036
23055
  onChange == null ? void 0 : onChange(currentState);
23037
23056
  }, [currentState]);
23038
- const isSkippingCompanyStructure = useEnableNewEntryFlow() && organizationTypesToSkipCompanyStructureForm.includes((_b = legalEntityResponse == null ? void 0 : legalEntityResponse.organization) == null ? void 0 : _b.type);
23057
+ const isSkippingCompanyStructure = useEnableNewEntryFlow() && organizationTypesToSkipCompanyStructureForm.includes((_b = legalEntityResponse == null ? void 0 : legalEntityResponse.organization) == null ? void 0 : _b.type) && accountHolder2 !== "aTrust";
23039
23058
  const forms2 = useMemo(() => {
23040
23059
  const requiredForms = getRequiredForms(companyForms, derivedProps == null ? void 0 : derivedProps.requiredFields, derivedProps == null ? void 0 : derivedProps.optionalFields);
23041
23060
  const validityAddedForms = addValidityToForms(requiredForms, formValidity, problems);
@@ -26487,18 +26506,15 @@ const BusinessTypeSelection = ({
26487
26506
  type: targetLegalEntityType
26488
26507
  };
26489
26508
  await (handleUpdateLegalEntity == null ? void 0 : handleUpdateLegalEntity(updateLegalEntityPayload, legalEntityResponse == null ? void 0 : legalEntityResponse.id));
26490
- if (targetLegalEntityType === LegalEntityType.ORGANIZATION && targetLegalEntityType) {
26491
- await (handleUpdateLegalEntity == null ? void 0 : handleUpdateLegalEntity({
26492
- organization: {
26493
- type: mapLegalArrangementOptionToCompanyTypesValue(targetLegalArrangement)
26494
- }
26495
- }, legalEntityResponse == null ? void 0 : legalEntityResponse.id));
26496
- }
26497
26509
  }
26498
- if (isLegalArrangementChanging && targetLegalArrangement) {
26510
+ if (targetLegalEntityType === LegalEntityType.INDIVIDUAL) {
26511
+ return;
26512
+ }
26513
+ const targetOrganizationType = determineOrganizationTypeToUpdate(defaultLegalArrangementType == null ? void 0 : defaultLegalArrangementType.id, targetLegalArrangement, currentCompanyTypesValue);
26514
+ if (targetOrganizationType !== void 0) {
26499
26515
  await (handleUpdateLegalEntity == null ? void 0 : handleUpdateLegalEntity({
26500
26516
  organization: {
26501
- type: mapLegalArrangementOptionToCompanyTypesValue(targetLegalArrangement)
26517
+ type: targetOrganizationType
26502
26518
  }
26503
26519
  }, legalEntityResponse == null ? void 0 : legalEntityResponse.id));
26504
26520
  }
@@ -31696,11 +31712,8 @@ const getDefaultTask = ({
31696
31712
  showIntroduction,
31697
31713
  shouldShowSingpassSelection
31698
31714
  }) => {
31699
- var _a, _b;
31700
- const hasOwnEntityAssocation = (_a = legalEntity.entityAssociations) == null ? void 0 : _a.some((ea) => ea.associatorId === legalEntity.id);
31701
- const hasOrganizationType = (_b = legalEntity.organization) == null ? void 0 : _b.type;
31702
- const hasProgressedBeyondEntitySelection = hasOwnEntityAssocation || !!hasOrganizationType;
31703
- if (isNewEntryFlowEnabled && !accountHolder2 && !hasProgressedBeyondEntitySelection)
31715
+ const hasLegalEntityProgressedBeyondEntitySelection = hasProgressedBeyondEntitySelection(legalEntity);
31716
+ if (isNewEntryFlowEnabled && !accountHolder2 && !hasLegalEntityProgressedBeyondEntitySelection)
31704
31717
  return TaskTypes.BUSINESS_TYPE_SELECTION;
31705
31718
  if (showIntroduction)
31706
31719
  return TaskTypes.INTRODUCTION;
@@ -31708,6 +31721,12 @@ const getDefaultTask = ({
31708
31721
  return TaskTypes.SINGPASS_SELECTION;
31709
31722
  return TaskTypes.TASKS_OVERVIEW;
31710
31723
  };
31724
+ const hasProgressedBeyondEntitySelection = (legalEntity) => {
31725
+ var _a, _b;
31726
+ const hasOwnEntityAssocation = (_a = legalEntity.entityAssociations) == null ? void 0 : _a.some((ea) => ea.associatorId === legalEntity.id);
31727
+ const hasOrganizationType = (_b = legalEntity.organization) == null ? void 0 : _b.type;
31728
+ return hasOwnEntityAssocation || !!hasOrganizationType;
31729
+ };
31711
31730
  const PAGES_WITH_POLLING = [TaskTypes.DECISION_MAKER_OVERVIEW, TaskTypes.TASKS_OVERVIEW];
31712
31731
  const POLLING_INTERVAL = 3e3;
31713
31732
  const logger$8 = createLogger("DropinComposerComponent");
@@ -32516,7 +32535,8 @@ function DropinComposerComponent({
32516
32535
  handleAddressSearch: args == null ? void 0 : args.handleAddressSearch,
32517
32536
  handleFindAddress: args == null ? void 0 : args.handleFindAddress,
32518
32537
  onTypeSwitch: navigateToTypeSwitcher,
32519
- isTargetLegalEntityType: legalEntityType === LegalEntityType.ORGANIZATION
32538
+ isTargetLegalEntityType: legalEntityType === LegalEntityType.ORGANIZATION,
32539
+ accountHolder: accountHolder2
32520
32540
  });
32521
32541
  case TaskTypes.COMPANY_SEARCH:
32522
32542
  return jsx(CompanySearchDropinComponent, {
@@ -32573,7 +32593,8 @@ function DropinComposerComponent({
32573
32593
  homeButtonLabel: i18n.get("saveAndGoToOverview"),
32574
32594
  associationDetail: trustMember,
32575
32595
  handleAddressSearch: args == null ? void 0 : args.handleAddressSearch,
32576
- handleFindAddress: args == null ? void 0 : args.handleFindAddress
32596
+ handleFindAddress: args == null ? void 0 : args.handleFindAddress,
32597
+ accountHolder: accountHolder2
32577
32598
  });
32578
32599
  case TaskTypes.PAYOUT:
32579
32600
  case TaskTypes.PAYIN:
@@ -33877,7 +33898,7 @@ const ConfigurationApiProvider = ({
33877
33898
  isEmbeddedDropin,
33878
33899
  loadingContext
33879
33900
  } = authContext;
33880
- const sdkVersion = "2.41.1";
33901
+ const sdkVersion = "2.41.2";
33881
33902
  useAnalytics({
33882
33903
  onUserEvent,
33883
33904
  legalEntityId: rootLegalEntityId,
@@ -30,6 +30,7 @@ export declare const useSelectionOptions: (legalEntityResponse: ExistingLegalEnt
30
30
  /**
31
31
  *
32
32
  */
33
- export declare const mapLegalArrangementOptionToCompanyTypesValue: (legalArrangement: LegalArrangementOption | undefined) => CompanyTypesValue | '';
33
+ export declare const mapLegalArrangementOptionToCompanyTypesValue: (legalArrangement: LegalArrangementOption | undefined) => CompanyTypesValue | undefined;
34
+ export declare const determineOrganizationTypeToUpdate: (defaultLegalArrangement?: LegalArrangementOption, targetLegalArrangement?: LegalArrangementOption, currentCompanyTypeValue?: CompanyTypesValue) => CompanyTypesValue | '' | undefined;
34
35
  export declare const getDefaultLegalArrangementOrSuborganizationType: (legalEntityResponse: ExistingLegalEntity | undefined, accountHolder: AccountHolderOption | null) => LegalArrangementOption | undefined;
35
36
  export declare const getTargetLegalEntityType: (businessType: BusinessType | undefined, legalArrangement: LegalArrangementOption | undefined, trusteeType: TrusteeType | undefined, currentLegalEntityType: LegalEntityType | undefined) => LegalEntityType;
@@ -1,2 +1,2 @@
1
1
  import type { CompanyDropinProps } from '../types';
2
- export declare function CompanyDropinComponent({ country: parentCountry, problems: propProblems, hideDropinLayout, taskName, capabilities, homeButtonLabel, taskType, trackingConfig, associationDetail, parentLegalEntity, legalEntityResponse, isTargetLegalEntityType, eventEmitter, onSubmit: onExternalSubmit, handleCreateDocument, handleGetDocument, handleUpdateDocument, handleAddressSearch, handleFindAddress, handleCreateLegalEntity, handleUpdateLegalEntity, handleHomeClick, onTypeSwitch, onChange, }: CompanyDropinProps): import("preact").JSX.Element;
2
+ export declare function CompanyDropinComponent({ country: parentCountry, problems: propProblems, hideDropinLayout, taskName, capabilities, homeButtonLabel, taskType, trackingConfig, associationDetail, parentLegalEntity, legalEntityResponse, isTargetLegalEntityType, eventEmitter, onSubmit: onExternalSubmit, handleCreateDocument, handleGetDocument, handleUpdateDocument, handleAddressSearch, handleFindAddress, handleCreateLegalEntity, handleUpdateLegalEntity, handleHomeClick, onTypeSwitch, onChange, accountHolder, }: CompanyDropinProps): import("preact").JSX.Element;
@@ -1,5 +1,6 @@
1
1
  import type { ExistingLegalEntity } from '../../../core/models/api/legal-entity';
2
2
  import type { CompanyProps, CompanySchema } from '../../Company/types';
3
+ import type { AccountHolderOption } from '../../internal/AccountHolder/types';
3
4
  import type { TrustMember } from '../../TrustMembers/types';
4
5
  import type { DropinAPIHandlers, DropinProps } from '../types';
5
6
  export interface CompanyDropinProps extends Omit<CompanyProps, 'isTopLevelEntity'>, DropinAPIHandlers, DropinProps {
@@ -7,4 +8,5 @@ export interface CompanyDropinProps extends Omit<CompanyProps, 'isTopLevelEntity
7
8
  associationDetail?: TrustMember;
8
9
  isTargetLegalEntityType?: boolean;
9
10
  onSubmit?: (company: CompanySchema) => void;
11
+ accountHolder?: AccountHolderOption;
10
12
  }
@@ -2,7 +2,7 @@ import type { BaseInnerFormProps } from '../../../core/hooks/useForm';
2
2
  import type { LegalEntityType } from '../../../core/models/api/legal-entity-type';
3
3
  import type { CountryCode } from '../../../core/models/country-code';
4
4
  export type LegalArrangementOption = 'aTrust' | 'partnershipIncorporated' | 'partnershipUnincorporated' | 'associationIncorporated';
5
- export type AccountHolderOption = 'myName' | 'mySoleProprietorName' | 'theCompanyIWorkFor' | LegalArrangementOption;
5
+ export type AccountHolderOption = 'myName' | 'mySoleProprietorName' | 'theCompanyIWorkFor' | 'aTrust';
6
6
  export interface AccountHolderSchema {
7
7
  accountHolder?: AccountHolderOption;
8
8
  }
@@ -7,5 +7,5 @@ export declare const entityTypeToCorrespondingAccountHolderOption: Record<LegalE
7
7
  ** Account holder option is not stored in backend as it does not effect any check evaluations.
8
8
  ** The value is computed in the front end based on the associations and current flow of the legalEntity
9
9
  * */
10
- export declare const getDefaultAccountHolderType: (legalEntityResponse: LegalEntity | undefined, isTypeChanging?: boolean) => AccountHolderOption | undefined;
10
+ export declare const getDefaultAccountHolderType: (legalEntityResponse: LegalEntity | undefined, isTypeChanging?: boolean, accountHolder?: AccountHolderOption) => AccountHolderOption | undefined;
11
11
  export declare const allowIndividualWithoutSoleProp: (capabilities: CapabilityName[]) => boolean;
@@ -1,6 +1,7 @@
1
1
  import type { BankDocumentSchema } from '../../components/BankDocument/types';
2
2
  import type { CompanySchema } from '../../components/Company/types';
3
3
  import type { IndividualSchema } from '../../components/Individual/types';
4
+ import type { AccountHolderOption } from '../../components/internal/AccountHolder/types';
4
5
  import type { PayoutDetailsSchema } from '../../components/PayoutDetails/types';
5
6
  import type { PersonalDetailsSchema } from '../../components/PersonalDetails/types';
6
7
  import type { SolePropSchema } from '../../components/SoleProp/types';
@@ -29,7 +30,7 @@ export declare const mapPayoutAccountToTransferInstrument: ({ data, legalEntity
29
30
  }) => TransferInstrument;
30
31
  export declare const mapLegalEntityToIndividual: (legalEntity: ExistingLegalEntity | undefined, isChangingType?: boolean) => IndividualSchema;
31
32
  export declare const mapIndividualToLegalEntity: (data: IndividualSchema) => LegalEntity;
32
- export declare const mapLegalEntityToCompany: (legalEntity: LegalEntity, isChangingType: boolean) => CompanySchema;
33
+ export declare const mapLegalEntityToCompany: (legalEntity: LegalEntity, isChangingType: boolean, accountHolder?: AccountHolderOption) => CompanySchema;
33
34
  export declare const mapCompanyToLegalEntity: (data: CompanySchema) => LegalEntity;
34
35
  export declare const mapLegalEntityToTrust: (legalEntity: LegalEntity) => TrustSchema;
35
36
  export declare const mapTrustToLegalEntity: (data: TrustSchema) => LegalEntity;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adyen/kyc-components",
3
- "version": "2.41.1",
3
+ "version": "2.41.2",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "files": [