diff options
author | Noah Loomans <noahloomans@gmail.com> | 2018-06-28 14:33:04 +0200 |
---|---|---|
committer | Noah Loomans <noahloomans@gmail.com> | 2018-06-28 14:33:04 +0200 |
commit | 8018bbc67b10b7b75589b98ed92c6dda1f6163f4 (patch) | |
tree | 2f6ebd53ee3d8f32fad34de0191d911ddc65757e /src/client/react/components/presentational | |
parent | e61429154d4c06e0362abd55482400a45b7636ab (diff) |
Extract shiftWeek from WeekSelector
Diffstat (limited to 'src/client/react/components/presentational')
-rw-r--r-- | src/client/react/components/presentational/WeekSelector.js | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/src/client/react/components/presentational/WeekSelector.js b/src/client/react/components/presentational/WeekSelector.js index e47a175..1b2cfb3 100644 --- a/src/client/react/components/presentational/WeekSelector.js +++ b/src/client/react/components/presentational/WeekSelector.js @@ -25,8 +25,6 @@ import moment from 'moment'; import ArrowBackIcon from 'react-icons/lib/md/arrow-back'; import ArrowForwardIcon from 'react-icons/lib/md/arrow-forward'; -import purifyWeek from '../../lib/purifyWeek'; - import './WeekSelector.scss'; import WeekDisplay from './WeekDisplay'; @@ -34,23 +32,15 @@ class WeekSelector extends React.Component { static propTypes = { // react-router week: PropTypes.number.isRequired, - setWeek: PropTypes.func.isRequired, + shiftWeek: PropTypes.func.isRequired, }; - updateWeek(change) { - const { week, setWeek } = this.props; - const newWeek = purifyWeek(week + change); - - const isCurrentWeek = moment().week() === newWeek; - setWeek(isCurrentWeek ? undefined : newWeek); - } - render() { - const { week } = this.props; + const { week, shiftWeek } = this.props; return ( <div className="WeekSelector"> - <button type="button" onClick={() => this.updateWeek(-1)}> + <button type="button" onClick={() => shiftWeek(-1)}> <ArrowBackIcon /> </button> <div className="text"> @@ -59,7 +49,7 @@ class WeekSelector extends React.Component { currentWeek={moment().week()} /> </div> - <button type="button" onClick={() => this.updateWeek(+1)}> + <button type="button" onClick={() => shiftWeek(+1)}> <ArrowForwardIcon /> </button> </div> |