All files / src/features/Merchants/MerchantSidePanel/hooks useGetPAHFiles.tsx

100% Statements 3/3
100% Branches 2/2
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                  22x 56x     22x                      
import { useQuery } from "react-query";
import { MERCHANT_SIDE_PANEL_PREVIEW_API_KEYS } from "@features/Merchants/MerchantSidePanel/constants";
import { customInstance } from "@services/api";
 
type Props = {
  enabled?: boolean;
  merchantId?: string | number | null;
};
 
export const useGetPAHFiles = ({ enabled, merchantId }: Props) => {
  return useQuery(
    [MERCHANT_SIDE_PANEL_PREVIEW_API_KEYS.GET_PAH_FILES, merchantId],
    async () => {
      return await customInstance({
        url: `/accounts/${merchantId}/files?filter=(isUploaded:true%3B(attTypeName:"account_owner_selfie",attTypeName:"account_owner"))&sort=-updatedAt`,
      });
    },
    {
      enabled: enabled && !!merchantId,
      refetchOnWindowFocus: false,
      refetchOnMount: false,
    },
  );
};