import { Router } from 'express';
import { authenticateToken } from '@middlewares/auth.middleware';
import {
  getTatAlertsByRequest,
  getTatAlertsByLevel,
  getTatComplianceSummary,
  getTatBreachReport,
  getApproverTatPerformance,
  updateBreachReason
} from '@controllers/tat.controller';

const router = Router();

// All TAT routes require authentication
router.use(authenticateToken);

/**
 * @route   GET /api/tat/alerts/request/:requestId
 * @desc    Get all TAT alerts for a specific request
 * @access  Private
 */
router.get('/alerts/request/:requestId', getTatAlertsByRequest);

/**
 * @route   GET /api/tat/alerts/level/:levelId
 * @desc    Get TAT alerts for a specific approval level
 * @access  Private
 */
router.get('/alerts/level/:levelId', getTatAlertsByLevel);

/**
 * @route   GET /api/tat/compliance/summary
 * @desc    Get TAT compliance summary with optional date range
 * @query   startDate, endDate (optional)
 * @access  Private
 */
router.get('/compliance/summary', getTatComplianceSummary);

/**
 * @route   GET /api/tat/breaches
 * @desc    Get TAT breach report (all breached requests)
 * @access  Private
 */
router.get('/breaches', getTatBreachReport);

/**
 * @route   GET /api/tat/performance/:approverId
 * @desc    Get TAT performance metrics for a specific approver
 * @access  Private
 */
router.get('/performance/:approverId', getApproverTatPerformance);

/**
 * @route   PUT /api/tat/breach-reason/:levelId
 * @desc    Update breach reason for a TAT alert
 * @access  Private (ADMIN, MANAGEMENT, or approver)
 */
router.put('/breach-reason/:levelId', updateBreachReason);

export default router;

