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

import { auth } from "@/auth"
import { isValidSession } from "@/utils/session"

import PaymentClient from "./PaymentClient"

import type { PaymentProps } from "@/types/components/hotelReservation/enterDetails/payment"

export default async function Payment({
  otherPaymentOptions,
  supportedCards,
}: PaymentProps) {
  const savedCreditCards = await getSavedPaymentCardsSafely({
    supportedCards,
  })
  const session = await auth()
  const isUserLoggedIn = isValidSession(session)

  return (
    <PaymentClient
      otherPaymentOptions={otherPaymentOptions}
      savedCreditCards={savedCreditCards}
      isUserLoggedIn={isUserLoggedIn}
    />
  )
}
