@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.
90 lines (89 loc) • 4.33 kB
JavaScript
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] = "237850fa-9e4e-44be-a5ec-3c2a9ee89f9c", e._sentryDebugIdIdentifier = "sentry-dbid-237850fa-9e4e-44be-a5ec-3c2a9ee89f9c");
} catch (e) {}
import { a as Icon, r as useTranslation, t as Trans } from "./translation-BFxyJ1c5.js";
import { p as TaskTypes } from "./entityAssociationUtil-BEzUdPbm.js";
import { n as getDecisionMakerDescriptionMap } from "./decisionMaker-j9cwyXuS.js";
import { t as TRUST_DEFAULT_DESCRIPTIONS_MAP } from "./trustMemberGuidance-B3VWjXzg.js";
import { t as UnincorporatedPartnershipMemberTypes } from "./unincorporated-partnership-5MvG_ts4.js";
import { n as getRoleTagVariant, t as getRoleName } from "./roleMetadata-CP3ZYYSI.js";
import { t as Tag } from "./Tag-BhU73i1R.js";
import { jsx, jsxs } from "preact/jsx-runtime";
//#region src/components/UnincorporatedPartnership/tasks/UnincorporatedPartnershipMembers/types.ts
var UNINCORPORATED_PARTNERSHIP__DEFAULT_DESCRIPTIONS_MAP = {
[UnincorporatedPartnershipMemberTypes.SECONDARY_PARTNER]: "provideAtLeastOneSecondaryPartner",
[UnincorporatedPartnershipMemberTypes.OWNER]: "provideAllOwners",
[UnincorporatedPartnershipMemberTypes.CONTROLLING_PERSON]: "ifNoOwnersSpecifyControllingPersons"
};
//#endregion
//#region src/utils/entityStatusUtil.ts
/**
* Determines the status of an entity based on the current and minimum values.
*
* This function compares the `current` number of entities provided with the `min` entities required.
* If the `current` value is greater than 0 and is greater than or equal to `min`,
* it returns `'satisfied'`. Otherwise, it returns `'empty'`.
*
* @param {number} current - The current value to be evaluated.
* @param {number} min - The minimum threshold that `current` must meet or exceed.
* @returns {EntityStatus} - Returns `'satisfied'` if the current value meets the condition, otherwise `'empty'`.
*/
var iconStatus = (current, min) => {
return current > 0 && current >= min ? "satisfied" : "empty";
};
var getEntityStatusRuleDescription = (country, currentTask, entityLabel) => {
const defaultMessage = getDecisionMakerDescriptionMap(country)[entityLabel];
switch (currentTask) {
case TaskTypes.TRUST_MEMBER_OVERVIEW: return TRUST_DEFAULT_DESCRIPTIONS_MAP[entityLabel];
case TaskTypes.UNINCORPORATED_PARTNERSHIP_MEMBER_OVERVIEW: return UNINCORPORATED_PARTNERSHIP__DEFAULT_DESCRIPTIONS_MAP[entityLabel] || defaultMessage;
default: return defaultMessage;
}
};
//#endregion
//#region src/components/Shared/EntityGuidanceStatus/EntityStatusIcon.tsx
var EntityStatusIcon = ({ status }) => {
switch (status) {
case "empty": return /* @__PURE__ */ jsx(Icon, {
name: "checkmark-circle",
className: "adyen-kyc-entity-status__icon adyen-kyc-entity-status__icon--empty",
testId: "empty-icon"
});
case "satisfied": return /* @__PURE__ */ jsx(Icon, {
name: "checkmark",
className: "adyen-kyc-entity-status__icon adyen-kyc-entity-status__icon--satisfied",
testId: "satisfied-icon"
});
default: return /* @__PURE__ */ jsx(Icon, {
name: "circle",
className: "adyen-kyc-entity-status__icon adyen-kyc-entity-status__icon--empty",
testId: "empty-icon"
});
}
};
//#endregion
//#region src/components/Shared/EntityGuidanceStatus/EntityGuidanceStatus.tsx
var EntityGuidanceStatus = ({ country, currentTask, entityLabel, status }) => {
const { t } = useTranslation("common");
return /* @__PURE__ */ jsxs("div", {
className: "adyen-kyc-entity-status__container",
children: [
/* @__PURE__ */ jsx(EntityStatusIcon, { status }),
/* @__PURE__ */ jsx(Tag, {
className: "adyen-kyc-entity-status__tag",
variant: getRoleTagVariant(entityLabel),
children: t(($) => $[getRoleName(entityLabel)])
}, entityLabel),
/* @__PURE__ */ jsx("span", {
className: "adyen-kyc-entity-status--text",
"data-testid": `${entityLabel}-rule--description`,
children: /* @__PURE__ */ jsx(Trans, {
t,
i18nKey: ($) => $[getEntityStatusRuleDescription(country, currentTask, entityLabel)]
})
})
]
});
};
//#endregion
export { iconStatus as n, EntityGuidanceStatus as t };