import { AllDualVariantIconKeys, MenuItem, MenuItemSize } from '@biom3/react'; import { SalePaymentTypes } from '@imtbl/checkout-sdk'; import { ReactElement } from 'react'; import { useTranslation } from 'react-i18next'; export interface PaymentOptionProps< RC extends ReactElement | undefined = undefined, > { rc?: RC; type: SalePaymentTypes; onClick: (type: SalePaymentTypes) => void; disabled?: boolean; caption?: string; size?: MenuItemSize; } export function PaymentOption({ type, onClick, disabled = false, caption, size, rc = , }: PaymentOptionProps) { const { t } = useTranslation(); const icon: Record = { [SalePaymentTypes.CRYPTO]: 'Coins', [SalePaymentTypes.DEBIT]: 'BankCard', [SalePaymentTypes.CREDIT]: 'BankCard', }; const handleClick = () => onClick(type); const menuItemProps = { disabled, emphasized: true, onClick: disabled ? undefined : handleClick, }; return ( {t(`views.PAYMENT_METHODS.options.${type}.heading`)} {!disabled && } {caption || t( `views.PAYMENT_METHODS.options.${type}.${ disabled ? 'disabledCaption' : 'caption' }`, )} ); }