import React, { Component } from 'react'; import PropTypes from 'prop-types'; import ButtonGroup from '../../../ui/button-group'; import Button from '../../../ui/button'; import { GAS_ESTIMATE_TYPES } from '../../../../helpers/constants/common'; const GAS_OBJECT_PROPTYPES_SHAPE = { gasEstimateType: PropTypes.oneOf(Object.values(GAS_ESTIMATE_TYPES)) .isRequired, feeInPrimaryCurrency: PropTypes.string, feeInSecondaryCurrency: PropTypes.string, timeEstimate: PropTypes.string, priceInHexWei: PropTypes.string, }; export default class GasPriceButtonGroup extends Component { static contextTypes = { t: PropTypes.func, }; static propTypes = { buttonDataLoading: PropTypes.bool, className: PropTypes.string, defaultActiveButtonIndex: PropTypes.number, gasButtonInfo: PropTypes.arrayOf( PropTypes.shape(GAS_OBJECT_PROPTYPES_SHAPE), ), handleGasPriceSelection: PropTypes.func, newActiveButtonIndex: PropTypes.number, noButtonActiveByDefault: PropTypes.bool, showCheck: PropTypes.bool, }; gasEstimateTypeLabel(gasEstimateType) { if (gasEstimateType === GAS_ESTIMATE_TYPES.SLOW) { return this.context.t('slow'); } else if (gasEstimateType === GAS_ESTIMATE_TYPES.AVERAGE) { return this.context.t('average'); } else if (gasEstimateType === GAS_ESTIMATE_TYPES.FAST) { return this.context.t('fast'); } else if (gasEstimateType === GAS_ESTIMATE_TYPES.FASTEST) { return this.context.t('fastest'); } throw new Error(`Unrecognized gas estimate type: ${gasEstimateType}`); } renderButtonContent( { gasEstimateType, feeInPrimaryCurrency, feeInSecondaryCurrency, timeEstimate, }, { className, showCheck }, ) { return (