2017-06-06 23:19:12 +02:00
|
|
|
import React from "react";
|
2017-09-18 02:52:57 +02:00
|
|
|
import TransactionListItem from "./internal/TransactionListItem";
|
2017-09-02 17:36:27 +02:00
|
|
|
import FormField from "component/formField";
|
2017-11-09 00:14:32 +01:00
|
|
|
import Link from "component/link";
|
|
|
|
import * as icons from "constants/icons";
|
2017-10-27 21:42:54 +02:00
|
|
|
import * as modals from "constants/modal_types";
|
2017-05-11 02:59:47 +02:00
|
|
|
|
2017-09-02 17:36:27 +02:00
|
|
|
class TransactionList extends React.PureComponent {
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this.state = {
|
2017-09-18 02:52:57 +02:00
|
|
|
filter: null,
|
2017-09-02 17:36:27 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
handleFilterChanged(event) {
|
|
|
|
this.setState({
|
|
|
|
filter: event.target.value,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-09-18 02:52:57 +02:00
|
|
|
filterTransaction(transaction) {
|
|
|
|
const { filter } = this.state;
|
|
|
|
|
|
|
|
return !filter || filter == transaction.type;
|
2017-09-04 19:35:41 +02:00
|
|
|
}
|
|
|
|
|
2017-10-24 15:10:27 +02:00
|
|
|
isRevokeable(txid, nout) {
|
|
|
|
// a claim/support/update is revokable if it
|
|
|
|
// is in my claim list(claim_list_mine)
|
|
|
|
return this.props.myClaims.has(`${txid}:${nout}`);
|
|
|
|
}
|
|
|
|
|
2017-11-01 21:23:30 +01:00
|
|
|
revokeClaim(txid, nout) {
|
|
|
|
this.props.openModal(modals.CONFIRM_CLAIM_REVOKE, { txid, nout });
|
2017-10-24 15:10:27 +02:00
|
|
|
}
|
|
|
|
|
2017-09-02 17:36:27 +02:00
|
|
|
render() {
|
2017-09-18 02:52:57 +02:00
|
|
|
const { emptyMessage, rewards, transactions } = this.props;
|
2017-09-02 17:36:27 +02:00
|
|
|
|
2017-09-18 02:52:57 +02:00
|
|
|
let transactionList = transactions.filter(
|
|
|
|
this.filterTransaction.bind(this)
|
|
|
|
);
|
2017-05-11 02:59:47 +02:00
|
|
|
|
|
|
|
return (
|
2017-09-02 17:36:27 +02:00
|
|
|
<div>
|
2017-11-24 22:36:10 +01:00
|
|
|
{(transactionList.length || this.state.filter) &&
|
2017-09-18 02:52:57 +02:00
|
|
|
<span className="sort-section">
|
2017-11-24 22:36:10 +01:00
|
|
|
{__("Filter")} {" "}
|
2017-09-18 02:52:57 +02:00
|
|
|
<FormField
|
|
|
|
type="select"
|
|
|
|
onChange={this.handleFilterChanged.bind(this)}
|
|
|
|
>
|
|
|
|
<option value="">{__("All")}</option>
|
|
|
|
<option value="spend">{__("Spends")}</option>
|
|
|
|
<option value="receive">{__("Receives")}</option>
|
|
|
|
<option value="publish">{__("Publishes")}</option>
|
|
|
|
<option value="channel">{__("Channels")}</option>
|
|
|
|
<option value="tip">{__("Tips")}</option>
|
|
|
|
<option value="support">{__("Supports")}</option>
|
|
|
|
<option value="update">{__("Updates")}</option>
|
2017-11-24 22:36:10 +01:00
|
|
|
</FormField>
|
|
|
|
{" "}
|
2017-11-09 00:14:32 +01:00
|
|
|
<Link
|
|
|
|
href="https://lbry.io/faq/transaction-types"
|
|
|
|
icon={icons.HELP_CIRCLE}
|
|
|
|
/>
|
2017-11-24 22:36:10 +01:00
|
|
|
</span>}
|
|
|
|
{!transactionList.length &&
|
2017-09-18 02:52:57 +02:00
|
|
|
<div className="empty">
|
|
|
|
{emptyMessage || __("No transactions to list.")}
|
2017-11-24 22:36:10 +01:00
|
|
|
</div>}
|
|
|
|
{Boolean(transactionList.length) &&
|
2017-09-18 02:52:57 +02:00
|
|
|
<table className="table-standard table-transactions table-stretch">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>{__("Date")}</th>
|
|
|
|
<th>{__("Amount (Fee)")}</th>
|
|
|
|
<th>{__("Type")} </th>
|
|
|
|
<th>{__("Details")} </th>
|
|
|
|
<th>{__("Transaction")}</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
2017-11-24 22:36:10 +01:00
|
|
|
{transactionList.map(t =>
|
2017-09-18 02:52:57 +02:00
|
|
|
<TransactionListItem
|
|
|
|
key={`${t.txid}:${t.nout}`}
|
|
|
|
transaction={t}
|
|
|
|
reward={rewards && rewards[t.txid]}
|
2017-10-24 15:10:27 +02:00
|
|
|
isRevokeable={this.isRevokeable(t.txid, t.nout)}
|
|
|
|
revokeClaim={this.revokeClaim.bind(this)}
|
2017-09-18 02:52:57 +02:00
|
|
|
/>
|
2017-11-24 22:36:10 +01:00
|
|
|
)}
|
2017-09-18 02:52:57 +02:00
|
|
|
</tbody>
|
2017-11-24 22:36:10 +01:00
|
|
|
</table>}
|
2017-08-20 23:42:00 +02:00
|
|
|
</div>
|
2017-06-06 23:19:12 +02:00
|
|
|
);
|
2017-05-11 02:59:47 +02:00
|
|
|
}
|
2017-09-02 17:36:27 +02:00
|
|
|
}
|
2017-05-11 02:59:47 +02:00
|
|
|
|
2017-06-06 06:21:55 +02:00
|
|
|
export default TransactionList;
|