import React from "react"; import { useAuth } from "~/contexts/auth-context"; import { LoginForm } from "./login-form"; import toast from "react-hot-toast"; interface AuthGuardProps { children: React.ReactNode; } export function AuthGuard({ children }: AuthGuardProps) { const { isAuthenticated, isLoading, user, token } = useAuth(); // Show loading while checking authentication if (isLoading) { return (

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

); } // If user is not authenticated or token is invalid, show login form if (!isAuthenticated || !token || !token.accessToken) { return ; } // If user is authenticated, show the protected content return <>{children}; }