From 6cdf250531b0d7b6d195e841a4e4d5b9bd2db4d6 Mon Sep 17 00:00:00 2001 From: Praagna L Vaishnavi <147193570+PraagnaVaishnavi@users.noreply.github.com> Date: Thu, 7 Aug 2025 10:21:02 +0530 Subject: [PATCH] Updated AllCategories.js --- .../admin/categories/AllCategories.js | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/client/src/components/admin/categories/AllCategories.js b/client/src/components/admin/categories/AllCategories.js index 2fec7194..d9f7a584 100644 --- a/client/src/components/admin/categories/AllCategories.js +++ b/client/src/components/admin/categories/AllCategories.js @@ -1,6 +1,9 @@ import React, { Fragment, useContext, useEffect } from "react"; import { getAllCategory, deleteCategory } from "./FetchApi"; import { CategoryContext } from "./index"; +import { ToastContainer, toast } from "react-toastify"; +import "react-toastify/dist/ReactToastify.css"; + import moment from "moment"; const apiURL = process.env.REACT_APP_API_URL; @@ -28,15 +31,19 @@ const AllCategory = (props) => { }, 1000); }; - const deleteCategoryReq = async (cId) => { - let deleteC = await deleteCategory(cId); - if (deleteC.error) { - console.log(deleteC.error); - } else if (deleteC.success) { - console.log(deleteC.success); - fetchData(); - } - }; +const deleteCategoryReq = async (cId) => { + let deleteC = await deleteCategory(cId); + if (deleteC.error) { + console.log(deleteC.error); + } else if (deleteC.success) { + toast.success("Category deleted successfully!", { + position: "top-right", + autoClose: 2000, + }); + fetchData(); + } +}; + /* This method call the editmodal & dispatch category context */ const editCategory = (cId, type, des, status) => { @@ -199,7 +206,7 @@ const CategoryTable = ({ category, deleteCat, editCat }) => { fillRule="evenodd" d="M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z" clipRule="evenodd" - /> + />