import express from 'express';
import { authenticate } from '../middleware/authMiddleware.js';
import {
    getTrainingGroups,
    createTrainingGroup,
    updateTrainingGroup,
    deleteTrainingGroup,
    addMemberToGroup,
    removeMemberFromGroup,
    getMemberGroups,
    ensurePresetGroups,
    enablePresetGroup,
} from '../controllers/trainingGroupController.js';

const router = express.Router();

router.use(authenticate);

// Spezifischere Routen zuerst (mit /member/ im Pfad)
router.get('/:clubId/member/:memberId', getMemberGroups);
router.post('/:clubId/:groupId/member/:memberId', addMemberToGroup);
router.delete('/:clubId/:groupId/member/:memberId', removeMemberFromGroup);

// Allgemeinere Routen danach
router.post('/:clubId/ensure-preset-groups', ensurePresetGroups);
router.post('/:clubId/enable-preset-group/:presetType', enablePresetGroup);
router.get('/:clubId', getTrainingGroups);
router.post('/:clubId', createTrainingGroup);
router.put('/:clubId/:groupId', updateTrainingGroup);
router.delete('/:clubId/:groupId', deleteTrainingGroup);

export default router;

