@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.
100 lines (99 loc) • 3.42 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] = "28fd20a4-45f9-4279-adcb-139009f9c0c4", e._sentryDebugIdIdentifier = "sentry-dbid-28fd20a4-45f9-4279-adcb-139009f9c0c4");
} catch (e) {}
import { r as useTranslation } from "./translation-BYvhW5zA.js";
import { k as Header } from "./resolveEnvironment-DNmu53Rr.js";
import { t as Button } from "./Button-i8I2dHP8.js";
import { r as httpPost, s as useApiContext } from "./http-8qgzqVqk.js";
import { n as useToastContext } from "./invalidateRootLegalEntity-DLpPeD5p.js";
import { r as LoaderWrapper } from "./utils-C1buyvRw.js";
import { t as Checkbox } from "./Checkbox-D7BRIoQL.js";
import { t as Spacer } from "./Spacer-CEHRO4Ml.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__ */ jsxs("div", { children: [
content,
" ",
/* @__PURE__ */ jsxs("div", {
class: "u-display-flex u-margin-top-48",
children: [
/* @__PURE__ */ jsx(Button, {
variant: "secondary",
onClick: handleHomeClick,
children: t(($) => $["goToOverview"])
}),
/* @__PURE__ */ jsx(Spacer, {}),
/* @__PURE__ */ jsx(Button, {
onClick: onConfirmClick,
disabled: !hasConfirmed,
children: t(($) => $["submitReview"])
})
]
})
] });
}
//#endregion
export { Review };