All files / src/features/Merchants/MerchantSidePanel/WithRepository/Challenges/Modals/components ChallengeDiscussion.tsx

0% Statements 0/8
0% Branches 0/2
0% Functions 0/5
0% Lines 0/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                                                                                                                                                                         
import { AvatarGroup, Stack } from "@mui/material";
import { CaretRightIcon } from "@phosphor-icons/react";
import GiveAvatar from "@shared/Avatar/GiveAvatar";
import GiveText from "@shared/Text/GiveText";
import { styled } from "@theme/v2/Provider";
 
type Props = {
  title: string;
  messageImages: string[];
  commentsCount: number;
  lastComment: string;
  onClick: () => void;
};
 
const ChallengeDiscussion = ({
  title,
  messageImages,
  commentsCount,
  lastComment,
  onClick,
}: Props) => {
  return (
    <Container onClick={onClick}>
      <Stack gap="8px">
        <Stack gap="16px" direction="row" alignItems="center">
          <GiveText>{title}</GiveText>
          <StyledAvatarGroup
            renderSurplus={(surplus) => (
              <GiveText variant="bodyS" color="secondary">
                {surplus.toString()[0]}
              </GiveText>
            )}
            max={4}
          >
            {messageImages?.map((img, idx) => (
              <GiveAvatar sx={{ zIndex: -idx }} key={idx} imageUrl={img} />
            ))}
          </StyledAvatarGroup>
        </Stack>
        <Stack gap="16px" direction="row" alignItems="center">
          <GiveText variant="bodyS" color="secondary">
            {commentsCount} comments
          </GiveText>
          {lastComment && (
            <GiveText variant="bodyS" color="secondary">
              Last comment: {lastComment}
            </GiveText>
          )}
        </Stack>
      </Stack>
      <CaretRightIcon />
    </Container>
  );
};
 
export default ChallengeDiscussion;
 
const StyledAvatarGroup = styled(AvatarGroup)(({ theme }) => ({
  "& .MuiAvatar-root": {
    zIndex: 100,
    width: "24px",
    height: "24px",
    "&.MuiAvatarGroup-avatar": {
      backgroundColor: "transparent",
    },
    "& .MuiTypography-root": {
      color: theme.palette.text?.primary,
      fontSize: "14px",
      lineHeight: "20px",
      fontWeight: "400",
    },
  },
}));
 
const Container = styled(Stack)(({ theme }) => ({
  boxShadow: "none",
  border: `1px solid ${theme.palette.border?.primary}`,
  borderRadius: "20px",
  padding: "20px",
  cursor: "pointer",
  flexDirection: "row",
  alignItems: "center",
  justifyContent: "space-between",
}));