mirror of
https://github.com/pawelmalak/flame.git
synced 2025-07-19 11:39:36 +02:00
13 lines
404 B
TypeScript
13 lines
404 B
TypeScript
import { useSelector } from 'react-redux';
|
|
import { Redirect, Route, RouteProps } from 'react-router';
|
|
import { State } from '../../store/reducers';
|
|
|
|
export const ProtectedRoute = ({ ...rest }: RouteProps) => {
|
|
const { isAuthenticated } = useSelector((state: State) => state.auth);
|
|
|
|
if (isAuthenticated) {
|
|
return <Route {...rest} />;
|
|
} else {
|
|
return <Redirect to="/settings/app" />;
|
|
}
|
|
};
|