import express from "express";
import {
  assignTask,
  getTasksByStatus,
  updateTaskStatus,
  getTasksbytask,
  getAllTasksByStatus,
  getTasksByDates,
} from "./TaskController.js";
import { isAuthenticatedSalesCoOrdinator } from "../../middlewares/SalesCoOrdinatorAuth.js";
import { isAuthenticatedTerritoryManager } from "../../middlewares/TerritoryManagerAuth.js";
import { isAuthenticated_SC_TM } from "../../middlewares/generalAuth.js";

const router = express.Router();

// Route for Territory Manager to assign a task
router.post("/assign-task", isAuthenticatedTerritoryManager, assignTask);

// Route for Sales Coordinator to view their tasks by status
router.get("/tasks/:status", isAuthenticatedSalesCoOrdinator, getTasksByStatus);
router.get(
  "/alltasks/:status",
  isAuthenticatedTerritoryManager,
  getAllTasksByStatus
);
router.get("/alltask", isAuthenticated_SC_TM, getTasksByDates);
router.get("/task/type/:task", isAuthenticatedSalesCoOrdinator, getTasksbytask);
// Route to update task status
router.put(
  "/update-task-status/:taskId",
  isAuthenticatedSalesCoOrdinator,
  updateTaskStatus
);

export default router;
