import express from 'express';
const router = express.Router();
import * as questionnaireController from './questionnaire.controller.js';
import { authenticate } from '../../common/middleware/auth.js';
import { checkRole } from '../../common/middleware/roleCheck.js';
import { ROLES } from '../../common/config/constants.js';

// Public routes (No Auth Required)
router.get('/public/:applicationId', questionnaireController.getPublicQuestionnaire);
router.post('/public/submit', questionnaireController.submitPublicResponse);

// Public routes (No Auth Required)
router.get('/public/:applicationId', questionnaireController.getPublicQuestionnaire);
router.post('/public/submit', questionnaireController.submitPublicResponse);

router.use(authenticate as any);

// Dealer routes (Application context)
router.get('/latest', questionnaireController.getLatestQuestionnaire);
router.post('/response', questionnaireController.submitResponse);

// Admin routes
router.post('/version', checkRole([ROLES.SUPER_ADMIN, ROLES.DD_ADMIN, ROLES.DD_HEAD]), questionnaireController.createQuestionnaireVersion);

export default router;
