All files / src/componentsV2/AccountProfile/Security Header.tsx

100% Statements 5/5
75% Branches 12/16
100% Functions 2/2
100% Lines 4/4

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                                              8x 8x 8x                                                                                 2x              
import { Box } from "@mui/material";
import { Stack } from "@mui/material";
import {
  CheckCircleIcon,
  LaptopIcon,
  WarningCircleIcon,
} from "@phosphor-icons/react";
import GiveText from "@shared/Text/GiveText";
import { styled, useAppTheme } from "@theme/v2/Provider";
 
interface HeaderProps {
  title: string | React.ReactElement;
  subtitle?: string;
  days?: number;
  isEmpty?: boolean;
}
 
export default function Header({
  title,
  subtitle,
  days,
  isEmpty,
}: HeaderProps) {
  const { palette } = useAppTheme();
  const isOver90Days = days && days > 90;
  return (
    <>
      {typeof title === "string" ? (
        <GiveText variant="h5">{title}</GiveText>
      ) : (
        title
      )}
      <Stack gap="8px">
        {days !== undefined ? (
          <Stack direction="row" alignItems="center" gap="8px">
            {isOver90Days ? (
              <WarningCircleIcon color={palette.primitive?.warning[50]} />
            ) : (
              <CheckCircleIcon color={palette.primitive?.blue[100]} />
            )}
            <GiveText
              variant="bodyS"
              color={isOver90Days ? "warning1" : "link"}
            >
              Last updated {days} {days > 1 ? "days" : "day"} ago
            </GiveText>
          </Stack>
        ) : null}
        {subtitle ? (
          <GiveText variant="bodyXS" color="secondary">
            {subtitle}
          </GiveText>
        ) : null}
        {isEmpty && (
          <Stack spacing={1} alignItems="center" my={3.5}>
            <EmptyIconContainer>
              <LaptopIcon size={20} />
            </EmptyIconContainer>
            <GiveText variant="bodyS">No devices</GiveText>
          </Stack>
        )}
      </Stack>
    </>
  );
}
 
const EmptyIconContainer = styled(Box)(({ theme }) => ({
  padding: "10px",
  borderRadius: "50%",
  background: theme.palette?.primitive?.transparent?.["darken-5"],
  width: "40px",
  height: "40px",
}));