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/Index.js15
-rw-r--r--src/client/react/components/page/User.js47
2 files changed, 62 insertions, 0 deletions
diff --git a/src/client/react/components/page/Index.js b/src/client/react/components/page/Index.js
new file mode 100644
index 0000000..e5e47c5
--- /dev/null
+++ b/src/client/react/components/page/Index.js
@@ -0,0 +1,15 @@
+import React from 'react';
+import Search from '../container/Search';
+import HelpBox from '../container/HelpBox';
+
+const IndexPage = () => (
+ <div className="page-index">
+ <div className="container">
+ <img src="/icons/mml-logo.png" alt="Metis" />
+ <Search />
+ <HelpBox />
+ </div>
+ </div>
+);
+
+export default IndexPage;
diff --git a/src/client/react/components/page/User.js b/src/client/react/components/page/User.js
new file mode 100644
index 0000000..215a6e0
--- /dev/null
+++ b/src/client/react/components/page/User.js
@@ -0,0 +1,47 @@
+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 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());
+
+ if (!users.allIds.includes(user)) {
+ // Invalid user, redirect to index.
+ return <Redirect to="/" />;
+ }
+
+ return (
+ <div className="page-user">
+ <div className="menu">
+ <div className="menu-container">
+ <Search urlUser={user} />
+ <WeekSelector urlWeek={week} />
+ </div>
+ </div>
+ <View user={user} week={week} />
+ </div>
+ );
+};
+
+UserPage.propTypes = {
+ match: PropTypes.shape({
+ params: PropTypes.shape({
+ type: PropTypes.string.isRequired,
+ value: PropTypes.string.isRequired,
+ }).isRequired,
+ }).isRequired,
+ location: PropTypes.shape({
+ search: PropTypes.string.isRequired,
+ }).isRequired,
+};
+
+export default UserPage;