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 {value > 0 ? value : value * -1} } let price if (currency === 'fiat') { price = currentTicker[fiatTicker].last } return ( {Number(convert('sats', currency, value, price)) .toFixed(8) .replace(/\.?0+$/, '')} ) } Value.propTypes = { value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), currency: PropTypes.string.isRequired, currentTicker: PropTypes.object, fiatTicker: PropTypes.string } export default Value