All files / src/features/Merchants/MerchantSidePanel/GiveMerchantFile/hooks useGetLinkedLegalEntity.ts

60% Statements 3/5
0% Branches 0/1
50% Functions 1/2
60% Lines 3/5

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 37 38 39              107x                 801x                                       801x    
import { useQuery } from "react-query";
import {
  GENERAL_STALE_TIME_15,
  MERCHANT_SIDE_PANEL_PREVIEW_API_KEYS,
} from "../../constants";
import { customInstance } from "@services/api";
 
export const useGetLinkedLegalEntity = ({
  merchantID,
  pendingLegalEntityID,
  enabled = true,
}: {
  merchantID?: number;
  pendingLegalEntityID?: number;
  enabled?: boolean;
}) => {
  const pendingLegalEntityQuery = useQuery(
    [
      MERCHANT_SIDE_PANEL_PREVIEW_API_KEYS.GET_LEGAL_ENTITY,
      merchantID,
      pendingLegalEntityID,
    ],
    async () => {
      const response = await customInstance({
        url: `merchants/${merchantID}/legal-entities/${pendingLegalEntityID}`,
      });
      return response;
    },
    {
      refetchOnWindowFocus: false,
      refetchOnMount: false,
      staleTime: GENERAL_STALE_TIME_15,
      enabled: enabled,
    },
  );
 
  return pendingLegalEntityQuery;
};