2018-11-23 15:23:41 -08:00
|
|
|
// @flow
|
|
|
|
|
2018-12-11 16:46:26 -08:00
|
|
|
import React, { Fragment } from 'react';
|
|
|
|
import styled from 'styled-components';
|
2018-11-23 15:23:41 -08:00
|
|
|
|
2018-12-10 09:09:30 -08:00
|
|
|
import { WalletSummaryComponent } from '../components/wallet-summary';
|
2018-12-11 04:13:45 -08:00
|
|
|
import { withDaemonStatusCheck } from '../components/with-daemon-status-check';
|
2018-12-11 16:46:26 -08:00
|
|
|
import { TextComponent } from '../components/text';
|
|
|
|
|
|
|
|
const Title = styled(TextComponent)`
|
|
|
|
font-size: 1.5em;
|
|
|
|
margin-top: 10px;
|
|
|
|
margin-bottom: 10px;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const Divider = styled.div`
|
|
|
|
width: 100%;
|
|
|
|
background-color: ${props => props.theme.colors.text};
|
|
|
|
height: 1px;
|
|
|
|
opacity: 0.1;
|
|
|
|
`;
|
2018-12-10 09:09:30 -08:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
getSummary: () => void,
|
|
|
|
total: number,
|
|
|
|
shielded: number,
|
|
|
|
transparent: number,
|
|
|
|
error: string | null,
|
|
|
|
isLoading: boolean,
|
|
|
|
dollarValue: number,
|
2018-12-10 16:11:53 -08:00
|
|
|
addresses: string[],
|
2018-12-10 09:09:30 -08:00
|
|
|
};
|
|
|
|
|
2018-12-11 04:13:45 -08:00
|
|
|
export class Dashboard extends React.Component<Props> {
|
2018-12-10 09:09:30 -08:00
|
|
|
componentDidMount() {
|
|
|
|
this.props.getSummary();
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
if (this.props.error) {
|
|
|
|
return this.props.error;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className='dashboard'>
|
|
|
|
{this.props.isLoading ? (
|
|
|
|
'Loading'
|
|
|
|
) : (
|
2018-12-11 16:46:26 -08:00
|
|
|
<Fragment>
|
|
|
|
<Title value='Dashboard' />
|
|
|
|
<Divider />
|
|
|
|
<WalletSummaryComponent
|
|
|
|
total={this.props.total}
|
|
|
|
shielded={this.props.shielded}
|
|
|
|
transparent={this.props.transparent}
|
|
|
|
dollarValue={this.props.dollarValue}
|
|
|
|
addresses={this.props.addresses}
|
|
|
|
/>
|
|
|
|
</Fragment>
|
2018-12-10 09:09:30 -08:00
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2018-12-11 04:13:45 -08:00
|
|
|
|
|
|
|
export const DashboardView = withDaemonStatusCheck(Dashboard);
|