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";
import {isAuthenticated_SC_TM } from "../../middlewares/generalAuth.js";
const router = express.Router();

// Route to add inventory data
router.post("/add", isAuthenticated_SC_TM, 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;
