import * as React from 'react'; import PaymentMethodItem from '../PaymentMethodItem/PaymentMethodItem'; import CreditCardIcon from '../icons/CreditCardIcon/CreditCardIcon'; import PayPalIcon from '../icons/PayPalIcon/PayPalIcon'; import MercadoPagoIcon from '../icons/MercadoPagoIcon/MercadoPagoIcon'; import PagSeguroIcon from '../icons/PagSeguroIcon/PagSeguroIcon'; import YandexIcon from '../icons/YandexIcon/YandexIcon'; import IDealIcon from '../icons/IDealIcon/IDealIcon'; import SofortIcon from '../icons/SofortIcon/SofortIcon'; import AlipayIcon from '../icons/AlipayIcon/AlipayIcon'; import * as styles from './PaymentMethodList.scss'; interface IPaymentMethod { value: string; label: string; } interface IPaymentMethodListProps { radioButtonClassName?: string; paymentMethods: IPaymentMethod[]; selectedMethod: string; activePaymentComponentNode?: JSX.Element; onPaymentMethodChanged: (pmId: string) => void; } export default class PaymentMethodList extends React.Component { iconsMap = { creditCard: , payPal: , mercadoPago: , pagSeguro: , yandex: , iDeal: , sofort: , alipay: }; handleEnterKey = (value, e) => { const isActionKey = e.key === 'Enter' || e.key === ' '; if (isActionKey && this.props.onPaymentMethodChanged) { this.props.onPaymentMethodChanged(value); } } renderList() { return this.props.paymentMethods.map((method) => { const selected = this.props.selectedMethod === method.value; return (
{ method.value === this.props.selectedMethod && this.props.activePaymentComponentNode ?
{this.props.activePaymentComponentNode}
: null }
); }); } render() { return (
{this.renderList()}
); } }