import React, { Component } from 'react' import PropTypes from 'prop-types' import ButtonGroup from '../../button-group' import Button from '../../button' const GAS_OBJECT_PROPTYPES_SHAPE = { label: PropTypes.string, 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, } renderButtonContent ({ labelKey, feeInPrimaryCurrency, feeInSecondaryCurrency, timeEstimate, }, { className, showCheck, }) { return (
{ labelKey &&
{ this.context.t(labelKey) }
} { feeInPrimaryCurrency &&
{ feeInPrimaryCurrency }
} { feeInSecondaryCurrency &&
{ feeInSecondaryCurrency }
} { timeEstimate &&
{ timeEstimate }
} { showCheck && }
) } renderButton ({ priceInHexWei, ...renderableGasInfo }, { buttonDataLoading, handleGasPriceSelection, ...buttonContentPropsAndFlags }, index) { return ( ) } render () { const { gasButtonInfo, defaultActiveButtonIndex = 1, newActiveButtonIndex, noButtonActiveByDefault = false, buttonDataLoading, ...buttonPropsAndFlags } = this.props return ( !buttonDataLoading ? { gasButtonInfo.map((obj, index) => this.renderButton(obj, buttonPropsAndFlags, index)) } :
{ this.context.t('loading') }
) } }