"use client"; import { useAuth } from "@/hooks/useAuth"; import { useRouter } from "next/navigation"; import { useEffect } from "react"; export function AuthGuard({ children }: { children: React.ReactNode }) { const { isAuthenticated, loading, login } = useAuth(); const router = useRouter(); useEffect(() => { if (!loading && !isAuthenticated) { login(typeof window !== "undefined" ? window.location.href : undefined); } }, [loading, isAuthenticated, login]); if (loading) { return

در حال بررسی احراز هویت...

; } if (!isAuthenticated) { return

در حال هدایت به صفحه ورود...

; } return <>{children}; }