import { getHotelData } from "@/lib/trpc/memoizedRequests"
import { HotelIncludeEnum } from "@/server/routers/hotels/input"

import { getQueryParamsForEnterDetails } from "@/components/HotelReservation/SelectRate/RoomSelection/utils"
import SidePeek from "@/components/HotelReservation/SidePeek"

import type { LangParams, PageArgs } from "@/types/params"

export default async function HotelSidePeek({
  params,
  searchParams,
}: PageArgs<LangParams, { hotel: string }>) {
  const search = new URLSearchParams(searchParams)
  const { hotel: hotelId } = getQueryParamsForEnterDetails(search)

  if (!hotelId) {
    return <SidePeek hotel={null} />
  }

  const hotel = await getHotelData({
    hotelId: hotelId,
    language: params.lang,
    include: [HotelIncludeEnum.RoomCategories],
  })

  return <SidePeek hotel={hotel} />
}
