Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions client/src/components/admin/categories/AllCategories.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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"
/>
/>
</svg>
</span>
</td>
Expand Down