extract `TableColumn` interface to a common place and use where necessary

This commit is contained in:
fernandomg 2020-07-14 16:22:22 -03:00
parent 1fb191b7ae
commit 5cb1eb483a
4 changed files with 23 additions and 19 deletions

View File

@ -4,6 +4,7 @@ import { List } from 'immutable'
import { FIXED, buildOrderFieldFrom } from 'src/components/Table/sorting' import { FIXED, buildOrderFieldFrom } from 'src/components/Table/sorting'
import { formatAmount } from 'src/logic/tokens/utils/formatAmount' import { formatAmount } from 'src/logic/tokens/utils/formatAmount'
import { ETH_ADDRESS } from 'src/logic/tokens/utils/tokenHelpers' import { ETH_ADDRESS } from 'src/logic/tokens/utils/tokenHelpers'
import { TableColumn } from 'src/routes/safe/components/tableTypes'
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'
@ -51,8 +52,8 @@ export const getBalanceData = (activeTokens, currencySelected, currencyValues, c
return rows return rows
} }
export const generateColumns = () => { export const generateColumns = (): List<TableColumn> => {
const assetColumn = { const assetColumn: TableColumn = {
id: BALANCE_TABLE_ASSET_ID, id: BALANCE_TABLE_ASSET_ID,
order: true, order: true,
disablePadding: false, disablePadding: false,
@ -61,7 +62,7 @@ export const generateColumns = () => {
width: 250, width: 250,
} }
const balanceColumn = { const balanceColumn: TableColumn = {
id: BALANCE_TABLE_BALANCE_ID, id: BALANCE_TABLE_BALANCE_ID,
align: 'right', align: 'right',
order: true, order: true,
@ -70,7 +71,7 @@ export const generateColumns = () => {
custom: false, custom: false,
} }
const actions = { const actions: TableColumn = {
id: 'actions', id: 'actions',
order: false, order: false,
disablePadding: false, disablePadding: false,
@ -79,7 +80,7 @@ export const generateColumns = () => {
static: true, static: true,
} }
const value = { const value: TableColumn = {
id: BALANCE_TABLE_VALUE_ID, id: BALANCE_TABLE_VALUE_ID,
order: false, order: false,
label: 'Value', label: 'Value',

View File

@ -1,4 +1,5 @@
import { List } from 'immutable' import { List } from 'immutable'
import { TableColumn } from 'src/routes/safe/components/tableTypes'
export const MODULES_TABLE_ADDRESS_ID = 'address' export const MODULES_TABLE_ADDRESS_ID = 'address'
export const MODULES_TABLE_ACTIONS_ID = 'actions' export const MODULES_TABLE_ACTIONS_ID = 'actions'
@ -11,16 +12,6 @@ export const getModuleData = (
})) }))
} }
interface TableColumn {
align?: 'inherit' | 'left' | 'center' | 'right' | 'justify'
custom: boolean
disablePadding: boolean
id: string
label: string
order: boolean
width?: number
}
export const generateColumns = (): List<TableColumn> => { export const generateColumns = (): List<TableColumn> => {
const addressColumn: TableColumn = { const addressColumn: TableColumn = {
align: 'left', align: 'left',

View File

@ -1,4 +1,5 @@
import { List } from 'immutable' import { List } from 'immutable'
import { TableColumn } from 'src/routes/safe/components/tableTypes'
export const OWNERS_TABLE_NAME_ID = 'name' export const OWNERS_TABLE_NAME_ID = 'name'
export const OWNERS_TABLE_ADDRESS_ID = 'address' export const OWNERS_TABLE_ADDRESS_ID = 'address'
@ -13,8 +14,8 @@ export const getOwnerData = (owners) => {
return rows return rows
} }
export const generateColumns = () => { export const generateColumns = (): List<TableColumn> => {
const nameColumn = { const nameColumn: TableColumn = {
id: OWNERS_TABLE_NAME_ID, id: OWNERS_TABLE_NAME_ID,
order: false, order: false,
disablePadding: false, disablePadding: false,
@ -24,7 +25,7 @@ export const generateColumns = () => {
align: 'left', align: 'left',
} }
const addressColumn = { const addressColumn: TableColumn = {
id: OWNERS_TABLE_ADDRESS_ID, id: OWNERS_TABLE_ADDRESS_ID,
order: false, order: false,
disablePadding: false, disablePadding: false,
@ -33,7 +34,7 @@ export const generateColumns = () => {
align: 'left', align: 'left',
} }
const actionsColumn = { const actionsColumn: TableColumn = {
id: OWNERS_TABLE_ACTIONS_ID, id: OWNERS_TABLE_ACTIONS_ID,
order: false, order: false,
disablePadding: false, disablePadding: false,

View File

@ -0,0 +1,11 @@
export interface TableColumn {
align?: 'inherit' | 'left' | 'center' | 'right' | 'justify'
custom: boolean
disablePadding: boolean
id: string
label: string
order: boolean
static?: boolean
style?: any
width?: number
}