// @flow import React, { Component } from 'react'; import translate from 'translations'; import { toFixedIfLarger } from 'utils/formatters'; import type { Pairs } from 'actions/swapTypes'; import { bityReferralURL } from 'config/data'; import bityLogoWhite from 'assets/images/logo-bity-white.svg'; import Spinner from 'components/ui/Spinner'; export default class CurrentRates extends Component { props: Pairs; state = { ETHBTCAmount: 1, ETHREPAmount: 1, BTCETHAmount: 1, BTCREPAmount: 1 }; onChange = (event: SyntheticInputEvent) => { const target = event.target; const value = target.value; const name = target.name; this.setState({ [name]: value }); }; buildPairRate = (origin: string, destination: string) => { const pair = origin + destination; const statePair = this.state[pair + 'Amount']; const propsPair = this.props[pair]; return !propsPair ? :

{` ${origin} = ${toFixedIfLarger( statePair * propsPair, 6 )} ${destination}`}

; }; render() { return (
{translate('SWAP_rates')}
{
{this.buildPairRate('ETH', 'BTC')} {this.buildPairRate('ETH', 'REP')}
{this.buildPairRate('BTC', 'ETH')} {this.buildPairRate('BTC', 'REP')}
}
); } }