All files / src/sections/ViewWinner WinnerListItem.tsx

70% Statements 7/10
0% Branches 0/6
0% Functions 0/1
70% Lines 7/10

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            2x               2x             2x           2x           2x             2x                           2x                                                            
import { Box, Paper } from "@mui/material";
import { useTheme } from "@mui/material/styles";
import useMediaQuery from "@mui/material/useMediaQuery";
import { Text } from "@common/Text";
import { palette } from "@palette";
 
const paperStyle = {
  padding: "12px",
  borderRadius: "8px",
  display: "flex",
  justifyContent: "space-between",
  mb: "8px",
};
 
const nameStyle = {
  color: palette.neutral[800],
  fontSize: 16,
  fontWeight: "600",
  mb: "4px",
};
 
const dateStyle = {
  color: palette.neutral[600],
  fontSize: 14,
  fontWeight: "500",
};
 
const emailStyle = {
  color: palette.neutral[600],
  fontSize: 14,
  fontWeight: "400",
};
 
const productStyle = {
  color: palette.neutral[800],
  fontSize: 14,
  fontWeight: "600",
  mb: "4px",
};
 
const rightBoxStyle = {
  display: "flex",
  flexDirection: "column",
  alignItems: "flex-end",
};
 
type WinnerListItemProps = {
  name: string;
  date: string;
  email: string;
  product: string;
  id: string;
};
 
const WinnerListItem: React.FC<WinnerListItemProps> = ({
  name,
  date,
  email,
  product,
  id,
}: WinnerListItemProps) => {
  const theme = useTheme();
  const isDesktop = useMediaQuery(theme.breakpoints.up("sm"));
 
  return (
    <Paper
      elevation={3}
      sx={{ ...paperStyle, ...(!isDesktop && { display: "block" }) }}
    >
      <Box sx={{ mb: isDesktop ? 0 : "12px" }}>
        <Text sx={nameStyle}>
          {name} <span style={dateStyle}>{date}</span>
        </Text>
        <Text style={emailStyle}>{email}</Text>
      </Box>
      <Box sx={{ ...(isDesktop && rightBoxStyle) }}>
        <Text style={productStyle}>{product}</Text>
        <Text style={emailStyle}>{id}</Text>
      </Box>
    </Paper>
  );
};
 
export default WinnerListItem;