import express from 'express';
import { authenticate } from '../middleware/authMiddleware.js';
import { authorize } from '../middleware/authorizationMiddleware.js';
import {
  createClubTask,
  deleteClubTask,
  dismissAutomatedClubTaskSuggestion,
  listClubTasks,
  materializeAutomatedClubTasks,
  updateClubTask,
  updateClubTaskStatus,
} from '../controllers/clubTaskController.js';

const router = express.Router();

router.get('/:clubId', authenticate, authorize('tasks', 'read'), listClubTasks);
router.post('/:clubId', authenticate, authorize('tasks', 'write'), createClubTask);
router.post('/:clubId/materialize', authenticate, authorize('tasks', 'write'), materializeAutomatedClubTasks);
router.post('/:clubId/dismiss-suggestion', authenticate, authorize('tasks', 'write'), dismissAutomatedClubTaskSuggestion);
router.put('/:clubId/:taskId', authenticate, authorize('tasks', 'write'), updateClubTask);
router.patch('/:clubId/:taskId/status', authenticate, authorize('tasks', 'write'), updateClubTaskStatus);
router.delete('/:clubId/:taskId', authenticate, authorize('tasks', 'write'), deleteClubTask);

export default router;
