import React, { useState, useContext } from 'react'; import PropTypes from 'prop-types'; import Button from '../../ui/button'; import Typography from '../../ui/typography/typography'; import { COLORS, TYPOGRAPHY, FONT_WEIGHT, } from '../../../helpers/constants/design-system'; import InfoTooltip from '../../ui/info-tooltip'; import TransactionTotalBanner from '../transaction-total-banner/transaction-total-banner.component'; import RadioGroup from '../../ui/radio-group/radio-group.component'; import AdvancedGasControls from '../advanced-gas-controls/advanced-gas-controls.component'; import { I18nContext } from '../../../contexts/i18n'; import ActionableMessage from '../../ui/actionable-message/actionable-message'; export default function EditGasDisplay({ alwaysShowForm, type, showEducationButton, onEducationClick, dappSuggestedGasFee, dappOrigin, }) { const t = useContext(I18nContext); const [warning] = useState(null); const [showAdvancedForm, setShowAdvancedForm] = useState(false); const [ dappSuggestedGasFeeAcknowledged, setDappSuggestedGasFeeAcknowledged, ] = useState(false); const requireDappAcknowledgement = dappSuggestedGasFee && !dappSuggestedGasFeeAcknowledged; return (
{warning && (
)} {requireDappAcknowledgement && (
)} {type === 'speed-up' && (
{t('speedUpTooltipText')}{' '}
)} {requireDappAcknowledgement && ( )} {!requireDappAcknowledgement && ( )} {!requireDappAcknowledgement && !alwaysShowForm && ( )} {((!requireDappAcknowledgement && alwaysShowForm) || showAdvancedForm) && }
{!requireDappAcknowledgement && showEducationButton && (
)}
); } EditGasDisplay.propTypes = { alwaysShowForm: PropTypes.bool, type: PropTypes.oneOf(['customize-gas', 'speed-up']), showEducationButton: PropTypes.bool, onEducationClick: PropTypes.func, dappSuggestedGasFee: PropTypes.number, dappOrigin: PropTypes.string, }; EditGasDisplay.defaultProps = { alwaysShowForm: false, type: 'customize-gas', showEducationButton: false, onEducationClick: undefined, dappSuggestedGasFee: 0, dappOrigin: '', };