import { Router } from 'express';
import * as yieldStudyController from '../controllers/yieldStudyController.js';
import { extractUser, requireAdmin } from '../middleware/roleMiddleware.js';

const router = Router();

// Public routes (read-only)
router.get('/', extractUser, yieldStudyController.getAllStudies);

// Protected routes (require admin permission)
router.post('/', extractUser, requireAdmin, yieldStudyController.createStudy);
router.put('/:id', extractUser, requireAdmin, yieldStudyController.updateStudy);
router.delete('/:id', extractUser, requireAdmin, yieldStudyController.deleteStudy);

export default router;
