Added home page with dashboard content and SEO metadata
This commit is contained in:
@@ -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 = (
|
||||
<div
|
||||
className="min-h-screen flex flex-col items-center justify-center"
|
||||
style={{ background: 'linear-gradient(to bottom, #c4d9d4, #f0f5fc)' }}
|
||||
style={{ background: "linear-gradient(to bottom, #c4d9d4, #f0f5fc)" }}
|
||||
>
|
||||
<Image src="/assets/images/splash-house.png" alt="" width={150} height={108} priority />
|
||||
<Image
|
||||
src="/assets/images/splash-house.png"
|
||||
alt=""
|
||||
width={150}
|
||||
height={108}
|
||||
priority
|
||||
/>
|
||||
<div className="mt-[35px]">
|
||||
<Image src="/assets/images/splash-logo.png" alt="RE-Quest" width={264} height={55} priority />
|
||||
<Image
|
||||
src="/assets/images/splash-logo.png"
|
||||
alt="RE-Quest"
|
||||
width={264}
|
||||
height={55}
|
||||
priority
|
||||
/>
|
||||
</div>
|
||||
<div className="mt-8">
|
||||
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-[#00293d]" />
|
||||
@@ -70,7 +86,7 @@ export default function UserLayout({
|
||||
);
|
||||
|
||||
// Show loading only for protected pages while checking auth
|
||||
if (status === 'loading' && !isPublic) {
|
||||
if (status === "loading" && !isPublic) {
|
||||
return splashLoading;
|
||||
}
|
||||
|
||||
@@ -105,9 +121,7 @@ export default function UserLayout({
|
||||
</div>
|
||||
|
||||
{/* Main Content */}
|
||||
<main className="flex-1">
|
||||
{children}
|
||||
</main>
|
||||
<main className="flex-1">{children}</main>
|
||||
</>
|
||||
)}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user