diff options
author | Noah Loomans <noahloomans@gmail.com> | 2018-01-28 16:06:56 +0100 |
---|---|---|
committer | Noah Loomans <noahloomans@gmail.com> | 2018-01-28 16:06:56 +0100 |
commit | 3b98d4c4f13424c89a10580065075998d37ae857 (patch) | |
tree | 2dc9917bd6c13770aaf07a1e1231cc11d97ec35a /src/client/react/components/page | |
parent | 8670ada517bc8beb69d152c82f282322b9ea8d64 (diff) |
Improve week logic
Diffstat (limited to 'src/client/react/components/page')
-rw-r--r-- | src/client/react/components/page/User.js | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/client/react/components/page/User.js b/src/client/react/components/page/User.js index 72e92c2..10d608d 100644 --- a/src/client/react/components/page/User.js +++ b/src/client/react/components/page/User.js @@ -3,6 +3,7 @@ import PropTypes from 'prop-types'; import { Redirect } from 'react-router-dom'; import queryString from 'query-string'; import moment from 'moment'; +import purifyWeek from '../../lib/purifyWeek'; import Search from '../container/Search'; import View from '../container/View'; import users from '../../users'; @@ -11,7 +12,7 @@ import WeekSelector from '../container/WeekSelector'; const App = ({ match, location }) => { const user = `${match.params.type}/${match.params.value}`; const weekStr = queryString.parse(location.search).week; - const week = weekStr ? moment().week(weekStr) : moment(); + const week = purifyWeek(weekStr ? parseInt(weekStr, 10) : moment().week()); if (!users.allIds.includes(user)) { // Invalid user, redirect to index. @@ -26,8 +27,7 @@ const App = ({ match, location }) => { <WeekSelector urlWeek={week} /> </div> </div> - {/* The View object just wants the week number. */} - <View user={user} week={week.week()} /> + <View user={user} week={week} /> </div> ); }; |