@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.
30 lines (29 loc) • 1.47 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] = "2986ef19-75a6-4166-a5a7-b1763ad2bcdb", e._sentryDebugIdIdentifier = "sentry-dbid-2986ef19-75a6-4166-a5a7-b1763ad2bcdb");
} catch (e) {}
import { r as httpPost, s as useApiContext } from "./http-D1NDkBxF.js";
import { t as useInvalidateRootLegalEntity } from "./invalidateRootLegalEntity-CZr0iiji.js";
import { useMutation, useQueryClient } from "@tanstack/preact-query";
//#region src/api/legalEntity/useUpdateLegalEntity.ts
var updateLegalEntity = async (rootLegalEntityId, baseUrl, data) => {
return httpPost({
baseUrl,
path: `legalEntities/${rootLegalEntityId}`
}, data);
};
var useUpdateLegalEntity = (options) => {
const { rootLegalEntityId, baseUrl } = useApiContext();
const invalidateRootLegalEntity = useInvalidateRootLegalEntity();
const queryClient = useQueryClient();
return useMutation({
mutationFn: (payload) => updateLegalEntity(rootLegalEntityId.value, baseUrl.value, payload),
onSuccess: async (response, payload) => {
if (response.id === rootLegalEntityId.value) await invalidateRootLegalEntity();
else queryClient.setQueryData(["legalEntity", payload.id], response);
},
...options
});
};
//#endregion
export { useUpdateLegalEntity as t };