@adyen/kyc-components 3.15.1 → 3.15.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.
@@ -10257,7 +10257,10 @@ const entityTypeToCorrespondingAccountHolderOption = {
10257
10257
  [LegalEntityType.SOLE_PROPRIETORSHIP]: "mySoleProprietorName",
10258
10258
  [LegalEntityType.TRUST]: "aTrust"
10259
10259
  };
10260
- const getDefaultAccountHolderType = (legalEntityResponse, isTypeChanging = false) => {
10260
+ const getDefaultAccountHolderType = (legalEntityResponse, isTypeChanging = false, accountHolder2) => {
10261
+ if (accountHolder2) {
10262
+ return accountHolder2;
10263
+ }
10261
10264
  if (!(legalEntityResponse == null ? void 0 : legalEntityResponse.type))
10262
10265
  return void 0;
10263
10266
  if (hasOwnEntityAssociationOfType(LegalEntityType.SOLE_PROPRIETORSHIP, legalEntityResponse.entityAssociations, legalEntityResponse.id)) {
@@ -10510,6 +10513,7 @@ const companyTypeValidationRules = {
10510
10513
  };
10511
10514
  const companyTypeFields = ["entityType", ...accountHolderFields];
10512
10515
  function CompanyTypeComponent(props) {
10516
+ var _a;
10513
10517
  const {
10514
10518
  i18n
10515
10519
  } = useI18nContext();
@@ -10540,8 +10544,8 @@ function CompanyTypeComponent(props) {
10540
10544
  const formUtils = formUtilities(props, i18n);
10541
10545
  const accountHolderProps = getFieldProps(props, accountHolderFields);
10542
10546
  useEffect(() => {
10543
- var _a, _b;
10544
- (_b = (_a = stateRef.current) == null ? void 0 : _a.setState) == null ? void 0 : _b.call(_a, {
10547
+ var _a2, _b;
10548
+ (_b = (_a2 = stateRef.current) == null ? void 0 : _a2.setState) == null ? void 0 : _b.call(_a2, {
10545
10549
  type: "addToState",
10546
10550
  value: {
10547
10551
  data,
@@ -10554,7 +10558,7 @@ function CompanyTypeComponent(props) {
10554
10558
  }
10555
10559
  });
10556
10560
  }, [data, valid, errors, isValid]);
10557
- const companyTypeOptions = isNewEntryFlowEnabled ? companyTypes.filter((companyType2) => companyType2.id !== CompanyTypesValue.INCORPORATED_PARTNERSHIP && companyType2.id !== CompanyTypesValue.INCORPORATED_ASSOCIATION) : companyTypes;
10561
+ 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;
10558
10562
  const companyTypeExamples2 = useCompanyTypeExamples(country2);
10559
10563
  return jsxs(Fragment, {
10560
10564
  children: [jsx(StateContextSetter, {
@@ -13593,7 +13597,7 @@ const mapIndividualToLegalEntity = (data) => {
13593
13597
  }
13594
13598
  return requestObj;
13595
13599
  };
13596
- const mapLegalEntityToCompany = (legalEntity, isChangingType) => {
13600
+ const mapLegalEntityToCompany = (legalEntity, isChangingType, accountHolder2) => {
13597
13601
  var _a, _b, _c, _d;
13598
13602
  let companyCompData;
13599
13603
  if (legalEntity == null ? void 0 : legalEntity.organization) {
@@ -13638,7 +13642,7 @@ const mapLegalEntityToCompany = (legalEntity, isChangingType) => {
13638
13642
  ...companyCompData,
13639
13643
  companyType: {
13640
13644
  ...companyCompData == null ? void 0 : companyCompData.companyType,
13641
- accountHolder: getDefaultAccountHolderType(legalEntity, isChangingType)
13645
+ accountHolder: getDefaultAccountHolderType(legalEntity, isChangingType, accountHolder2)
13642
13646
  }
13643
13647
  };
13644
13648
  return companyCompData;
@@ -22878,23 +22882,35 @@ const mapLegalArrangementOptionToCompanyTypesValue = (legalArrangement) => {
22878
22882
  case "associationIncorporated":
22879
22883
  return CompanyTypesValue.INCORPORATED_ASSOCIATION;
22880
22884
  default:
22885
+ return void 0;
22886
+ }
22887
+ };
22888
+ const determineOrganizationTypeToUpdate = (defaultLegalArrangement, targetLegalArrangement, currentCompanyTypeValue) => {
22889
+ if (targetLegalArrangement === "aTrust") {
22890
+ return;
22891
+ }
22892
+ if (!targetLegalArrangement) {
22893
+ const isUnavailableTypesInCompany = currentCompanyTypeValue === CompanyTypesValue.INCORPORATED_ASSOCIATION || currentCompanyTypeValue === CompanyTypesValue.INCORPORATED_PARTNERSHIP;
22894
+ if (isUnavailableTypesInCompany) {
22881
22895
  return "";
22896
+ }
22882
22897
  }
22898
+ return mapLegalArrangementOptionToCompanyTypesValue(targetLegalArrangement);
22883
22899
  };
22884
22900
  const getDefaultLegalArrangementOrSuborganizationType = (legalEntityResponse, accountHolder2) => {
22885
22901
  var _a;
22886
22902
  const entityAssociations = legalEntityResponse == null ? void 0 : legalEntityResponse.entityAssociations;
22887
22903
  const suborganizationType = (_a = legalEntityResponse == null ? void 0 : legalEntityResponse.organization) == null ? void 0 : _a.type;
22904
+ const hasTrust = hasOwnEntityAssociationOfType(LegalEntityType.TRUST, entityAssociations, legalEntityResponse == null ? void 0 : legalEntityResponse.id);
22905
+ if (hasTrust || accountHolder2 === "aTrust") {
22906
+ return "aTrust";
22907
+ }
22888
22908
  if (suborganizationType === CompanyTypesValue.INCORPORATED_PARTNERSHIP) {
22889
22909
  return "partnershipIncorporated";
22890
22910
  }
22891
22911
  if (suborganizationType === CompanyTypesValue.INCORPORATED_ASSOCIATION) {
22892
22912
  return "associationIncorporated";
22893
22913
  }
22894
- const hasTrust = hasOwnEntityAssociationOfType(LegalEntityType.TRUST, entityAssociations, legalEntityResponse == null ? void 0 : legalEntityResponse.id);
22895
- if (hasTrust || accountHolder2 === "aTrust") {
22896
- return "aTrust";
22897
- }
22898
22914
  return void 0;
22899
22915
  };
22900
22916
  const getTargetLegalEntityType = (businessType, legalArrangement, trusteeType, currentLegalEntityType) => {
@@ -22904,11 +22920,12 @@ const getTargetLegalEntityType = (businessType, legalArrangement, trusteeType, c
22904
22920
  if (businessType === "legalArrangement" && legalArrangement === "aTrust" && trusteeType === "individual" || businessType === "individual" || businessType === "soleProprietorship") {
22905
22921
  return LegalEntityType.INDIVIDUAL;
22906
22922
  }
22907
- if (legalArrangement === "partnershipIncorporated") {
22923
+ if (legalArrangement && isLegalArrangementOrganizationSubtype(legalArrangement)) {
22908
22924
  return LegalEntityType.ORGANIZATION;
22909
22925
  }
22910
22926
  return currentLegalEntityType;
22911
22927
  };
22928
+ const isLegalArrangementOrganizationSubtype = (legalArrangementOption) => legalArrangementOption === "partnershipIncorporated" || legalArrangementOption === "associationIncorporated";
22912
22929
  var ToastType = /* @__PURE__ */ ((ToastType2) => {
22913
22930
  ToastType2["LOADING"] = "loading";
22914
22931
  ToastType2["SUCCESS"] = "success";
@@ -23218,7 +23235,8 @@ function CompanyDropinComponent({
23218
23235
  handleUpdateLegalEntity,
23219
23236
  handleHomeClick,
23220
23237
  onTypeSwitch,
23221
- onChange
23238
+ onChange,
23239
+ accountHolder: accountHolder2
23222
23240
  }) {
23223
23241
  var _a, _b;
23224
23242
  const {
@@ -23235,7 +23253,8 @@ function CompanyDropinComponent({
23235
23253
  i18n,
23236
23254
  setLocale
23237
23255
  } = useI18nContext();
23238
- const dataFromResponse = mapLegalEntityToCompany(legalEntityResponse, isTargetLegalEntityType);
23256
+ const isNewEntryFlowEnabled = useEnableNewEntryFlow();
23257
+ const dataFromResponse = mapLegalEntityToCompany(legalEntityResponse, isTargetLegalEntityType, isNewEntryFlowEnabled ? accountHolder2 : void 0);
23239
23258
  const {
23240
23259
  getConfiguration: getConfiguration2
23241
23260
  } = useConfigurationApi();
@@ -23291,7 +23310,7 @@ function CompanyDropinComponent({
23291
23310
  });
23292
23311
  onChange == null ? void 0 : onChange(currentState);
23293
23312
  }, [currentState]);
23294
- const isSkippingCompanyStructure = useEnableNewEntryFlow() && organizationTypesToSkipCompanyStructureForm.includes((_b = legalEntityResponse == null ? void 0 : legalEntityResponse.organization) == null ? void 0 : _b.type);
23313
+ const isSkippingCompanyStructure = useEnableNewEntryFlow() && organizationTypesToSkipCompanyStructureForm.includes((_b = legalEntityResponse == null ? void 0 : legalEntityResponse.organization) == null ? void 0 : _b.type) && accountHolder2 !== "aTrust";
23295
23314
  const forms2 = useMemo(() => {
23296
23315
  const requiredForms = getRequiredForms(companyForms, derivedProps == null ? void 0 : derivedProps.requiredFields, derivedProps == null ? void 0 : derivedProps.optionalFields);
23297
23316
  const validityAddedForms = addValidityToForms(requiredForms, formValidity, problems);
@@ -26743,18 +26762,15 @@ const BusinessTypeSelection = ({
26743
26762
  type: targetLegalEntityType
26744
26763
  };
26745
26764
  await (handleUpdateLegalEntity == null ? void 0 : handleUpdateLegalEntity(updateLegalEntityPayload, legalEntityResponse == null ? void 0 : legalEntityResponse.id));
26746
- if (targetLegalEntityType === LegalEntityType.ORGANIZATION && targetLegalEntityType) {
26747
- await (handleUpdateLegalEntity == null ? void 0 : handleUpdateLegalEntity({
26748
- organization: {
26749
- type: mapLegalArrangementOptionToCompanyTypesValue(targetLegalArrangement)
26750
- }
26751
- }, legalEntityResponse == null ? void 0 : legalEntityResponse.id));
26752
- }
26753
26765
  }
26754
- if (isLegalArrangementChanging && targetLegalArrangement) {
26766
+ if (targetLegalEntityType === LegalEntityType.INDIVIDUAL) {
26767
+ return;
26768
+ }
26769
+ const targetOrganizationType = determineOrganizationTypeToUpdate(defaultLegalArrangementType == null ? void 0 : defaultLegalArrangementType.id, targetLegalArrangement, currentCompanyTypesValue);
26770
+ if (targetOrganizationType !== void 0) {
26755
26771
  await (handleUpdateLegalEntity == null ? void 0 : handleUpdateLegalEntity({
26756
26772
  organization: {
26757
- type: mapLegalArrangementOptionToCompanyTypesValue(targetLegalArrangement)
26773
+ type: targetOrganizationType
26758
26774
  }
26759
26775
  }, legalEntityResponse == null ? void 0 : legalEntityResponse.id));
26760
26776
  }
@@ -31966,11 +31982,8 @@ const getDefaultTask = ({
31966
31982
  showIntroduction,
31967
31983
  shouldShowSingpassSelection
31968
31984
  }) => {
31969
- var _a, _b;
31970
- const hasOwnEntityAssocation = (_a = legalEntity.entityAssociations) == null ? void 0 : _a.some((ea) => ea.associatorId === legalEntity.id);
31971
- const hasOrganizationType = (_b = legalEntity.organization) == null ? void 0 : _b.type;
31972
- const hasProgressedBeyondEntitySelection = hasOwnEntityAssocation || !!hasOrganizationType;
31973
- if (isNewEntryFlowEnabled && !accountHolder2 && !hasProgressedBeyondEntitySelection)
31985
+ const hasLegalEntityProgressedBeyondEntitySelection = hasProgressedBeyondEntitySelection(legalEntity);
31986
+ if (isNewEntryFlowEnabled && !accountHolder2 && !hasLegalEntityProgressedBeyondEntitySelection)
31974
31987
  return TaskTypes.BUSINESS_TYPE_SELECTION;
31975
31988
  if (showIntroduction)
31976
31989
  return TaskTypes.INTRODUCTION;
@@ -31978,6 +31991,12 @@ const getDefaultTask = ({
31978
31991
  return TaskTypes.SINGPASS_SELECTION;
31979
31992
  return TaskTypes.TASKS_OVERVIEW;
31980
31993
  };
31994
+ const hasProgressedBeyondEntitySelection = (legalEntity) => {
31995
+ var _a, _b;
31996
+ const hasOwnEntityAssocation = (_a = legalEntity.entityAssociations) == null ? void 0 : _a.some((ea) => ea.associatorId === legalEntity.id);
31997
+ const hasOrganizationType = (_b = legalEntity.organization) == null ? void 0 : _b.type;
31998
+ return hasOwnEntityAssocation || !!hasOrganizationType;
31999
+ };
31981
32000
  const PAGES_WITH_POLLING = [TaskTypes.DECISION_MAKER_OVERVIEW, TaskTypes.TASKS_OVERVIEW];
31982
32001
  const POLLING_INTERVAL = 3e3;
31983
32002
  const logger$b = createLogger("DropinComposerComponent");
@@ -32786,7 +32805,8 @@ function DropinComposerComponent({
32786
32805
  handleAddressSearch: args == null ? void 0 : args.handleAddressSearch,
32787
32806
  handleFindAddress: args == null ? void 0 : args.handleFindAddress,
32788
32807
  onTypeSwitch: navigateToTypeSwitcher,
32789
- isTargetLegalEntityType: legalEntityType === LegalEntityType.ORGANIZATION
32808
+ isTargetLegalEntityType: legalEntityType === LegalEntityType.ORGANIZATION,
32809
+ accountHolder: accountHolder2
32790
32810
  });
32791
32811
  case TaskTypes.COMPANY_SEARCH:
32792
32812
  return jsx(CompanySearchDropinComponent, {
@@ -32843,7 +32863,8 @@ function DropinComposerComponent({
32843
32863
  homeButtonLabel: i18n.get("saveAndGoToOverview"),
32844
32864
  associationDetail: trustMember,
32845
32865
  handleAddressSearch: args == null ? void 0 : args.handleAddressSearch,
32846
- handleFindAddress: args == null ? void 0 : args.handleFindAddress
32866
+ handleFindAddress: args == null ? void 0 : args.handleFindAddress,
32867
+ accountHolder: accountHolder2
32847
32868
  });
32848
32869
  case TaskTypes.PAYOUT:
32849
32870
  case TaskTypes.PAYIN:
@@ -34798,7 +34819,7 @@ const ConfigurationApiProvider = ({
34798
34819
  isEmbeddedDropin,
34799
34820
  loadingContext
34800
34821
  } = authContext;
34801
- const sdkVersion = "3.15.1";
34822
+ const sdkVersion = "3.15.2";
34802
34823
  useAnalytics({
34803
34824
  onUserEvent,
34804
34825
  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: ExistingLegalEntity | undefined, isTypeChanging?: boolean) => AccountHolderOption | undefined;
10
+ export declare const getDefaultAccountHolderType: (legalEntityResponse: ExistingLegalEntity | 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 mapPayoutDetailsToTransferInstrument: ({ 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: ExistingLegalEntity, isChangingType: boolean) => CompanySchema;
33
+ export declare const mapLegalEntityToCompany: (legalEntity: ExistingLegalEntity, 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": "3.15.1",
3
+ "version": "3.15.2",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "files": [