37 lines
1.1 KiB
JavaScript
37 lines
1.1 KiB
JavaScript
import express from "express";
|
|
import { addInventory, getDistributors,getAllInventories,getSingleInventory } from "./InventoryController.js";
|
|
import { isAuthenticatedSalesCoOrdinator } from "../../middlewares/SalesCoOrdinatorAuth.js";
|
|
import { isAuthenticatedTerritoryManager } from "../../middlewares/TerritoryManagerAuth.js";
|
|
import { authorizeRoles, isAuthenticatedUser } from "../../middlewares/auth.js";
|
|
const router = express.Router();
|
|
|
|
// Route to add inventory data
|
|
router.post("/add-SC", isAuthenticatedSalesCoOrdinator, addInventory);
|
|
router.post("/add-TM", isAuthenticatedTerritoryManager, addInventory);
|
|
// Route to get all PD or RD names based on type
|
|
router.get(
|
|
"/distributors-SC/:type",
|
|
isAuthenticatedSalesCoOrdinator,
|
|
getDistributors
|
|
);
|
|
router.get(
|
|
"/distributors-TM/:type",
|
|
isAuthenticatedTerritoryManager,
|
|
getDistributors
|
|
);
|
|
|
|
// Admin routes
|
|
router.get(
|
|
"/all",
|
|
isAuthenticatedUser,
|
|
authorizeRoles("admin"),
|
|
getAllInventories
|
|
);
|
|
router.get(
|
|
"/:id",
|
|
isAuthenticatedUser,
|
|
authorizeRoles("admin"),
|
|
getSingleInventory
|
|
);
|
|
export default router;
|