2018-08-26 14:23:48 +00:00
|
|
|
import * as React from "react";
|
|
|
|
|
|
|
|
import Grid from "@material-ui/core/Grid";
|
|
|
|
import Typography from "@material-ui/core/Typography";
|
|
|
|
import Button from "@material-ui/core/Button";
|
|
|
|
import Card from '@material-ui/core/Card';
|
|
|
|
import CardActions from '@material-ui/core/CardActions';
|
|
|
|
import CardContent from '@material-ui/core/CardContent';
|
|
|
|
|
2018-09-14 15:19:11 +00:00
|
|
|
import { Link } from "react-router-dom";
|
|
|
|
|
2018-09-06 18:13:29 +00:00
|
|
|
import { ILevel } from "../models/lesson";
|
2018-08-26 14:23:48 +00:00
|
|
|
|
|
|
|
interface IProps {
|
2018-09-06 18:13:29 +00:00
|
|
|
levels: ILevel[];
|
2018-08-26 14:23:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export default class Dashboard extends React.Component<{}> {
|
|
|
|
constructor(props: any) {
|
|
|
|
super(props);
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const small = window.matchMedia("(max-width: 700px)").matches;
|
|
|
|
const cName = small ? "lesson-card-xs" : "lesson-card-lg";
|
|
|
|
|
|
|
|
let key = 0;
|
2018-09-06 18:13:29 +00:00
|
|
|
const levelToCard = (level: ILevel) => {
|
2018-08-26 14:23:48 +00:00
|
|
|
return <Grid item key={key++}>
|
|
|
|
<Card style={{
|
|
|
|
width: small ? window.width - 32 : "300px"
|
|
|
|
}}>
|
|
|
|
<CardContent className={cName}>
|
2018-09-06 18:13:29 +00:00
|
|
|
<Typography variant="title">{`Level ${level.level}`}</Typography>
|
|
|
|
<Typography variant="title" component="p">{level.name}</Typography>
|
2018-08-26 14:23:48 +00:00
|
|
|
<br />
|
|
|
|
<Typography component="p">
|
2018-09-06 18:13:29 +00:00
|
|
|
{level.desc}
|
2018-08-26 14:23:48 +00:00
|
|
|
</Typography>
|
|
|
|
</CardContent>
|
|
|
|
<CardActions>
|
2018-09-14 15:19:11 +00:00
|
|
|
<Button
|
|
|
|
component={Link}
|
|
|
|
to={`/level/${level.level}`}
|
|
|
|
className="lesson-card-btn">
|
2018-08-26 14:23:48 +00:00
|
|
|
Zum Level
|
|
|
|
</Button>
|
|
|
|
</CardActions>
|
|
|
|
</Card>
|
|
|
|
</Grid>;
|
|
|
|
};
|
|
|
|
|
|
|
|
return <Grid container spacing={16} direction="row">
|
2018-09-06 18:13:29 +00:00
|
|
|
{this.props.levels.map(levelToCard)}
|
2018-08-26 14:23:48 +00:00
|
|
|
</Grid>
|
|
|
|
}
|
|
|
|
};
|