2019-09-23 04:47:07 +02:00
|
|
|
// @flow
|
|
|
|
import * as MODALS from 'constants/modal_types';
|
|
|
|
import React from 'react';
|
2020-04-10 19:31:36 +02:00
|
|
|
import TxoListItem from './internal/txo-list-item';
|
|
|
|
import Spinner from 'component/spinner';
|
2020-09-02 22:08:37 +02:00
|
|
|
import LbcSymbol from 'component/common/lbc-symbol';
|
2020-04-17 18:51:53 +02:00
|
|
|
|
2019-09-23 04:47:07 +02:00
|
|
|
type Props = {
|
|
|
|
emptyMessage: ?string,
|
|
|
|
loading: boolean,
|
2020-04-14 22:37:20 +02:00
|
|
|
openModal: (id: string, { tx: Txo, cb: string => void }) => void,
|
2019-09-23 04:47:07 +02:00
|
|
|
rewards: {},
|
2020-04-10 19:31:36 +02:00
|
|
|
txos: Array<Txo>,
|
2019-09-23 04:47:07 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
function TransactionListTable(props: Props) {
|
2020-04-10 19:31:36 +02:00
|
|
|
const { emptyMessage, rewards, loading, txos } = props;
|
|
|
|
const REVOCABLE_TYPES = ['channel', 'stream', 'repost', 'support', 'claim'];
|
2020-04-14 22:37:20 +02:00
|
|
|
function revokeClaim(tx: any, cb: string => void) {
|
2020-04-10 19:31:36 +02:00
|
|
|
props.openModal(MODALS.CONFIRM_CLAIM_REVOKE, { tx, cb });
|
2019-09-23 04:47:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<React.Fragment>
|
2020-04-10 19:31:36 +02:00
|
|
|
{!loading && !txos.length && <h2 className="main--empty empty">{emptyMessage || __('No transactions.')}</h2>}
|
|
|
|
{loading && (
|
|
|
|
<h2 className="main--empty empty">
|
|
|
|
<Spinner delayed />
|
|
|
|
</h2>
|
2019-09-23 04:47:07 +02:00
|
|
|
)}
|
2020-04-10 19:31:36 +02:00
|
|
|
{!loading && !!txos.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>
|
2020-04-21 16:18:54 +02:00
|
|
|
<th>{<>{__('Type')}</>}</th>
|
2019-09-23 04:47:07 +02:00
|
|
|
<th>{__('Details')} </th>
|
|
|
|
<th>{__('Transaction')}</th>
|
2020-09-02 22:08:37 +02:00
|
|
|
<th className="table__item--align-right">
|
|
|
|
<LbcSymbol size={18} />
|
|
|
|
</th>
|
2019-09-23 04:47:07 +02:00
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
2020-04-10 19:31:36 +02:00
|
|
|
{txos &&
|
|
|
|
txos.map((t, i) => (
|
|
|
|
<TxoListItem
|
|
|
|
key={`${t.txid}:${t.nout}-${i}`}
|
|
|
|
txo={t}
|
|
|
|
reward={rewards && rewards[t.txid]}
|
|
|
|
isRevokeable={t.is_my_output && !t.is_spent && REVOCABLE_TYPES.includes(t.type)}
|
|
|
|
revokeClaim={revokeClaim}
|
|
|
|
/>
|
|
|
|
))}
|
2019-09-23 04:47:07 +02:00
|
|
|
</tbody>
|
|
|
|
</table>
|
2019-12-18 06:27:08 +01:00
|
|
|
</div>
|
2019-09-23 04:47:07 +02:00
|
|
|
)}
|
|
|
|
</React.Fragment>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default TransactionListTable;
|