All files / src/hooks/merchant-api/BankAccounts useGetBankFiles.ts

100% Statements 3/3
100% Branches 0/0
100% Functions 2/2
100% Lines 3/3

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        55x                 139x             25x                      
import { useQuery } from "react-query";
import { customInstance } from "../../../services/api";
import { MERCHANT_SIDE_PANEL_PREVIEW_API_KEYS } from "@features/Merchants/MerchantSidePanel/constants";
 
export const useGetBankFiles = ({
  enabled,
  bankAccountId,
  merchantId,
}: {
  enabled?: boolean;
  bankAccountId?: string | number;
  merchantId?: string | number | null;
}) => {
  return useQuery(
    [
      MERCHANT_SIDE_PANEL_PREVIEW_API_KEYS.GET_BANK_FILES,
      merchantId,
      bankAccountId,
    ],
    async () => {
      return await customInstance({
        url: `/accounts/${merchantId}/files?filter=%3BisUploaded%3Atrue%3BattTypeName%3A%22bank_account%22%3BbankAccountID%3A${bankAccountId}&sort=-updatedAt`,
      });
    },
    {
      enabled: enabled,
      refetchOnWindowFocus: false,
      refetchOnMount: false,
    },
  );
};