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

import RouterTransition from "@/components/TrackingSDK/RouterTransition"

import type {
  TrackingSDKHotelInfo,
  TrackingSDKPageData,
  TrackingSDKPaymentInfo,
} from "@/types/components/tracking"

export const preloadUserTracking = () => {
  void getUserTracking()
}

export default async function TrackingSDK({
  pageData,
  hotelInfo,
  paymentInfo,
}: {
  pageData: TrackingSDKPageData
  hotelInfo?: TrackingSDKHotelInfo
  paymentInfo?: TrackingSDKPaymentInfo
}) {
  const userTrackingData = await getUserTracking()

  return (
    <RouterTransition
      pageData={pageData}
      userData={userTrackingData}
      hotelInfo={hotelInfo}
      paymentInfo={paymentInfo}
    />
  )
}
