import type { ResponseHotelData } from "@/types/hotel";
import config from "@/utils/config";

interface LocationSectionBusinessProps {
  hotel: ResponseHotelData;
}

/**
 * LEIS-987 — "Location," a much smaller stand-in for leisure-ui's
 * LocationSection: an embedded map centred on the property, not the
 * nearby-landmarks/nearby-hotels/routing feature that component builds.
 *
 * That feature needs a `/api/hotels/nearby` + `/api/hotels/route` pair corp
 * has never had, backed by a landmarks data source nothing in this session
 * confirmed exists independent of leisure-ui's own Next.js API routes — only
 * the Google Maps API key itself is shared (NEXT_PUBLIC_GOOGLE_MAPS_API_KEY,
 * already in corp's .env). The Maps **Embed** API needs just that key and an
 * iframe, no JS SDK loader and no new backend route, so that's what this
 * renders: the hotel pinned on a map, nothing interactive beyond what Google
 * Maps itself offers. Worth building the fuller version later if an
 * employee actually needs to search near a landmark before requesting — nothing
 * so far has called for it.
 */
export function LocationSectionBusiness({ hotel }: LocationSectionBusinessProps) {
  const apiKey = config.ENV_VARS.GOOGLE_MAPS_API_KEY;
  if (!hotel.latitude || !hotel.longitude || !apiKey) return null;

  const src = `https://www.google.com/maps/embed/v1/place?key=${apiKey}&q=${hotel.latitude},${hotel.longitude}`;

  return (
    <section className="property-location-view mb-4" id="location">
      <div className="container webNewContent">
        <div className="row">
          <div className="col-12">
            <div className="bgColor-white shadow-sm rounded-4 p-3 p-md-4 mb-0">
              <div className="row mb-3">
                <div className="col-12">
                  <h5 className="subHeading fw-bold">Location</h5>
                </div>
              </div>
              <div className="mapView rounded-3 overflow-hidden" style={{ height: 420 }}>
                <iframe
                  title={`Map showing ${hotel.hotelname}`}
                  width="100%"
                  height="100%"
                  style={{ border: 0 }}
                  loading="lazy"
                  allowFullScreen
                  src={src}
                />
              </div>
            </div>
          </div>
        </div>
      </div>
    </section>
  );
}
