aboutsummaryrefslogtreecommitdiff
path: root/src/client/react/components/page
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/react/components/page')
-rw-r--r--src/client/react/components/page/User.js22
1 files changed, 7 insertions, 15 deletions
diff --git a/src/client/react/components/page/User.js b/src/client/react/components/page/User.js
index 0c79a8b..1b7e1ce 100644
--- a/src/client/react/components/page/User.js
+++ b/src/client/react/components/page/User.js
@@ -1,20 +1,15 @@
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 purifyWeek from '../../lib/purifyWeek';
import Search from '../container/Search';
import View from '../container/View';
-import users from '../../users';
+import { userFromMatch } from '../../lib/url';
import WeekSelector from '../container/WeekSelector';
-const UserPage = ({ match, location }) => {
- const user = `${match.params.type}/${match.params.value}`;
- const weekStr = queryString.parse(location.search).week;
- const week = purifyWeek(weekStr ? parseInt(weekStr, 10) : moment().week());
+const UserPage = ({ match }) => {
+ const user = userFromMatch(match);
- if (!users.allIds.includes(user)) {
+ if (!user) {
// Invalid user, redirect to index.
return <Redirect to="/" />;
}
@@ -23,15 +18,15 @@ const UserPage = ({ match, location }) => {
<div className="page-user">
<div className="search-wrapper">
<div className="search-container">
- <Search urlUser={user} />
+ <Search />
</div>
</div>
<div className="menu">
<div className="menu-container">
- <WeekSelector urlWeek={week} />
+ <WeekSelector />
</div>
</div>
- <View user={user} week={week} />
+ <View />
</div>
);
};
@@ -43,9 +38,6 @@ UserPage.propTypes = {
value: PropTypes.string.isRequired,
}).isRequired,
}).isRequired,
- location: PropTypes.shape({
- search: PropTypes.string.isRequired,
- }).isRequired,
};
export default UserPage;