This repository has been archived on 2022-03-12. You can view files and clone it, but cannot push or open issues or pull requests.
Lateinicus/src/pages/dashboard.tsx

69 lines
2.4 KiB
TypeScript
Raw Normal View History

2018-08-26 14:23:48 +00:00
import * as React from "react";
2018-09-14 16:53:01 +00:00
import { Link } from "react-router-dom";
2018-09-06 18:05:21 +00:00
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-09-12 17:23:00 +00:00
import SummaryTable from "../components/SummaryTable";
2018-08-26 14:23:48 +00:00
2018-09-06 18:13:29 +00:00
import { ILevel } from "../models/level";
2018-08-26 15:12:07 +00:00
import { ILearner } from "../models/learner";
2018-09-12 17:23:00 +00:00
import { IReviewMetadata } from "../models/review";
2018-08-26 14:23:48 +00:00
interface IProps {
2018-09-06 18:13:29 +00:00
nextLevel: () => ILevel;
getLastReview: () => IReviewMetadata;
2018-09-14 16:53:01 +00:00
getTopTen: () => ILearner[];
2018-08-26 14:23:48 +00:00
}
2018-09-14 16:53:01 +00:00
export default class Dashboard extends React.Component<IProps> {
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:13:29 +00:00
const level = this.props.nextLevel();
2018-09-06 18:05:21 +00:00
return <div>
<Grid container direction={direction} spacing={16}>
<Grid item lg={4}>
<Paper className="paper">
2018-09-06 18:13:29 +00:00
<Typography variant="title">{`Level ${level.level}`}</Typography>
<Typography variant="title" component="p">{level.name}</Typography>
2018-09-06 18:05:21 +00:00
<br />
<Typography component="p">
2018-09-06 18:13:29 +00:00
{level.desc}
2018-09-06 18:05:21 +00:00
</Typography>
2018-09-14 16:53:01 +00:00
<Button
component={Link}
to={`/level/${level.level}`}
className="lesson-card-btn">
2018-09-06 18:05:21 +00:00
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-14 16:53:01 +00:00
<Scoreboard topTen={this.props.getTopTen()} />
2018-09-06 18:05:21 +00:00
</Paper>
</Grid>
<Grid item lg={4}>
<Paper className="paper">
2018-09-12 17:23:00 +00:00
<Typography variant="title">
Letzte Wiederholung
</Typography>
<SummaryTable reviewMeta={this.props.getLastReview} />
2018-09-12 17:23:00 +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
}
};