Mexar / frontend /src /components /ProtectedRoute.jsx
Devrajsinh bharatsinh gohil
Initial commit of MEXAR Ultimate - Phase 2 cleanup complete
b0b150b
raw
history blame contribute delete
557 Bytes
import React from 'react';
import { Navigate, Outlet } from 'react-router-dom';
import { useAuth } from '../contexts/AuthContext';
import { CircularProgress, Box } from '@mui/material';
const ProtectedRoute = () => {
const { token, loading } = useAuth();
if (loading) {
return (
<Box display="flex" justifyContent="center" alignItems="center" height="100vh">
<CircularProgress />
</Box>
);
}
return token ? <Outlet /> : <Navigate to="/login" />;
};
export default ProtectedRoute;