import express from 'express';
import { authenticate } from '../middleware/authMiddleware.js';
import { authorize } from '../middleware/authorizationMiddleware.js';
import {
  getMemberOrders,
  createMemberOrder,
  updateMemberOrder,
  getGlobalOrders
} from '../controllers/memberOrderController.js';

const router = express.Router();

router.get('/global', authenticate, getGlobalOrders);
router.get('/:clubId/:memberId', authenticate, authorize('members', 'read'), getMemberOrders);
router.post('/:clubId/:memberId', authenticate, authorize('members', 'write'), createMemberOrder);
router.patch('/:clubId/:memberId/:orderId', authenticate, authorize('members', 'write'), updateMemberOrder);

export default router;
