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, noButtonActiveByDefault: PropTypes.bool, showCheck: PropTypes.bool, } renderButtonContent ({ label, feeInPrimaryCurrency, feeInSecondaryCurrency, timeEstimate, }, { className, showCheck, }) { return (
{ label &&
{ label }
} { feeInPrimaryCurrency &&
{ feeInPrimaryCurrency }
} { feeInSecondaryCurrency &&
{ feeInSecondaryCurrency }
} { timeEstimate &&
{ timeEstimate }
} { showCheck && }
) } renderButton ({ priceInHexWei, ...renderableGasInfo }, { buttonDataLoading, handleGasPriceSelection, ...buttonContentPropsAndFlags }, index) { return ( ) } render () { const { gasButtonInfo, defaultActiveButtonIndex = 1, noButtonActiveByDefault = false, ...buttonPropsAndFlags } = this.props return ( { gasButtonInfo.map((obj, index) => this.renderButton(obj, buttonPropsAndFlags, index)) } ) } }