1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-11-15 01:34:57 +01:00

hack @coingecko/cryptoformat into what we want

* closes #70
* closes #53
This commit is contained in:
Matthias Kretschmann 2020-09-22 15:24:08 +00:00
parent da5ef5d5fc
commit 7bae93f42d
3 changed files with 11 additions and 6 deletions

View File

@ -40,7 +40,7 @@ export default function Conversion({
const fiatValue = values[currency.toLowerCase()]
const converted = fiatValue * Number(price)
const convertedFormatted = Number(
formatCurrency(converted, currency, undefined, true)
formatCurrency(converted, currency, 'en', true)
).toFixed(2)
setPriceConverted(`${convertedFormatted}`)

View File

@ -27,11 +27,14 @@ export default function PriceUnit({
return (
<div className={styleClasses}>
{Number.isInteger(Number(price))
? price
: Number.isNaN(Number(price))
{Number.isNaN(Number(price))
? '-'
: formatCurrency(Number(price), '', undefined, false, true)}{' '}
: formatCurrency(Number(price), '', 'en', false, {
// Not exactly clear what `significant figures` are for this library,
// but setting this seems to give us the formatting we want.
// See https://github.com/oceanprotocol/market/issues/70
significantFigures: 4
})}{' '}
<span>{symbol || 'OCEAN'}</span>
{conversion && <Conversion price={price} />}
</div>

View File

@ -17,7 +17,9 @@ export default function Details(): ReactElement {
{Object.entries(balance).map(([key, value]) => (
<li className={styles.balance} key={key}>
<span>{key.toUpperCase()}</span>{' '}
{formatCurrency(value, '', undefined, true, true)}
{formatCurrency(Number(value), '', 'en', false, {
significantFigures: 4
})}
{key === 'ocean' && <Conversion price={value} />}
</li>
))}