Safe view tabs as routes wip

This commit is contained in:
Mikhail Mikheev 2019-10-04 18:10:17 +04:00
parent b458aa44ba
commit 051b677651

View File

@ -1,6 +1,7 @@
// @flow // @flow
import * as React from 'react' import * as React from 'react'
import classNames from 'classnames/bind' import classNames from 'classnames/bind'
import { Switch, Redirect, Route } from 'react-router-dom'
import OpenInNew from '@material-ui/icons/OpenInNew' import OpenInNew from '@material-ui/icons/OpenInNew'
import Tabs from '@material-ui/core/Tabs' import Tabs from '@material-ui/core/Tabs'
import Tab from '@material-ui/core/Tab' import Tab from '@material-ui/core/Tab'
@ -21,9 +22,7 @@ import Receive from './Balances/Receive'
import NoSafe from '~/components/NoSafe' import NoSafe from '~/components/NoSafe'
import { type SelectorProps } from '~/routes/safe/container/selector' import { type SelectorProps } from '~/routes/safe/container/selector'
import { getEtherScanLink } from '~/logic/wallets/getWeb3' import { getEtherScanLink } from '~/logic/wallets/getWeb3'
import { import { secondary, border } from '~/theme/variables'
secondary, border,
} from '~/theme/variables'
import { copyToClipboard } from '~/utils/clipboard' import { copyToClipboard } from '~/utils/clipboard'
import { type Actions } from '../container/actions' import { type Actions } from '../container/actions'
import Balances from './Balances' import Balances from './Balances'
@ -49,7 +48,7 @@ type Props = SelectorProps &
onShow: Function, onShow: Function,
onHide: Function, onHide: Function,
showSendFunds: Function, showSendFunds: Function,
hideSendFunds: Function hideSendFunds: Function,
} }
const openIconStyle = { const openIconStyle = {
@ -99,6 +98,7 @@ class Layout extends React.Component<Props, State> {
showSendFunds, showSendFunds,
hideSendFunds, hideSendFunds,
} = this.props } = this.props
console.log(this.props)
const { tabIndex } = this.state const { tabIndex } = this.state
if (!safe) { if (!safe) {
@ -162,7 +162,11 @@ class Layout extends React.Component<Props, State> {
</Tabs> </Tabs>
</Row> </Row>
<Hairline color={border} style={{ marginTop: '-2px' }} /> <Hairline color={border} style={{ marginTop: '-2px' }} />
{tabIndex === 0 && ( <Switch>
<Route
exact
path="balances"
render={() => (
<Balances <Balances
ethBalance={ethBalance} ethBalance={ethBalance}
tokens={tokens} tokens={tokens}
@ -174,7 +178,11 @@ class Layout extends React.Component<Props, State> {
createTransaction={createTransaction} createTransaction={createTransaction}
/> />
)} )}
{tabIndex === 1 && ( />
<Route
exact
path="transactions"
render={() => (
<Transactions <Transactions
threshold={safe.threshold} threshold={safe.threshold}
owners={safe.owners} owners={safe.owners}
@ -188,7 +196,11 @@ class Layout extends React.Component<Props, State> {
processTransaction={processTransaction} processTransaction={processTransaction}
/> />
)} )}
{tabIndex === 2 && ( />
<Route
exact
path="settings"
render={() => (
<Settings <Settings
granted={granted} granted={granted}
safeAddress={address} safeAddress={address}
@ -202,6 +214,9 @@ class Layout extends React.Component<Props, State> {
createTransaction={createTransaction} createTransaction={createTransaction}
/> />
)} )}
/>
<Redirect to="balances" />
</Switch>
<SendModal <SendModal
onClose={hideSendFunds} onClose={hideSendFunds}
isOpen={sendFunds.isOpen} isOpen={sendFunds.isOpen}
@ -221,12 +236,7 @@ class Layout extends React.Component<Props, State> {
open={showReceive} open={showReceive}
paperClassName={classes.receiveModal} paperClassName={classes.receiveModal}
> >
<Receive <Receive safeName={name} safeAddress={address} etherScanLink={etherScanLink} onClose={onHide('Receive')} />
safeName={name}
safeAddress={address}
etherScanLink={etherScanLink}
onClose={onHide('Receive')}
/>
</Modal> </Modal>
</> </>
) )