import React, { useContext } from 'react' import PropTypes from 'prop-types' import BigNumber from 'bignumber.js' import classnames from 'classnames' import { I18nContext } from '../../../contexts/i18n' import InfoTooltip from '../../../components/ui/info-tooltip' import { decEthToConvertedCurrency } from '../../../helpers/utils/conversions.util' import { formatCurrency } from '../../../helpers/utils/confirm-tx.util' import PigIcon from './pig-icon' export default function FeeCard({ primaryFee, secondaryFee, hideTokenApprovalRow, onFeeCardMaxRowClick, tokenApprovalTextComponent, tokenApprovalSourceTokenSymbol, onTokenApprovalClick, metaMaskFee, savings, isBestQuote, numberOfQuotes, onQuotesClick, conversionRate, currentCurrency, tokenConversionRate, }) { const t = useContext(I18nContext) const savingAmount = isBestQuote && savings?.total ? formatCurrency( decEthToConvertedCurrency( savings.total, currentCurrency, conversionRate, ), currentCurrency, ) : null const savingsIsPositive = savings?.total && new BigNumber(savings.total, 10).gt(0) const inDevelopment = process.env.NODE_ENV === 'development' const shouldDisplaySavings = inDevelopment && isBestQuote && tokenConversionRate && savingsIsPositive let savingsText = '' if (inDevelopment && shouldDisplaySavings) { savingsText = t('swapSaving', [ ~ , savingAmount, ]) } else if (inDevelopment && isBestQuote && tokenConversionRate) { savingsText = t('swapUsingBestQuote') } else if (inDevelopment && savingsIsPositive && tokenConversionRate) { savingsText = t('swapBetterQuoteAvailable') } return (
{savingsText}
)}{t('swapNQuotes', [numberOfQuotes])}
{t('swapNetworkFeeSummary')}
{t('swapEstimatedNetworkFeeSummary', [ {t('swapEstimatedNetworkFee')} , ])}
{t('swapMaxNetworkFeeInfo', [ {t('swapMaxNetworkFees')} , ])}
> } containerClassName="fee-card__info-tooltip-content-container" wrapperClassName="fee-card__row-label fee-card__info-tooltip-container" wide />