2018-12-15 14:36:50 -08:00
|
|
|
// @flow
|
2018-12-18 13:41:27 -08:00
|
|
|
import React, { PureComponent, Fragment } from 'react';
|
2018-12-15 14:36:50 -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-15 14:36:50 -08:00
|
|
|
|
2019-01-08 08:01:20 -08:00
|
|
|
import type { TransactionsList } from '../redux/modules/transactions';
|
2018-12-15 14:36:50 -08:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
error: string | null,
|
2019-01-08 08:01:20 -08:00
|
|
|
transactions: TransactionsList,
|
2018-12-15 14:36:50 -08:00
|
|
|
zecPrice: number,
|
|
|
|
getTransactions: () => void,
|
|
|
|
};
|
|
|
|
|
2018-12-18 13:41:27 -08:00
|
|
|
export class TransactionsView extends PureComponent<Props> {
|
2018-12-15 14:36:50 -08:00
|
|
|
componentDidMount() {
|
|
|
|
// eslint-disable-next-line
|
|
|
|
this.props.getTransactions();
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2019-01-05 11:31:19 -08:00
|
|
|
const { error, transactions, zecPrice } = this.props;
|
2018-12-15 14:36:50 -08:00
|
|
|
|
|
|
|
if (error) {
|
2019-01-05 11:31:19 -08:00
|
|
|
return <TextComponent value={error} />;
|
2018-12-15 14:36:50 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Fragment>
|
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}
|
|
|
|
/>
|
|
|
|
))
|
|
|
|
)}
|
2018-12-15 14:36:50 -08:00
|
|
|
</Fragment>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|