import React, { useContext } from 'react'; import PropTypes from 'prop-types'; import classnames from 'classnames'; import { useSelector } from 'react-redux'; import Box from '../../ui/box/box'; import Button from '../../ui/button'; import EditGasFeeButton from '../edit-gas-fee-button/edit-gas-fee-button'; import { Text } from '../../component-library'; import { AlignItems, BLOCK_SIZES, DISPLAY, FLEX_DIRECTION, FontWeight, JustifyContent, TextAlign, TextColor, TextVariant, } from '../../../helpers/constants/design-system'; import { PRIMARY, SECONDARY } from '../../../helpers/constants/common'; import { I18nContext } from '../../../contexts/i18n'; import { getPreferences } from '../../../selectors'; import { ConfirmGasDisplay } from '../confirm-gas-display'; import MultiLayerFeeMessage from '../multilayer-fee-message/multi-layer-fee-message'; import { formatCurrency } from '../../../helpers/utils/confirm-tx.util'; import TransactionDetailItem from '../transaction-detail-item/transaction-detail-item.component'; import UserPreferencedCurrencyDisplay from '../user-preferenced-currency-display'; export default function ApproveContentCard({ showHeader = true, symbol, title, showEdit, showAdvanceGasFeeOptions = false, onEditClick, footer, noBorder, supportsEIP1559, renderTransactionDetailsContent, renderDataContent, isMultiLayerFeeNetwork, ethTransactionTotal, nativeCurrency, fullTxData, hexMinimumTransactionFee, hexTransactionTotal, fiatTransactionTotal, currentCurrency, isSetApproveForAll, isApprovalOrRejection, data, userAcknowledgedGasMissing, renderSimulationFailureWarning, useCurrencyRateCheck, }) { const t = useContext(I18nContext); const { useNativeCurrencyAsPrimaryCurrency } = useSelector(getPreferences); return ( {showHeader && ( {supportsEIP1559 && title === t('transactionFee') ? null : ( <> {symbol} {title} )} {showEdit && (!showAdvanceGasFeeOptions || !supportsEIP1559) && ( )} {showEdit && showAdvanceGasFeeOptions && supportsEIP1559 && !renderSimulationFailureWarning && ( )} )} {renderTransactionDetailsContent && (!isMultiLayerFeeNetwork && supportsEIP1559 && !renderSimulationFailureWarning ? ( ) : ( {isMultiLayerFeeNetwork ? ( } detailText={ } noBold flexWidthValues /> ) : ( <> {t('feeAssociatedRequest')} {useCurrencyRateCheck && ( {formatCurrency( fiatTransactionTotal, currentCurrency, )} )} {`${ethTransactionTotal} ${nativeCurrency}`} )} ))} {renderDataContent && ( {isSetApproveForAll ? t('functionSetApprovalForAll') : t('functionApprove')} {isSetApproveForAll && isApprovalOrRejection !== undefined ? ( {`${t('parameters')}: ${isApprovalOrRejection}`} ) : null} {data} )} {footer} ); } ApproveContentCard.propTypes = { /** * Whether to show header including icon, transaction fee text and edit button */ showHeader: PropTypes.bool, /** * Symbol icon */ symbol: PropTypes.node, /** * Title to be included in the header */ title: PropTypes.string, /** * Whether to show edit button or not */ showEdit: PropTypes.bool, /** * Whether to show advanced gas fee options or not */ showAdvanceGasFeeOptions: PropTypes.bool, /** * Should open customize gas modal when edit button is clicked */ onEditClick: PropTypes.func, /** * Footer to be shown */ footer: PropTypes.node, /** * Whether to include border-bottom or not */ noBorder: PropTypes.bool, /** * Is enhanced gas fee enabled or not */ supportsEIP1559: PropTypes.bool, /** * Whether to render transaction details content or not */ renderTransactionDetailsContent: PropTypes.bool, /** * Whether to render data content or not */ renderDataContent: PropTypes.bool, /** * Is multi-layer fee network or not */ isMultiLayerFeeNetwork: PropTypes.bool, /** * Total sum of the transaction in native currency */ ethTransactionTotal: PropTypes.string, /** * Current native currency */ nativeCurrency: PropTypes.string, /** * Current transaction */ fullTxData: PropTypes.object, /** * Total sum of the transaction converted to hex value */ hexTransactionTotal: PropTypes.string, /** * Minimum transaction fee converted to hex value */ hexMinimumTransactionFee: PropTypes.string, /** * Total sum of the transaction in fiat currency */ fiatTransactionTotal: PropTypes.string, /** * Current fiat currency */ currentCurrency: PropTypes.string, /** * Is set approve for all or not */ isSetApproveForAll: PropTypes.bool, /** * Whether a current set approval for all transaction will approve or revoke access */ isApprovalOrRejection: PropTypes.bool, /** * Current transaction data */ data: PropTypes.string, /** * User acknowledge gas is missing or not */ userAcknowledgedGasMissing: PropTypes.bool, /** * Render simulation failure warning */ renderSimulationFailureWarning: PropTypes.bool, /** * Fiat conversion control */ useCurrencyRateCheck: PropTypes.bool, };