2018-08-26 14:23:48 +00:00
|
|
|
import * as React from "react";
|
|
|
|
|
2018-09-06 18:05:21 +00:00
|
|
|
import { Redirect } from "react-router";
|
|
|
|
|
2018-08-26 14:23:48 +00:00
|
|
|
import Grid from "@material-ui/core/Grid";
|
|
|
|
import Typography from "@material-ui/core/Typography";
|
|
|
|
import Button from "@material-ui/core/Button";
|
2018-08-26 15:12:07 +00:00
|
|
|
import Paper from "@material-ui/core/Paper";
|
|
|
|
|
|
|
|
import Scoreboard from "../components/scoreboard";
|
2018-08-26 14:23:48 +00:00
|
|
|
|
|
|
|
import { ILesson } from "../models/lesson";
|
2018-08-26 15:12:07 +00:00
|
|
|
import { ILearner } from "../models/learner";
|
2018-08-26 14:23:48 +00:00
|
|
|
|
|
|
|
interface IProps {
|
2018-09-06 18:05:21 +00:00
|
|
|
nextLesson: () => ILesson;
|
2018-08-26 15:12:07 +00:00
|
|
|
learners: ILearner[];
|
2018-08-26 14:23:48 +00:00
|
|
|
}
|
|
|
|
|
2018-09-06 18:05:21 +00:00
|
|
|
interface IState {
|
|
|
|
toLevel: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
export default class Dashboard extends React.Component<IProps, IState> {
|
|
|
|
constructor(props: any) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
toLevel: -1;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-08-26 14:23:48 +00:00
|
|
|
render() {
|
|
|
|
const small = window.matchMedia("(max-width: 700px)").matches;
|
2018-08-26 15:12:07 +00:00
|
|
|
const direction = small ? "column" : "row";
|
2018-08-26 14:23:48 +00:00
|
|
|
|
2018-09-06 18:05:21 +00:00
|
|
|
const lesson = this.props.nextLesson();
|
|
|
|
|
|
|
|
return <div>
|
|
|
|
{
|
|
|
|
this.state.toLevel !== -1 ? (
|
|
|
|
<Redirect to={`/level/${this.state.toLevel}`} />
|
|
|
|
) : undefined
|
|
|
|
}
|
|
|
|
<Grid container direction={direction} spacing={16}>
|
|
|
|
<Grid item lg={4}>
|
|
|
|
<Paper className="paper">
|
|
|
|
<Typography variant="title">{`Level ${lesson.level}`}</Typography>
|
|
|
|
<Typography variant="title" component="p">{lesson.name}</Typography>
|
|
|
|
<br />
|
|
|
|
<Typography component="p">
|
|
|
|
{lesson.desc}
|
|
|
|
</Typography>
|
|
|
|
<Button className="lesson-card-btn"
|
|
|
|
onClick={() => {
|
|
|
|
this.setState({
|
|
|
|
toLevel: lesson.level,
|
|
|
|
});
|
|
|
|
}}>
|
|
|
|
Zum Level
|
|
|
|
</Button>
|
|
|
|
</Paper>
|
|
|
|
</Grid>
|
|
|
|
<Grid item lg={4}>
|
|
|
|
<Paper className="paper">
|
|
|
|
<Typography variant="title" component="p">
|
|
|
|
Rangliste: Top 10
|
2018-08-26 15:12:07 +00:00
|
|
|
</Typography>
|
2018-08-26 14:23:48 +00:00
|
|
|
|
2018-09-06 18:05:21 +00:00
|
|
|
<Scoreboard learners={this.props.learners.slice(0, 10)} />
|
|
|
|
</Paper>
|
|
|
|
</Grid>
|
|
|
|
<Grid item lg={4}>
|
|
|
|
<Paper className="paper">
|
|
|
|
Some stuff
|
2018-08-26 15:12:07 +00:00
|
|
|
</Paper>
|
2018-09-06 18:05:21 +00:00
|
|
|
</Grid>
|
2018-08-26 15:12:07 +00:00
|
|
|
</Grid>
|
2018-09-06 18:05:21 +00:00
|
|
|
</div>;
|
2018-08-26 14:23:48 +00:00
|
|
|
}
|
|
|
|
};
|