"use client" import React, { useEffect } from 'react' import { useAuth } from '@/lib/auth-context' import { LoginForm } from './login-form' interface ProtectedRouteProps { children: React.ReactNode requiredRole?: 'admin' | 'user' fallback?: React.ReactNode } export function ProtectedRoute({ children, requiredRole, fallback }: ProtectedRouteProps) { const { isAuthenticated, isLoading, user, error, authEnabled } = useAuth() // If authentication is not enabled, allow access if (!authEnabled) { return <>{children}> } if (isLoading) { return (
Loading...
Please sign in to continue
You don't have permission to access this page.
( Component: React.ComponentType
,
options?: { requiredRole?: 'admin' | 'user' }
) {
return function AuthenticatedComponent(props: P) {
return (