@adyen/kyc-components
Version:
`adyen-kyc-components` provides the required pieces to build an onboarding flow based on a legal entity. To onboard and verify users, you need to create a user interface (UI) to collect user data. To speed up building your integration, Adyen offers onboar
126 lines (125 loc) • 5.02 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] = "f4f430b6-6c53-49c4-9556-62819830fc32", e._sentryDebugIdIdentifier = "sentry-dbid-f4f430b6-6c53-49c4-9556-62819830fc32");
} catch (e) {
}
}
;
import { jsx, jsxs } from "preact/jsx-runtime";
import { useState } from "preact/hooks";
import { u as useI18nContext, D as useForm, H as Typography, J as Field, R as RadioGroupCard, B as Button, U as Svg, L as LegalEntityType } from "./core-B_WrZP-J.js";
const setupAccountMethods = ["singpass", "manual"];
const setupAccountMethodFields = ["setupAccountMethod"];
const getSingpassSelectionDisabled = (legalEntityType) => {
switch (legalEntityType) {
case LegalEntityType.INDIVIDUAL:
case LegalEntityType.ORGANIZATION:
return false;
default:
return true;
}
};
const legalEntityTypeToSelectionTranslationKeyMap = {
[LegalEntityType.INDIVIDUAL]: "retrieveMyInfo",
[LegalEntityType.ORGANIZATION]: "retrieveMyInfoBusiness"
};
const legalEntityTypeToSelectionDescriptionTranslationKeyMap = {
[LegalEntityType.INDIVIDUAL]: "getYourVerifiedDetailsInstantly",
[LegalEntityType.ORGANIZATION]: "getYourBusinessVerifiedDetails"
};
const getSetupAccountMethodMetadata = (legalEntityType) => {
const translationSingpassNameKey = legalEntityTypeToSelectionTranslationKeyMap[legalEntityType] ?? "retrieveMyInfoBusiness";
const translationSingpassDescriptionKey = legalEntityTypeToSelectionDescriptionTranslationKeyMap[legalEntityType] ?? "getYourBusinessVerifiedDetails";
const isSingpassSelectionDisabled = getSingpassSelectionDisabled(legalEntityType);
return {
singpass: {
name: translationSingpassNameKey,
description: translationSingpassDescriptionKey,
icon: /* @__PURE__ */ jsx(
Svg,
{
type: "image",
name: "singpass-verification-instant",
className: "adyen-kyc-setup-singpass-container"
}
),
provider: {
name: "singpass",
icon: /* @__PURE__ */ jsx(Svg, { type: "image", name: "singpass-logo", className: "adyen-kyc-singpass-logo-container" })
},
isOptionDisabled: isSingpassSelectionDisabled
},
manual: {
name: "enterTheDetailsYourself",
description: "youAlsoHaveToUploadSomeSupportingDocuments",
icon: /* @__PURE__ */ jsx(
Svg,
{
type: "image",
name: "singpass-verification-manual",
className: "adyen-kyc-setup-manual-container"
}
)
}
};
};
const SingpassSelection = (props) => {
const { legalEntityType, handleNextClick } = props;
const { i18n } = useI18nContext();
const [selectedMethod, setSelectedMethod] = useState();
const selectSetupAccountMethod = (method) => {
setSelectedMethod(method);
handleChangeFor("setupAccountMethod")(method);
};
const { handleChangeFor, data } = useForm({
...props,
schema: setupAccountMethodFields,
defaultData: {}
});
const methodsMetadata = getSetupAccountMethodMetadata(legalEntityType);
return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("div", { className: "adyen-kyc-singpass-selection", children: [
/* @__PURE__ */ jsx("header", { className: "adyen-kyc-u-margin-bottom-32", children: /* @__PURE__ */ jsx(Typography, { el: "h2", variant: "title-m", children: i18n.get("howWouldYouLikeToSetUpYourAccount") }) }),
/* @__PURE__ */ jsx("form", { children: /* @__PURE__ */ jsx(Field, { name: "setupAccountMethod", children: (childProps) => /* @__PURE__ */ jsx(
RadioGroupCard,
{
...childProps,
name: "setupAccountMethod",
options: setupAccountMethods,
onSelect: selectSetupAccountMethod,
selected: data.setupAccountMethod,
optionId: (method) => method,
optionName: (method) => methodsMetadata[method].name,
optionDescription: (method) => methodsMetadata[method].description,
className: "adyen-kyc-field-verification-methods",
optionClassNames: () => ({
icon: "adyen-kyc-radio-group-card__illustration",
label: "adyen-kyc-field-verification-methods__card",
footer: "adyen-kyc-field-verification-methods__footer"
}),
renderOptionIcon: (method) => methodsMetadata[method].icon,
renderOptionFooter: (method) => {
var _a;
return (_a = methodsMetadata[method].provider) == null ? void 0 : _a.icon;
},
floatingRadio: true
}
) }) }),
/* @__PURE__ */ jsx(
Button,
{
disabled: !selectedMethod,
onClick: () => {
if (!selectedMethod) return;
handleNextClick(selectedMethod);
},
fullWidth: true,
children: i18n.get("next")
}
)
] }) });
};
export {
SingpassSelection
};