const { createHotelBooking } = require('../models/hotelBookingModel');

exports.bookHotel = async (req, res) => {
  try {
    const bookingData = req.body;
    const offerId =
      bookingData?.data?.roomAssociations?.[0]?.hotelOfferId;

    if (!offerId) {
      return res.status(400).json({ error: 'hotelOfferId is required' });
    }

   
    const data = await createHotelBooking(bookingData);

    res.status(201).json({ success: true, data });
  } catch (error) {
    console.error('Hotel Booking Controller Error:', error);
    res.status(error.statusCode || 500).json({
      success: false,
      error: error.description || error.message,
    });
  }
};
