feat: add CMS page and service to manage website content.

This commit is contained in:
pradeepkumar
2026-02-22 21:52:05 +05:30
parent 287faa4570
commit 26b24bdd50
4 changed files with 710 additions and 0 deletions

View File

@@ -0,0 +1,86 @@
import api, { ApiResponse } from './api';
// TypeScript interfaces for each section's content shape
export interface HeroContent {
headline: string;
description: string;
ctaButtonText: string;
helperText: string;
}
export interface FeatureItem {
iconPath: string;
title: string;
description: string;
}
export interface FeaturesContent {
title: string;
subtitle: string;
features: FeatureItem[];
}
export interface ProfessionalItem {
name: string;
subtitle: string;
location: string;
experience: string;
expertise: string[];
imageUrl: string;
}
export interface TopProfessionalsContent {
title: string;
ctaText: string;
ctaButtonText: string;
agents: ProfessionalItem[];
lenders: ProfessionalItem[];
}
export interface TestimonialItem {
rating: number;
title: string;
content: string;
author: string;
role: string;
}
export interface StatItem {
iconPath: string;
boldText: string;
normalText: string;
}
export interface TestimonialsContent {
title: string;
subtitle: string;
ratingInfo: string;
stats: StatItem[];
testimonials: TestimonialItem[];
}
export interface CmsContentRecord {
id: string;
pageSlug: string;
sectionKey: string;
content: HeroContent | FeaturesContent | TopProfessionalsContent | TestimonialsContent;
isPublished: boolean;
createdAt: string;
updatedAt: string;
}
class CmsService {
private basePath = '/cms';
async getByPage(pageSlug: string): Promise<CmsContentRecord[]> {
const response = await api.get<ApiResponse<CmsContentRecord[]>>(`${this.basePath}/page/${pageSlug}`);
return response.data.data;
}
async upsert(data: { pageSlug: string; sectionKey: string; content: unknown; isPublished?: boolean }): Promise<CmsContentRecord> {
const response = await api.put<ApiResponse<CmsContentRecord>>(`${this.basePath}/upsert`, data);
return response.data.data;
}
}
export const cmsService = new CmsService();

View File

@@ -59,3 +59,17 @@ export type {
// Upload Service
export { uploadService } from './upload.service';
// CMS Service
export { cmsService } from './cms.service';
export type {
CmsContentRecord,
HeroContent,
FeaturesContent,
FeatureItem,
TopProfessionalsContent,
ProfessionalItem,
TestimonialsContent,
TestimonialItem,
StatItem,
} from './cms.service';