feat: health checkup CRUD apis #30
@@ -95,18 +95,45 @@ export const createCategoryApi = async (data: {
|
|||||||
slug: string;
|
slug: string;
|
||||||
sortOrder: number;
|
sortOrder: number;
|
||||||
}) => {
|
}) => {
|
||||||
|
try {
|
||||||
const res = await apiClient.post("/health-check/categories", data);
|
const res = await apiClient.post("/health-check/categories", data);
|
||||||
|
|
||||||
|
toast.success("Category created successfully");
|
||||||
|
|
||||||
return res.data;
|
return res.data;
|
||||||
|
} catch (error: any) {
|
||||||
|
toast.error(error?.response?.data?.message || "Failed to create category");
|
||||||
|
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const updateCategoryApi = async (id: number, data: any) => {
|
export const updateCategoryApi = async (id: number, data: any) => {
|
||||||
|
try {
|
||||||
const res = await apiClient.patch(`/health-check/categories/${id}`, data);
|
const res = await apiClient.patch(`/health-check/categories/${id}`, data);
|
||||||
|
|
||||||
|
toast.success("Category updated successfully");
|
||||||
|
|
||||||
return res.data;
|
return res.data;
|
||||||
|
} catch (error: any) {
|
||||||
|
toast.error(error?.response?.data?.message || "Failed to update category");
|
||||||
|
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const deleteCategoryApi = async (id: number) => {
|
export const deleteCategoryApi = async (id: number) => {
|
||||||
|
try {
|
||||||
const res = await apiClient.delete(`/health-check/categories/${id}`);
|
const res = await apiClient.delete(`/health-check/categories/${id}`);
|
||||||
|
|
||||||
|
toast.success("Category deleted successfully");
|
||||||
|
|
||||||
return res.data;
|
return res.data;
|
||||||
|
} catch (error: any) {
|
||||||
|
toast.error(error?.response?.data?.message || "Failed to delete category");
|
||||||
|
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getAllInquiriesApi = async (
|
export const getAllInquiriesApi = async (
|
||||||
|
|||||||
Reference in New Issue
Block a user