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

65 lines
2 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 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: {},
txos: Array<Txo>,
2019-09-23 04:47:07 +02:00
};
function TransactionListTable(props: Props) {
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) {
props.openModal(MODALS.CONFIRM_CLAIM_REVOKE, { tx, cb });
2019-09-23 04:47:07 +02:00
}
return (
<React.Fragment>
{!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
)}
{!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>
{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;