import React from 'react'; import { connect } from 'react-redux'; import translate from 'translations'; import { fetchTransactionData, TFetchTransactionData } from 'actions/transactions'; import { getTransactionDatas } from 'selectors/transactions'; import { getNetworkConfig } from 'selectors/config'; import { Spinner } from 'components/ui'; import TransactionDataTable from './TransactionDataTable'; import { AppState } from 'reducers'; import { NetworkConfig } from 'types/network'; import { TransactionState } from 'types/transactions'; import './TransactionStatus.scss'; interface OwnProps { txHash: string; } interface StateProps { tx: TransactionState | null; network: NetworkConfig; } interface ActionProps { fetchTransactionData: TFetchTransactionData; } type Props = OwnProps & StateProps & ActionProps; class TransactionStatus extends React.Component { public componentDidMount() { this.props.fetchTransactionData(this.props.txHash); } public 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: getTransactionDatas(state)[txHash], network: getNetworkConfig(state) }; } export default connect(mapStateToProps, { fetchTransactionData })(TransactionStatus);