All files / src/components/Merchants/CreateMerchantPanel/modals/utils index.ts

100% Statements 11/11
100% Branches 4/4
100% Functions 1/1
100% Lines 10/10

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    92x 7x   5x 5x               2x   3x   3x 1x     2x       92x  
import { customInstance } from "@services/api";
 
export const checkTaxIDAvailability = async (value?: string) => {
  if (!value) return { isDeclinedOrNotApproved: false, isLinked: false, id: 0 };
 
  try {
    const response = await customInstance({
      url: "/legal-entities/exists-with-approval",
      method: "POST",
      data: {
        taxID: value,
      },
    });
 
    return { isDeclinedOrNotApproved: false, isLinked: true, id: response?.id };
  } catch (error: any) {
    const errorMessage = error?.response?.data?.message;
 
    if (errorMessage === "Legal entity is not approved") {
      return { isDeclinedOrNotApproved: true, isLinked: false };
    }
 
    return { isDeclinedOrNotApproved: false, isLinked: false };
  }
};
 
export const DOWNLOAD_MERCHANT_AGREEMENT = "Download Merchant Agreement";