Convert FiatValue component to ES6 class (#7786)

Co-authored-by: Mark Stacey <markjstacey@gmail.com>
feature/default_network_editable
Whymarrh Whitby 5 years ago committed by GitHub
parent 789dd19677
commit f850a17f63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 48
      ui/app/components/ui/fiat-value.js

@ -1,36 +1,36 @@
import PropTypes from 'prop-types'
import React, { Component } from 'react'
import { inherits } from 'util'
import { formatBalance } from '../../helpers/utils/util'
export default FiatValue
export default class FiatValue extends Component {
static propTypes = {
conversionRate: PropTypes.number.isRequired,
currentCurrency: PropTypes.string,
style: PropTypes.object,
value: PropTypes.string.isRequired,
}
inherits(FiatValue, Component)
function FiatValue () {
Component.call(this)
}
render () {
const { conversionRate, currentCurrency, style } = this.props
const renderedCurrency = currentCurrency || ''
FiatValue.prototype.render = function () {
const props = this.props
const { conversionRate, currentCurrency, style } = props
const renderedCurrency = currentCurrency || ''
const value = formatBalance(this.props.value, 6)
const value = formatBalance(props.value, 6)
if (value === 'None') {
return value
}
let fiatDisplayNumber, fiatTooltipNumber
const splitBalance = value.split(' ')
if (value === 'None') {
return value
}
let fiatDisplayNumber, fiatTooltipNumber
const splitBalance = value.split(' ')
if (conversionRate !== 0) {
fiatTooltipNumber = Number(splitBalance[0]) * conversionRate
fiatDisplayNumber = fiatTooltipNumber.toFixed(2)
} else {
fiatDisplayNumber = 'N/A'
}
if (conversionRate !== 0) {
fiatTooltipNumber = Number(splitBalance[0]) * conversionRate
fiatDisplayNumber = fiatTooltipNumber.toFixed(2)
} else {
fiatDisplayNumber = 'N/A'
fiatTooltipNumber = 'Unknown'
return fiatDisplay(fiatDisplayNumber, renderedCurrency.toUpperCase(), style)
}
return fiatDisplay(fiatDisplayNumber, renderedCurrency.toUpperCase(), style)
}
function fiatDisplay (fiatDisplayNumber, fiatSuffix, styleOveride = {}) {

Loading…
Cancel
Save