// Assessment Routes - Skill Assessment for Interviews
const express = require('express');
const router = express.Router();
const { protect } = require('../middleware/authMiddleware');
const {
    createAssessment,
    getAssessments,
    inviteCandidate,
    getAssessmentByToken,
    startAssessment,
    submitResponse,
    completeAssessment,
    getCandidateResults,
    deleteAssessment,
    getAssessmentInvites,
    getMyInvites
} = require('../controllers/assessmentController');

// Protected routes (org admin)
router.post('/', protect, createAssessment);
router.get('/', protect, getAssessments);
router.get('/my-invites', protect, getMyInvites); // Add this BEFORE generic :ids
router.post('/:assessmentId/invite', protect, inviteCandidate);
router.get('/results/:inviteId', protect, getCandidateResults);
router.get('/:assessmentId/invites', protect, getAssessmentInvites);
router.delete('/:assessmentId', protect, deleteAssessment);

// Public routes (for candidates)
router.get('/take/:token', getAssessmentByToken);
router.post('/take/:token/start', startAssessment);
router.post('/take/:token/submit', submitResponse);
router.post('/take/:token/complete', completeAssessment);

module.exports = router;
