2018-11-23 15:23:41 -08:00
|
|
|
// @flow
|
|
|
|
|
2018-12-18 13:41:27 -08:00
|
|
|
import React, { PureComponent, Fragment } from 'react';
|
2018-11-23 15:23:41 -08:00
|
|
|
|
2018-12-10 09:09:30 -08:00
|
|
|
import { WalletSummaryComponent } from '../components/wallet-summary';
|
2018-12-13 12:21:08 -08:00
|
|
|
import { TransactionDailyComponent } from '../components/transaction-daily';
|
2019-01-05 11:31:19 -08:00
|
|
|
import { TextComponent } from '../components/text';
|
2019-01-07 11:24:42 -08:00
|
|
|
import { EmptyTransactionsComponent } from '../components/empty-transactions';
|
2018-12-10 09:09:30 -08:00
|
|
|
|
2019-01-08 08:01:20 -08:00
|
|
|
import type { TransactionsList } from '../redux/modules/transactions';
|
2018-12-13 12:21:08 -08:00
|
|
|
|
2018-12-10 09:09:30 -08:00
|
|
|
type Props = {
|
|
|
|
getSummary: () => void,
|
|
|
|
total: number,
|
|
|
|
shielded: number,
|
|
|
|
transparent: number,
|
|
|
|
error: string | null,
|
2018-12-13 13:37:15 -08:00
|
|
|
zecPrice: number,
|
2018-12-10 16:11:53 -08:00
|
|
|
addresses: string[],
|
2019-01-08 08:01:20 -08:00
|
|
|
transactions: TransactionsList,
|
2018-12-10 09:09:30 -08:00
|
|
|
};
|
|
|
|
|
2018-12-19 07:59:54 -08:00
|
|
|
export class DashboardView extends PureComponent<Props> {
|
2018-12-10 09:09:30 -08:00
|
|
|
componentDidMount() {
|
2019-02-04 20:41:45 -08:00
|
|
|
const { getSummary } = this.props;
|
|
|
|
getSummary();
|
2018-12-10 09:09:30 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2018-12-12 10:59:13 -08:00
|
|
|
const {
|
2018-12-15 07:10:39 -08:00
|
|
|
error,
|
|
|
|
total,
|
|
|
|
shielded,
|
|
|
|
transparent,
|
|
|
|
zecPrice,
|
|
|
|
addresses,
|
|
|
|
transactions,
|
2018-12-12 10:59:13 -08:00
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
if (error) {
|
2019-01-05 11:31:19 -08:00
|
|
|
return <TextComponent value={error} />;
|
2018-12-10 09:09:30 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2018-12-15 14:37:12 -08:00
|
|
|
<Fragment>
|
2019-01-05 11:31:19 -08:00
|
|
|
<WalletSummaryComponent
|
|
|
|
total={total}
|
|
|
|
shielded={shielded}
|
|
|
|
transparent={transparent}
|
|
|
|
zecPrice={zecPrice}
|
|
|
|
addresses={addresses}
|
|
|
|
/>
|
2019-01-08 08:01:20 -08:00
|
|
|
{transactions.length === 0 ? (
|
2019-01-07 11:24:42 -08:00
|
|
|
<EmptyTransactionsComponent />
|
|
|
|
) : (
|
2019-01-08 08:01:20 -08:00
|
|
|
transactions.map(({ day, list }) => (
|
2019-01-07 11:24:42 -08:00
|
|
|
<TransactionDailyComponent
|
|
|
|
transactionsDate={day}
|
2019-01-08 08:01:20 -08:00
|
|
|
transactions={list}
|
2019-01-07 11:24:42 -08:00
|
|
|
zecPrice={zecPrice}
|
|
|
|
key={day}
|
|
|
|
/>
|
|
|
|
))
|
|
|
|
)}
|
2018-12-15 14:37:12 -08:00
|
|
|
</Fragment>
|
2018-12-10 09:09:30 -08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|