import { env } from "@/env/server"

import { BookingWidget } from "@/components/BookingWidget"
import { parseBookingWidgetSearchParams } from "@/utils/url"

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

export default async function BookingWidgetPage(
  props: PageArgs<LangParams, NextSearchParams>
) {
  const params = await props.params
  const searchParams = await props.searchParams
  if (!env.isLangLive(params.lang)) {
    return null
  }

  const booking = parseBookingWidgetSearchParams(searchParams)

  return <BookingWidget booking={booking} />
}
