diff options
author | Noah Loomans <noahloomans@gmail.com> | 2018-01-26 20:30:34 +0100 |
---|---|---|
committer | Noah Loomans <noahloomans@gmail.com> | 2018-01-26 20:30:34 +0100 |
commit | 19534b4770b4f4097b02f5fa021a24822b12d907 (patch) | |
tree | 4bc0d8ceca5d0c5ae36969dcd14588f0b37f051b /src/client/react/components/page | |
parent | 16723546de81e29fa8a31acc4070df5acb182b24 (diff) |
Add week selector
Diffstat (limited to 'src/client/react/components/page')
-rw-r--r-- | src/client/react/components/page/User.js | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/client/react/components/page/User.js b/src/client/react/components/page/User.js index ff304c0..980070f 100644 --- a/src/client/react/components/page/User.js +++ b/src/client/react/components/page/User.js @@ -1,12 +1,17 @@ import React from 'react'; import PropTypes from 'prop-types'; import { Redirect } from 'react-router-dom'; +import queryString from 'query-string'; +import moment from 'moment'; import Search from '../container/Search'; import View from '../container/View'; import users from '../../users'; +import WeekSelector from '../container/WeekSelector'; -const App = ({ match }) => { +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(); if (!users.allIds.includes(user)) { // Invalid user, redirect to index. @@ -18,6 +23,7 @@ const App = ({ match }) => { <div className="menu"> <div className="menu-container"> <Search urlUser={user} /> + <WeekSelector urlWeek={week} /> </div> </div> <View user={user} /> @@ -32,6 +38,9 @@ App.propTypes = { value: PropTypes.string.isRequired, }).isRequired, }).isRequired, + location: PropTypes.shape({ + search: PropTypes.string.isRequired, + }).isRequired, }; export default App; |