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.
29 lines
703 B
29 lines
703 B
import React from 'react'
|
|
import PropTypes from 'prop-types'
|
|
import { convert } from 'lib/utils/btc'
|
|
|
|
const Value = ({ value, currency, currentTicker, fiatTicker }) => {
|
|
if (currency === 'sats') {
|
|
return <i>{value > 0 ? value : value * -1}</i>
|
|
}
|
|
let price
|
|
if (currency === 'fiat') {
|
|
price = currentTicker[fiatTicker].last
|
|
}
|
|
return (
|
|
<i>
|
|
{Number(convert('sats', currency, value, price))
|
|
.toFixed(8)
|
|
.replace(/\.?0+$/, '')}
|
|
</i>
|
|
)
|
|
}
|
|
|
|
Value.propTypes = {
|
|
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
currency: PropTypes.string.isRequired,
|
|
currentTicker: PropTypes.object,
|
|
fiatTicker: PropTypes.string
|
|
}
|
|
|
|
export default Value
|
|
|