import React from 'react'; import { connect } from 'react-redux'; import translate from 'translations'; import { NetworkConfig } from 'types/network'; import { TransactionState } from 'types/transactions'; import { AppState } from 'features/reducers'; import { getNetworkConfig } from 'features/config'; import { transactionsActions, transactionsSelectors } from 'features/transactions'; import { Spinner } from 'components/ui'; import TransactionDataTable from './TransactionDataTable'; import './TransactionStatus.scss'; interface OwnProps { txHash: string; } interface StateProps { tx: TransactionState | null; network: NetworkConfig; } interface ActionProps { fetchTransactionData: transactionsActions.TFetchTransactionData; } type Props = OwnProps & StateProps & ActionProps; class TransactionStatus extends React.Component { public componentDidMount() { this.props.fetchTransactionData(this.props.txHash); } public UNSAFE_componentWillReceiveProps(nextProps: Props) { if (this.props.txHash !== nextProps.txHash) { this.props.fetchTransactionData(nextProps.txHash); } } public render() { const { tx, network } = this.props; let content; if (tx && tx.data) { content = (
); } else if (tx && tx.error) { content = (

{translate('TX_NOTFOUND')}

{translate('TX_NOTFOUND_1')}

); } else if (tx && tx.isLoading) { // tx.isLoading... probably. content = (
); } return
{content}
; } } function mapStateToProps(state: AppState, ownProps: OwnProps): StateProps { const { txHash } = ownProps; return { tx: transactionsSelectors.getTransactionDatas(state)[txHash], network: getNetworkConfig(state) }; } export default connect(mapStateToProps, { fetchTransactionData: transactionsActions.fetchTransactionData })(TransactionStatus);