diff --git a/app/src/PrivateRoute.js b/app/src/PrivateRoute.js new file mode 100644 index 0000000..ccf1809 --- /dev/null +++ b/app/src/PrivateRoute.js @@ -0,0 +1,28 @@ +import React from 'react' +import {connect} from 'react-redux'; +import { Route, Redirect } from 'react-router-dom' + +const PrivateRoute = ({ component: Component, ...rest }) => ( + + props.hasSignedUp ? ( + + ) : ( + + ) + } + /> +); + +const mapStateToProps = state => { + return { + hasSignedUp: state.user.hasSignedUp, + } +}; + +export default connect(mapStateToProps)(PrivateRoute); diff --git a/app/src/containers/NavBarContainer.js b/app/src/containers/NavBarContainer.js index 2bb4b1a..873fa20 100644 --- a/app/src/containers/NavBarContainer.js +++ b/app/src/containers/NavBarContainer.js @@ -8,10 +8,6 @@ import { Image, Menu } from 'semantic-ui-react' import logo from '../assets/images/logo.png'; class NavBarContainer extends Component { - constructor(props){ - super(props); - } - render() { return ( diff --git a/app/src/routes.js b/app/src/routes.js index 0f25112..b837d4a 100644 --- a/app/src/routes.js +++ b/app/src/routes.js @@ -1,6 +1,7 @@ import React from 'react' -import { Route, Switch } from 'react-router-dom' -import NavBarContainer from "./containers/NavBarContainer"; +import { Route, Switch, Redirect } from 'react-router-dom' +import PrivateRoute from './PrivateRoute.js'; +import NavBarContainer from './containers/NavBarContainer'; import HomeContainer from './containers/HomeContainer' import SignUpContainer from './containers/SignUpContainer' import NotFound from './components/NotFound' @@ -10,11 +11,11 @@ const routes = (
- +
); -export default routes \ No newline at end of file +export default routes