@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.
90 lines (89 loc) • 3.22 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] = "5d175b6a-a57c-4a30-ae3c-4d8375816fde", e._sentryDebugIdIdentifier = "sentry-dbid-5d175b6a-a57c-4a30-ae3c-4d8375816fde");
} catch (e) {}
import { r as useTranslation } from "./translation-BFxyJ1c5.js";
import { r as httpPost, s as useApiContext } from "./http-D1NDkBxF.js";
import { t as Header } from "./Header-CPmJyuoP.js";
import { t as DropinLayout } from "./DropinLayout-Ce8IeTl4.js";
import { t as useToastContext } from "./useToastContext-CYgfHjSb.js";
import { t as LoaderWrapper } from "./LoaderWrapper-Dq8TNJCi.js";
import { t as Checkbox } from "./Checkbox-BCYjFPa4.js";
import { t as ActionBar } from "./ActionBar-Doac020y.js";
import { useState } from "preact/hooks";
import { jsx, jsxs } from "preact/jsx-runtime";
import { useMutation } from "@tanstack/preact-query";
//#region src/api/legalEntity/useConfirmReview.ts
var confirmReview = async (legalEntityId, baseUrl) => {
return httpPost({
baseUrl,
path: `legalEntities/${legalEntityId}/confirmDataReview`
});
};
var useConfirmReview = (options) => {
const { rootLegalEntityId, baseUrl } = useApiContext();
return useMutation({
mutationFn: () => {
return confirmReview(rootLegalEntityId.value, baseUrl.value);
},
...options
});
};
//#endregion
//#region src/components/Shared/tasks/Review/Review.tsx
function Review({ handleHomeClick }) {
const { t } = useTranslation("common");
const [loadingStatus, setLoadingStatus] = useState();
const { showToast } = useToastContext();
const [hasConfirmed, setHasConfirmed] = useState(false);
const content = /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs(LoaderWrapper, {
status: loadingStatus,
formOpacityWhenLoading: .3,
showSpinner: false,
children: [
/* @__PURE__ */ jsx(Header, { title: t(($) => $["submitReviewOfYourData"]) }),
/* @__PURE__ */ jsx("span", { children: t(($) => $["pleaseNote"]) }),
/* @__PURE__ */ jsx("br", {}),
/* @__PURE__ */ jsx("br", {}),
/* @__PURE__ */ jsx(Checkbox, {
id: "review-checkbox",
checked: hasConfirmed,
onChange: setHasConfirmed,
label: t(($) => $["byClickingSubmitReview"]),
name: "confirmReviewData"
})
]
}) });
const { mutateAsync: confirmReview } = useConfirmReview();
const onConfirmClick = async () => {
try {
setLoadingStatus("loading");
await confirmReview();
setLoadingStatus("success");
showToast({
label: t(($) => $["submitSuccessful"]),
variant: "success"
});
handleHomeClick();
} catch {
showToast({
label: t(($) => $["submitFailed"]),
variant: "error"
});
} finally {
setLoadingStatus("success");
}
};
return /* @__PURE__ */ jsx(DropinLayout, {
content,
footer: /* @__PURE__ */ jsx(ActionBar, {
onHome: handleHomeClick,
homeButtonLabel: t(($) => $["goToOverview"]),
onNext: onConfirmClick,
nextButtonLabel: t(($) => $["submitReview"]),
nextButtonDisabled: !hasConfirmed
})
});
}
//#endregion
export { Review };