You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
703 B
30 lines
703 B
7 years ago
|
import React from 'react'
|
||
|
import PropTypes from 'prop-types'
|
||
6 years ago
|
import { convert } from 'lib/utils/btc'
|
||
7 years ago
|
|
||
7 years ago
|
const Value = ({ value, currency, currentTicker, fiatTicker }) => {
|
||
7 years ago
|
if (currency === 'sats') {
|
||
|
return <i>{value > 0 ? value : value * -1}</i>
|
||
|
}
|
||
6 years ago
|
let price
|
||
|
if (currency === 'fiat') {
|
||
|
price = currentTicker[fiatTicker].last
|
||
|
}
|
||
6 years ago
|
return (
|
||
|
<i>
|
||
|
{Number(convert('sats', currency, value, price))
|
||
|
.toFixed(8)
|
||
|
.replace(/\.?0+$/, '')}
|
||
|
</i>
|
||
|
)
|
||
7 years ago
|
}
|
||
7 years ago
|
|
||
|
Value.propTypes = {
|
||
7 years ago
|
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
||
7 years ago
|
currency: PropTypes.string.isRequired,
|
||
6 years ago
|
currentTicker: PropTypes.object,
|
||
|
fiatTicker: PropTypes.string
|
||
7 years ago
|
}
|
||
|
|
||
|
export default Value
|