formatAmounts wip
This commit is contained in:
parent
b3b4887fdb
commit
f5d324fff8
|
@ -1,9 +1,10 @@
|
|||
// @flow
|
||||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat
|
||||
export const formatAmount = (number: string | number) => {
|
||||
let numberFloat = parseFloat(number)
|
||||
|
||||
if (numberFloat < 999.999999) {
|
||||
numberFloat = numberFloat.toFixed(2).toLocaleString()
|
||||
numberFloat = numberFloat.toFixed(5).toLocaleString()
|
||||
}
|
||||
|
||||
return numberFloat
|
|
@ -3,6 +3,7 @@ import { List } from 'immutable'
|
|||
import { type Token } from '~/logic/tokens/store/model/token'
|
||||
import { buildOrderFieldFrom, FIXED, type SortRow } from '~/components/Table/sorting'
|
||||
import { type Column } from '~/components/Table/TableHead'
|
||||
import { formatAmount } from '~/logic/tokens/utils/formatAmount'
|
||||
|
||||
export const BALANCE_TABLE_ASSET_ID = 'asset'
|
||||
export const BALANCE_TABLE_BALANCE_ID = 'balance'
|
||||
|
@ -19,7 +20,7 @@ export const getBalanceData = (activeTokens: List<Token>): List<BalanceRow> => {
|
|||
const rows = activeTokens.map((token: Token) => ({
|
||||
[BALANCE_TABLE_ASSET_ID]: { name: token.name, logoUri: token.logoUri },
|
||||
[buildOrderFieldFrom(BALANCE_TABLE_ASSET_ID)]: token.name,
|
||||
[BALANCE_TABLE_BALANCE_ID]: `${token.balance} ${token.symbol}`,
|
||||
[BALANCE_TABLE_BALANCE_ID]: `${formatAmount(token.balance)} ${token.symbol}`,
|
||||
[buildOrderFieldFrom(BALANCE_TABLE_BALANCE_ID)]: Number(token.balance),
|
||||
[FIXED]: token.get('symbol') === 'ETH',
|
||||
}))
|
||||
|
|
Loading…
Reference in New Issue