mirror of https://gitlab.com/ecentrics/concordia
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
576 B
27 lines
576 B
import React from 'react';
|
|
import { connect } from 'react-redux';
|
|
import { Redirect, Route } from 'react-router-dom';
|
|
|
|
const PrivateRoute = ({ component: Component, ...rest }) => (
|
|
<Route
|
|
{...rest}
|
|
render={props => (props.hasSignedUp ? (
|
|
<Component {...props} />
|
|
) : (
|
|
<Redirect to={{
|
|
pathname: '/signup',
|
|
state: {
|
|
from: props.location
|
|
}
|
|
}}
|
|
/>
|
|
))
|
|
}
|
|
/>
|
|
);
|
|
|
|
const mapStateToProps = state => ({
|
|
hasSignedUp: state.user.hasSignedUp
|
|
});
|
|
|
|
export default connect(mapStateToProps)(PrivateRoute);
|
|
|