lbry-desktop/ui/component/transactionListTable/view.jsx

65 lines
1.9 KiB
React
Raw Normal View History

2019-09-23 04:47:07 +02:00
// @flow
import * as MODALS from 'constants/modal_types';
import React from 'react';
import TransactionListItem from './internal/transaction-list-item';
type Props = {
emptyMessage: ?string,
loading: boolean,
mySupports: {},
myClaims: any,
openModal: (id: string, { nout: number, txid: string }) => void,
rewards: {},
transactionList: Array<any>,
};
function TransactionListTable(props: Props) {
const { emptyMessage, rewards, loading, transactionList } = props;
function isRevokeable(txid: string, nout: number) {
const outpoint = `${txid}:${nout}`;
const { mySupports, myClaims } = props;
return !!mySupports[outpoint] || myClaims.has(outpoint);
}
function revokeClaim(txid: string, nout: number) {
props.openModal(MODALS.CONFIRM_CLAIM_REVOKE, { txid, nout });
}
return (
<React.Fragment>
{!loading && !transactionList.length && (
<h2 className="main--empty empty">{emptyMessage || __('No transactions.')}</h2>
)}
{!!transactionList.length && (
2019-12-18 06:27:08 +01:00
<div className="table__wrapper">
2019-09-23 04:47:07 +02:00
<table className="table table--transactions">
<thead>
<tr>
2019-11-22 22:13:00 +01:00
<th>{__('Date')}</th>
2019-09-23 04:47:07 +02:00
<th>{__('Type')} </th>
<th>{__('Details')} </th>
<th>{__('Transaction')}</th>
2019-11-22 22:13:00 +01:00
<th className="table__item--align-right">{__('Amount')}</th>
2019-09-23 04:47:07 +02:00
</tr>
</thead>
<tbody>
{transactionList.map(t => (
<TransactionListItem
key={`${t.txid}:${t.nout}`}
transaction={t}
reward={rewards && rewards[t.txid]}
isRevokeable={isRevokeable(t.txid, t.nout)}
revokeClaim={revokeClaim}
/>
))}
</tbody>
</table>
2019-12-18 06:27:08 +01:00
</div>
2019-09-23 04:47:07 +02:00
)}
</React.Fragment>
);
}
export default TransactionListTable;