"use client"; import { useAuth } from "@/context/AuthContext"; import Link from "next/link"; import { useRouter } from "next/navigation"; import { useEffect } from "react"; export default function DashboardLayout({ children }) { const { user, logout, isLoading } = useAuth(); const router = useRouter(); useEffect(() => { if (!isLoading && !user) { router.push("/login"); } }, [user, isLoading, router]); if (isLoading) { return (
Loading...
); } if (!user) { return null; } return (
{children}
); }