UNPKG

@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.

46 lines (45 loc) 2.16 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] = "a0ee6edb-5477-4002-b767-31a9660cd539", e._sentryDebugIdIdentifier = "sentry-dbid-a0ee6edb-5477-4002-b767-31a9660cd539"); } catch (e) {} import { o as createLogger } from "./translation-BFxyJ1c5.js"; import { s as useApiContext } from "./http-D1NDkBxF.js"; import { useCallback } from "preact/hooks"; import { useQueryClient } from "@tanstack/preact-query"; //#region src/api/invalidateRootLegalEntity.ts var logger = createLogger(); /** * If updating the root LE, a bunch of other queries need to be invalidated too. * This is an easy way for us to keep track of them. * * Consumers can then simply call the function returned by {@link useInvalidateRootLegalEntity}, * and know that all dependent queries will also be invalidated. * * *Note: this doesn't mean that all of those queries will immediately be refetched; invalidated * queries will only refetch when they are active (mounted) on the page.* */ var QUERIES_TO_INVALIDATE_WHEN_ROOT_LE_IS_INVALIDATED = [ "businessLines", "onboardingStatus", "pciStatus", "pciQuestionnaireList", "scenarios", "taskStatus", "taskTypes", "taxClassification", "termsOfServiceAcceptanceInfos", "termsOfServiceStatus", "transferInstruments" ]; /** * Returns a function which invalidates the root legal entity and all of its dependent queries. * * See {@link QUERIES_TO_INVALIDATE_WHEN_ROOT_LE_IS_INVALIDATED}. */ var useInvalidateRootLegalEntity = () => { const queryClient = useQueryClient(); const { rootLegalEntityId } = useApiContext(); return useCallback(() => Promise.all([queryClient.invalidateQueries({ queryKey: ["legalEntity", rootLegalEntityId.value] }), queryClient.invalidateQueries({ predicate: ({ queryKey }) => QUERIES_TO_INVALIDATE_WHEN_ROOT_LE_IS_INVALIDATED.includes(queryKey[0]) })]).catch(logger.error), [rootLegalEntityId.value, queryClient]); }; //#endregion export { useInvalidateRootLegalEntity as t };