UNPKG

@adyen/adyen-platform-experience-web

Version:

![Platform Experience header](https://github.com/Adyen/adyen-platform-experience-web/assets/7926613/18094965-9e01-450e-8dc9-ea84e6b22c2b)

26 lines (25 loc) 974 B
import { useFetch as h } from "./useFetch.js"; import { useMemo as s } from "../external/preact/hooks/dist/hooks.module.js"; import { useConfigContext as p } from "../core/ConfigContext/context.js"; import { EMPTY_OBJECT as u } from "../utils/value/constants.js"; const y = (t, i) => { const { getBalanceAccounts: o } = p().endpoints, { data: e, isFetching: m, error: f } = h( s( () => ({ fetchOptions: { enabled: !!o && (i ?? !0), keepPrevData: !0 }, queryFn: async () => o == null ? void 0 : o(u) }), [o] ) ), r = s( () => e == null ? void 0 : e.data.filter((n) => t ? n.id === t : !0), [e == null ? void 0 : e.data, t] ), g = s( () => !!t && !!(e != null && e.data.length) && (r == null ? void 0 : r.length) === 0, [r == null ? void 0 : r.length, e == null ? void 0 : e.data.length, t] ); return { balanceAccounts: r, isBalanceAccountIdWrong: g, isFetching: m, error: f }; }; export { y as default };