UNPKG

@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

83 lines (82 loc) 3.01 kB
; { 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] = "2782ae0c-bc99-424b-8812-6248aaf2c401", e._sentryDebugIdIdentifier = "sentry-dbid-2782ae0c-bc99-424b-8812-6248aaf2c401"); } catch (e) { } } ; import { jsx, jsxs } from "preact/jsx-runtime"; import { useState } from "preact/hooks"; import { aj as useApiContext, ak as useMutation, al as httpPost, u as useI18nContext, r as useToastContext, G as LoaderWrapper, W as FormHeader, am as Checkbox, a9 as ActionBar, X as DropinLayout } from "./core-B_WrZP-J.js"; const confirmReview = async (legalEntityId, url) => { return httpPost({ loadingContext: url, errorLevel: "warn", errorMessage: `Failed to confirm data review`, path: `legalEntities/${legalEntityId}/confirmDataReview`, authentication: "jwt", headers: { "Content-Type": "application/json" } }); }; const useConfirmReview = (options) => { const { legalEntityId, baseUrl } = useApiContext(); return useMutation({ mutationFn: () => { return confirmReview(legalEntityId.value, baseUrl.value); }, ...options }); }; function Review({ handleHomeClick }) { const { i18n } = useI18nContext(); const [loadingStatus, setLoadingStatus] = useState(); const { showToast } = useToastContext(); const [hasConfirmed, setHasConfirmed] = useState(false); const content = /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs(LoaderWrapper, { status: loadingStatus, formOpacityWhenLoading: 0.3, showSpinner: false, children: [ /* @__PURE__ */ jsx(FormHeader, { heading: i18n.get("submitReviewOfYourData") }), /* @__PURE__ */ jsx("span", { children: i18n.get("pleaseNote") }), /* @__PURE__ */ jsx("br", {}), /* @__PURE__ */ jsx("br", {}), /* @__PURE__ */ jsx( Checkbox, { checked: hasConfirmed, onChange: setHasConfirmed, label: i18n.get("byClickingSubmitReview"), name: "confirmReviewData" } ) ] }) }); const { mutateAsync: confirmReview2 } = useConfirmReview(); const onConfirmClick = async () => { try { setLoadingStatus("loading"); await confirmReview2(); setLoadingStatus("success"); showToast({ label: i18n.get("submitSuccessful"), variant: "success" }); handleHomeClick(); } catch { showToast({ label: i18n.get("submitFailed"), variant: "error" }); } finally { setLoadingStatus("success"); } }; const footer = /* @__PURE__ */ jsx( ActionBar, { onHome: handleHomeClick, homeButtonLabel: i18n.get("goToOverview"), onNext: onConfirmClick, nextButtonLabel: i18n.get("submitReview"), nextButtonDisabled: !hasConfirmed } ); return /* @__PURE__ */ jsx(DropinLayout, { content, footer }); } export { Review };