"use client"
import { Label } from "react-aria-components"
import { useIntl } from "react-intl"
import {
PAYMENT_METHOD_TITLES,
PaymentMethodEnum,
} from "@scandic-hotels/common/constants/paymentMethod"
import { PaymentOption } from "@scandic-hotels/design-system/Form/PaymentOption"
import { PaymentOptionsGroup } from "@scandic-hotels/design-system/Form/PaymentOptionsGroup"
import { Typography } from "@scandic-hotels/design-system/Typography"
import { useAvailablePaymentOptions } from "../../../../hooks/useAvailablePaymentOptions"
import { useEnterDetailsStore } from "../../../../stores/enter-details"
import MixedRatePaymentBreakdown from "../../Payment/MixedRatePaymentBreakdown"
import styles from "./paymentOptions.module.css"
import type { CreditCard } from "@scandic-hotels/trpc/types/user"
interface ConfirmBookingPaymentOptionsProps {
savedCreditCards: CreditCard[] | null
hasMixedRates: boolean
otherPaymentOptions: PaymentMethodEnum[]
}
export function ConfirmBookingPaymentOptions({
savedCreditCards,
hasMixedRates,
otherPaymentOptions,
}: ConfirmBookingPaymentOptionsProps) {
const intl = useIntl()
const { rooms, currency } = useEnterDetailsStore((state) => ({
rooms: state.rooms,
currency: state.totalPrice.local.currency,
}))
const availablePaymentOptions =
useAvailablePaymentOptions(otherPaymentOptions)
return (
<>
{savedCreditCards?.length ? (
<>
{intl.formatMessage({
id: "payment.mySavedCards",
defaultMessage: "My saved cards",
})}
{savedCreditCards.map((savedCreditCard) => (
))}
{intl.formatMessage({
id: "enterDetails.payment.otherPaymentMethods",
defaultMessage: "Other payment methods",
})}
>
) : null}
{!hasMixedRates
? availablePaymentOptions.map((paymentMethod) => (
))
: null}
{hasMixedRates ? (
) : null}
>
)
}