All files / src/features/GiveRiskProfile/Overview/components RiskEscalationWrapper.tsx

100% Statements 7/7
50% Branches 2/4
100% Functions 1/1
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 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 87 88 89 90                                                  17x   17x                                   17x 16x                               16x   16x                                                  
import { Box, Stack } from "@mui/material";
import {
  CellSignalFullIcon,
  CellSignalLowIcon,
  CellSignalMediumIcon,
} from "@phosphor-icons/react";
import GiveText from "@shared/Text/GiveText";
import { useAppTheme } from "@theme/v2/Provider";
import React from "react";
 
function RiskEscalationWrapper({
  children,
  title,
  subTitle,
  level = "one",
  isEscalation = false,
}: {
  children: React.ReactNode;
  title: string;
  subTitle: string;
  level: "one" | "two" | "three";
  isEscalation?: boolean;
}) {
  const {
    palette: { primitive },
  } = useAppTheme();
 
  const colors = {
    one: {
      border: primitive?.warning[25],
      bgcolor: primitive?.warning[10],
      icon: primitive?.warning[50],
    },
    two: {
      border: primitive?.warning[25],
      bgcolor: primitive?.warning[10],
      icon: primitive?.warning[50],
    },
    three: {
      border: primitive?.error[10],
      bgcolor: primitive?.error[25],
      icon: primitive?.error[100],
    },
  };
 
  if (!isEscalation) return children;
  const icons = {
    one: (
      <CellSignalLowIcon fill={colors?.[level].icon} size={20} weight="fill" />
    ),
    two: (
      <CellSignalMediumIcon
        fill={colors?.[level].icon}
        size={20}
        weight="fill"
      />
    ),
 
    three: (
      <CellSignalFullIcon fill={colors?.[level].icon} size={20} weight="fill" />
    ),
  };
  const Icon = icons[level];
 
  return (
    <Stack
      borderRadius="20px"
      p="12px"
      border={`1.5px solid ${colors?.[level].border}`}
      bgcolor={colors?.[level].bgcolor}
    >
      <Stack mb="16px" gap="8px" flexDirection="row" alignItems="center">
        {Icon}
 
        <Box>
          <GiveText fontWeight={400} fontSize="14px" color="primary">
            {title}
          </GiveText>
          <GiveText fontWeight={400} fontSize="12px" color="secondary">
            {subTitle}
          </GiveText>
        </Box>
      </Stack>
      {children}
    </Stack>
  );
}
 
export default RiskEscalationWrapper;