feat: Conditionally render the header layout based on whether the current path is the user dashboard.
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { useSession } from 'next-auth/react';
|
import { useSession } from 'next-auth/react';
|
||||||
import { useRouter } from 'next/navigation';
|
import { useRouter, usePathname } from 'next/navigation';
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import { Footer } from '@/components/layout/Footer';
|
import { Footer } from '@/components/layout/Footer';
|
||||||
import { CommonHeader } from '@/components/layout/CommonHeader';
|
import { CommonHeader } from '@/components/layout/CommonHeader';
|
||||||
@@ -13,6 +13,9 @@ export default function UserLayout({
|
|||||||
}) {
|
}) {
|
||||||
const { data: session, status } = useSession();
|
const { data: session, status } = useSession();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const pathname = usePathname();
|
||||||
|
|
||||||
|
const isDashboard = pathname === '/user/dashboard';
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (status === 'loading') return;
|
if (status === 'loading') return;
|
||||||
@@ -39,7 +42,9 @@ export default function UserLayout({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="min-h-screen flex flex-col">
|
<div className="min-h-screen flex flex-col">
|
||||||
{/* Main Content with Header inside */}
|
{isDashboard ? (
|
||||||
|
<>
|
||||||
|
{/* Main Content with Header Overlay for Dashboard */}
|
||||||
<main className="flex-1 relative">
|
<main className="flex-1 relative">
|
||||||
{/* Header overlaying the content */}
|
{/* Header overlaying the content */}
|
||||||
<div className="absolute top-0 left-0 right-0 z-50 px-4 py-3">
|
<div className="absolute top-0 left-0 right-0 z-50 px-4 py-3">
|
||||||
@@ -49,6 +54,22 @@ export default function UserLayout({
|
|||||||
</div>
|
</div>
|
||||||
{children}
|
{children}
|
||||||
</main>
|
</main>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
{/* Regular Header for other pages */}
|
||||||
|
<div className="px-4 py-3 bg-white">
|
||||||
|
<div className="max-w-7xl mx-auto">
|
||||||
|
<CommonHeader />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Main Content */}
|
||||||
|
<main className="flex-1">
|
||||||
|
{children}
|
||||||
|
</main>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Footer */}
|
{/* Footer */}
|
||||||
<Footer />
|
<Footer />
|
||||||
|
|||||||
Reference in New Issue
Block a user