import { type ReactNode } from 'react' import { Navigate } from 'react-router' import { useAuth } from '@/hooks/use-auth' interface ProtectedRouteProps { children: ReactNode requireAdmin?: boolean } export function ProtectedRoute({ children, requireAdmin = false }: ProtectedRouteProps) { const { user, loading } = useAuth() if (loading) { return (

Loading...

) } if (!user) { return } if (requireAdmin && user.role !== 'admin') { return (

Access Denied

You don't have permission to access this page.

) } if (!user.is_active) { return (

Account Disabled

Your account has been disabled. Please contact support.

) } return <>{children} }