import { PaymentCallbackPage as PaymentCallbackPagePrimitive } from "@scandic-hotels/booking-flow/pages/PaymentCallbackPage"
import { logger } from "@scandic-hotels/common/logger"

import type { PaymentCallbackStatusEnum } from "@scandic-hotels/common/constants/paymentCallbackStatusEnum"

import type { LangParams, PageArgs } from "@/types/params"

export default async function PaymentCallbackPage(
  props: PageArgs<LangParams & { status: string }>
) {
  const searchParams = await props.searchParams
  const params = await props.params
  logger.debug(`[payment-callback] callback started`)
  const lang = params.lang

  let userAccessToken = null
  // TODO fix when auth is implemented
  // const session = await auth()
  // if (isValidSession(session)) {
  //   userAccessToken = session.token.access_token
  // }

  return (
    <PaymentCallbackPagePrimitive
      lang={lang}
      userAccessToken={userAccessToken}
      searchParams={searchParams}
      status={params.status as PaymentCallbackStatusEnum}
    />
  )
}
