From 315adeb5e2012b7f7bcfcd1478f9d6dd2cc1092d Mon Sep 17 00:00:00 2001 From: Noah Loomans Date: Tue, 26 Jun 2018 21:46:41 +0200 Subject: Update code to comply with new styling --- .../react/components/container/WeekSelector.js | 39 +++++++++++++--------- 1 file changed, 24 insertions(+), 15 deletions(-) (limited to 'src/client/react/components/container/WeekSelector.js') 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 (
- -
{this.getWeekText()}
- + +
+ {this.getWeekText()} +
+
); } -- cgit v1.1