diff --git a/src/app/(user)/layout.tsx b/src/app/(user)/layout.tsx index 536ecd3..1304658 100644 --- a/src/app/(user)/layout.tsx +++ b/src/app/(user)/layout.tsx @@ -1,23 +1,26 @@ -'use client'; +"use client"; -import { useSession } from 'next-auth/react'; -import { useRouter, usePathname } from 'next/navigation'; -import { useEffect } from 'react'; -import Image from 'next/image'; -import { Footer } from '@/components/layout/Footer'; -import { CommonHeader } from '@/components/layout/CommonHeader'; -import { PresenceProvider } from '@/components/providers/presence-provider'; +import { useSession } from "next-auth/react"; +import { useRouter, usePathname } from "next/navigation"; +import { useEffect } from "react"; +import Image from "next/image"; +import { Footer } from "@/components/layout/Footer"; +import { CommonHeader } from "@/components/layout/CommonHeader"; +import { PresenceProvider } from "@/components/providers/presence-provider"; // Pages that don't require authentication const publicPaths = [ - '/user/dashboard', - '/user/profiles', - '/user/profile/', // Agent profile view (includes /user/profile/[id]) + "/home", + "/user/dashboard", + "/user/profiles", + "/user/profile/", // Agent profile view (includes /user/profile/[id]) ]; // Check if current path is public const isPublicPath = (pathname: string) => { - return publicPaths.some(path => pathname === path || pathname.startsWith(path)); + return publicPaths.some( + (path) => pathname === path || pathname.startsWith(path), + ); }; export default function UserLayout({ @@ -28,11 +31,12 @@ export default function UserLayout({ const { data: session, status } = useSession(); const router = useRouter(); const pathname = usePathname(); - const isDashboard = pathname === '/user/dashboard'; + // const isDashboard = pathname === "/user/dashboard"; + const isDashboard = pathname === "/user/dashboard" || pathname === "/home"; const isPublic = isPublicPath(pathname); useEffect(() => { - if (status === 'loading') return; + if (status === "loading") return; // Allow public pages without authentication. // Agents are intentionally allowed to land on /user/dashboard — the logo @@ -49,19 +53,31 @@ export default function UserLayout({ // Redirect agents to agent dashboard for protected user pages const userRole = (session.user as any)?.role; - if (userRole === 'AGENT') { - router.replace('/agent/dashboard'); + if (userRole === "AGENT") { + router.replace("/agent/dashboard"); } }, [session, status, router, pathname, isPublic]); const splashLoading = (