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

import { isLoggedInUser } from "@/utils/isLoggedInUser"

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 isUserLoggedIn = await isLoggedInUser()

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