@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.
107 lines (106 loc) • 5.65 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] = "2cbb5ad7-ca79-4596-8018-2f18bea1c5a1", e._sentryDebugIdIdentifier = "sentry-dbid-2cbb5ad7-ca79-4596-8018-2f18bea1c5a1");
} catch (e) {}
import { n as addResourceBundles, r as useTranslation } from "./translation-BYvhW5zA.js";
import { A as _rolldown_dynamic_import_helper_default, mt as stylesheets, n as EmbedShell, t as resolveEnvironment } from "./resolveEnvironment-DNmu53Rr.js";
import { s as useApiContext } from "./http-8qgzqVqk.js";
import { r as useLegalEntity, t as ROOT_LE } from "./useLegalEntity-CtlUQv_J.js";
import { t as emitAdyenSdkEvent } from "./emitEvent-CcGIaOut.js";
import { t as useOnboardingStatus } from "./useOnboardingStatus-BlXlrSAS.js";
import { t as OnboardingStatuses } from "./view-verification-status-XSQs02td.js";
import { t as EmbeddedStatus } from "./EmbeddedStatus-_k9EhrGV.js";
import register from "preact-custom-element";
import { useRef } from "preact/hooks";
import { jsx } from "preact/jsx-runtime";
//#region src/components/EmbeddedDropins/ManageIndividualComponent/ManageIndividualComponent.tsx
function ManageIndividualComponent({ legalEntityId, onClick }) {
const { i18n } = useTranslation();
const { rootLegalEntityId: currentLegalEntityId } = useApiContext();
currentLegalEntityId.value = legalEntityId;
addResourceBundles(i18n, [{
ns: "common",
importFn: (lang) => _rolldown_dynamic_import_helper_default(/* @__PURE__ */ Object.assign({
"../../../language/locales/bg-BG.json": () => import("./bg-BG-BcmC41vE.js"),
"../../../language/locales/cs-CZ.json": () => import("./cs-CZ-ghdW0Tc6.js"),
"../../../language/locales/da-DK.json": () => import("./da-DK-CBOVFYaa.js"),
"../../../language/locales/de-DE.json": () => import("./de-DE-CA81fzkA.js"),
"../../../language/locales/el-GR.json": () => import("./el-GR-BjOmQ_B_.js"),
"../../../language/locales/en-US.instructions.json": () => import("./en-US.instructions-FOYUYA3c.js"),
"../../../language/locales/en-US.json": () => import("./en-US-Dab7moVA.js"),
"../../../language/locales/es-ES.json": () => import("./es-ES-BEYl7Z8S.js"),
"../../../language/locales/es-LA.json": () => import("./es-LA-D741KUNg.js"),
"../../../language/locales/et-EE.json": () => import("./et-EE-CfgyGext.js"),
"../../../language/locales/fi-FI.json": () => import("./fi-FI-DFO20YZY.js"),
"../../../language/locales/fr-FR.json": () => import("./fr-FR-wvWrk_PU.js"),
"../../../language/locales/hr-HR.json": () => import("./hr-HR-D0zfmZK6.js"),
"../../../language/locales/hu-HU.json": () => import("./hu-HU-CL021irk.js"),
"../../../language/locales/it-IT.json": () => import("./it-IT-6VoxKX97.js"),
"../../../language/locales/ja-JP.json": () => import("./ja-JP-Cja4dur8.js"),
"../../../language/locales/lt-LT.json": () => import("./lt-LT-CNFgOeH4.js"),
"../../../language/locales/lv-LV.json": () => import("./lv-LV-BdSdhjTP.js"),
"../../../language/locales/nl-NL.json": () => import("./nl-NL-CclRrN3_.js"),
"../../../language/locales/no-NO.json": () => import("./no-NO-CO5xyGPh.js"),
"../../../language/locales/pl-PL.json": () => import("./pl-PL-DUH23AYC.js"),
"../../../language/locales/pt-BR.json": () => import("./pt-BR-MAQR_CUu2.js"),
"../../../language/locales/pt-PT.json": () => import("./pt-PT-CoKsjpyN.js"),
"../../../language/locales/ro-RO.json": () => import("./ro-RO-Cpv5pKod.js"),
"../../../language/locales/sk-SK.json": () => import("./sk-SK-p_p2X_aA.js"),
"../../../language/locales/sl-SI.json": () => import("./sl-SI-BpZp1MAq.js"),
"../../../language/locales/sv-SE.json": () => import("./sv-SE-BoXCPhGb.js")
}), `../../../language/locales/${lang}.json`, 6)
}]);
const { data: legalEntityData } = useLegalEntity(ROOT_LE);
const { isPending, data: onboardingStatusData } = useOnboardingStatus({ refetchInterval: (res) => res.state.data?.status === OnboardingStatuses.AWAITING_DATA ? 3e3 : false });
const name = legalEntityData?.individual?.name;
const fullName = name ? `${name.firstName} ${name.lastName}` : "";
const subtitle = legalEntityData?.individual?.email ?? "";
const status = onboardingStatusData?.status;
return /* @__PURE__ */ jsx(EmbeddedStatus, {
onClick,
title: fullName,
subtitle,
status,
loading: isPending
});
}
//#endregion
//#region src/embeds/individual-status/adyen-individual-status.tsx
/**
* Enables users to view their current verification status and update their information if necessary.
*/
var AdyenManageIndividual = ({ rootlegalentityid, fetchToken, environment, locale, settings = {}, experiments = {} }) => {
const eventEmitterRef = useRef(null);
const handleOnClick = () => {
emitAdyenSdkEvent(eventEmitterRef, "click");
};
return /* @__PURE__ */ jsx("div", {
ref: eventEmitterRef,
style: "width:100%;",
children: /* @__PURE__ */ jsx(EmbedShell, {
componentName: "adyen-individual-status",
rootLegalEntityId: rootlegalentityid,
settings,
features: experiments,
getSdkToken: fetchToken,
locale,
baseUrl: resolveEnvironment(environment),
children: /* @__PURE__ */ jsx(ManageIndividualComponent, {
legalEntityId: rootlegalentityid,
onClick: handleOnClick
})
})
});
};
register(AdyenManageIndividual, "adyen-individual-status", [
"rootlegalentityid",
"fetchToken",
"environment",
"locale",
"settings",
"experiments"
], {
shadow: true,
adoptedStyleSheets: stylesheets
});
//#endregion