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>
|
||||
</>
|
||||
)}
|
||||
|
||||
|
||||
16
src/app/home/page.tsx
Normal file
16
src/app/home/page.tsx
Normal file
@@ -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 (
|
||||
<UserLayout>
|
||||
<DashboardPage />
|
||||
</UserLayout>
|
||||
);
|
||||
}
|
||||
@@ -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]);
|
||||
|
||||
|
||||
@@ -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 (
|
||||
<header
|
||||
@@ -92,7 +95,7 @@ export function CommonHeader() {
|
||||
</Link>
|
||||
|
||||
{/* Navigation - Desktop only */}
|
||||
{/* <nav className="hidden md:flex items-center gap-8 ml-auto mr-8">
|
||||
<nav className="hidden md:flex items-center gap-8 ml-auto mr-8">
|
||||
{navLinks.map((link) => (
|
||||
<Link
|
||||
key={link.href}
|
||||
@@ -102,8 +105,8 @@ export function CommonHeader() {
|
||||
{link.label}
|
||||
</Link>
|
||||
))}
|
||||
</nav> */}
|
||||
<nav className="hidden md:flex items-center gap-8 ml-auto mr-8">
|
||||
</nav>
|
||||
{/* <nav className="hidden md:flex items-center gap-8 ml-auto mr-8">
|
||||
{showProfessional && (
|
||||
<Link
|
||||
href="/user/profiles"
|
||||
@@ -122,7 +125,7 @@ export function CommonHeader() {
|
||||
{link.label}
|
||||
</Link>
|
||||
))}
|
||||
</nav>
|
||||
</nav> */}
|
||||
|
||||
{/* Right Side Icons */}
|
||||
<div className="flex items-center gap-2 md:gap-4">
|
||||
@@ -470,7 +473,7 @@ export function CommonHeader() {
|
||||
{/* Mobile Navigation Menu */}
|
||||
{showMobileMenu && (
|
||||
<div className="md:hidden border-t border-white/20 py-3 pb-4">
|
||||
{/* <nav className="flex flex-col gap-1">
|
||||
<nav className="flex flex-col gap-1">
|
||||
{navLinks.map((link) => (
|
||||
<Link
|
||||
key={link.href}
|
||||
@@ -481,8 +484,8 @@ export function CommonHeader() {
|
||||
{link.label}
|
||||
</Link>
|
||||
))}
|
||||
</nav> */}
|
||||
<nav className="flex flex-col gap-1">
|
||||
</nav>
|
||||
{/* <nav className="flex flex-col gap-1">
|
||||
{showProfessional && (
|
||||
<Link
|
||||
href="/user/profiles"
|
||||
@@ -503,7 +506,7 @@ export function CommonHeader() {
|
||||
{link.label}
|
||||
</Link>
|
||||
))}
|
||||
</nav>
|
||||
</nav> */}
|
||||
</div>
|
||||
)}
|
||||
</header>
|
||||
|
||||
@@ -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") ||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user