const express = require('express');
const router = express.Router();
const memberController = require('../controllers/memberController');
const { authenticateToken, requireManager } = require('../middleware/auth');

// All routes require authentication
router.use(authenticateToken);

// Member Management (Manager only)
router.get('/users', requireManager, memberController.getAllUsers);
router.get('/users/available/:groupId', requireManager, memberController.getAvailableUsersForGroup);
router.post('/:groupId/members', requireManager, memberController.addMemberToGroup);
router.delete('/:groupId/members/:memberId', requireManager, memberController.removeMemberFromGroup);
router.put('/:groupId/members/:memberId/status', requireManager, memberController.updateMemberStatus);

// Member Access (Manager and Members)
router.get('/:groupId/members', memberController.getGroupMembers);
router.get('/:groupId/members/:memberId', memberController.getMemberDetails);
router.get('/:groupId/members/:memberId/payment-summary', memberController.getMemberPaymentSummary);

module.exports = router;
