diff --git a/frontend/src/api/healthCheck.ts b/frontend/src/api/healthCheck.ts index 698e26b..6de0d50 100644 --- a/frontend/src/api/healthCheck.ts +++ b/frontend/src/api/healthCheck.ts @@ -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 (