Added home page with dashboard content and SEO metadata #2
11
src/app/(user)/home/page.tsx
Normal file
11
src/app/(user)/home/page.tsx
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import { HomeDashboard } from '@/components/home/HomeDashboard';
|
||||||
|
|
||||||
|
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 <HomeDashboard />;
|
||||||
|
}
|
||||||
@@ -1,53 +1,7 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { useState, useEffect } from 'react';
|
import { HomeDashboard } from '@/components/home/HomeDashboard';
|
||||||
import { HeroSection } from '@/components/home/HeroSection';
|
|
||||||
import { FeaturesSection } from '@/components/home/FeaturesSection';
|
|
||||||
import { TopProfessionals } from '@/components/home/TopProfessionals';
|
|
||||||
import { TestimonialsSection } from '@/components/home/TestimonialsSection';
|
|
||||||
import { cmsService, resolveImageUrl } from '@/services/cms.service';
|
|
||||||
import type { HeroContent, FeaturesContent, TopProfessionalsContent, TestimonialsContent, CmsContentRecord } from '@/types/cms';
|
|
||||||
|
|
||||||
export default function UserDashboard() {
|
export default function UserDashboard() {
|
||||||
const [cmsData, setCmsData] = useState<Record<string, unknown>>({});
|
return <HomeDashboard />;
|
||||||
const [cmsLoaded, setCmsLoaded] = useState(false);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const fetchCms = async () => {
|
|
||||||
try {
|
|
||||||
const sections = await cmsService.getPageContent('landing');
|
|
||||||
const data: Record<string, unknown> = {};
|
|
||||||
for (const s of sections) {
|
|
||||||
const content = s.content as Record<string, unknown>;
|
|
||||||
// Resolve S3 keys in image fields
|
|
||||||
if (s.sectionKey === 'features' && Array.isArray(content.features)) {
|
|
||||||
for (const feat of content.features as { iconPath?: string }[]) {
|
|
||||||
if (feat.iconPath) feat.iconPath = await resolveImageUrl(feat.iconPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (s.sectionKey === 'testimonials' && Array.isArray(content.stats)) {
|
|
||||||
for (const stat of content.stats as { iconPath?: string }[]) {
|
|
||||||
if (stat.iconPath) stat.iconPath = await resolveImageUrl(stat.iconPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
data[s.sectionKey] = content;
|
|
||||||
}
|
|
||||||
setCmsData(data);
|
|
||||||
} catch {
|
|
||||||
// Use default content on error
|
|
||||||
} finally {
|
|
||||||
setCmsLoaded(true);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
fetchCms();
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<HeroSection content={cmsData.hero as HeroContent | undefined} />
|
|
||||||
{cmsLoaded && <FeaturesSection content={cmsData.features as FeaturesContent | undefined} />}
|
|
||||||
<TopProfessionals content={cmsData.topProfessionals as TopProfessionalsContent | undefined} />
|
|
||||||
<TestimonialsSection content={cmsData.testimonials as TestimonialsContent | undefined} />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
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>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
54
src/components/home/HomeDashboard.tsx
Normal file
54
src/components/home/HomeDashboard.tsx
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import { useState, useEffect } from 'react';
|
||||||
|
import { HeroSection } from '@/components/home/HeroSection';
|
||||||
|
import { FeaturesSection } from '@/components/home/FeaturesSection';
|
||||||
|
import { TopProfessionals } from '@/components/home/TopProfessionals';
|
||||||
|
import { TestimonialsSection } from '@/components/home/TestimonialsSection';
|
||||||
|
import { cmsService, resolveImageUrl } from '@/services/cms.service';
|
||||||
|
import type { HeroContent, FeaturesContent, TopProfessionalsContent, TestimonialsContent } from '@/types/cms';
|
||||||
|
|
||||||
|
// Shared landing/dashboard content rendered by both /home and /user/dashboard.
|
||||||
|
export function HomeDashboard() {
|
||||||
|
const [cmsData, setCmsData] = useState<Record<string, unknown>>({});
|
||||||
|
const [cmsLoaded, setCmsLoaded] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const fetchCms = async () => {
|
||||||
|
try {
|
||||||
|
const sections = await cmsService.getPageContent('landing');
|
||||||
|
const data: Record<string, unknown> = {};
|
||||||
|
for (const s of sections) {
|
||||||
|
const content = s.content as Record<string, unknown>;
|
||||||
|
// Resolve S3 keys in image fields
|
||||||
|
if (s.sectionKey === 'features' && Array.isArray(content.features)) {
|
||||||
|
for (const feat of content.features as { iconPath?: string }[]) {
|
||||||
|
if (feat.iconPath) feat.iconPath = await resolveImageUrl(feat.iconPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (s.sectionKey === 'testimonials' && Array.isArray(content.stats)) {
|
||||||
|
for (const stat of content.stats as { iconPath?: string }[]) {
|
||||||
|
if (stat.iconPath) stat.iconPath = await resolveImageUrl(stat.iconPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
data[s.sectionKey] = content;
|
||||||
|
}
|
||||||
|
setCmsData(data);
|
||||||
|
} catch {
|
||||||
|
// Use default content on error
|
||||||
|
} finally {
|
||||||
|
setCmsLoaded(true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
fetchCms();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<HeroSection content={cmsData.hero as HeroContent | undefined} />
|
||||||
|
{cmsLoaded && <FeaturesSection content={cmsData.features as FeaturesContent | undefined} />}
|
||||||
|
<TopProfessionals content={cmsData.topProfessionals as TopProfessionalsContent | undefined} />
|
||||||
|
<TestimonialsSection content={cmsData.testimonials as TestimonialsContent | undefined} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user