@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.
141 lines (140 loc) • 7.62 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] = "b27f56bd-11dc-4690-b520-46463a487ce3", e._sentryDebugIdIdentifier = "sentry-dbid-b27f56bd-11dc-4690-b520-46463a487ce3");
} catch (e) {}
import { n as addResourceBundles, r as useTranslation } from "./translation-BFxyJ1c5.js";
import { a as stylesheets, n as EmbedShell, t as resolveEnvironment } from "./resolveEnvironment-CguBRdxx.js";
import { s as useApiContext } from "./http-D1NDkBxF.js";
import { t as _rolldown_dynamic_import_helper_default } from "./_rolldown_dynamic_import_helper-rq_tsyLP.js";
import { n as useTermsOfServiceAcceptanceInfos, t as useTermsOfServiceStatus } from "./useTermsOfServiceStatus-YBxJYvyS.js";
import { t as emitAdyenSdkEvent } from "./emitEvent-Cdd95HOT.js";
import { t as EmbeddedStatus } from "./EmbeddedStatus-C0cKHgzR.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-BUBUyZgz.js"),
"../../ui/language/cs-CZ.json": () => import("./cs-CZ-BFJyFYpX.js"),
"../../ui/language/da-DK.json": () => import("./da-DK-BNvIcL59.js"),
"../../ui/language/de-DE.json": () => import("./de-DE-B8Eby_UK.js"),
"../../ui/language/el-GR.json": () => import("./el-GR-DYmDnzZe.js"),
"../../ui/language/en-US.json": () => import("./en-US-Mma5wIWL.js"),
"../../ui/language/es-ES.json": () => import("./es-ES-DLBRDQJZ.js"),
"../../ui/language/et-EE.json": () => import("./et-EE-C_Z4PWda.js"),
"../../ui/language/fi-FI.json": () => import("./fi-FI-azwPyx-k.js"),
"../../ui/language/fr-FR.json": () => import("./fr-FR-CzdHSH04.js"),
"../../ui/language/hr-HR.json": () => import("./hr-HR-C7Hp8OgD.js"),
"../../ui/language/hu-HU.json": () => import("./hu-HU-B34uBEZ9.js"),
"../../ui/language/it-IT.json": () => import("./it-IT-BCqVu72_.js"),
"../../ui/language/ja-JP.json": () => import("./ja-JP-C7_6K98B.js"),
"../../ui/language/lt-LT.json": () => import("./lt-LT-BhzsTniu.js"),
"../../ui/language/lv-LV.json": () => import("./lv-LV-B6yxwa6Z.js"),
"../../ui/language/nl-NL.json": () => import("./nl-NL-4iZ44kzK.js"),
"../../ui/language/no-NO.json": () => import("./no-NO-BSJ1rjY4.js"),
"../../ui/language/pl-PL.json": () => import("./pl-PL-BHjlKdWC.js"),
"../../ui/language/pt-BR.json": () => import("./pt-BR-BMIZHo3V.js"),
"../../ui/language/pt-PT.json": () => import("./pt-PT-s_KcBKav.js"),
"../../ui/language/ro-RO.json": () => import("./ro-RO-DsFmqo3p.js"),
"../../ui/language/sk-SK.json": () => import("./sk-SK-BspZv60l.js"),
"../../ui/language/sl-SI.json": () => import("./sl-SI-D26FDPwq.js"),
"../../ui/language/sv-SE.json": () => import("./sv-SE-JKGeqd9J.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-DaiKPUAP.js"),
"../../Contract/language/cs-CZ.json": () => import("./cs-CZ-Dit1sTZS.js"),
"../../Contract/language/da-DK.json": () => import("./da-DK-CSuIOYvv.js"),
"../../Contract/language/de-DE.json": () => import("./de-DE-UxQXcw2Z.js"),
"../../Contract/language/el-GR.json": () => import("./el-GR-JdIfiWWD.js"),
"../../Contract/language/en-US.json": () => import("./en-US-DtWDVC_l.js"),
"../../Contract/language/es-ES.json": () => import("./es-ES-CgcvvmLv.js"),
"../../Contract/language/et-EE.json": () => import("./et-EE-BtoIECkX.js"),
"../../Contract/language/fi-FI.json": () => import("./fi-FI-CUapPvf9.js"),
"../../Contract/language/fr-FR.json": () => import("./fr-FR-D34baGa-.js"),
"../../Contract/language/hr-HR.json": () => import("./hr-HR-C4sBzG1i.js"),
"../../Contract/language/hu-HU.json": () => import("./hu-HU-DgjvclPA.js"),
"../../Contract/language/it-IT.json": () => import("./it-IT-BZrpE0qK.js"),
"../../Contract/language/ja-JP.json": () => import("./ja-JP-DB56llc7.js"),
"../../Contract/language/lt-LT.json": () => import("./lt-LT-DFZD-gis.js"),
"../../Contract/language/lv-LV.json": () => import("./lv-LV-BJgLY-OW.js"),
"../../Contract/language/nl-NL.json": () => import("./nl-NL-CBBxSKzB.js"),
"../../Contract/language/no-NO.json": () => import("./no-NO-3PlX_ro5.js"),
"../../Contract/language/pl-PL.json": () => import("./pl-PL-ComkJGTw.js"),
"../../Contract/language/pt-BR.json": () => import("./pt-BR-Ct1Nhi9U.js"),
"../../Contract/language/pt-PT.json": () => import("./pt-PT-BhEGejvl.js"),
"../../Contract/language/ro-RO.json": () => import("./ro-RO-QlHjtTpP.js"),
"../../Contract/language/sk-SK.json": () => import("./sk-SK-CxisoTfT.js"),
"../../Contract/language/sl-SI.json": () => import("./sl-SI-CG07y9Cp.js"),
"../../Contract/language/sv-SE.json": () => import("./sv-SE-C2lw5FJ7.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