mirror of
https://github.com/status-im/safe-react.git
synced 2025-02-26 00:15:23 +00:00
Refactor Balance component. Moving columns generator to helper class
This commit is contained in:
parent
ebcfb2b30b
commit
019be0d12a
10
src/routes/safe/component/Balances/Tokens.jsx
Normal file
10
src/routes/safe/component/Balances/Tokens.jsx
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
// @flow
|
||||||
|
import * as React from 'react'
|
||||||
|
|
||||||
|
const Tokens = () => (
|
||||||
|
<React.Fragment>
|
||||||
|
Manage Tokens
|
||||||
|
</React.Fragment>
|
||||||
|
)
|
||||||
|
|
||||||
|
export default Tokens
|
@ -1,5 +1,7 @@
|
|||||||
// @flow
|
// @flow
|
||||||
|
import { List } from 'immutable'
|
||||||
import { buildOrderFieldFrom } from '~/components/Table/sorting'
|
import { buildOrderFieldFrom } from '~/components/Table/sorting'
|
||||||
|
import { type Column } from '~/components/Table/TableHead'
|
||||||
|
|
||||||
export const BALANCE_TABLE_ASSET_ID = 'asset'
|
export const BALANCE_TABLE_ASSET_ID = 'asset'
|
||||||
export const BALANCE_TABLE_BALANCE_ID = 'balance'
|
export const BALANCE_TABLE_BALANCE_ID = 'balance'
|
||||||
@ -42,5 +44,45 @@ export const getBalanceData = (): Array<BalanceRow> => [
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
export const generateColumns = () => {
|
||||||
|
const assetRow: Column = {
|
||||||
|
id: BALANCE_TABLE_ASSET_ID,
|
||||||
|
order: false,
|
||||||
|
numeric: false,
|
||||||
|
disablePadding: false,
|
||||||
|
label: 'Asset',
|
||||||
|
custom: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
const balanceRow: Column = {
|
||||||
|
id: BALANCE_TABLE_BALANCE_ID,
|
||||||
|
order: true,
|
||||||
|
numeric: true,
|
||||||
|
disablePadding: false,
|
||||||
|
label: 'Balance',
|
||||||
|
custom: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
const valueRow: Column = {
|
||||||
|
id: BALANCE_TABLE_VALUE_ID,
|
||||||
|
order: true,
|
||||||
|
numeric: true,
|
||||||
|
disablePadding: false,
|
||||||
|
label: 'Value',
|
||||||
|
custom: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
const actions: Column = {
|
||||||
|
id: 'actions',
|
||||||
|
order: false,
|
||||||
|
numeric: false,
|
||||||
|
disablePadding: false,
|
||||||
|
label: '',
|
||||||
|
custom: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
return List([assetRow, balanceRow, valueRow, actions])
|
||||||
|
}
|
||||||
|
|
||||||
export const filterByZero = (data: Array<BalanceRow>, hideZero: boolean): Array<BalanceRow> =>
|
export const filterByZero = (data: Array<BalanceRow>, hideZero: boolean): Array<BalanceRow> =>
|
||||||
data.filter((row: BalanceRow) => (hideZero ? row[buildOrderFieldFrom(BALANCE_TABLE_BALANCE_ID)] !== 0 : true))
|
data.filter((row: BalanceRow) => (hideZero ? row[buildOrderFieldFrom(BALANCE_TABLE_BALANCE_ID)] !== 0 : true))
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
// @flow
|
// @flow
|
||||||
import * as React from 'react'
|
import * as React from 'react'
|
||||||
import { List } from 'immutable'
|
|
||||||
import classNames from 'classnames/bind'
|
import classNames from 'classnames/bind'
|
||||||
import CallMade from '@material-ui/icons/CallMade'
|
import CallMade from '@material-ui/icons/CallMade'
|
||||||
import CallReceived from '@material-ui/icons/CallReceived'
|
import CallReceived from '@material-ui/icons/CallReceived'
|
||||||
@ -16,47 +15,8 @@ import Modal from '~/components/Modal'
|
|||||||
import { type Column } from '~/components/Table/TableHead'
|
import { type Column } from '~/components/Table/TableHead'
|
||||||
import Table from '~/components/Table'
|
import Table from '~/components/Table'
|
||||||
import { sm, xs } from '~/theme/variables'
|
import { sm, xs } from '~/theme/variables'
|
||||||
import { getBalanceData, BALANCE_TABLE_ASSET_ID, BALANCE_TABLE_BALANCE_ID, BALANCE_TABLE_VALUE_ID, type BalanceRow, filterByZero } from './dataFetcher'
|
import { getBalanceData, generateColumns, BALANCE_TABLE_ASSET_ID, type BalanceRow, filterByZero } from './dataFetcher'
|
||||||
|
import Tokens from './Tokens'
|
||||||
const generateColumns = () => {
|
|
||||||
const assetRow: Column = {
|
|
||||||
id: BALANCE_TABLE_ASSET_ID,
|
|
||||||
order: false,
|
|
||||||
numeric: false,
|
|
||||||
disablePadding: false,
|
|
||||||
label: 'Asset',
|
|
||||||
custom: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
const balanceRow: Column = {
|
|
||||||
id: BALANCE_TABLE_BALANCE_ID,
|
|
||||||
order: true,
|
|
||||||
numeric: true,
|
|
||||||
disablePadding: false,
|
|
||||||
label: 'Balance',
|
|
||||||
custom: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
const valueRow: Column = {
|
|
||||||
id: BALANCE_TABLE_VALUE_ID,
|
|
||||||
order: true,
|
|
||||||
numeric: true,
|
|
||||||
disablePadding: false,
|
|
||||||
label: 'Value',
|
|
||||||
custom: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
const actions: Column = {
|
|
||||||
id: 'actions',
|
|
||||||
order: false,
|
|
||||||
numeric: false,
|
|
||||||
disablePadding: false,
|
|
||||||
label: '',
|
|
||||||
custom: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
return List([assetRow, balanceRow, valueRow, actions])
|
|
||||||
}
|
|
||||||
|
|
||||||
type State = {
|
type State = {
|
||||||
hideZero: boolean,
|
hideZero: boolean,
|
||||||
@ -171,7 +131,7 @@ class Balances extends React.Component<Props, State> {
|
|||||||
handleClose={this.onHideToken}
|
handleClose={this.onHideToken}
|
||||||
open={showToken}
|
open={showToken}
|
||||||
>
|
>
|
||||||
List of tokens will show here
|
<Tokens />
|
||||||
</Modal>
|
</Modal>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
|
@ -175,6 +175,12 @@ export default createMuiTheme({
|
|||||||
fontWeight: 'normal',
|
fontWeight: 'normal',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
MuiBackdrop: {
|
||||||
|
root: {
|
||||||
|
backdropFilter: 'blur(1px)',
|
||||||
|
backgroundColor: 'rgba(228, 232, 241, 0.75)',
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
palette,
|
palette,
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user