Finish admin dashboard and update sql code
This commit is contained in:
14
backend/routes/category.js
Normal file
14
backend/routes/category.js
Normal file
@@ -0,0 +1,14 @@
|
||||
const express = require("express");
|
||||
const {
|
||||
getAllCategoriesWithPagination,
|
||||
addCategory,
|
||||
removeCategory,
|
||||
} = require("../controllers/category");
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
router.get("/getCategories", getAllCategoriesWithPagination);
|
||||
router.post("/addCategory", addCategory);
|
||||
router.delete("/:id", removeCategory);
|
||||
|
||||
module.exports = router;
|
||||
@@ -7,6 +7,8 @@ const {
|
||||
getAllProducts,
|
||||
getProductById,
|
||||
addProduct,
|
||||
removeProduct,
|
||||
getProductWithPagination,
|
||||
} = require("../controllers/product");
|
||||
const router = express.Router();
|
||||
|
||||
@@ -22,6 +24,12 @@ router.post("/delFavorite", removeFavorite);
|
||||
|
||||
router.post("/addProduct", addProduct);
|
||||
router.get("/getProduct", getAllProducts);
|
||||
|
||||
//Remove product
|
||||
router.delete("/:id", removeProduct);
|
||||
//Get products with pagination
|
||||
router.get("/getProductWithPagination", getProductWithPagination);
|
||||
|
||||
router.get("/:id", getProductById); // Simplified route
|
||||
|
||||
module.exports = router;
|
||||
|
||||
@@ -8,6 +8,8 @@ const {
|
||||
updateUser,
|
||||
deleteUser,
|
||||
doLogin,
|
||||
isAdmin,
|
||||
getUsersWithPagination,
|
||||
} = require("../controllers/user");
|
||||
|
||||
const router = express.Router();
|
||||
@@ -36,4 +38,10 @@ router.post("/update", updateUser);
|
||||
//Delete A uses Data:
|
||||
router.post("/delete", deleteUser);
|
||||
|
||||
//Check admin status
|
||||
router.get("/isAdmin/:id", isAdmin);
|
||||
|
||||
//Fetch user with pagination
|
||||
router.get("/getUserWithPagination", getUsersWithPagination);
|
||||
|
||||
module.exports = router;
|
||||
|
||||
Reference in New Issue
Block a user