All files / src/sections/ViewWinner ViewWinner.tsx

25% Statements 2/8
0% Branches 0/6
0% Functions 0/4
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 70 71 72 73 74 75 76 77 78 79 80                              2x                                                                             2x                                                  
import { Button } from "@common/Button";
import { Box, Grid } from "@mui/material";
import { Modal } from "@common/Modal";
import { Text } from "@common/Text";
import { palette } from "@palette";
import { useTheme } from "@mui/material/styles";
import useMediaQuery from "@mui/material/useMediaQuery";
import WinnerListItem from "./WinnerListItem";
 
type ViewWinnerProps = {
  open: boolean;
  setOpen: (open: boolean) => void;
  title: string;
};
 
const ViewWinner = ({ open, setOpen, title }: ViewWinnerProps) => {
  const theme = useTheme();
  const isDesktop = useMediaQuery(theme.breakpoints.up("sm"));
 
  return (
    <Modal
      open={open}
      title={`Winner${winners.length > 1 ? "s" : ""} Draw Result`}
      onClose={() => setOpen(false)}
      actions={<Button onClick={() => setOpen(false)}>Close</Button>}
    >
      <Text
        sx={{
          color: palette.neutral[800],
          fontSize: isDesktop ? "24px" : "20px",
          fontWeight: 600,
          mb: "8px",
        }}
      >
        Winner{winners.length > 1 && "s"} of {title}
      </Text>
      <Text
        sx={{
          color: palette.neutral[600],
          fontSize: "14px",
          fontWeight: 400,
          mb: "24px",
        }}
      >
        An email was sent to all the participants.
      </Text>
 
      {winners.map(winner => (
        <WinnerListItem {...winner} key={winner.id} />
      ))}
    </Modal>
  );
};
 
const winners = [
  {
    name: "Ump Ump1331",
    date: "Sep 2nd, 2020",
    email: "ump_ump1331@buddyteal.com",
    product: "iPhone 14 Pro 512GB",
    id: "28fa325e-ead7-4f95-9aaa-7779ae8f1780",
  },
  {
    name: "Ump Ump1331",
    date: "Sep 2nd, 2020",
    email: "ump_ump1331@buddyteal.com",
    product: "Apple Watch 7",
    id: "28fa325e-ead7-4f95-9aaa-7779ae8f1782",
  },
  {
    name: "Ump Ump1331",
    date: "Sep 2nd, 2020",
    email: "ump_ump1331@buddyteal.com",
    product: "Apple Air Tag",
    id: "28fa325e-ead7-4f95-9aaa-7779ae8f1783",
  },
];
 
export default ViewWinner;