zepio/app/views/transactions.js

48 lines
1.2 KiB
JavaScript
Raw Normal View History

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';
import { TextComponent } from '../components/text';
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() {
const { error, transactions, zecPrice } = this.props;
2018-12-15 14:36:50 -08:00
if (error) {
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 ? (
<EmptyTransactionsComponent />
) : (
2019-01-08 08:01:20 -08:00
transactions.map(({ day, list }) => (
<TransactionDailyComponent
transactionsDate={day}
2019-01-08 08:01:20 -08:00
transactions={list}
zecPrice={zecPrice}
key={day}
/>
))
)}
2018-12-15 14:36:50 -08:00
</Fragment>
);
}
}