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

import { FloatingBookingWidgetClient } from "./FloatingBookingWidgetClient"

import type { BookingWidgetProps } from "@/types/components/bookingWidget"

export async function FloatingBookingWidget({
  bookingWidgetSearchParams,
}: Omit<BookingWidgetProps, "type">) {
  console.log("DEBUG: FloatingBookingWidget", bookingWidgetSearchParams)

  let pageSettingsBookingCodePromise: Promise<string> | null = null
  if (!bookingWidgetSearchParams.bookingCode) {
    pageSettingsBookingCodePromise = getPageSettingsBookingCode()
  }

  return (
    <FloatingBookingWidgetClient
      bookingWidgetSearchParams={bookingWidgetSearchParams}
      pageSettingsBookingCodePromise={pageSettingsBookingCodePromise}
    />
  )
}
