Fetching active Tokens and showing them in Balances' Tab #73
This commit is contained in:
parent
4e019af2a4
commit
24dfd80122
|
@ -1,5 +1,6 @@
|
|||
// @flow
|
||||
import { List } from 'immutable'
|
||||
import { type Token } from '~/routes/tokens/store/model/token'
|
||||
import { buildOrderFieldFrom, FIXED, type SortRow } from '~/components/Table/sorting'
|
||||
import { type Column } from '~/components/Table/TableHead'
|
||||
|
||||
|
@ -14,39 +15,17 @@ type BalanceData = {
|
|||
|
||||
export type BalanceRow = SortRow<BalanceData>
|
||||
|
||||
export const getBalanceData = (): Array<BalanceRow> => [
|
||||
{
|
||||
[BALANCE_TABLE_ASSET_ID]: 'CVL Journalism',
|
||||
[BALANCE_TABLE_BALANCE_ID]: '234 CVL',
|
||||
[buildOrderFieldFrom(BALANCE_TABLE_BALANCE_ID)]: 234,
|
||||
},
|
||||
{
|
||||
[BALANCE_TABLE_ASSET_ID]: 'ABC Periodico',
|
||||
[BALANCE_TABLE_BALANCE_ID]: '1.394 ABC',
|
||||
[buildOrderFieldFrom(BALANCE_TABLE_BALANCE_ID)]: 1.394,
|
||||
},
|
||||
{
|
||||
[BALANCE_TABLE_ASSET_ID]: 'Ethereum',
|
||||
[BALANCE_TABLE_BALANCE_ID]: '9.394 ETH',
|
||||
[buildOrderFieldFrom(BALANCE_TABLE_BALANCE_ID)]: 9.394,
|
||||
[FIXED]: true,
|
||||
},
|
||||
{
|
||||
[BALANCE_TABLE_ASSET_ID]: 'Gnosis',
|
||||
[BALANCE_TABLE_BALANCE_ID]: '0.599 GNO',
|
||||
[buildOrderFieldFrom(BALANCE_TABLE_BALANCE_ID)]: 0.559,
|
||||
},
|
||||
{
|
||||
[BALANCE_TABLE_ASSET_ID]: 'OmiseGO',
|
||||
[BALANCE_TABLE_BALANCE_ID]: '39.922 OMG',
|
||||
[buildOrderFieldFrom(BALANCE_TABLE_BALANCE_ID)]: 39.922,
|
||||
},
|
||||
{
|
||||
[BALANCE_TABLE_ASSET_ID]: 'Moe Feo',
|
||||
[BALANCE_TABLE_BALANCE_ID]: '0 MOE',
|
||||
[buildOrderFieldFrom(BALANCE_TABLE_BALANCE_ID)]: 0,
|
||||
},
|
||||
]
|
||||
export const getBalanceData = (activeTokens: List<Token>): Array<BalanceRow> => {
|
||||
const rows = activeTokens.map((token: Token) => ({
|
||||
[BALANCE_TABLE_ASSET_ID]: token.get('name'),
|
||||
[BALANCE_TABLE_BALANCE_ID]: `${token.get('funds')} ${token.get('symbol')}`,
|
||||
[buildOrderFieldFrom(BALANCE_TABLE_BALANCE_ID)]: Number(token.get('funds')),
|
||||
[FIXED]: token.get('symbol') === 'ETH',
|
||||
}))
|
||||
|
||||
return Array.from(rows)
|
||||
}
|
||||
|
||||
|
||||
export const generateColumns = () => {
|
||||
const assetRow: Column = {
|
||||
|
|
|
@ -33,6 +33,7 @@ type Props = {
|
|||
classes: Object,
|
||||
granted: boolean,
|
||||
tokens: List<Token>,
|
||||
activeTokens: List<Token>,
|
||||
safeAddress: string,
|
||||
}
|
||||
|
||||
|
@ -65,7 +66,7 @@ class Balances extends React.Component<Props, State> {
|
|||
hideZero, showToken, showReceive, showSend,
|
||||
} = this.state
|
||||
const {
|
||||
classes, granted, tokens, safeAddress,
|
||||
classes, granted, tokens, safeAddress, activeTokens,
|
||||
} = this.props
|
||||
|
||||
const columns = generateColumns()
|
||||
|
@ -74,7 +75,7 @@ class Balances extends React.Component<Props, State> {
|
|||
root: classes.root,
|
||||
}
|
||||
|
||||
const filteredData = filterByZero(getBalanceData(), hideZero)
|
||||
const filteredData = filterByZero(getBalanceData(activeTokens), hideZero)
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
|
|
Loading…
Reference in New Issue