import React, { Component } from 'react'; import translate from 'translations'; import PropTypes from 'prop-types'; import { toFixedIfLarger } from 'utils/formatters'; export default class CurrentRates extends Component { constructor(props) { super(props); this.state = { ETHBTCAmount: 1, ETHREPAmount: 1, BTCETHAmount: 1, BTCREPAmount: 1 }; } static propTypes = { ETHBTC: PropTypes.number, ETHREP: PropTypes.number, BTCETH: PropTypes.number, BTCREP: PropTypes.number }; onChange = event => { const target = event.target; const value = target.value; const name = target.name; this.setState({ [name]: value }); }; // TODO - A little code duplication here, but simple enough to where it doesn't seem worth the time to fix. render() { return (
{translate('SWAP_rates')}

{` ETH = ${toFixedIfLarger( this.state.ETHBTCAmount * this.props.ETHBTC, 6 )} BTC`}

{` ETH = ${toFixedIfLarger( this.state.ETHREPAmount * this.props.ETHREP, 6 )} REP`}

{` BTC = ${toFixedIfLarger( this.state.BTCETHAmount * this.props.BTCETH, 6 )} ETH`}

{` BTC = ${toFixedIfLarger( this.state.BTCREPAmount * this.props.BTCREP, 6 )} REP`}

); } }