2017-06-06 23:19:12 +02:00
|
|
|
import React from "react";
|
|
|
|
import { Address, BusyMessage, CreditAmount } from "component/common";
|
2017-05-11 02:59:47 +02:00
|
|
|
|
2017-06-08 06:42:19 +02:00
|
|
|
class TransactionList extends React.PureComponent {
|
2017-05-11 02:59:47 +02:00
|
|
|
componentWillMount() {
|
2017-06-06 23:19:12 +02:00
|
|
|
this.props.fetchTransactions();
|
2017-05-11 02:59:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2017-06-06 23:19:12 +02:00
|
|
|
const { fetchingTransactions, transactionItems } = this.props;
|
2017-05-11 02:59:47 +02:00
|
|
|
|
2017-06-06 23:19:12 +02:00
|
|
|
const rows = [];
|
2017-05-11 02:59:47 +02:00
|
|
|
if (transactionItems.length > 0) {
|
2017-06-06 23:19:12 +02:00
|
|
|
transactionItems.forEach(function(item) {
|
2017-05-11 02:59:47 +02:00
|
|
|
rows.push(
|
|
|
|
<tr key={item.id}>
|
2017-06-06 23:19:12 +02:00
|
|
|
<td>{(item.amount > 0 ? "+" : "") + item.amount}</td>
|
2017-05-11 02:59:47 +02:00
|
|
|
<td>
|
2017-06-06 23:19:12 +02:00
|
|
|
{item.date
|
|
|
|
? item.date.toLocaleDateString()
|
|
|
|
: <span className="empty">{__("(Transaction pending)")}</span>}
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
{item.date
|
|
|
|
? item.date.toLocaleTimeString()
|
|
|
|
: <span className="empty">{__("(Transaction pending)")}</span>}
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<a
|
|
|
|
className="button-text"
|
|
|
|
href={"https://explorer.lbry.io/#!/transaction?id=" + item.id}
|
|
|
|
>
|
|
|
|
{item.id.substr(0, 7)}
|
|
|
|
</a>
|
2017-05-11 02:59:47 +02:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<section className="card">
|
|
|
|
<div className="card__title-primary">
|
2017-05-26 16:19:49 +02:00
|
|
|
<h3>{__("Transaction History")}</h3>
|
2017-05-11 02:59:47 +02:00
|
|
|
</div>
|
|
|
|
<div className="card__content">
|
2017-06-06 23:19:12 +02:00
|
|
|
{fetchingTransactions &&
|
|
|
|
<BusyMessage message={__("Loading transactions")} />}
|
|
|
|
{!fetchingTransactions && rows.length === 0
|
|
|
|
? <div className="empty">{__("You have no transactions.")}</div>
|
|
|
|
: ""}
|
|
|
|
{rows.length > 0
|
|
|
|
? <table className="table-standard table-stretch">
|
2017-05-11 02:59:47 +02:00
|
|
|
<thead>
|
|
|
|
<tr>
|
2017-05-26 16:19:49 +02:00
|
|
|
<th>{__("Amount")}</th>
|
|
|
|
<th>{__("Date")}</th>
|
|
|
|
<th>{__("Time")}</th>
|
|
|
|
<th>{__("Transaction")}</th>
|
2017-05-11 02:59:47 +02:00
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{rows}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
2017-06-06 23:19:12 +02:00
|
|
|
: ""}
|
2017-05-11 02:59:47 +02:00
|
|
|
</div>
|
|
|
|
</section>
|
2017-06-06 23:19:12 +02:00
|
|
|
);
|
2017-05-11 02:59:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-06 06:21:55 +02:00
|
|
|
export default TransactionList;
|