From 987ca11a4df61ec5b1b6defd8e22b445aa282159 Mon Sep 17 00:00:00 2001 From: Chinraj P Date: Tue, 23 Jun 2026 14:14:08 +0530 Subject: [PATCH] Added home page with dashboard content and SEO metadata --- src/app/(user)/layout.tsx | 60 ++++++++++++++++---------- src/app/home/page.tsx | 16 +++++++ src/app/page.tsx | 18 ++++---- src/components/layout/CommonHeader.tsx | 23 +++++----- src/middleware.ts | 40 +++++++++++++---- 5 files changed, 107 insertions(+), 50 deletions(-) create mode 100644 src/app/home/page.tsx 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 = (
- +
- RE-Quest + RE-Quest
@@ -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({
{/* Main Content */} -
- {children} -
+
{children}
)} diff --git a/src/app/home/page.tsx b/src/app/home/page.tsx new file mode 100644 index 0000000..eefe108 --- /dev/null +++ b/src/app/home/page.tsx @@ -0,0 +1,16 @@ +import UserLayout from "../(user)/layout"; +import DashboardPage from "../(user)/user/dashboard/page"; + +export const metadata = { + title: "RE-Quest - Connect with Trusted Real Estate Professionals", + description: + "Discover verified real estate professionals for buying, selling, renting, and investing. Search by location, specialization, and expertise to connect with trusted agents on RE-Quest.", +}; + +export default function HomePage() { + return ( + + + + ); +} diff --git a/src/app/page.tsx b/src/app/page.tsx index 1cb606b..9301350 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,27 +1,27 @@ -'use client'; +"use client"; -import { useSession } from 'next-auth/react'; -import { useRouter } from 'next/navigation'; -import { useEffect } from 'react'; +import { useSession } from "next-auth/react"; +import { useRouter } from "next/navigation"; +import { useEffect } from "react"; export default function Home() { const { data: session, status } = useSession(); const router = useRouter(); useEffect(() => { - if (status === 'loading') return; + if (status === "loading") return; // Redirect based on user role, or to public dashboard if not logged in if (session) { const userRole = (session.user as any)?.role; - if (userRole === 'AGENT') { - router.replace('/agent/dashboard'); + if (userRole === "AGENT") { + router.replace("/agent/dashboard"); } else { - router.replace('/user/dashboard'); + router.replace("/user/dashboard"); } } else { // Not logged in - go to public user dashboard - router.replace('/user/dashboard'); + router.replace("/home"); } }, [session, status, router]); diff --git a/src/components/layout/CommonHeader.tsx b/src/components/layout/CommonHeader.tsx index a0279d8..9a42e90 100644 --- a/src/components/layout/CommonHeader.tsx +++ b/src/components/layout/CommonHeader.tsx @@ -7,6 +7,7 @@ import { useSession } from "next-auth/react"; import { useHeaderData } from "@/components/providers/header-provider"; const navLinks = [ + { label: "Professional", href: "/user/profiles" }, { label: "Education", href: "/education" }, { label: "About Us", href: "/about" }, { label: "FAQ's", href: "/faq" }, @@ -56,6 +57,7 @@ export function CommonHeader() { if (showProfileMenu || showGuestMenu || showMobileMenu) { document.addEventListener("mousedown", handleClickOutside); } + // const showProfessional = userRole === "AGENT" || userRole === "LENDER"; return () => { document.removeEventListener("mousedown", handleClickOutside); @@ -66,12 +68,13 @@ export function CommonHeader() { const userName = profileName || session?.user?.name; const userEmail = session?.user?.email; const userRole = (session?.user as any)?.role; - const showProfessional = userRole === "AGENT" || userRole === "LENDER"; + // const showProfessional = userRole === "AGENT" || userRole === "LENDER"; // Use fetched profile image, fallback to session image const userImage = profileImage || session?.user?.image; // Logo destination — always lands on the user dashboard regardless of role. - const dashboardLink = "/user/dashboard"; + // const dashboardLink = "/user/dashboard"; + const dashboardLink = "/home"; return (
{/* Navigation - Desktop only */} - {/* */} {/* Right Side Icons */}
@@ -470,7 +473,7 @@ export function CommonHeader() { {/* Mobile Navigation Menu */} {showMobileMenu && (
- {/* */}
)}
diff --git a/src/middleware.ts b/src/middleware.ts index 5e136fe..6f19c1e 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -2,10 +2,30 @@ import { auth } from "@/auth"; import { NextResponse } from "next/server"; // Auth routes - logged-in users should be redirected away from these -const authRoutes = ["/login", "/signup", "/forgot-password", "/reset-password", "/verify-email"]; +const authRoutes = [ + "/login", + "/signup", + "/forgot-password", + "/reset-password", + "/verify-email", +]; // Public routes - accessible to everyone (logged in or not) -const publicRoutes = ["/", "/contact", "/about", "/faq", "/education", "/coming-soon", "/privacy-policy", "/terms-of-service", "/logout", "/user/dashboard", "/user/profiles", "/user/profile"]; +const publicRoutes = [ + "/", + "/home", + "/contact", + "/about", + "/faq", + "/education", + "/coming-soon", + "/privacy-policy", + "/terms-of-service", + "/logout", + "/user/dashboard", + "/user/profiles", + "/user/profile", +]; // Routes that should NEVER be redirected away from (even if logged in) const noRedirectRoutes = ["/logout"]; @@ -16,23 +36,27 @@ export default auth((req) => { const userRole = (req.auth?.user as any)?.role; const isAuthRoute = authRoutes.some( - (route) => nextUrl.pathname === route || nextUrl.pathname.startsWith(route + "/") + (route) => + nextUrl.pathname === route || nextUrl.pathname.startsWith(route + "/"), ); const isPublicRoute = publicRoutes.some( - (route) => nextUrl.pathname === route || nextUrl.pathname.startsWith(route + "/") + (route) => + nextUrl.pathname === route || nextUrl.pathname.startsWith(route + "/"), ); const isAgentRoute = nextUrl.pathname.startsWith("/agent"); const isUserRoute = nextUrl.pathname.startsWith("/user"); const isApiRoute = nextUrl.pathname.startsWith("/api"); - const isStaticRoute = nextUrl.pathname.startsWith("/_next") || - nextUrl.pathname.startsWith("/assets") || - nextUrl.pathname.includes("."); + const isStaticRoute = + nextUrl.pathname.startsWith("/_next") || + nextUrl.pathname.startsWith("/assets") || + nextUrl.pathname.includes("."); const isNoRedirectRoute = noRedirectRoutes.some( - (route) => nextUrl.pathname === route || nextUrl.pathname.startsWith(route + "/") + (route) => + nextUrl.pathname === route || nextUrl.pathname.startsWith(route + "/"), ); // Skip middleware for API routes and static files