From 852a25269a09272a626f5cdfe17d20a30ac093eb Mon Sep 17 00:00:00 2001 From: Kailasdevdas Date: Mon, 18 May 2026 10:58:24 +0530 Subject: [PATCH] feat: add toast --- frontend/src/api/healthCheck.ts | 39 ++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 6 deletions(-) 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 (