const express = require('express');
const router = express.Router();
const db = require('../db');

// Get menus by position
router.get('/:position', (req, res) => {
  const { position } = req.params;
  try {
    const menus = db.prepare('SELECT * FROM menus WHERE position = ? ORDER BY sort_order ASC, id ASC').all(position);
    res.json(menus);
  } catch (err) {
    res.status(500).json({ error: 'މެނޫ ހޯދުމުގައި މައްސަލައެއް ދިމާވެއްޖެ' });
  }
});

module.exports = router;
