feat: Display a message when the user hits the max level

This commit is contained in:
Alexander Polynomdivision 2018-10-09 20:24:20 +02:00
parent 5c3603f595
commit ede271f604

View File

@ -56,7 +56,16 @@ export default class Drawer extends React.Component<IProps> {
}
render() {
const level = userScoreToLevel(this.props.user.score);
const { score } = this.props.user;
const level = userScoreToLevel(score);
// Determine whether we hit the maximum level
const maxLevel = score >= level.levelCap;
const scoreStr = maxLevel ? (
`${score}`
) : (
`${score} / ${level.levelCap}`
);
return (
<div>
@ -80,7 +89,7 @@ export default class Drawer extends React.Component<IProps> {
color="inherit"
buttonRef={node => this.scoreBtnRef = node}
onClick={this.toggleScorePopover}>
{`${this.props.user.score} / ${level.levelCap}`}
{scoreStr}
</Button>
) : undefined
}
@ -98,9 +107,17 @@ export default class Drawer extends React.Component<IProps> {
onClose={this.closeScorePopover}>
<div className="content">
<Typography variant="headline">Du bist: {level.name}</Typography>
{
maxLevel ? (
<Typography variant="subheading">
Veni Vidi Vici...
</Typography>
) : (
<Typography variant="subheading">
Dir fehlen noch <b>{level.levelCap - this.props.user.score}</b> Erfahrungspunkte bis zum nächsten Level
</Typography>
)
}
</div>
</Popover>
</Toolbar>