All files / src/hooks/enterprise-api/merchants useFindBusinessProfileById.tsx

85.71% Statements 6/7
83.33% Branches 5/6
100% Functions 2/2
100% Lines 6/6

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        14x             67x     3x 3x 3x               67x        
import { QKEY_BUSINESS_PROFILE_BY_ID } from "@constants/queryKeys";
import { getLegalEntityByID } from "@services/api/businessProfile";
import { useQuery } from "react-query";
 
const useFindBusinessProfileById = ({
  id,
  merchantId,
}: {
  id?: number;
  merchantId?: number;
}) => {
  const { data, isLoading, isError, refetch } = useQuery(
    [QKEY_BUSINESS_PROFILE_BY_ID, id, merchantId],
    async () => {
      Iif (!id || !merchantId) return;
      const data = await getLegalEntityByID(id, merchantId);
      return data;
    },
    {
      refetchOnWindowFocus: false,
      enabled: !!id && !!merchantId,
    },
  );
 
  return { data, isLoading, isError, refetch };
};
 
export default useFindBusinessProfileById;