b444f6a08f
- Implement CMS table with row listing and pagination - Add delete functionality for CMS entries with confirmation modal - Introduce edit button to navigate to edit page for specific CMS entry - Update page type form to include new 'key' field for CMS entries - Modify CMS service and types to support new data structure - Enhance table presenter with additional actions and state management Resolves data management and user interaction improvements for CMS module
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import api from "../axios";
|
|
import { API_ENDPOINTS } from "../endpoints";
|
|
import { ApiResponse } from "../types";
|
|
import { TCmsListResponse } from "../types/TCms";
|
|
|
|
export const cmsService = {
|
|
getCms: async (): Promise<ApiResponse<TCmsListResponse>> => {
|
|
try {
|
|
return (await api.get(API_ENDPOINTS.CMS.BASE())).data;
|
|
} catch (error) {
|
|
console.error("Error Caught in CMS Service => Get cms", error);
|
|
throw error;
|
|
}
|
|
},
|
|
createCms: async (data: any) => {
|
|
try {
|
|
return (await api.post(API_ENDPOINTS.CMS.BASE(), data)).data;
|
|
} catch (error) {
|
|
console.error("Error Caught in CMS Service => Create cms", error);
|
|
throw error;
|
|
}
|
|
},
|
|
getCmsDetails: async (id: string) => {
|
|
try {
|
|
return (await api.get(API_ENDPOINTS.CMS.BASE(id))).data;
|
|
} catch (error) {
|
|
console.error("Error Caught In CMS Service => getCmsDetails: ", error);
|
|
throw error;
|
|
}
|
|
},
|
|
deleteCms: async (id: string) => {
|
|
try {
|
|
return (await api.delete(API_ENDPOINTS.CMS.BASE(id))).data;
|
|
} catch (error) {
|
|
console.error("Error caught in CMS Service => delete CMS: ", error);
|
|
throw error;
|
|
}
|
|
},
|
|
};
|