// @flow import * as React from 'react'; import { FormField } from 'component/common/form'; import Button from 'component/button'; import FileExporter from 'component/common/file-exporter'; import * as icons from 'constants/icons'; import * as modals from 'constants/modal_types'; import TransactionListItem from './internal/transaction-list-item'; export type Transaction = { amount: number, claim_id: string, claim_name: string, fee: number, nout: number, txid: string, type: string, date: Date, }; type Props = { emptyMessage: ?string, slim?: boolean, transactions: Array, rewards: {}, openModal: ({ id: string }, { nout: number, txid: string }) => void, myClaims: any, }; type State = { filter: string, }; class TransactionList extends React.PureComponent { constructor(props: Props) { super(props); this.state = { filter: 'all', }; (this: any).handleFilterChanged = this.handleFilterChanged.bind(this); (this: any).filterTransaction = this.filterTransaction.bind(this); (this: any).revokeClaim = this.revokeClaim.bind(this); (this: any).isRevokeable = this.isRevokeable.bind(this); } handleFilterChanged(event: SyntheticInputEvent<*>) { this.setState({ filter: event.target.value, }); } filterTransaction(transaction: Transaction) { const { filter } = this.state; return filter === 'all' || filter === transaction.type; } isRevokeable(txid: string, nout: number) { const { myClaims } = this.props; // a claim/support/update is revokable if it // is in my claim list(claim_list_mine) return myClaims.has(`${txid}:${nout}`); } revokeClaim(txid: string, nout: number) { this.props.openModal({ id: modals.CONFIRM_CLAIM_REVOKE }, { txid, nout }); } render() { const { emptyMessage, rewards, transactions, slim } = this.props; const { filter } = this.state; const transactionList = transactions.filter(this.filterTransaction); return ( {!transactionList.length && (

{emptyMessage || __('No transactions to list.')}

)} {!slim && !!transactionList.length && (
)} {!slim && (
} >
)} {!!transactionList.length && ( {transactionList.map(t => ( ))}
{__('Amount')} {__('Type')} {__('Details')} {__('Transaction')} {__('Date')}
)}
); } } export default TransactionList;