feat: add CMS page and service to manage website content.
This commit is contained in:
86
src/services/cms.service.ts
Normal file
86
src/services/cms.service.ts
Normal 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();
|
||||
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user