From 484f01d74da316e1398f780013809262f7d5eb1a Mon Sep 17 00:00:00 2001 From: pradeepkumar Date: Mon, 19 Jan 2026 10:30:28 +0530 Subject: [PATCH] feat: Conditionally render the header layout based on whether the current path is the user dashboard. --- src/app/(user)/layout.tsx | 41 +++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/src/app/(user)/layout.tsx b/src/app/(user)/layout.tsx index a47b195..371c094 100644 --- a/src/app/(user)/layout.tsx +++ b/src/app/(user)/layout.tsx @@ -1,7 +1,7 @@ 'use client'; import { useSession } from 'next-auth/react'; -import { useRouter } from 'next/navigation'; +import { useRouter, usePathname } from 'next/navigation'; import { useEffect } from 'react'; import { Footer } from '@/components/layout/Footer'; import { CommonHeader } from '@/components/layout/CommonHeader'; @@ -13,6 +13,9 @@ export default function UserLayout({ }) { const { data: session, status } = useSession(); const router = useRouter(); + const pathname = usePathname(); + + const isDashboard = pathname === '/user/dashboard'; useEffect(() => { if (status === 'loading') return; @@ -39,16 +42,34 @@ export default function UserLayout({ return (
- {/* Main Content with Header inside */} -
- {/* Header overlaying the content */} -
-
- + {isDashboard ? ( + <> + {/* Main Content with Header Overlay for Dashboard */} +
+ {/* Header overlaying the content */} +
+
+ +
+
+ {children} +
+ + ) : ( + <> + {/* Regular Header for other pages */} +
+
+ +
-
- {children} -
+ + {/* Main Content */} +
+ {children} +
+ + )} {/* Footer */}