aboutsummaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
authorBilal ayachi <bilal.ayachi@hetmml.nl>2018-02-02 22:10:30 +0100
committerBilal ayachi <bilal.ayachi@hetmml.nl>2018-02-02 22:10:30 +0100
commit82ba6eb9c363d79b5efd084ef56e86cf6d2b41bf (patch)
tree3bd9e931b6883435a2453bb3fd63e8573ef95219 /src/client
parentf7c886a6e1e9f82873747e8fa7ae732ba57665e4 (diff)
Add relative week change messagecurrentWeek
Diffstat (limited to 'src/client')
-rw-r--r--src/client/react/components/container/WeekSelector.js16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/client/react/components/container/WeekSelector.js b/src/client/react/components/container/WeekSelector.js
index 5977c98..03f1880 100644
--- a/src/client/react/components/container/WeekSelector.js
+++ b/src/client/react/components/container/WeekSelector.js
@@ -10,6 +10,20 @@ import ArrowForwardIcon from 'react-icons/lib/md/arrow-forward';
import purifyWeek from '../../lib/purifyWeek';
import { weekFromLocation } from '../../lib/url';
+function weekName(week) {
+ 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;
+ }
+
+ return "Week " + week;
+}
+
const WeekSelector = ({ location, history }) => {
const week = weekFromLocation(location);
@@ -26,7 +40,7 @@ const WeekSelector = ({ location, history }) => {
return (
<div className="week-selector">
<button onClick={() => updateWeek(-1)}><ArrowBackIcon /></button>
- <div className="text">Week {week}</div>
+ <div className="text">{weekName(week)}</div>
<button onClick={() => updateWeek(+1)}><ArrowForwardIcon /></button>
</div>
);