import React from 'react'; import translate from 'translations'; import { NonceFieldFactory } from 'components/NonceFieldFactory'; import Help from 'components/ui/Help'; import { Spinner } from 'components/ui'; import { connect } from 'react-redux'; import { getNonceRequested, TGetNonceRequested } from 'actions/transaction'; import { nonceRequestPending } from 'selectors/transaction'; import { getOffline } from 'selectors/config'; import { AppState } from 'reducers'; import './NonceField.scss'; interface OwnProps { alwaysDisplay: boolean; } interface StateProps { isOffline: boolean; noncePending: boolean; } interface DispatchProps { requestNonce: TGetNonceRequested; } type Props = OwnProps & DispatchProps & StateProps; class NonceField extends React.Component { public render() { const { alwaysDisplay, requestNonce, noncePending, isOffline } = this.props; return ( { return alwaysDisplay || shouldDisplay ? (
{noncePending ? (
) : ( !isOffline && ( ) )}
) : null; }} /> ); } } const mapStateToProps = (state: AppState): StateProps => { return { isOffline: getOffline(state), noncePending: nonceRequestPending(state) }; }; export default connect(mapStateToProps, { requestNonce: getNonceRequested })(NonceField);