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 36 | 4x 72x 72x 16x 72x | 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 { ReconciliationHubMerchantsView } from "../types";
import { buildHubQueryString } from "./buildHubQueryString";
/**
* Fetches the per-merchant reconciliation breakdown (one row per submerchant +
* a Totals row) for the acquirer, scoped by the current period + processor.
* The merchant scope is intentionally NOT sent — this endpoint always groups
* across every merchant in the acquirer.
*/
export const useReconciliationHubMerchants = (
merchantId: number | undefined,
filters: HubFilters,
) => {
const query = buildHubQueryString(filters, { includeMerchant: false });
const { data, isLoading, isFetching } = useQuery(
["reconciliation-hub-merchants", merchantId, query],
async ({ signal }): Promise<ReconciliationHubMerchantsView> =>
await customInstance({
url: `/merchants/${merchantId}/reconciliation-hub/merchants?${query}`,
method: "GET",
signal,
}),
{
enabled: Boolean(merchantId) && isProcessorResolved(filters),
...DEFAULT_QUERY_CONFIG,
},
);
return { data, isLoading, isFetching };
};
|