diff options
author | Noah Loomans <noahloomans@gmail.com> | 2018-06-26 21:46:41 +0200 |
---|---|---|
committer | Noah Loomans <noahloomans@gmail.com> | 2018-06-26 21:46:41 +0200 |
commit | 315adeb5e2012b7f7bcfcd1478f9d6dd2cc1092d (patch) | |
tree | 17ecdc44866845b679ca69337041856df3cab33c /src/client/react/components/container/WeekSelector.js | |
parent | d95009ed42a3a94c947bccbed8a436cbf6b9306c (diff) |
Update code to comply with new styling
Diffstat (limited to 'src/client/react/components/container/WeekSelector.js')
-rw-r--r-- | src/client/react/components/container/WeekSelector.js | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/src/client/react/components/container/WeekSelector.js b/src/client/react/components/container/WeekSelector.js index a8f5936..80ad754 100644 --- a/src/client/react/components/container/WeekSelector.js +++ b/src/client/react/components/container/WeekSelector.js @@ -39,40 +39,49 @@ class WeekSelector extends React.Component { }; getWeekText() { - const week = weekFromLocation(this.props.location); + const { location } = this.props; + const week = weekFromLocation(location); const currentWeek = moment().week(); - if (currentWeek === week) { - return `Huidige week • ${week}`; - } else if (currentWeek + 1 === week) { - return `Volgende week • ${week}`; - } else if (currentWeek - 1 === week) { - return `Vorige week • ${week}`; + switch (week) { + case currentWeek: + return `Huidige week • ${week}`; + case currentWeek + 1: + return `Volgende week • ${week}`; + case currentWeek - 1: + return `Vorige week • ${week}`; + default: + return `Week ${week}`; } - - return `Week ${week}`; } updateWeek(change) { - const week = weekFromLocation(this.props.location); + const { location, history } = this.props; + const week = weekFromLocation(location); const newWeek = purifyWeek(week + change); const isCurrentWeek = moment().week() === newWeek; setWeek( isCurrentWeek ? undefined : newWeek, - this.props.location, - this.props.history, + location, + history, ); } render() { return ( <div className="WeekSelector"> - <button onClick={() => this.updateWeek(-1)}><ArrowBackIcon /></button> - <div className="text">{this.getWeekText()}</div> - <button onClick={() => this.updateWeek(+1)}><ArrowForwardIcon /></button> + <button type="button" onClick={() => this.updateWeek(-1)}> + <ArrowBackIcon /> + </button> + <div className="text"> + {this.getWeekText()} + </div> + <button type="button" onClick={() => this.updateWeek(+1)}> + <ArrowForwardIcon /> + </button> </div> ); } |