import { BookingWidget } from "@scandic-hotels/booking-flow/BookingWidget"
import { parseBookingWidgetSearchParams } from "@scandic-hotels/booking-flow/utils/url"

import { bookingFlowConfig } from "@/constants/bookingFlowConfig"

import { getLang } from "@/i18n/serverContext"

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

export default async function BookingWidgetPage(
  props: PageArgs<LangParams, NextSearchParams>
) {
  const searchParams = await props.searchParams

  const booking = parseBookingWidgetSearchParams(searchParams)

  const lang = await getLang()

  return (
    <BookingWidget booking={booking} lang={lang} config={bookingFlowConfig} />
  )
}
