import React from 'react'; import { connect } from 'react-redux'; import translate, { translateRaw } from 'translations'; import { getRecentWalletTransactions } from 'selectors/transactions'; import { getNetworkConfig } from 'selectors/config'; import RecentTransaction from './RecentTransaction'; import { TransactionStatus } from 'components'; import { IWallet } from 'libs/wallet'; import { NetworkConfig } from 'types/network'; import { AppState } from 'reducers'; import './RecentTransactions.scss'; interface OwnProps { wallet: IWallet; } interface StateProps { recentTransactions: AppState['transactions']['recent']; network: NetworkConfig; } type Props = OwnProps & StateProps; interface State { activeTxHash: string; } class RecentTransactions extends React.Component { public state: State = { activeTxHash: '' }; public render() { const { activeTxHash } = this.state; let content: React.ReactElement; if (activeTxHash) { content = ( ); } else { content = this.renderTxList(); } return
{content}
; } private renderTxList() { const { wallet, recentTransactions, network } = this.props; let explorer: string; if (network.isCustom) { explorer = translateRaw('RECENT_TX_NETWORK_EXPLORER', { $network_name: network.name }); } else { explorer = `[${network.blockExplorer.name}](${network.blockExplorer.addressUrl( wallet.getAddressString() )})`; } return ( {recentTransactions.length ? ( {recentTransactions.map(tx => ( ))}
{translate('SEND_ADDR')} {translate('SEND_AMOUNT_SHORT')} {translate('SENT')}
) : (

{translate('NO_RECENT_TX_FOUND', { $explorer: explorer })}

)}

{translate('RECENT_TX_HELP', { $network: network.name, $explorer: explorer })}

); } private setActiveTxHash = (activeTxHash: string) => this.setState({ activeTxHash }); private clearActiveTxHash = () => this.setState({ activeTxHash: '' }); } export default connect((state: AppState): StateProps => ({ recentTransactions: getRecentWalletTransactions(state), network: getNetworkConfig(state) }))(RecentTransactions);