2018-03-26 23:32:43 +02:00
|
|
|
// @flow
|
2018-11-07 20:35:47 +01:00
|
|
|
import React, { Fragment } from 'react';
|
2018-03-26 23:32:43 +02:00
|
|
|
import BusyIndicator from 'component/common/busy-indicator';
|
|
|
|
import Button from 'component/button';
|
2017-12-21 22:08:54 +01:00
|
|
|
import TransactionList from 'component/transactionList';
|
|
|
|
import * as icons from 'constants/icons';
|
2018-03-26 23:32:43 +02:00
|
|
|
import type { Transaction } from 'component/transactionList/view';
|
2017-08-20 23:42:00 +02:00
|
|
|
|
2018-03-26 23:32:43 +02:00
|
|
|
type Props = {
|
|
|
|
fetchTransactions: () => void,
|
|
|
|
fetchingTransactions: boolean,
|
|
|
|
hasTransactions: boolean,
|
|
|
|
transactions: Array<Transaction>,
|
2018-11-07 20:35:47 +01:00
|
|
|
fetchMyClaims: () => void,
|
2018-03-26 23:32:43 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class TransactionListRecent extends React.PureComponent<Props> {
|
|
|
|
componentDidMount() {
|
2018-11-07 20:35:47 +01:00
|
|
|
const { fetchMyClaims, fetchTransactions } = this.props;
|
|
|
|
|
|
|
|
fetchMyClaims();
|
|
|
|
fetchTransactions();
|
2017-08-20 23:42:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2018-11-07 20:35:47 +01:00
|
|
|
const { fetchingTransactions, hasTransactions, transactions, fetchTransactions } = this.props;
|
2017-08-20 23:42:00 +02:00
|
|
|
return (
|
2018-03-26 23:32:43 +02:00
|
|
|
<section className="card card--section">
|
2018-11-07 20:35:47 +01:00
|
|
|
<div className="card__title card--space-between">
|
|
|
|
{__('Recent Transactions')}
|
|
|
|
<div className="card__actions-top-corner">
|
|
|
|
<Button
|
|
|
|
button="inverse"
|
|
|
|
label={__('Refresh')}
|
|
|
|
onClick={fetchTransactions}
|
|
|
|
disabled={fetchingTransactions}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
2018-10-04 06:11:08 +02:00
|
|
|
<div className="card__subtitle">
|
|
|
|
{__('To view all of your transactions, navigate to the')}{' '}
|
|
|
|
<Button button="link" navigate="/history" label={__('transactions page')} />.
|
|
|
|
</div>
|
2018-11-07 20:35:47 +01:00
|
|
|
{fetchingTransactions &&
|
|
|
|
!hasTransactions && (
|
|
|
|
<div className="card__content">
|
|
|
|
<BusyIndicator message={__('Loading transactions')} />
|
|
|
|
</div>
|
|
|
|
)}
|
2017-11-24 15:31:05 +01:00
|
|
|
{hasTransactions && (
|
2018-11-07 20:35:47 +01:00
|
|
|
<Fragment>
|
|
|
|
<TransactionList
|
|
|
|
slim
|
|
|
|
transactions={transactions}
|
|
|
|
emptyMessage={__("Looks like you don't have any recent transactions.")}
|
2017-08-20 23:42:00 +02:00
|
|
|
/>
|
2018-11-07 20:35:47 +01:00
|
|
|
<div className="card__actions">
|
|
|
|
<Button
|
|
|
|
button="primary"
|
|
|
|
navigate="/history"
|
|
|
|
label={__('Full History')}
|
|
|
|
icon={icons.CLOCK}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</Fragment>
|
2017-11-24 15:31:05 +01:00
|
|
|
)}
|
2017-08-20 23:42:00 +02:00
|
|
|
</section>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default TransactionListRecent;
|