import express from "express";
import { addSales,getAllSales,getSingleSales } from "./SalesController.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 Sales data
router.post("/add-SC", isAuthenticatedSalesCoOrdinator, addSales);
router.post("/add-TM", isAuthenticatedTerritoryManager, addSales);

// Admin routes
router.get(
  "/all",
  isAuthenticatedUser,
  authorizeRoles("admin"),
  getAllSales
);
router.get(
  "/:id",
  isAuthenticatedUser,
  authorizeRoles("admin"),
  getSingleSales
);
export default router;
