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

interface UserReviewsSummaryBusinessProps {
  hotel: ResponseHotelData;
}

/**
 * LEIS-987 — "User Reviews," a plain score summary (or the same empty state
 * leisure-ui's own HotelReviewsSection shows) rather than a port of that
 * component's full filterable review list. That component reads from
 * useHotelReviews/reviews.client, a review-aggregation feature corp has no
 * client for and this build found no evidence a Business-mode employee
 * needs — hotel-details's own search-service response already carries
 * avg_overall_rating/total_reviews, so this renders exactly those two
 * numbers when present.
 */
export function UserReviewsSummaryBusiness({ hotel }: UserReviewsSummaryBusinessProps) {
  const hasReviews = (hotel.total_reviews ?? 0) > 0 && hotel.avg_overall_rating != null;

  return (
    <section className="reviewsSection mb-4" id="hotel-reviews">
      <div className="container webNewContent">
        <div className="row">
          <div className="col-12">
            <div className="bgColor-white shadow-sm rounded-4 p-3 p-md-4">
              <h5 className="subHeading fw-bold mb-4">User Reviews</h5>
              {hasReviews ? (
                <div className="d-flex align-items-center gap-3">
                  <span className="w-60 h-60 ratingBox rounded bgColor-first color-text-white fw-500 text-lg d-flex justify-content-center align-items-center p-2">
                    {hotel.avg_overall_rating!.toFixed(1)}
                  </span>
                  <div>
                    <strong className="thirdHeading d-block">
                      {hotel.avg_overall_rating! >= 4.5
                        ? "Excellent"
                        : hotel.avg_overall_rating! >= 4
                          ? "Very Good"
                          : "Good"}
                    </strong>
                    <small className="d-block text-sm">
                      {hotel.total_reviews!.toLocaleString()} Review{hotel.total_reviews === 1 ? "" : "s"}
                    </small>
                  </div>
                </div>
              ) : (
                <div
                  className="d-flex flex-column align-items-center justify-content-center py-5"
                  style={{ minHeight: 120 }}
                >
                  <p className="fw-semibold color-text-dark mb-1">No reviews yet</p>
                  <small className="text-muted">Be the first to share your experience at this hotel</small>
                </div>
              )}
            </div>
          </div>
        </div>
      </div>
    </section>
  );
}
