All files / src/components/common/AssignMenu MobileAssigneeItem.tsx

22.22% Statements 2/9
0% Branches 0/4
0% Functions 0/3
25% Lines 2/8

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                              76x                                                                           76x                              
import { TickIcon } from "@assets/icons";
import { Image } from "@common/StyledImage/Image";
import { TruncateText } from "@common/Text";
import { Stack, styled } from "@mui/material";
import { palette } from "@palette";
import React from "react";
 
type MobileAssigneeItemProps = {
  name: string;
  image: string;
  selected: boolean;
  handleDeselect: () => void;
  onClick: () => void;
}
 
const MobileAssigneeItem = ({
  name,
  image,
  selected,
  handleDeselect,
  onClick,
}: MobileAssigneeItemProps) => {
 
  const handleClick = (event: React.MouseEvent<HTMLDivElement>) => {
    event.stopPropagation();
    if (selected) {
      handleDeselect();
    } else {
      onClick();
    }
  }
 
  return (
    <Container onClick={handleClick}>
      <Image width={32} height={32} src={image} alt={name} />
      <TruncateText
        lineClamp={1}
        color={palette.black[100]}
        lineHeight="16.8px"
        fontWeight="book"
        flexGrow={1}
      >
        {name}
      </TruncateText>
      {selected && (
        <Stack width={32} height={32} alignSelf="flex-end" alignItems="center">
          <TickIcon stroke={palette.black[100]} width={28} height={28} />
        </Stack>
      )}
    </Container>
  )
}
 
const Container = styled(Stack)(() => ({
  flexDirection: "row",
  justifyContent: "stretch",
  alignItems: "center",
  gap: "2px",
  padding: "12px 8px",
  borderRadius: "4px",
  background: "inherit",
 
  "&:active": {
    background: palette.liftedWhite[100],
  },
}))
 
export default MobileAssigneeItem;