const express = require('express');
const router = express.Router();
const { 
  createRestaurant, 
  getAllRestaurants, 
  getRestaurantById,
  updateRestaurantTables,
  updateRestaurant
} = require('../controllers/restaurantController');
const { protect, ownerOnly } = require('../middleware/authMiddleware');
const upload = require('../middleware/uploadMiddleware');

router.route('/')
  .get(getAllRestaurants)
  .post(protect, ownerOnly, createRestaurant);

router.route('/profile')
  .put(protect, ownerOnly, upload.single('image'), updateRestaurant);

router.route('/tables')
  .put(protect, ownerOnly, updateRestaurantTables);

router.route('/:id')
  .get(getRestaurantById);

module.exports = router;
