From 457c84eb8e4233aecf018458b7dbc148807f1f35 Mon Sep 17 00:00:00 2001 From: Roman Storm Date: Sun, 24 Jun 2018 18:06:44 -0700 Subject: [PATCH] add startedUrl --- src/App.js | 36 +++++++++++++++++++++++++++++------- src/components/1.js | 2 +- src/stores/web3Store.js | 5 +++++ 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/src/App.js b/src/App.js index 9dbc30b3..4970b4a1 100644 --- a/src/App.js +++ b/src/App.js @@ -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 }) => ( + + startedUrl === '#/' || startedUrl === '#/1' ? ( + + ) : ( + + ) + } + /> +); + +@inject("UiStore") export class App extends React.Component { render(){ + let startedUrl = this.props.UiStore.web3Store.startedUrl + return (
- - - - + + + + + + {/* */}
); } -} +} \ No newline at end of file diff --git a/src/components/1.js b/src/components/1.js index b32e83f0..18793e2a 100644 --- a/src/components/1.js +++ b/src/components/1.js @@ -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'; @@ -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); diff --git a/src/stores/web3Store.js b/src/stores/web3Store.js index 0a4062ec..cc9ee588 100644 --- a/src/stores/web3Store.js +++ b/src/stores/web3Store.js @@ -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) => { @@ -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()