mirror of
https://github.com/ClaytonWWilson/CS307-Team24.git
synced 2026-03-10 21:25:04 +00:00
23 lines
561 B
JavaScript
23 lines
561 B
JavaScript
import React from 'react';
|
|
import { Route, Redirect } from 'react-router-dom';
|
|
import { connect } from 'react-redux';
|
|
import PropTypes from 'prop-types';
|
|
|
|
const AuthRoute = ({ component: Component, authenticated, ...rest }) => (
|
|
<Route
|
|
{...rest}
|
|
render={(props) =>
|
|
authenticated === true ? <Redirect to="/home" /> : <Component {...props} />
|
|
}
|
|
/>
|
|
);
|
|
|
|
const mapStateToProps = (state) => ({
|
|
authenticated: state.user.authenticated
|
|
});
|
|
|
|
AuthRoute.propTypes = {
|
|
user: PropTypes.object
|
|
};
|
|
|
|
export default connect(mapStateToProps)(AuthRoute); |