From b91bada91a513ca8d7634bf663317452688dbddc Mon Sep 17 00:00:00 2001 From: Manuel Calavera Date: Mon, 9 Sep 2019 07:42:08 -0700 Subject: [PATCH] fix: review feedback --- src/v2/@types/table.js | 8 ++++++++ src/v2/components/Applications/Table/index.jsx | 12 +++--------- src/v2/components/Blocks/Table/index.jsx | 12 +++--------- src/v2/components/Favorites/Accounts.jsx | 12 +++--------- src/v2/components/Favorites/index.jsx | 12 +++++++----- src/v2/components/Transactions/Table/index.jsx | 11 +++-------- 6 files changed, 27 insertions(+), 40 deletions(-) create mode 100644 src/v2/@types/table.js diff --git a/src/v2/@types/table.js b/src/v2/@types/table.js new file mode 100644 index 00000000..ffbeb926 --- /dev/null +++ b/src/v2/@types/table.js @@ -0,0 +1,8 @@ +//@flow + +export type TableHeadProps = { + name: string, + text: string, + term: string, + width?: number, +}; diff --git a/src/v2/components/Applications/Table/index.jsx b/src/v2/components/Applications/Table/index.jsx index 15141ddc..9b9af596 100644 --- a/src/v2/components/Applications/Table/index.jsx +++ b/src/v2/components/Applications/Table/index.jsx @@ -16,17 +16,11 @@ import {Link} from 'react-router-dom'; import {map} from 'lodash/fp'; import HelpLink from 'v2/components/HelpLink'; import TypeLabel from 'v2/components/UI/TypeLabel'; +import type {TableHeadProps} from 'v2/@types/table'; import useStyles from './styles'; -type THead = { - name: string, - text: string, - term: string, - width?: number, -}; - -const tHeads: THead[] = [ +const tHeads: TableHeadProps[] = [ { name: 'Application Id', text: '', @@ -65,7 +59,7 @@ const ApplicationsTable = ({separate}: {separate: boolean}) => { ); }; - const renderTH = ({name, width, ...rest}: THead) => ( + const renderTH = ({name, width, ...rest}: TableHeadProps) => ( {name} diff --git a/src/v2/components/Blocks/Table/index.jsx b/src/v2/components/Blocks/Table/index.jsx index 8f4cde05..827c6ab2 100644 --- a/src/v2/components/Blocks/Table/index.jsx +++ b/src/v2/components/Blocks/Table/index.jsx @@ -15,18 +15,12 @@ import {observer} from 'mobx-react-lite'; import {Link} from 'react-router-dom'; import {map} from 'lodash/fp'; import Avatar from 'v2/components/UI/Avatar'; +import type {TableHeadProps} from 'v2/@types/table'; import HelpLink from '../../HelpLink'; import useStyles from './styles'; -type THead = { - name: string, - text: string, - term: string, - width?: number, -}; - -const tHeads: THead[] = [ +const tHeads: TableHeadProps[] = [ { name: 'blocks', text: '', @@ -79,7 +73,7 @@ const BlocksTable = ({separate}: {separate: boolean}) => { ); }; - const renderTH = ({name, width, ...rest}: THead) => ( + const renderTH = ({name, width, ...rest}: TableHeadProps) => ( {name} diff --git a/src/v2/components/Favorites/Accounts.jsx b/src/v2/components/Favorites/Accounts.jsx index 6ea450c1..2ed0c613 100644 --- a/src/v2/components/Favorites/Accounts.jsx +++ b/src/v2/components/Favorites/Accounts.jsx @@ -15,17 +15,11 @@ import {observer} from 'mobx-react-lite'; import {Link} from 'react-router-dom'; import {map} from 'lodash/fp'; import HelpLink from 'v2/components/HelpLink'; +import type {TableHeadProps} from 'v2/@types/table'; import useStyles from './styles'; -type THead = { - name: string, - text: string, - term: string, - width?: number, -}; - -const tHeads: THead[] = [ +const tHeads: TableHeadProps[] = [ { name: 'Account Id', text: '', @@ -68,7 +62,7 @@ const AccountsTable = ({separate}: {separate: boolean}) => { ); }; - const renderTH = ({name, width, ...rest}: THead) => ( + const renderTH = ({name, width, ...rest}: TableHeadProps) => ( {name} diff --git a/src/v2/components/Favorites/index.jsx b/src/v2/components/Favorites/index.jsx index e815b1ce..1201c9ac 100644 --- a/src/v2/components/Favorites/index.jsx +++ b/src/v2/components/Favorites/index.jsx @@ -13,12 +13,14 @@ import useStyles from './styles'; const TransactionsPage = () => { const classes = useStyles(); - const [tab, setTab] = useState(0); + const [tab, setTab] = useState('applications'); const theme = useTheme(); const verticalTabs = useMediaQuery(theme.breakpoints.down('xs')); const handleTabChange = (event, tab) => setTab(tab); - const tabNav = ['Applications', 'Accounts']; - const renderTabNav = label => ; + const tabNav = ['applications', 'accounts']; + const renderTabNav = label => ( + + ); return ( @@ -38,8 +40,8 @@ const TransactionsPage = () => { > {map(renderTabNav)(tabNav)} - {eq(0, tab) && } - {eq(1, tab) && } + {eq('applications', tab) && } + {eq('accounts', tab) && } ); }; diff --git a/src/v2/components/Transactions/Table/index.jsx b/src/v2/components/Transactions/Table/index.jsx index eb43600f..61ec8315 100644 --- a/src/v2/components/Transactions/Table/index.jsx +++ b/src/v2/components/Transactions/Table/index.jsx @@ -16,16 +16,11 @@ import {Link} from 'react-router-dom'; import {map} from 'lodash/fp'; import HelpLink from 'v2/components/HelpLink'; import TypeLabel from 'v2/components/UI/TypeLabel'; +import type {TableHeadProps} from 'v2/@types/table'; import useStyles from './styles'; -type THead = { - name: string, - text: string, - term: string, -}; - -const tHeads: THead[] = [ +const tHeads: TableHeadProps[] = [ { name: 'hash', text: '', @@ -97,7 +92,7 @@ const TransactionsTable = ({ ); }; - const renderTH = ({name, ...rest}: THead) => ( + const renderTH = ({name, ...rest}: TableHeadProps) => ( {name}