aboutsummaryrefslogtreecommitdiff
path: root/src/components/SolutionCard/SolutionCard.js
blob: 5f3e5b481c9f758b4cd6caddc5eb223f79efaf52 (plain)
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
import React from 'react';

import {
  Typography,
  Card,
  CardHeader,
  CardContent,
  IconButton,
  Avatar,
  Grid,
} from "@material-ui/core";

import { makeStyles } from "@material-ui/core/styles";
import TimerIcon from '@material-ui/icons/Timer';
import MoreVertIcon from '@material-ui/icons/MoreVert';


const useStyles = makeStyles(theme => ({
  root: {
    padding: theme.spacing(1),

    '& .MuiTypography-h3': {
      color: theme.palette.secondary.main,
      margin: theme.spacing(2),
    },
  },
}));

const SolutionCard = ({ solution }) => {
  const classes = useStyles();

  const author = solution.author? solution.author.username : 'anonymous';
  return (
    <Card elevation={5} className={classes.root}>
      <CardHeader
        avatar={
          author === 'anonymous'?
            (<Avatar/>)
            :
            (<Avatar>{author[0].toUpperCase()}</Avatar>)
        }
        title={author}
        subheader="04.01.2020 13:20"
        action={(
          <IconButton>
            <MoreVertIcon />
          </IconButton>
        )}
      />
      <CardContent>
        <Grid container direction="row" justify="center" alignItems="center">
          <Grid item>
            <TimerIcon/>
          </Grid>
          <Grid item>
            <Typography variant="h3">
              { solution.result }
            </Typography>
          </Grid>
        </Grid>
      </CardContent>
    </Card>
  )
};

export default SolutionCard;