"use client"

import { trpc } from "@/lib/trpc/client"

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

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

export default function TrackingSDK({
  pageData,
  hotelInfo,
  paymentInfo,
}: {
  pageData: TrackingSDKPageData
  hotelInfo?: TrackingSDKHotelInfo
  paymentInfo?: TrackingSDKPaymentInfo
}) {
  const { data: userTrackingData, isPending } =
    trpc.user.userTrackingInfo.useQuery()

  if (isPending || !userTrackingData) {
    return null
  }

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