import { getHotelsByCSFilter } from "@/lib/trpc/memoizedRequests"

import CampaignHotelListingClient from "./Client"

interface CampaignHotelListingProps {
  heading: string
  preamble?: string | null
  hotelIds: string[]
  visibleCountMobile?: 3 | 6
  visibleCountDesktop?: 3 | 6
}

export default async function CampaignHotelListing({
  heading,
  preamble,
  hotelIds,
  visibleCountMobile,
  visibleCountDesktop,
}: CampaignHotelListingProps) {
  const hotels = await getHotelsByCSFilter({ hotelsToInclude: hotelIds })

  if (!hotels.length) {
    return null
  }

  return (
    <CampaignHotelListingClient
      heading={heading}
      preamble={preamble}
      hotels={hotels}
      visibleCountMobile={visibleCountMobile}
      visibleCountDesktop={visibleCountDesktop}
    />
  )
}
