import React, { useContext } from 'react'; import PropTypes from 'prop-types'; import classnames from 'classnames'; import Box from '../../ui/box/box'; import Button from '../../ui/button'; import EditGasFeeButton from '../edit-gas-fee-button/edit-gas-fee-button'; import Typography from '../../ui/typography/typography'; import { ALIGN_ITEMS, BLOCK_SIZES, COLORS, DISPLAY, FLEX_DIRECTION, FONT_WEIGHT, JUSTIFY_CONTENT, TEXT_ALIGN, TYPOGRAPHY, } from '../../../helpers/constants/design-system'; import { I18nContext } from '../../../../.storybook/i18n'; import GasDetailsItem from '../gas-details-item/gas-details-item'; import MultiLayerFeeMessage from '../multilayer-fee-message/multi-layer-fee-message'; import { formatCurrency } from '../../../helpers/utils/confirm-tx.util'; export default function ApproveContentCard({ showHeader = true, symbol, title, showEdit, showAdvanceGasFeeOptions = false, onEditClick, footer, noBorder, supportsEIP1559V2, renderTransactionDetailsContent, renderDataContent, isMultiLayerFeeNetwork, ethTransactionTotal, nativeCurrency, fullTxData, hexTransactionTotal, fiatTransactionTotal, currentCurrency, isSetApproveForAll, isApprovalOrRejection, data, }) { const t = useContext(I18nContext); return ( {showHeader && ( {supportsEIP1559V2 && title === t('transactionFee') ? null : ( <> {symbol} {title} )} {showEdit && (!showAdvanceGasFeeOptions || !supportsEIP1559V2) && ( )} {showEdit && showAdvanceGasFeeOptions && supportsEIP1559V2 && ( )} )} {renderTransactionDetailsContent && (!isMultiLayerFeeNetwork && supportsEIP1559V2 ? ( ) : ( {isMultiLayerFeeNetwork ? ( {t('transactionDetailLayer2GasHeading')} {`${ethTransactionTotal} ${nativeCurrency}`} ) : ( <> {t('feeAssociatedRequest')} {formatCurrency(fiatTransactionTotal, currentCurrency)} {`${ethTransactionTotal} ${nativeCurrency}`} )} ))} {renderDataContent && ( {isSetApproveForAll ? t('functionSetApprovalForAll') : t('functionApprove')} {isSetApproveForAll && isApprovalOrRejection !== undefined ? ( {`${t('parameters')}: ${isApprovalOrRejection}`} ) : null} {data} )} {footer} ); } ApproveContentCard.propTypes = { showHeader: PropTypes.bool, symbol: PropTypes.node, title: PropTypes.string, showEdit: PropTypes.bool, showAdvanceGasFeeOptions: PropTypes.bool, onEditClick: PropTypes.func, footer: PropTypes.node, noBorder: PropTypes.bool, supportsEIP1559V2: PropTypes.bool, renderTransactionDetailsContent: PropTypes.bool, renderDataContent: PropTypes.bool, isMultiLayerFeeNetwork: PropTypes.bool, ethTransactionTotal: PropTypes.string, nativeCurrency: PropTypes.string, fullTxData: PropTypes.object, hexTransactionTotal: PropTypes.string, fiatTransactionTotal: PropTypes.string, currentCurrency: PropTypes.string, isSetApproveForAll: PropTypes.bool, isApprovalOrRejection: PropTypes.bool, data: PropTypes.string, };