import { Navigate, Outlet } from 'react-router';
import { useAuth } from './useAuth';
const REQUIRED_ROLE = 'WING_PERMIT';
export function ProtectedRoute() {
const { user, loading } = useAuth();
if (loading) {
return (
);
}
if (!user) {
return ;
}
if (user.status === 'PENDING') {
return ;
}
if (user.status === 'REJECTED' || user.status === 'DISABLED') {
return ;
}
const hasPermit = user.roles.some((r) => r.name === REQUIRED_ROLE);
if (!hasPermit) {
return ;
}
return ;
}