import express from 'express';
import clubAccountController from '../controllers/clubAccountController.js';
import { authenticate } from '../middleware/authMiddleware.js';
import { authorize } from '../middleware/authorizationMiddleware.js';

const router = express.Router();

router.use(authenticate);

router.get('/:clubId', authorize('finance_accounts', 'read'), clubAccountController.listClubAccounts);
router.post('/:clubId', authorize('finance_accounts', 'write'), clubAccountController.createClubAccount);
router.put('/:clubId/:accountId', authorize('finance_accounts', 'write'), clubAccountController.updateClubAccount);
router.patch('/:clubId/:accountId/status', authorize('finance_accounts', 'write'), clubAccountController.updateClubAccountStatus);
router.delete('/:clubId/:accountId', authorize('finance_accounts', 'write'), clubAccountController.deleteClubAccount);
router.post('/:clubId/transactions', authorize('finance_accounts', 'write'), clubAccountController.createTransaction);
router.put('/:clubId/transactions/:transactionId', authorize('finance_accounts', 'write'), clubAccountController.updateTransaction);
router.delete('/:clubId/transactions/:transactionId', authorize('finance_accounts', 'write'), clubAccountController.deleteTransaction);

export default router;
