feat: Add CMS context, hooks, and types for managing CMS data

- Implemented CmsContext and CmsProvider for global state management of CMS data.
- Created a custom hook `useGetCms` to fetch CMS data using React Query.
- Defined TypeScript interfaces for CMS response and its related data structures.
- Added error handling for data fetching in both the service and context.
This commit is contained in:
AmirReza Jamali
2025-11-11 15:22:12 +03:30
parent 910e8aed89
commit efbdb82535
12 changed files with 198 additions and 107 deletions
+72
View File
@@ -0,0 +1,72 @@
export interface CmsResponse {
success: boolean;
message: string;
data: CmsData;
}
export interface CmsData {
id: string;
key: string;
hero: CmsHero;
chart: CmsChart;
features: CmsSectionWithCards;
challenges: CmsSectionWithCards;
advantages: CmsSectionWithCards;
contact: CmsContact;
footer: CmsFooter;
created_at: number;
updated_at: number;
}
export interface CmsHero {
Title: string;
Description: string;
ButtonText: string;
ButtonLink: string;
GifFile: string;
}
export interface CmsChart {
title: string;
missedAmount: string;
data: CmsChartDataItem[];
}
export interface CmsChartDataItem {
key: string;
value: number;
}
export interface CmsSectionWithCards {
Title: string;
Description: string;
Cards: CmsCard[];
}
export interface CmsCard {
Icon: string;
Title: string;
Description: string;
}
export interface CmsContact {
Title: string;
Description: string;
SubmitButtonText: string;
Fields: CmsContactField[];
}
export interface CmsContactField {
Name: string;
Label: string;
Placeholder: string;
Required: boolean;
}
export interface CmsFooter {
Email: string;
Phone: string;
Location: string;
Tagline: string;
Copyright: string;
}