const hotelService = require("../services/hotelSearchService");

exports.searchHotelAvailability = async (req, res) => {
  console.log("=================================================");
  console.log("CONTROLLER: Hotel Search Availability - START");

  try {
    const payload = req.body;

    console.log("Incoming Request Body:");
    console.log(JSON.stringify(payload, null, 2));

    if (!payload) {
      return res.status(400).json({
        success: false,
        message: "Request body is required",
      });
    }

    const response = await hotelService.searchHotelAvailability(payload);

    console.log("CONTROLLER: Hotel Search Availability - SUCCESS");
    console.log("=================================================");

    res.status(200).json({
      success: true,
      message: "Hotel availability fetched successfully",
      data: response,
    });

  } catch (error) {
    console.error("CONTROLLER ERROR:", error.message);

    res.status(500).json({
      success: false,
      message: "Hotel availability failed",
      error: error.message,
    });
  }
};