From 5cb1eb483a79641d54d2835c831f96a9bcc26496 Mon Sep 17 00:00:00 2001 From: fernandomg Date: Tue, 14 Jul 2020 16:22:22 -0300 Subject: [PATCH] extract `TableColumn` interface to a common place and use where necessary --- src/routes/safe/components/Balances/dataFetcher.ts | 11 ++++++----- .../safe/components/Settings/Advanced/dataFetcher.ts | 11 +---------- .../components/Settings/ManageOwners/dataFetcher.ts | 9 +++++---- src/routes/safe/components/tableTypes.d.ts | 11 +++++++++++ 4 files changed, 23 insertions(+), 19 deletions(-) create mode 100644 src/routes/safe/components/tableTypes.d.ts diff --git a/src/routes/safe/components/Balances/dataFetcher.ts b/src/routes/safe/components/Balances/dataFetcher.ts index d4ab9eee..dc427c99 100644 --- a/src/routes/safe/components/Balances/dataFetcher.ts +++ b/src/routes/safe/components/Balances/dataFetcher.ts @@ -4,6 +4,7 @@ import { List } from 'immutable' import { FIXED, buildOrderFieldFrom } from 'src/components/Table/sorting' import { formatAmount } from 'src/logic/tokens/utils/formatAmount' 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_BALANCE_ID = 'balance' @@ -51,8 +52,8 @@ export const getBalanceData = (activeTokens, currencySelected, currencyValues, c return rows } -export const generateColumns = () => { - const assetColumn = { +export const generateColumns = (): List => { + const assetColumn: TableColumn = { id: BALANCE_TABLE_ASSET_ID, order: true, disablePadding: false, @@ -61,7 +62,7 @@ export const generateColumns = () => { width: 250, } - const balanceColumn = { + const balanceColumn: TableColumn = { id: BALANCE_TABLE_BALANCE_ID, align: 'right', order: true, @@ -70,7 +71,7 @@ export const generateColumns = () => { custom: false, } - const actions = { + const actions: TableColumn = { id: 'actions', order: false, disablePadding: false, @@ -79,7 +80,7 @@ export const generateColumns = () => { static: true, } - const value = { + const value: TableColumn = { id: BALANCE_TABLE_VALUE_ID, order: false, label: 'Value', diff --git a/src/routes/safe/components/Settings/Advanced/dataFetcher.ts b/src/routes/safe/components/Settings/Advanced/dataFetcher.ts index 8ef9b4f5..1e6965c9 100644 --- a/src/routes/safe/components/Settings/Advanced/dataFetcher.ts +++ b/src/routes/safe/components/Settings/Advanced/dataFetcher.ts @@ -1,4 +1,5 @@ import { List } from 'immutable' +import { TableColumn } from 'src/routes/safe/components/tableTypes' export const MODULES_TABLE_ADDRESS_ID = 'address' 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 => { const addressColumn: TableColumn = { align: 'left', diff --git a/src/routes/safe/components/Settings/ManageOwners/dataFetcher.ts b/src/routes/safe/components/Settings/ManageOwners/dataFetcher.ts index 25b2ff48..f85595c0 100644 --- a/src/routes/safe/components/Settings/ManageOwners/dataFetcher.ts +++ b/src/routes/safe/components/Settings/ManageOwners/dataFetcher.ts @@ -1,4 +1,5 @@ import { List } from 'immutable' +import { TableColumn } from 'src/routes/safe/components/tableTypes' export const OWNERS_TABLE_NAME_ID = 'name' export const OWNERS_TABLE_ADDRESS_ID = 'address' @@ -13,8 +14,8 @@ export const getOwnerData = (owners) => { return rows } -export const generateColumns = () => { - const nameColumn = { +export const generateColumns = (): List => { + const nameColumn: TableColumn = { id: OWNERS_TABLE_NAME_ID, order: false, disablePadding: false, @@ -24,7 +25,7 @@ export const generateColumns = () => { align: 'left', } - const addressColumn = { + const addressColumn: TableColumn = { id: OWNERS_TABLE_ADDRESS_ID, order: false, disablePadding: false, @@ -33,7 +34,7 @@ export const generateColumns = () => { align: 'left', } - const actionsColumn = { + const actionsColumn: TableColumn = { id: OWNERS_TABLE_ACTIONS_ID, order: false, disablePadding: false, diff --git a/src/routes/safe/components/tableTypes.d.ts b/src/routes/safe/components/tableTypes.d.ts new file mode 100644 index 00000000..133b0f14 --- /dev/null +++ b/src/routes/safe/components/tableTypes.d.ts @@ -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 +}