Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | 2x 37x 37x 9x 37x | import { DEFAULT_QUERY_CONFIG } from "@components/VirtualList/hooks/queries";
import { customInstance } from "@services/api";
import { useQuery } from "react-query";
import { HubFilters, isProcessorResolved } from "../useHubFilters";
import { ReconciliationHubView } from "../types";
import { buildHubQueryString } from "./buildHubQueryString";
/**
* Fetches the single-row reconciliation-hub summary (KPIs, cash position,
* financial details, per-brand cost matrix) for the acquirer, scoped by the
* current period + processor + (optional) merchant.
*/
export const useReconciliationHub = (
merchantId: number | undefined,
filters: HubFilters,
) => {
const query = buildHubQueryString(filters, { includeMerchant: true });
const { data, isLoading, isFetching, isError, refetch } = useQuery(
["reconciliation-hub", merchantId, query],
async ({ signal }): Promise<ReconciliationHubView> =>
await customInstance({
url: `/merchants/${merchantId}/reconciliation-hub?${query}`,
method: "GET",
signal,
}),
{
enabled: Boolean(merchantId) && isProcessorResolved(filters),
...DEFAULT_QUERY_CONFIG,
},
);
return { data, isLoading, isFetching, isError, refetch };
};
|