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