show error if it fails

This commit is contained in:
Jonathan Rainville 2018-10-16 15:49:07 -04:00 committed by Pascal Precht
parent 847e20d092
commit 7ea2cb2ed6
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
3 changed files with 9 additions and 5 deletions

View File

@ -366,7 +366,7 @@ export function listenToGasOracle(){
export function stopGasOracle(){ export function stopGasOracle(){
return { return {
type: STOP_GAS_ORACLE type: STOP_GAS_ORACLE
} };
} }
// Actions without Side Effect // Actions without Side Effect

View File

@ -4,6 +4,7 @@ import connect from "react-redux/es/connect/connect";
import {Route, Switch, withRouter} from 'react-router-dom'; import {Route, Switch, withRouter} from 'react-router-dom';
import {explorerSearch} from "../actions"; import {explorerSearch} from "../actions";
import {searchResult} from "../reducers/selectors"; import {searchResult} from "../reducers/selectors";
import {Alert} from 'reactstrap';
import AccountsContainer from '../containers/AccountsContainer'; import AccountsContainer from '../containers/AccountsContainer';
import AccountContainer from '../containers/AccountContainer'; import AccountContainer from '../containers/AccountContainer';
@ -16,7 +17,10 @@ import SearchBar from '../components/SearchBar';
class ExplorerLayout extends React.Component { class ExplorerLayout extends React.Component {
shouldComponentUpdate(nextProps) { shouldComponentUpdate(nextProps) {
if (nextProps.searchResult && nextProps.searchResult !== this.props.searchResult) { if (nextProps.searchResult && nextProps.searchResult !== this.props.searchResult) {
console.log('New result', nextProps.searchResult); if (nextProps.searchResult.error) {
return true;
}
if (nextProps.searchResult.address) { if (nextProps.searchResult.address) {
this.props.history.push(`/embark/explorer/accounts/${nextProps.searchResult.address}`); this.props.history.push(`/embark/explorer/accounts/${nextProps.searchResult.address}`);
return false; return false;
@ -35,11 +39,11 @@ class ExplorerLayout extends React.Component {
} }
render() { render() {
const {explorerSearch} = this.props; const {explorerSearch, searchResult} = this.props;
return ( return (
<React.Fragment> <React.Fragment>
<SearchBar searchSubmit={searchValue => explorerSearch(searchValue)}/> <SearchBar searchSubmit={searchValue => explorerSearch(searchValue)}/>
{searchResult && <span>{JSON.stringify(searchResult)}</span>} {searchResult.error && <Alert color="danger">{searchResult.error}</Alert>}
<Switch> <Switch>
<Route exact path="/embark/explorer/accounts" component={AccountsContainer}/> <Route exact path="/embark/explorer/accounts" component={AccountsContainer}/>
<Route exact path="/embark/explorer/accounts/:address" component={AccountContainer}/> <Route exact path="/embark/explorer/accounts/:address" component={AccountContainer}/>

View File

@ -52,7 +52,7 @@ function *searchExplorer(entity, payload) {
return yield put(entity.success(result)); return yield put(entity.success(result));
} }
return yield put(entity.failure('No results')); return yield put(entity.success({error: 'No result found in transactions, accounts or blocks'}));
} }
export const fetchPlugins = doRequest.bind(null, actions.plugins, api.fetchPlugins); export const fetchPlugins = doRequest.bind(null, actions.plugins, api.fetchPlugins);