import express from 'express';
import { authenticate } from '../middleware/authMiddleware.js';
import { authorize } from '../middleware/authorizationMiddleware.js';
import { 
  getTeams, 
  getTeam, 
  createTeam, 
  updateTeam, 
  deleteTeam, 
  getLeagues 
} from '../controllers/teamController.js';

const router = express.Router();

// Get all teams for a club
router.get('/club/:clubid', authenticate, authorize('teams', 'read'), getTeams);

// Get leagues for a club
router.get('/leagues/:clubid', authenticate, authorize('teams', 'read'), getLeagues);

// Get a specific team
router.get('/:teamid', authenticate, authorize('teams', 'read'), getTeam);

// Create a new team
router.post('/club/:clubid', authenticate, authorize('teams', 'write'), createTeam);

// Update a team
router.put('/:teamid', authenticate, authorize('teams', 'write'), updateTeam);

// Delete a team
router.delete('/:teamid', authenticate, authorize('teams', 'delete'), deleteTeam);

export default router;