diff options
author | Noah Loomans <noahloomans@gmail.com> | 2018-01-06 15:42:04 +0100 |
---|---|---|
committer | Noah Loomans <noahloomans@gmail.com> | 2018-01-06 15:42:04 +0100 |
commit | c0aa588bc8f85b13b5a55ccd6cdf11bf99048a1c (patch) | |
tree | 4914a9d09b362e222a83b0b9637ed87e11eebe7b /src/client/react/components/page | |
parent | 928edee90f4a35eea20d581e093b002be04e9b47 (diff) |
Add user page
Diffstat (limited to 'src/client/react/components/page')
-rw-r--r-- | src/client/react/components/page/Index.js | 10 | ||||
-rw-r--r-- | src/client/react/components/page/User.js | 31 |
2 files changed, 33 insertions, 8 deletions
diff --git a/src/client/react/components/page/Index.js b/src/client/react/components/page/Index.js index dcc521d..a91d7a9 100644 --- a/src/client/react/components/page/Index.js +++ b/src/client/react/components/page/Index.js @@ -1,16 +1,10 @@ import React from 'react'; -import PropTypes from 'prop-types'; import Search from '../container/Search'; -const App = ({ location }) => ( +const App = () => ( <div> - <Search location={location} /> + <Search /> </div> ); -App.propTypes = { - // eslint-disable-next-line react/forbid-prop-types - location: PropTypes.object.isRequired, -}; - export default App; diff --git a/src/client/react/components/page/User.js b/src/client/react/components/page/User.js new file mode 100644 index 0000000..2ad65a6 --- /dev/null +++ b/src/client/react/components/page/User.js @@ -0,0 +1,31 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { Redirect } from 'react-router-dom'; +import Search from '../container/Search'; +import users from '../../users'; + +const App = ({ match }) => { + const user = `${match.params.type}/${match.params.value}`; + + if (!users.allIds.includes(user)) { + // Invalid user, redirect to index. + return <Redirect to="/" />; + } + + return ( + <div> + <Search urlUser={user} /> + </div> + ); +}; + +App.propTypes = { + match: PropTypes.shape({ + params: PropTypes.shape({ + type: PropTypes.string.isRequired, + value: PropTypes.string.isRequired, + }).isRequired, + }).isRequired, +}; + +export default App; |