UNPKG

@adyen/kyc-components

Version:

This guide assumes that you have already an account with Adyen. A legalEntity needs to be created, and you need to have a `legalEntityId` to instatiate a Component.

45 lines (44 loc) 2.16 kB
try { let e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack; n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "5d6eb755-d109-4351-9f61-7eceae1e6918", e._sentryDebugIdIdentifier = "sentry-dbid-5d6eb755-d109-4351-9f61-7eceae1e6918"); } catch (e) {} import { t as LegalEntityTypes } from "./legal-entity-type-VIfNYnJP.js"; import { t as getNestedPropertyKeys } from "./getNestedPropertyKeys-CVAsNBJ8.js"; //#region src/stores/globalStore/isEmptyEntity.ts /** * These fields will be present on an empty (just created) entity of the given type. * If any more fields than these are present, we consider the LE to not be "empty". */ var emptyFieldsForIndividual = [ "name.firstName", "name.lastName", "residentialAddress.country" ]; var emptyFieldsForOrganization = ["legalName", "registeredAddress.country"]; var emptyFieldsForTrust = ["name", "registeredAddress.country"]; var emptyFieldsForSoleProp = ["name", "registeredAddress.country"]; var emptyFieldsForUnincorporatedPartnership = [ "name", "countryOfGoverningLaw", "registeredAddress.country" ]; var emptyFieldsByEntityType = { [LegalEntityTypes.INDIVIDUAL]: emptyFieldsForIndividual, [LegalEntityTypes.ORGANIZATION]: emptyFieldsForOrganization, [LegalEntityTypes.TRUST]: emptyFieldsForTrust, [LegalEntityTypes.SOLE_PROPRIETORSHIP]: emptyFieldsForSoleProp, [LegalEntityTypes.UNINCORPORATED_PARTNERSHIP]: emptyFieldsForUnincorporatedPartnership }; function isEmptyEntity(legalEntity) { const type = legalEntity?.type; if (!type) return true; if (legalEntity.documentDetails?.length) return false; const minimumFields = emptyFieldsByEntityType[type]; const typeSpecificSection = legalEntity[type]; if (!typeSpecificSection) return true; const fieldsOnEntity = getNestedPropertyKeys(typeSpecificSection, false, false); const sortedMinimumFields = [...minimumFields].sort(); return [...fieldsOnEntity].sort().every((value, index) => value === sortedMinimumFields[index]); } //#endregion export { isEmptyEntity as t };