2018-07-24 20:40:05 +02:00
|
|
|
import React, { PureComponent } from 'react'
|
|
|
|
import PropTypes from 'prop-types'
|
2018-07-24 20:40:22 +02:00
|
|
|
import Media from 'react-media'
|
2018-07-24 20:40:05 +02:00
|
|
|
import { Redirect } from 'react-router-dom'
|
2019-03-22 00:03:30 +01:00
|
|
|
import WalletView from '../../components/app/wallet-view'
|
|
|
|
import TransactionView from '../../components/app/transaction-view'
|
2018-09-27 20:19:09 +02:00
|
|
|
import ProviderApproval from '../provider-approval'
|
|
|
|
|
2018-07-24 20:40:05 +02:00
|
|
|
import {
|
2019-01-23 16:25:34 +01:00
|
|
|
INITIALIZE_SEED_PHRASE_ROUTE,
|
2018-07-24 20:40:05 +02:00
|
|
|
RESTORE_VAULT_ROUTE,
|
|
|
|
CONFIRM_TRANSACTION_ROUTE,
|
2018-08-28 20:20:30 +02:00
|
|
|
CONFIRM_ADD_SUGGESTED_TOKEN_ROUTE,
|
2019-03-22 00:03:30 +01:00
|
|
|
} from '../../helpers/constants/routes'
|
2018-07-24 20:40:05 +02:00
|
|
|
|
|
|
|
export default class Home extends PureComponent {
|
|
|
|
static propTypes = {
|
|
|
|
history: PropTypes.object,
|
|
|
|
forgottenPassword: PropTypes.bool,
|
|
|
|
seedWords: PropTypes.string,
|
2018-08-28 20:20:30 +02:00
|
|
|
suggestedTokens: PropTypes.object,
|
2018-07-31 07:03:20 +02:00
|
|
|
unconfirmedTransactionsCount: PropTypes.number,
|
2018-09-27 20:19:09 +02:00
|
|
|
providerRequests: PropTypes.array,
|
2018-07-24 20:40:05 +02:00
|
|
|
}
|
|
|
|
|
2019-04-27 11:29:55 +02:00
|
|
|
componentWillMount () {
|
|
|
|
const {
|
|
|
|
history,
|
|
|
|
unconfirmedTransactionsCount = 0,
|
|
|
|
} = this.props
|
|
|
|
|
|
|
|
if (unconfirmedTransactionsCount > 0) {
|
|
|
|
history.push(CONFIRM_TRANSACTION_ROUTE)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-24 20:40:05 +02:00
|
|
|
componentDidMount () {
|
2018-08-28 20:20:30 +02:00
|
|
|
const {
|
|
|
|
history,
|
|
|
|
suggestedTokens = {},
|
|
|
|
} = this.props
|
|
|
|
|
|
|
|
// suggested new tokens
|
|
|
|
if (Object.keys(suggestedTokens).length > 0) {
|
|
|
|
history.push(CONFIRM_ADD_SUGGESTED_TOKEN_ROUTE)
|
|
|
|
}
|
2018-07-24 20:40:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
|
|
|
const {
|
|
|
|
forgottenPassword,
|
|
|
|
seedWords,
|
2018-09-27 20:19:09 +02:00
|
|
|
providerRequests,
|
2019-04-27 11:29:55 +02:00
|
|
|
history,
|
2018-07-24 20:40:05 +02:00
|
|
|
} = this.props
|
|
|
|
|
|
|
|
// seed words
|
|
|
|
if (seedWords) {
|
2019-01-23 16:25:34 +01:00
|
|
|
return <Redirect to={{ pathname: INITIALIZE_SEED_PHRASE_ROUTE }}/>
|
2018-07-24 20:40:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (forgottenPassword) {
|
|
|
|
return <Redirect to={{ pathname: RESTORE_VAULT_ROUTE }} />
|
|
|
|
}
|
|
|
|
|
2018-09-27 20:19:09 +02:00
|
|
|
if (providerRequests && providerRequests.length > 0) {
|
2018-11-05 14:07:56 +01:00
|
|
|
return (
|
|
|
|
<ProviderApproval providerRequest={providerRequests[0]} />
|
|
|
|
)
|
2018-09-27 20:19:09 +02:00
|
|
|
}
|
|
|
|
|
2018-07-24 20:40:05 +02:00
|
|
|
return (
|
|
|
|
<div className="main-container">
|
|
|
|
<div className="account-and-transaction-details">
|
2018-07-24 20:40:22 +02:00
|
|
|
<Media
|
|
|
|
query="(min-width: 576px)"
|
|
|
|
render={() => <WalletView />}
|
|
|
|
/>
|
2019-04-27 11:29:55 +02:00
|
|
|
{ !history.location.pathname.match(/^\/confirm-transaction/) ? <TransactionView /> : null }
|
2018-07-24 20:40:05 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|