zepio/app/views/dashboard.js

75 lines
1.7 KiB
JavaScript
Raw Normal View History

// @flow
2018-12-18 13:41:27 -08:00
import React, { PureComponent, Fragment } from 'react';
import { WalletSummaryComponent } from '../components/wallet-summary';
import { TransactionDailyComponent } from '../components/transaction-daily';
2018-12-11 04:13:45 -08:00
import { withDaemonStatusCheck } from '../components/with-daemon-status-check';
import type { Transaction } from '../components/transaction-item';
type Props = {
getSummary: () => void,
total: number,
shielded: number,
transparent: number,
error: string | null,
isLoading: boolean,
zecPrice: number,
2018-12-10 16:11:53 -08:00
addresses: string[],
transactions: { [day: string]: Transaction[] },
};
2018-12-18 13:41:27 -08:00
export class Dashboard extends PureComponent<Props> {
componentDidMount() {
/* eslint-disable-next-line */
this.props.getSummary();
}
render() {
const {
2018-12-15 07:10:39 -08:00
error,
isLoading,
total,
shielded,
transparent,
zecPrice,
addresses,
transactions,
} = this.props;
const days = Object.keys(transactions);
if (error) {
return error;
}
return (
2018-12-15 14:37:12 -08:00
<Fragment>
{isLoading ? (
'Loading'
) : (
2018-12-15 14:37:12 -08:00
<Fragment>
<WalletSummaryComponent
total={total}
shielded={shielded}
transparent={transparent}
zecPrice={zecPrice}
addresses={addresses}
/>
{days.map(day => (
2018-12-15 07:10:39 -08:00
<TransactionDailyComponent
transactionsDate={day}
transactions={transactions[day]}
zecPrice={zecPrice}
/>
))}
2018-12-15 14:37:12 -08:00
</Fragment>
)}
2018-12-15 14:37:12 -08:00
</Fragment>
);
}
}
2018-12-11 04:13:45 -08:00
export const DashboardView = withDaemonStatusCheck(Dashboard);