Yassine Mhirsi
fixed typescript adn added logout
2251e03
raw
history blame contribute delete
424 Bytes
import React from 'react';
import { Navigate } from 'react-router-dom';
import { isUserRegistered } from '../../utils/index.ts';
type ProtectedRouteProps = {
children?: any;
};
const ProtectedRoute = ({ children }: ProtectedRouteProps) => {
const isAuthenticated = isUserRegistered();
if (!isAuthenticated) {
return <Navigate to="/" replace />;
}
return <>{children}</>;
};
export default ProtectedRoute;