import { redirect } from "next/navigation"

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

import SidePeek from "@/components/HotelReservation/EnterDetails/SidePeek"

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

export default async function HotelSidePeek({
  params,
  searchParams,
}: PageArgs<LangParams, { hotel: string }>) {
  if (!searchParams.hotel) {
    redirect(`/${params.lang}`)
  }
  const hotel = await getHotelData({
    hotelId: searchParams.hotel,
    language: params.lang,
  })
  if (!hotel?.data) {
    redirect(`/${params.lang}`)
  }
  return <SidePeek hotel={hotel.data.attributes} />
}
