const express = require('express');
const router = express.Router();
const {
    getAllLocations,
    getLocationById,
    getLocationsByCountryId,
    createLocation,
    updateLocation,
    deleteLocation,
    getLocationDepartments,
    addDepartmentToLocation,
    removeDepartmentFromLocation,
    getLocationDepartmentPairs
} = require('../controllers/locationsController');

router.get('/', getAllLocations);
router.get('/country/:country_id', getLocationsByCountryId);
router.get('/departments/list', getLocationDepartmentPairs);
router.get('/:id', getLocationById);
router.post('/', createLocation);
router.put('/:id', updateLocation);
router.delete('/:id', deleteLocation);

// Location-Department relationships
router.get('/:id/departments', getLocationDepartments);
router.post('/:id/departments', addDepartmentToLocation);
router.delete('/:id/departments', removeDepartmentFromLocation);

module.exports = router;

