import { Suspense } from "react"

import MyStay from "@/components/HotelReservation/MyStay"
import { MyStaySkeleton } from "@/components/HotelReservation/MyStay/myStaySkeleton"
import { setLang } from "@/i18n/serverContext"

import Tracking from "./tracking"

import type { Lang } from "@scandic-hotels/common/constants/language"

export default async function MyStayWebviewPage(
  props: PageProps<"/[lang]/webview/hotelreservation/my-stay">
) {
  const searchParams = await props.searchParams
  const params = await props.params
  const lang = params.lang as Lang
  setLang(lang)
  const refId =
    typeof searchParams.RefId === "string" ? searchParams.RefId : undefined

  return (
    <Suspense fallback={<MyStaySkeleton />}>
      <MyStay refId={refId} lang={lang} isWebview={true} />
      <Tracking />
    </Suspense>
  )
}
