import { useIntl } from 'react-intl' import { Label } from 'react-aria-components' import { PaymentOptionsGroup } from '../PaymentOption/PaymentOptionsGroup' import { PaymentOption } from '../PaymentOption/PaymentOption' import { Typography } from '../../../components/Typography' import styles from './selectPaymentMethod.module.css' import { PAYMENT_METHOD_TITLES, PaymentMethodEnum, } from '@scandic-hotels/common/constants/paymentMethod' type PaymentMethod = { id: string truncatedNumber: string alias: string cardType: PaymentMethodEnum } type SelectPaymentMethodProps = { paymentMethods: PaymentMethod[] onChange: (value: string) => void formName: string } export function SelectPaymentMethod({ paymentMethods, onChange, formName, }: SelectPaymentMethodProps) { const intl = useIntl() const hasSavedCards = paymentMethods.length > 0 if (!hasSavedCards) { return null } const mySavedCardsLabel = paymentMethods.length ? intl.formatMessage({ id: 'payment.mySavedCards', defaultMessage: 'My saved cards', }) : undefined const otherCardLabel = paymentMethods.length ? intl.formatMessage({ id: 'common.other', defaultMessage: 'Other', }) : undefined return (
{mySavedCardsLabel} {paymentMethods?.map((paymentMethods) => { const label = PAYMENT_METHOD_TITLES[paymentMethods.cardType] || paymentMethods.alias || paymentMethods.cardType return ( ) })} {otherCardLabel}
) }