2019-05-08 01:02:02 +02:00
|
|
|
import React, { PureComponent } from 'react'
|
|
|
|
import { Link } from '@reach/router'
|
2019-05-08 21:41:24 +02:00
|
|
|
import { AppContext } from '../store/createContext'
|
2019-05-10 00:37:59 +02:00
|
|
|
import Welcome from '../components/Welcome'
|
2019-05-08 01:02:02 +02:00
|
|
|
import Total from '../components/Total'
|
|
|
|
import Account from '../components/Account'
|
|
|
|
import Ticker from '../components/Ticker'
|
|
|
|
import Spinner from '../components/Spinner'
|
2019-05-09 00:58:05 +02:00
|
|
|
import IconCog from '../images/cog.svg'
|
2019-05-08 01:02:02 +02:00
|
|
|
import './Home.css'
|
|
|
|
|
|
|
|
export default class Home extends PureComponent {
|
2019-05-08 21:41:24 +02:00
|
|
|
static contextType = AppContext
|
|
|
|
|
2019-05-08 01:02:02 +02:00
|
|
|
render() {
|
2019-05-08 21:41:24 +02:00
|
|
|
const { isLoading, accounts, needsConfig } = this.context
|
|
|
|
|
2019-05-08 01:02:02 +02:00
|
|
|
return (
|
2019-05-08 21:41:24 +02:00
|
|
|
<>
|
2019-05-10 00:37:59 +02:00
|
|
|
<main className="main box">
|
2019-05-10 22:22:33 +02:00
|
|
|
<Link className="preferences-link" to="/preferences">
|
2019-05-09 00:58:05 +02:00
|
|
|
<IconCog />
|
|
|
|
</Link>
|
|
|
|
|
2019-05-08 21:41:24 +02:00
|
|
|
{needsConfig ? (
|
2019-05-10 00:37:59 +02:00
|
|
|
<Welcome />
|
2019-05-08 21:41:24 +02:00
|
|
|
) : isLoading ? (
|
|
|
|
<Spinner />
|
|
|
|
) : (
|
|
|
|
<>
|
|
|
|
<Total />
|
2019-05-08 01:02:02 +02:00
|
|
|
|
2019-05-08 21:41:24 +02:00
|
|
|
<div className="number-unit-wrap number-unit-wrap--accounts">
|
|
|
|
{accounts.map((account, i) => (
|
|
|
|
<Account key={i} account={account} />
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
</main>
|
2019-05-08 01:02:02 +02:00
|
|
|
|
2019-05-08 21:41:24 +02:00
|
|
|
<Ticker style={isLoading ? { opacity: 0 } : null} />
|
|
|
|
</>
|
2019-05-08 01:02:02 +02:00
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|