default layuout
This commit is contained in:
111
src/app/page.tsx
111
src/app/page.tsx
@@ -1,86 +1,43 @@
|
||||
'use client';
|
||||
|
||||
import { useSession, signOut } from 'next-auth/react';
|
||||
import Link from 'next/link';
|
||||
import { useSession } from 'next-auth/react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { useEffect } from 'react';
|
||||
|
||||
export default function Home() {
|
||||
const { data: session } = useSession();
|
||||
const { data: session, status } = useSession();
|
||||
const router = useRouter();
|
||||
|
||||
useEffect(() => {
|
||||
if (status === 'loading') return;
|
||||
|
||||
if (!session) {
|
||||
router.replace('/login');
|
||||
return;
|
||||
}
|
||||
|
||||
// Redirect based on user role
|
||||
const userRole = (session.user as any)?.role;
|
||||
|
||||
if (userRole === 'AGENT') {
|
||||
router.replace('/agent/dashboard');
|
||||
} else {
|
||||
router.replace('/user/dashboard');
|
||||
}
|
||||
}, [session, status, router]);
|
||||
|
||||
// Loading state while determining redirect
|
||||
return (
|
||||
<div className="min-h-screen bg-gradient-to-b from-[#c4d9d4] to-[#f0f5fc]">
|
||||
{/* Header */}
|
||||
<header className="bg-white/80 backdrop-blur-sm shadow-sm">
|
||||
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<div className="flex justify-between items-center h-16">
|
||||
{/* Logo */}
|
||||
<Link href="/">
|
||||
<img
|
||||
src="/assets/logo.svg"
|
||||
alt="RE-QuestN"
|
||||
className="h-8"
|
||||
/>
|
||||
</Link>
|
||||
|
||||
{/* User Menu */}
|
||||
<div className="flex items-center gap-4">
|
||||
<span className="text-sm text-[#00293d]">
|
||||
Welcome, {session?.user?.name || session?.user?.email || 'User'}
|
||||
</span>
|
||||
<button
|
||||
onClick={() => signOut({ callbackUrl: '/login' })}
|
||||
className="px-4 py-2 bg-[#e58625] hover:bg-[#d47a1f] text-white text-sm font-medium rounded-lg transition-colors"
|
||||
>
|
||||
Sign Out
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
{/* Main Content */}
|
||||
<main className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
|
||||
<div className="bg-white rounded-[20px] shadow-lg p-8">
|
||||
<h1 className="text-3xl font-bold text-[#00293d] mb-4">
|
||||
Welcome to RE-QuestN
|
||||
</h1>
|
||||
<p className="text-[#00293d]/70 mb-8">
|
||||
Your real estate journey starts here. Explore properties, connect with agents, and find your dream home.
|
||||
</p>
|
||||
|
||||
{/* Quick Actions */}
|
||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-6">
|
||||
<div className="bg-[#f0f5fc] rounded-[20px] p-6 hover:shadow-md transition-shadow">
|
||||
<div className="w-12 h-12 bg-[#00293d] rounded-full flex items-center justify-center mb-4">
|
||||
<svg className="w-6 h-6 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6" />
|
||||
</svg>
|
||||
</div>
|
||||
<h3 className="text-lg font-semibold text-[#00293d] mb-2">Browse Properties</h3>
|
||||
<p className="text-sm text-[#00293d]/70">Explore thousands of listings in your area</p>
|
||||
</div>
|
||||
|
||||
<div className="bg-[#f0f5fc] rounded-[20px] p-6 hover:shadow-md transition-shadow">
|
||||
<div className="w-12 h-12 bg-[#e58625] rounded-full flex items-center justify-center mb-4">
|
||||
<svg className="w-6 h-6 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z" />
|
||||
</svg>
|
||||
</div>
|
||||
<h3 className="text-lg font-semibold text-[#00293d] mb-2">Find Agents</h3>
|
||||
<p className="text-sm text-[#00293d]/70">Connect with top real estate professionals</p>
|
||||
</div>
|
||||
|
||||
<div className="bg-[#f0f5fc] rounded-[20px] p-6 hover:shadow-md transition-shadow">
|
||||
<div className="w-12 h-12 bg-[#5ba4a4] rounded-full flex items-center justify-center mb-4">
|
||||
<svg className="w-6 h-6 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z" />
|
||||
</svg>
|
||||
</div>
|
||||
<h3 className="text-lg font-semibold text-[#00293d] mb-2">Saved Favorites</h3>
|
||||
<p className="text-sm text-[#00293d]/70">View your saved properties and searches</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
<div className="min-h-screen bg-gradient-to-b from-[#c4d9d4] to-[#f0f5fc] flex items-center justify-center">
|
||||
<div className="text-center">
|
||||
<img
|
||||
src="/assets/logo.svg"
|
||||
alt="RE-QuestN"
|
||||
className="h-10 mx-auto mb-4"
|
||||
/>
|
||||
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-[#00293d] mx-auto"></div>
|
||||
<p className="mt-4 text-[#00293d]/70">Loading...</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user