import { Box, Caption, Drawer, MenuItem, Divider, MenuItemSize, } from '@biom3/react'; import { motion } from 'framer-motion'; import { useTranslation } from 'react-i18next'; import { SalePaymentTypes, TransactionRequirement, WidgetTheme, } from '@imtbl/checkout-sdk'; import { Environment } from '@imtbl/config'; import { listVariants, listItemVariants } from '../../../lib/animation/listAnimation'; import { CoinsDrawerItem } from './CoinsDrawerItem'; import { FundingBalance } from '../types'; import { PaymentOptions } from './PaymentOptions'; type CoinsDrawerProps = { conversions: Map; balances: FundingBalance[]; selectedIndex: number; visible: boolean; loading: boolean; transactionRequirement?: TransactionRequirement; onSelect: (index: number) => void; onClose: () => void; onPayWithCard?: (paymentType: SalePaymentTypes) => void; disabledPaymentTypes?: SalePaymentTypes[]; theme: WidgetTheme; environment: Environment; }; export function CoinsDrawer({ conversions, balances, selectedIndex, visible, loading, transactionRequirement, onClose, onSelect, onPayWithCard, disabledPaymentTypes, theme, environment, }: CoinsDrawerProps) { const { t } = useTranslation(); const handleOnclick = (index: number) => () => { onSelect(index); onClose(); }; let size: MenuItemSize = 'medium'; if (balances.length > 3) { size = 'small'; } const otherPaymentOptions = [SalePaymentTypes.DEBIT, SalePaymentTypes.CREDIT]; const withOtherOptions = !otherPaymentOptions.every((type) => disabledPaymentTypes?.includes(type)); return ( } > {t('views.ORDER_SUMMARY.coinsDrawer.caption1')} {t('views.ORDER_SUMMARY.coinsDrawer.caption2')} {balances?.map((balance: FundingBalance, idx: number) => ( } /> ))} {loading && ( )} {onPayWithCard && ( )} > {withOtherOptions && ( } sx={{ my: 'base.spacing.x4' }} > {t('views.ORDER_SUMMARY.coinsDrawer.divider')} )} )} ); }