import { Navigate } from 'react-router-dom' import { useAuth } from '../../context/AuthContext' import { PageLoader } from './Spinner' import Layout from './Layout' export function ProtectedRoute({ children, role }) { const { user, loading } = useAuth() if (loading) return if (!user) return if (role === 'admin' && user.role !== 'admin') return if (role === 'aspirant' && !['admin', 'aspirant', 'user'].includes(user.role)) return return children } export function GuestRoute({ children }) { const { user } = useAuth() if (user) { if (user.role === 'admin') return if (user.role === 'aspirant' || user.role === 'user') return return } return children }