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

import BookingWidgetClient from "./Client"

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

export default async function BookingWidget({
  type,
  bookingWidgetSearchParams,
}: BookingWidgetProps) {
  const isHidden = await isBookingWidgetHidden()

  if (isHidden) {
    return null
  }

  return (
    <BookingWidgetClient
      type={type}
      bookingWidgetSearchParams={bookingWidgetSearchParams}
    />
  )
}
