'use client' import { useEffect } from 'react' import { useRouter } from 'next/navigation' import { useAuth } from '@/contexts/AuthContext' export default function ProtectedRoute({ children }: { children: React.ReactNode }) { const { isAuthenticated, isLoading } = useAuth() const router = useRouter() useEffect(() => { if (!isLoading && !isAuthenticated) { router.push('/') } }, [isAuthenticated, isLoading, router]) if (isLoading) { return (

جاري التحميل...

) } if (!isAuthenticated) { return null } return <>{children} }