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

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,
  })

  return <SidePeek hotel={hotel} />
}
