const express = require('express');
const router = express.Router();
const {
  getAllSubCategories,
  getSubCategoriesByCategory,
  getActiveSubCategories,
  getSubCategoryById,
  getSubCategoryBySlug,
  getSubCategoryWithTours,
  createSubCategory,
  updateSubCategory,
  deleteSubCategory
} = require('../controllers/subCategoryController');
const { protect, adminOnly } = require('../middleware/authMiddleware');

// Public routes
router.get('/', getAllSubCategories);
router.get('/active', getActiveSubCategories);
router.get('/category/:categoryId', getSubCategoriesByCategory);
router.get('/:id', getSubCategoryById);
router.get('/slug/:slug', getSubCategoryBySlug);
router.get('/:id/tours', getSubCategoryWithTours);

// Admin routes
router.post('/', protect, adminOnly, createSubCategory);
router.put('/:id', protect, adminOnly, updateSubCategory);
router.delete('/:id', protect, adminOnly, deleteSubCategory);

module.exports = router;
