import Image from "next/image";

import type { ResponseHotelData } from "@/types/hotel";
import type { HotelMetaForRequest } from "@/components/hotel-review/types";
import { assetPath } from "@/utils/assets";
import { OfferDetailsBusiness } from "./OfferDetailsBusiness";

interface RoomDetailsBusinessProps {
  room: ResponseHotelData["rooms"][number];
  hotelMeta: HotelMetaForRequest;
}

/**
 * LEIS-987 — a Business-mode fork of leisure-ui's RoomDetails: same
 * image/amenities/rate-card layout, a static primary image instead of the
 * hover-activated carousel (one fewer dynamic import for a card that is
 * otherwise unchanged).
 */
export function RoomDetailsBusiness({ room, hotelMeta }: RoomDetailsBusinessProps) {
  const primaryImage = room.images?.[0]?.href || assetPath("/assets/img/no-image.png");

  return (
    <div className="row">
      <div className="col-xxl-4 col-xl-4 col-lg-4 col-md-5 col-12 border-end">
        <div className="card border-0 bg-transparent p-0 p-md-3">
          <div
            className="h-imgs-carousel position-relative"
            style={{ height: "200px", minHeight: "200px", maxHeight: "200px" }}
          >
            <Image
              src={primaryImage}
              width={300}
              height={200}
              className="d-block w-100 h-100 rounded-3"
              alt={room.roomName}
              loading="lazy"
              style={{ objectFit: "cover", maxHeight: "200px" }}
            />
          </div>
          <div className="card-body p-0 mt-3">
            <h5 className="smallHeading my-3 fw-bold">{room.roomName}</h5>
            <ul className="p-0">
              {(room.amenities || []).map((amenity, idx) => (
                <li key={idx} className="text-md mb-0 pb-2">
                  {amenity}
                </li>
              ))}
            </ul>
          </div>
        </div>
      </div>
      <div className="col-xxl-8 col-xl-8 col-lg-8 col-md-7 col-12 ps-sm-0 ps-3">
        {(room.offers || []).map((offer, idx) => (
          <OfferDetailsBusiness
            key={idx}
            offer={offer}
            roomName={room.roomName}
            hotelMeta={hotelMeta}
            isLast={idx === (room.offers?.length || 0) - 1}
          />
        ))}
      </div>
    </div>
  );
}
