import express from 'express';
import {
  getTasks,
  getAssignees,
  createTask,
  updateTask,
  toggleTaskStatus,
  deleteTask
} from '../controllers/taskController.js';
import verifyToken from '../middleware/authMiddleware.js';

const router = express.Router();

// All task routes require authenticated admin/moderator token
router.use(verifyToken);

// GET /api/admin/tasks/assignees - List potential assignees
router.get('/assignees', getAssignees);

// GET /api/admin/tasks - List all tasks with filters & stats
router.get('/', getTasks);

// POST /api/admin/tasks - Create task
router.post('/', createTask);

// PUT /api/admin/tasks/:id - Update task details
router.put('/:id', updateTask);

// PATCH /api/admin/tasks/:id/toggle - Toggle completed / pending
router.patch('/:id/toggle', toggleTaskStatus);

// DELETE /api/admin/tasks/:id - Delete task
router.delete('/:id', deleteTask);

export default router;
