"use client";

import type { HotelRequestSelection } from "@/components/hotel-review/types";
import { formatMoney, formatDate } from "@/services/employee-requests/format";

/* eslint-disable @next/next/no-img-element */

/**
 * The hotel stay being requested, pinned above the approval form — the hotel
 * equivalent of SelectedFlightBand. See that component's doc comment for why
 * every element states its own colour: this is portalled the same way.
 */
export function SelectedHotelBand({ selection }: { selection: HotelRequestSelection }) {
  return (
    <div className="mt-[16px] mb-1 flex flex-col gap-[12px] rounded-xl bg-[linear-gradient(120deg,var(--fra-navy)_0%,var(--fra-navy-2)_100%)] px-[16px] py-3.5 text-white sm:flex-row sm:items-center sm:gap-3.5">
      {selection.imageUrl && (
        <img
          src={selection.imageUrl}
          alt={selection.property}
          className="size-12 shrink-0 rounded-xl object-cover"
        />
      )}
      <div className="min-w-0 flex-1">
        <strong className="block text-base text-white">{selection.property}</strong>
        {selection.location && (
          <span className="mt-0.5 block text-[13px] text-white/80">{selection.location}</span>
        )}
        <span className="mt-0.5 block text-[13px] text-white/80">
          {formatDate(selection.checkIn)} – {formatDate(selection.checkOut)} · {selection.nights} night
          {selection.nights === 1 ? "" : "s"} · 1 room · {selection.adults ?? 1} adult
          {(selection.adults ?? 1) === 1 ? "" : "s"}
        </span>
        <span className="mt-0.5 block text-[13px] text-white/80">
          {selection.roomType}
          {selection.rateType ? ` · ${selection.rateType}` : ""}
        </span>
      </div>
      <div className="shrink-0 text-left sm:text-right">
        <div className="text-2xl font-bold text-white">
          {formatMoney(selection.nightlyRate, selection.currency)}
        </div>
        <small className="block text-xs font-medium text-white/70">per night</small>
      </div>
    </div>
  );
}
