/**
 * Progress Routes
 *
 * Route definitions for progress tracking endpoints
 */

import { Router } from 'express';
import { progressController } from './progress.controller';
import { authenticate } from '../../shared/middleware/auth.middleware';

const router = Router();

// All progress routes require authentication
router.use(authenticate);

/**
 * @route   GET /api/progress
 * @desc    Get overall progress for authenticated user
 * @access  Private
 */
router.get('/', progressController.getOverallProgress.bind(progressController));

/**
 * @route   GET /api/progress/module/:moduleId
 * @desc    Get progress for a specific module
 * @param   moduleId - Module ID
 * @access  Private
 */
router.get(
  '/module/:moduleId',
  progressController.getModuleProgress.bind(progressController)
);

/**
 * @route   GET /api/progress/type/:type
 * @desc    Get progress by module type
 * @param   type - Module type (FUNDAMENTOS, SISTEMAS_ESPACIOS, APLICACIONES)
 * @access  Private
 */
router.get(
  '/type/:type',
  progressController.getProgressByType.bind(progressController)
);

/**
 * @route   GET /api/progress/activity
 * @desc    Get recent activity for authenticated user
 * @query   limit - Number of recent activities to return (default: 10)
 * @access  Private
 */
router.get(
  '/activity',
  progressController.getRecentActivity.bind(progressController)
);

/**
 * @route   GET /api/progress/statistics
 * @desc    Get statistics summary for authenticated user
 * @access  Private
 */
router.get(
  '/statistics',
  progressController.getStatistics.bind(progressController)
);

/**
 * @route   GET /api/progress/leaderboard
 * @desc    Get leaderboard
 * @query   moduleId - Filter by module ID (optional, empty = global)
 * @query   limit - Number of entries to return (default: 50)
 * @query   includeSelf - Include user's position (default: true)
 * @access  Private
 */
router.get(
  '/leaderboard',
  progressController.getLeaderboard.bind(progressController)
);

/**
 * @route   DELETE /api/progress/module/:moduleId
 * @desc    Reset module progress
 * @param   moduleId - Module ID
 * @access  Private (TODO: Admin only)
 */
router.delete(
  '/module/:moduleId',
  progressController.resetModuleProgress.bind(progressController)
);

/**
 * @route   GET /api/progress/dashboard
 * @desc    Get dashboard data for authenticated user
 * @access  Private
 */
router.get(
  '/dashboard',
  progressController.getDashboard.bind(progressController)
);

export default router;
