diff --git a/frontend/src/app/(main)/dashboard/page.tsx b/frontend/src/app/(main)/dashboard/page.tsx index 4bea044..ad7a18b 100644 --- a/frontend/src/app/(main)/dashboard/page.tsx +++ b/frontend/src/app/(main)/dashboard/page.tsx @@ -2,32 +2,10 @@ "use client"; import { useAuth } from "@/context/auth-context"; -import { useRouter } from "next/navigation"; -import { useEffect } from "react"; +import Navbar from "@/components/layout/navbar"; export default function DashboardPage() { - const { user, isLoading, isAuthenticated, logout } = useAuth(); - const router = useRouter(); - - // Redirect to login if not authenticated - useEffect(() => { - // Add a small delay to ensure context is fully updated - const checkAuth = setTimeout(() => { - if (!isLoading && !isAuthenticated) { - console.log("Not authenticated, redirecting to login"); - router.push("/login"); - } - }, 100); - - return () => clearTimeout(checkAuth); - }, [isLoading, isAuthenticated, router]); - - // Handle logout with explicit redirect - const handleLogout = () => { - logout(); - // Force redirection to login - router.push("/login"); - }; + const { user, isLoading } = useAuth(); // Show loading state if (isLoading) { @@ -41,48 +19,40 @@ export default function DashboardPage() { ); } - // Extra safeguard - if we somehow get here without authentication, redirect - if (!isAuthenticated) { - router.push("/login"); - return
- You are now logged in to EventSpace. -
++ You are now logged in to EventSpace. +
-No events yet
- ++ No events yet +
+ +