This repository has been archived by the owner on Jun 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
App.js
80 lines (74 loc) · 2.24 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import React from 'react'
import { BrowserRouter, Route } from 'react-router-dom'
import { withWeb3 } from 'react-web3-provider'
import Header from './ui/layout/Header'
import Footer from './ui/layout/Footer'
import Main from './ui/layout/Main'
import Sidebar from './ui/layout/Sidebar'
import Content from './ui/layout/Content'
import Section from './ui/layout/Section'
import IndexPage from './ui/pages/IndexPage'
import HelpPage from './ui/pages/HelpPage'
import ErrorPage from './ui/pages/ErrorPage'
import MyPlaidBankAccountsPage from './ui/pages/MyPlaidBankAccountsPage'
import MyVerifiedBankAccountsPage from './ui/pages/MyVerifiedBankAccountsPage'
export class AppContainer extends React.Component {
constructor(props) {
super(props)
this.state = {
selectedAccount: null
}
}
componentDidUpdate(prevProps) {
const { web3, web3State } = this.props
if (web3State.isConnected !== prevProps.web3State.isConnected && web3) {
web3.eth.getAccounts().then(accounts => {
this.setState({
selectedAccount: accounts[0]
})
})
}
}
renderRoutes() {
const { web3 } = this.props
const { selectedAccount } = this.state
return (
<BrowserRouter>
<Route exact path="/" component={IndexPage} />
<Route exact path="/help" component={HelpPage} />
<Route
path="/bankaccountslist/:token"
component={props => (
<MyPlaidBankAccountsPage props={props} web3={web3} account={selectedAccount} />
)}
/>
<Route
path="/mybankaccountslist"
component={() => <MyVerifiedBankAccountsPage web3={web3} account={selectedAccount} />}
/>
</BrowserRouter>
)
}
render() {
const { web3 } = this.props
const { selectedAccount } = this.state
return (
<div className="App">
<Main>
<Sidebar />
<Content>
<Header />
<Section>
<section className="h100percent">
{!web3 || !selectedAccount ? <ErrorPage /> : this.renderRoutes()}
</section>
</Section>
<Footer />
</Content>
</Main>
</div>
)
}
}
const App = withWeb3(AppContainer)
export default App