All files / src/features/Merchants/MerchantSidePanel/ApprovalFlowPanel/hooks useTaskMissingItems.tsx

90% Statements 9/10
75% Branches 3/4
100% Functions 4/4
100% Lines 8/8

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    28x         28x 3279x     28x     1x         1x   1x       5x          
import { customInstance } from "@services/api";
 
const ITEM_NAME_MAP = {
  "Legal Principal": "Business Owner",
  "Legal Entity": "Business Profile",
} as const;
 
export const useTaskMissingItems = (merchantId: number) => {
  return { getMissingItems: () => getMissingItems(merchantId) };
};
 
export const getMissingItems = async (
  merchantId: number,
): Promise<string[]> => {
  const response = await customInstance({
    url: `/merchants/${merchantId}/tasks/missing-items`,
    method: "GET",
  });
 
  Iif (!Array.isArray(response)) return [];
 
  return Array.from(
    new Set(
      response.map(
        ({ ItemName }) =>
          ITEM_NAME_MAP[ItemName as keyof typeof ITEM_NAME_MAP] || ItemName,
      ),
    ),
  );
};