All files / src/components/ProfileMenu/modals ProfileModalSidebar.tsx

100% Statements 10/10
100% Branches 2/2
100% Functions 6/6
100% Lines 9/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 87 88 89 90 91 92 93                                7x 503x   503x                                                                             2012x     55x                   7x 6043x 2012x                   503x                  
import { Text, TruncateText } from "@common/Text";
import { ITextProps } from "@common/Text/Text";
import ProfilePicture from "@components/CustomBreadcrumbsPage/ components/ProfilePicture";
import useUserReducer from "@hooks/Reducers/useUserReducer";
import { Box, Stack, styled } from "@mui/material";
import { palette } from "@palette";
import { TProfileTab } from "./types";
 
type Props = {
  sidebarList: {
    tab: TProfileTab;
    active: boolean;
  }[];
  handleSelectTab: (tab: TProfileTab) => void;
};
 
const ProfileModalSidebar = ({ sidebarList, handleSelectTab }: Props) => {
  const { globalName, email } = useUserReducer();
 
  return (
    <Container data-testid="profile-modal-sidebar">
      <Stack direction="row" p="8px 0px" spacing={1} mb={2}>
        <ProfilePicture
          sx={{
            cursor: "default",
            "&:hover": {
              borderColor: "transparent",
              "& * > path": {
                fill: palette.neutral.white,
              },
            },
          }}
        />
        <Stack spacing={0.5}>
          <TruncateText
            lineClamp={1}
            color={palette.neutral[80]}
            fontWeight="book"
            lineHeight="16.8px"
          >
            {globalName?.firstName} {globalName?.lastName}
          </TruncateText>
          <TruncateText
            lineClamp={1}
            fontSize={12}
            color={palette.neutral[70]}
            fontWeight="book"
            lineHeight="16.8px"
            sx={{
              wordBreak: "break-all",
            }}
          >
            {email}
          </TruncateText>
        </Stack>
      </Stack>
      <Stack spacing={1.5}>
        {sidebarList.map((item) => (
          <Tab
            key={item.tab}
            active={item.active}
            onClick={() => handleSelectTab(item.tab)}
          >
            {item.tab}
          </Tab>
        ))}
      </Stack>
    </Container>
  );
};
 
const Tab = styled(Text, {
  shouldForwardProp: (prop) => prop !== "active",
})<ITextProps & { active: boolean }>(({ active }) => ({
  color: palette.neutral[70],
  fontWeight: 350,
  cursor: "pointer",
  ...(active && {
    color: palette.neutral[100],
    borderRight: `4px solid ${palette.neutral[100]}`,
  }),
}));
 
const Container = styled(Box)(() => ({
  padding: "24px 0px 24px 16px",
  borderRight: `1px solid ${palette.neutral[10]}`,
  background: "transparent",
 
  height: "100%",
}));
 
export default ProfileModalSidebar;