feat: Integrate CMS to dynamically populate home page sections with dedicated content types and a new service.

This commit is contained in:
pradeepkumar
2026-02-22 21:52:54 +05:30
parent c5dc139633
commit b235378815
9 changed files with 227 additions and 86 deletions

View File

@@ -1,17 +1,34 @@
'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 } from '@/services/cms.service';
import type { HeroContent, FeaturesContent, TopProfessionalsContent, TestimonialsContent, CmsContentRecord } from '@/types/cms';
export default function UserDashboard() {
const [cmsData, setCmsData] = useState<Record<string, unknown>>({});
useEffect(() => {
const fetchCms = async () => {
const sections = await cmsService.getPageContent('landing');
const data: Record<string, unknown> = {};
sections.forEach((s: CmsContentRecord) => {
data[s.sectionKey] = s.content;
});
setCmsData(data);
};
fetchCms();
}, []);
return (
<div>
<HeroSection />
<FeaturesSection />
<TopProfessionals />
<TestimonialsSection />
<HeroSection content={cmsData.hero as HeroContent | undefined} />
<FeaturesSection content={cmsData.features as FeaturesContent | undefined} />
<TopProfessionals content={cmsData.topProfessionals as TopProfessionalsContent | undefined} />
<TestimonialsSection content={cmsData.testimonials as TestimonialsContent | undefined} />
</div>
);
}