@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.
65 lines (64 loc) • 2.85 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] = "f4bc85fe-0564-40b1-9faf-120601430c93", e._sentryDebugIdIdentifier = "sentry-dbid-f4bc85fe-0564-40b1-9faf-120601430c93");
} catch (e) {}
import { r as useTranslation } from "./translation-BYvhW5zA.js";
import { x as Alert } from "./resolveEnvironment-DNmu53Rr.js";
import { s as useApiContext, t as httpDelete } from "./http-8qgzqVqk.js";
import { t as useInvalidateRootLegalEntity } from "./invalidateRootLegalEntity-DLpPeD5p.js";
import { jsx } from "preact/jsx-runtime";
import { useMutation } from "@tanstack/preact-query";
//#region src/api/transferInstruments/useDeleteTransferInstrument.ts
var deleteTransferInstrument = async (legalEntityId, baseUrl, transferInstrumentId) => {
return httpDelete({
baseUrl,
path: `legalEntities/${legalEntityId}/transferInstruments/${transferInstrumentId}`
});
};
/**
* Deletes a transfer instrument associated with a legal entity
* @param options additional options passed to Tanstack Query, eg; onSuccess
*/
var useDeleteTransferInstrument = (options) => {
const { rootLegalEntityId, baseUrl } = useApiContext();
const invalidateRootLegalEntity = useInvalidateRootLegalEntity();
return useMutation({
mutationFn: (transferInstrumentId) => deleteTransferInstrument(rootLegalEntityId.value, baseUrl.value, transferInstrumentId),
onSuccess: async () => {
await invalidateRootLegalEntity();
},
...options
});
};
//#endregion
//#region src/components/ui/molecules/Alert/VerificationErrorAlert.tsx
var VerificationErrorAlert = ({ className, problems, children, fallbackErrorMessage }) => {
const { t } = useTranslation("common");
if (problems?.verificationErrors && Object.keys(problems.verificationErrors).length > 0) {
const childErrors = Object.values(problems.verificationErrors).reduce((acc, parentChildErrors) => {
acc = {
...acc,
...parentChildErrors
};
return acc;
}, {});
const childErrorCodes = Object.keys(childErrors);
if (childErrorCodes.length === 1) {
const remediationActions = Object.values(childErrors?.[childErrorCodes?.[0]] ?? {}).flat();
if (remediationActions.length === 1) return /* @__PURE__ */ jsx(Alert, {
className,
variant: "error",
title: `${t(($) => $[`errorMessage_${childErrorCodes[0]}`])}. ${t(($) => $[`remediationMessage_${remediationActions[0].code}`])}`,
children
});
}
}
return /* @__PURE__ */ jsx(Alert, {
className,
variant: "error",
title: fallbackErrorMessage ?? t(($) => $["verificationErrorMessage"]),
children
});
};
//#endregion
export { useDeleteTransferInstrument as n, VerificationErrorAlert as t };