Skip to content

Commit

Permalink
add startedUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
rstormsf committed Jun 25, 2018
1 parent e8fff85 commit 457c84e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 8 deletions.
36 changes: 29 additions & 7 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,44 @@
import React, { Component } from 'react';
import { Header, FirstStep, SecondStep, ThirdStep, FourthStep, FifthStep, Retry, Welcome } from './components';
import { Route } from 'react-router-dom';
import { Route, Redirect } from 'react-router-dom';
import { inject, observer } from "mobx-react";
import './assets/stylesheets/application.css';

console.log('agregator of txs')
const PrivateRoute = ({ component: Component, startedUrl, ...rest }) => (
<Route
{...rest}
render={props =>
startedUrl === '#/' || startedUrl === '#/1' ? (
<Component {...props} />
) : (
<Redirect
to={{
pathname: "/"
}}
/>
)
}
/>
);

@inject("UiStore")
export class App extends React.Component {
render(){
let startedUrl = this.props.UiStore.web3Store.startedUrl

return (
<div>
<Header/>
<Route exact path="/" component={FirstStep}/>
<Route exact path="/1" component={FirstStep}/>
<Route exact path="/2" component={SecondStep}/>
<Route exact path="/3" component={ThirdStep}/>
<Route exact path="/4" component={FourthStep}/>
<Route exact path="/5" component={FifthStep}/>
<PrivateRoute path="/2" component={SecondStep} startedUrl={startedUrl} />
<PrivateRoute exact path="/2" component={SecondStep} startedUrl={startedUrl}/>
<PrivateRoute exact path="/3" component={ThirdStep} startedUrl={startedUrl}/>
<PrivateRoute exact path="/4" component={FourthStep} startedUrl={startedUrl}/>
<PrivateRoute exact path="/5" component={FifthStep} startedUrl={startedUrl}/>

{/* <Route exact path="/retry" component={Retry}/> */}
</div>
);
}
}
}
2 changes: 1 addition & 1 deletion src/components/1.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import { Link } from 'react-router-dom';
import Web3Utils from 'web3-utils';
import Form from 'react-validation/build/form';
import Textarea from 'react-validation/build/textarea';
Expand Down Expand Up @@ -52,6 +51,7 @@ export class FirstStep extends React.Component {
super(props);
this.tokenStore = props.UiStore.tokenStore;
this.web3Store = props.UiStore.web3Store;
this.web3Store.setStartedUrl('#/');
this.onTokenAddress = this.onTokenAddress.bind(this);
this.onDecimalsChange = this.onDecimalsChange.bind(this);
this.onJsonChange = this.onJsonChange.bind(this);
Expand Down
5 changes: 5 additions & 0 deletions src/stores/web3Store.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class Web3Store {
@observable errors = [];
@observable userTokens = [];
@observable explorerUrl = '';
@observable startedUrl = window.location.hash
constructor(rootStore) {

this.getWeb3Promise = getWeb3().then(async (web3Config) => {
Expand All @@ -23,6 +24,10 @@ class Web3Store {
this.errors.push(e.message)
})
}
@action
setStartedUrl(url){
this.startedUrl = url;
}
async getUserTokens({trustApiName, defaultAccount}) {
window.fetch(`https://${trustApiName}.trustwalletapp.com/tokens?address=${defaultAccount}`).then((res) => {
return res.json()
Expand Down

0 comments on commit 457c84e

Please sign in to comment.