import express from 'express';
import { authenticate } from '../middleware/authMiddleware.js';
import { authorize } from '../middleware/authorizationMiddleware.js';
import { getClubs, addClub, getClub, requestClubAccess, getPendingApprovals, approveClubAccess, rejectClubAccess, updateClubSettings } from '../controllers/clubsController.js';

const router = express.Router();

router.get('/', authenticate, getClubs);
router.post('/', authenticate, addClub);
// Spezifische Routen VOR generischem /:clubid
router.get('/request/:clubid', authenticate, requestClubAccess);
router.get('/pending/:clubid', authenticate, authorize('approvals', 'read'), getPendingApprovals);
router.post('/approve', authenticate, authorize('approvals', 'write'), approveClubAccess);
router.post('/reject', authenticate, authorize('approvals', 'write'), rejectClubAccess);
router.put('/:clubid/settings', authenticate, updateClubSettings);
router.get('/:clubid', authenticate, getClub);

export default router;
