All files / src/features/Merchants/MerchantSidePanel/GiveMerchantFile/businessOwners GivePepStatusChip.tsx

88.88% Statements 8/9
78.57% Branches 11/14
100% Functions 2/2
88.88% Lines 8/9

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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86                          59x           61x 61x             61x       61x     61x   61x                                 59x                                                                
import { PEPStatusType } from "@components/Merchants/MerchantPreview/PEP/types";
import GiveChip from "@shared/Chip/GiveChip";
import { memo, useMemo } from "react";
 
type Props = {
  ownerPepStatus?: PEPStatusType;
  EndIcon?: JSX.Element;
  pepStatusSetByUnderwriter?: boolean;
  manualPepStatus?: PEPStatusType;
  isSidePanel?: boolean;
  withPEP?: boolean;
};
 
const GivePepStatusChip = ({
  ownerPepStatus = "pending",
  manualPepStatus,
  pepStatusSetByUnderwriter,
  withPEP,
}: Props) => {
  const status = useMemo(() => {
    Iif (
      (ownerPepStatus === "clear" || manualPepStatus === "clear") &&
      pepStatusSetByUnderwriter
    )
      return "clear_manually";
 
    const statusManually =
      ownerPepStatus === "clear" || manualPepStatus === "clear"
        ? "clear_manually"
        : "confirmed_match";
 
    return manualPepStatus ? statusManually : ownerPepStatus;
  }, [ownerPepStatus, manualPepStatus, pepStatusSetByUnderwriter]);
 
  const { color, label } = PEPStatus[status];
 
  return (
    <GiveChip
      variant="light"
      size="small"
      color={color}
      label={withPEP ? `PEP ${label}` : label}
      sx={{ marginRight: "5px", maxHeight: "22px" }}
    />
  );
};
 
type StatusObject = {
  label: string;
  color: "default" | "success" | "warning" | "blue" | "error";
};
type ExtendedPEPStatusType = PEPStatusType | "disabled_pending";
 
const PEPStatus: Record<ExtendedPEPStatusType, StatusObject> = {
  pending: {
    label: "Pending",
    color: "default",
  },
  possible_match: {
    label: "Possible Match",
    color: "warning",
  },
  clear: {
    label: "Clear",
    color: "success",
  },
  clear_manually: {
    label: "Manually Cleared",
    color: "success",
  },
  confirmed_match: {
    label: "Confirmed Match",
    color: "error",
  },
  disabled_pending: {
    label: "Pending",
    color: "default",
  },
  manually_cleared: {
    label: "Manually Cleared",
    color: "success",
  },
};
 
export default memo(GivePepStatusChip);