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

91.66% Statements 11/12
83.33% Branches 10/12
100% Functions 2/2
91.66% Lines 11/12

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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60                21x           440x 440x 8x           432x             432x             105x           327x 69x           258x           440x        
import { TAG_STATUSES_ENUM } from "@common/TextTag/types";
import InviteSentPanelContent from "../components/InviteSentPanelContent/InviteSentPanelContent";
import SidePanelBody from "../components/SidePanelBody";
import { useCallback } from "react";
import { IPanelLoadingSkeletonProps } from "../components/PanelLoadingSkeleton";
import ProviderPanelBody from "../components/ProviderPanelBody";
import RiskPanelBody from "../components/RiskViewPanelBody";
 
const useGetPanelContent = (
  status?: TAG_STATUSES_ENUM | null,
  isProvider?: boolean,
  isRiskView?: boolean,
  isPendingTab?: boolean,
) => {
  const getPanelContent = useCallback(() => {
    if (isProvider) {
      return {
        panelBody: <ProviderPanelBody />,
        skeletonVariant: "provider" as IPanelLoadingSkeletonProps["variant"],
      };
    }
 
    Iif (status === TAG_STATUSES_ENUM.INVITE && !isPendingTab) {
      return {
        panelBody: <InviteSentPanelContent />,
        skeletonVariant: `invite_sent`,
      };
    }
 
    if (
      [
        TAG_STATUSES_ENUM.KYB,
        TAG_STATUSES_ENUM.UNDERWRITING,
        TAG_STATUSES_ENUM.SPONSOR,
      ].includes(status as TAG_STATUSES_ENUM)
    ) {
      return {
        panelBody: <SidePanelBody />,
        skeletonVariant: `underwriting`,
      };
    }
 
    if (isRiskView && !isProvider) {
      return {
        panelBody: <RiskPanelBody />,
        skeletonVariant: "underwriting",
      };
    }
 
    return {
      panelBody: <SidePanelBody />,
      skeletonVariant: `default`,
    };
  }, [status, isProvider, isRiskView, isPendingTab]);
 
  return getPanelContent();
};
 
export default useGetPanelContent;