diff options
author | Bilal Ayachi <ayachi-code@users.noreply.github.com> | 2018-02-02 22:16:23 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-02 22:16:23 +0100 |
commit | 9f83f98c5f3c40d02f97bb934a3ab02c02adc256 (patch) | |
tree | 3bd9e931b6883435a2453bb3fd63e8573ef95219 /src/client/react | |
parent | f7c886a6e1e9f82873747e8fa7ae732ba57665e4 (diff) | |
parent | 82ba6eb9c363d79b5efd084ef56e86cf6d2b41bf (diff) |
Merge pull request #21 from nloomans/currentWeek
Add relative week change message
Diffstat (limited to 'src/client/react')
-rw-r--r-- | src/client/react/components/container/WeekSelector.js | 16 |
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> ); |