@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.
142 lines (141 loc) • 7.7 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] = "3fe03513-2ea2-4d3c-b983-9213bafac63d", e._sentryDebugIdIdentifier = "sentry-dbid-3fe03513-2ea2-4d3c-b983-9213bafac63d");
} 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 { n as useTermsOfServiceAcceptanceInfos, t as useTermsOfServiceStatus } from "./useTermsOfServiceStatus-D1_ECrkO.js";
import { t as emitAdyenSdkEvent } from "./emitEvent-CcGIaOut.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/ManageTermsOfServiceComponent/ManageTermsOfServiceComponent.tsx
function ManageTermsOfServiceComponent({ legalEntityId, onClick }) {
const { rootLegalEntityId: currentLegalEntityId } = useApiContext();
currentLegalEntityId.value = legalEntityId;
const { i18n, t } = useTranslation(["ui", "contract"]);
const { isLoading: isLoadingSigned, data: signedData } = useTermsOfServiceAcceptanceInfos();
const { isLoading: isLoadingUnsigned, data: unsignedData } = useTermsOfServiceStatus();
addResourceBundles(i18n, [{
ns: "ui",
importFn: (lang) => _rolldown_dynamic_import_helper_default(/* @__PURE__ */ Object.assign({
"../../ui/language/bg-BG.json": () => import("./bg-BG-CzXoDIev.js"),
"../../ui/language/cs-CZ.json": () => import("./cs-CZ-JUprtMsH.js"),
"../../ui/language/da-DK.json": () => import("./da-DK-D2RrHm98.js"),
"../../ui/language/de-DE.json": () => import("./de-DE-o8i-cfnA.js"),
"../../ui/language/el-GR.json": () => import("./el-GR-BAhj1djs.js"),
"../../ui/language/en-US.json": () => import("./en-US-COWs58AF.js"),
"../../ui/language/es-ES.json": () => import("./es-ES-BNjxmV8Q.js"),
"../../ui/language/es-LA.json": () => import("./es-LA-BIPVrwXX.js"),
"../../ui/language/et-EE.json": () => import("./et-EE-Dl6n-Am8.js"),
"../../ui/language/fi-FI.json": () => import("./fi-FI-T33BAikx.js"),
"../../ui/language/fr-FR.json": () => import("./fr-FR-CRO4taJU.js"),
"../../ui/language/hr-HR.json": () => import("./hr-HR-CbEXwWeO.js"),
"../../ui/language/hu-HU.json": () => import("./hu-HU-B9JCbRow.js"),
"../../ui/language/it-IT.json": () => import("./it-IT-DE_Dkl_X.js"),
"../../ui/language/ja-JP.json": () => import("./ja-JP-BaD-vLXo.js"),
"../../ui/language/lt-LT.json": () => import("./lt-LT-5OY6az4F.js"),
"../../ui/language/lv-LV.json": () => import("./lv-LV-DjAUG4pi.js"),
"../../ui/language/nl-NL.json": () => import("./nl-NL-C3cXv5PD.js"),
"../../ui/language/no-NO.json": () => import("./no-NO-DyMlgewS.js"),
"../../ui/language/pl-PL.json": () => import("./pl-PL-ClUTW9pd.js"),
"../../ui/language/pt-BR.json": () => import("./pt-BR-Bk2xOhdi.js"),
"../../ui/language/pt-PT.json": () => import("./pt-PT-5O7ohkQD.js"),
"../../ui/language/ro-RO.json": () => import("./ro-RO-BOV_LMAu.js"),
"../../ui/language/sk-SK.json": () => import("./sk-SK-BUGTKkOC.js"),
"../../ui/language/sl-SI.json": () => import("./sl-SI-DffYWi9P.js"),
"../../ui/language/sv-SE.json": () => import("./sv-SE-D_bagacj.js")
}), `../../ui/language/${lang}.json`, 5)
}, {
ns: "contract",
importFn: (lang) => _rolldown_dynamic_import_helper_default(/* @__PURE__ */ Object.assign({
"../../Contract/language/bg-BG.json": () => import("./bg-BG-BKPnSg5G.js"),
"../../Contract/language/cs-CZ.json": () => import("./cs-CZ-BBnvx4CY.js"),
"../../Contract/language/da-DK.json": () => import("./da-DK-CRp6gV0v.js"),
"../../Contract/language/de-DE.json": () => import("./de-DE-asP1wacy.js"),
"../../Contract/language/el-GR.json": () => import("./el-GR-B18pS-T4.js"),
"../../Contract/language/en-US.json": () => import("./en-US-CmzloEL3.js"),
"../../Contract/language/es-ES.json": () => import("./es-ES-BN2YT82N.js"),
"../../Contract/language/es-LA.json": () => import("./es-LA-DK1UJyRv.js"),
"../../Contract/language/et-EE.json": () => import("./et-EE-6Fsbs-mA.js"),
"../../Contract/language/fi-FI.json": () => import("./fi-FI-C4Ta33KJ.js"),
"../../Contract/language/fr-FR.json": () => import("./fr-FR-DKTSJHnY.js"),
"../../Contract/language/hr-HR.json": () => import("./hr-HR-CII1fh9u.js"),
"../../Contract/language/hu-HU.json": () => import("./hu-HU-CAlsW_OP.js"),
"../../Contract/language/it-IT.json": () => import("./it-IT-BUwmmlzT.js"),
"../../Contract/language/ja-JP.json": () => import("./ja-JP-XWbEAz1Y.js"),
"../../Contract/language/lt-LT.json": () => import("./lt-LT-Vhhg1gZf.js"),
"../../Contract/language/lv-LV.json": () => import("./lv-LV-x-MIpGh3.js"),
"../../Contract/language/nl-NL.json": () => import("./nl-NL-CvSvFKVp.js"),
"../../Contract/language/no-NO.json": () => import("./no-NO-TyUIFxXT.js"),
"../../Contract/language/pl-PL.json": () => import("./pl-PL-BYzL4w2k.js"),
"../../Contract/language/pt-BR.json": () => import("./pt-BR-D5r3Ig2a.js"),
"../../Contract/language/pt-PT.json": () => import("./pt-PT-Dsxz9fKe.js"),
"../../Contract/language/ro-RO.json": () => import("./ro-RO-BfVd2Ps9.js"),
"../../Contract/language/sk-SK.json": () => import("./sk-SK-ID0z1rIS.js"),
"../../Contract/language/sl-SI.json": () => import("./sl-SI-hxmAPrRM.js"),
"../../Contract/language/sv-SE.json": () => import("./sv-SE-BuzHXTQj.js")
}), `../../Contract/language/${lang}.json`, 5)
}]);
const signed = signedData?.data?.map((d) => d.type);
const unsigned = unsignedData?.termsOfServiceTypes;
const hasSignedAll = signed?.length !== 0 && unsigned?.length === 0;
const isLoading = isLoadingSigned && isLoadingUnsigned;
const title = t(($) => $["serviceAgreements"], { ns: "contract" });
return hasSignedAll ? /* @__PURE__ */ jsx(EmbeddedStatus, {
onClick,
title,
tag: {
text: t(($) => $["complete"]),
variant: "green"
},
loading: isLoading
}) : /* @__PURE__ */ jsx(EmbeddedStatus, {
onClick,
actionIndicator: { text: t(($) => $["accept"], { ns: "contract" }) },
title,
loading: isLoading
});
}
//#endregion
//#region src/embeds/terms-of-service-status/adyen-terms-of-service-status.tsx
/**
* Enables users to view the status of the Terms of Service documents and download the signed copies.
*/
var AdyenManageTermsOfService = ({ 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-terms-of-service-status",
rootLegalEntityId: rootlegalentityid,
settings,
features: experiments,
getSdkToken: fetchToken,
locale,
baseUrl: resolveEnvironment(environment),
children: /* @__PURE__ */ jsx(ManageTermsOfServiceComponent, {
legalEntityId: rootlegalentityid,
onClick: handleOnClick
})
})
});
};
register(AdyenManageTermsOfService, "adyen-terms-of-service-status", [
"rootlegalentityid",
"fetchToken",
"environment",
"locale",
"settings",
"experiments"
], {
shadow: true,
adoptedStyleSheets: stylesheets
});
//#endregion