const express = require('express');
const router = express.Router();
const appLanguageController = require('../controllers/app-language.controller');
const { isAuthenticated, allowRoles } = require('../middlewares/authenticate');

// ============================================================================
// Public Routes
// ============================================================================

// List active languages (for dropdowns)
router.get('/', appLanguageController.listLanguages);

// Get specific language content (for i18n initialization)
router.get('/:code', appLanguageController.getLanguage);

// ============================================================================
// Protected Routes (Super Admin Only)
// ============================================================================

router.use(isAuthenticated);
router.use(allowRoles('super-admin'));

// Admin specific list (includes inactive and full content)
router.get('/admin/all', appLanguageController.getAllLanguagesAdmin);

// Create or Update language
router.post('/', appLanguageController.upsertLanguage);

// Delete language
router.delete('/:code', appLanguageController.deleteLanguage);

module.exports = router;
