import { useState } from 'react' import type { JumperQuote } from '@features/wallet' import { fromBaseUnits } from '@shared/lib/utils/baseUnits' import { truncateDecimals } from '@shared/lib/utils/truncateDecimals' import styles from './BridgeConfirmModal.module.css' interface Props { quote: JumperQuote fromAmountHuman: string insufficientBalance?: boolean isExecuting?: boolean onConfirm: () => void onClose: () => void } export function BridgeConfirmModal({ quote, fromAmountHuman, insufficientBalance, isExecuting, onConfirm, onClose }: Props) { const { action, estimate, toolDetails } = quote const toSymbol = action.toToken.symbol const fromSymbol = action.fromToken.symbol const [closing, setClosing] = useState(false) // Trigger the exit animation; the real close fires on animation end so the × // and backdrop paths play the same closing transition. function requestClose() { setClosing(true) } function handleAnimationEnd() { if (closing) onClose() } const toAmount = truncateDecimals(fromBaseUnits(estimate.toAmount, action.toToken.decimals), 8) const toMin = truncateDecimals(fromBaseUnits(estimate.toAmountMin, action.toToken.decimals), 8) const feesUsd = (estimate.feeCosts ?? []) .reduce((sum, f) => sum + (parseFloat(f.amountUSD) || 0), 0) .toFixed(2) return (
Введённое количество превышает баланс кошелька — бридж будет отклонён.
)}