import { formatFiatAmount } from '@/internal/utils/formatFiatAmount'; import { border, cn, text } from '@/styles/theme'; import { useCallback, useMemo } from 'react'; import { useAnalytics } from '../../core/analytics/hooks/useAnalytics'; import { FundEvent } from '../../core/analytics/types'; import type { PresetAmountInputItemProps } from '../types'; export function FundCardPresetAmountInputItem({ presetAmountInput, currency, onClick, }: PresetAmountInputItemProps) { const { sendAnalytics } = useAnalytics(); const presetAmountInputText = useMemo(() => { return formatFiatAmount({ amount: presetAmountInput, currency, minimumFractionDigits: 0, }); }, [presetAmountInput, currency]); const handleClick = useCallback(() => { sendAnalytics(FundEvent.FundAmountChanged, { amount: Number(presetAmountInput), currency, }); onClick(presetAmountInput); }, [presetAmountInput, currency, onClick, sendAnalytics]); const handleKeyPress = useCallback( (event: React.KeyboardEvent) => { if (event.key === 'Enter' || event.key === ' ') { event.preventDefault(); sendAnalytics(FundEvent.FundAmountChanged, { amount: Number(presetAmountInput), currency, }); onClick(presetAmountInput); } }, [presetAmountInput, currency, onClick, sendAnalytics], ); if (!presetAmountInput) { return null; } return ( ); }