Newer
Older
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
Axel Chalon
committed
import React, { Component } from 'react';
import {
BrowserRouter,
MemoryRouter,
Redirect,
Route,
Switch
Axel Chalon
committed
} from 'react-router-dom';
import { inject, observer } from 'mobx-react';
import isElectron from 'is-electron';
import ReactResizeDetector from 'react-resize-detector';
Axel Chalon
committed
import Accounts from '../Accounts';
import Onboarding from '../Onboarding';
import Overlay from '../Overlay';
import { STATUS } from '../stores/healthStore';
Axel Chalon
committed
import Tokens from '../Tokens';
// Use MemoryRouter for production viewing in file:// protocol
// https://github.com/facebook/create-react-app/issues/3591
const Router =
Axel Chalon
committed
process.env.NODE_ENV === 'production' ? MemoryRouter : BrowserRouter;
const electron = isElectron() ? window.require('electron') : null;
Axel Chalon
committed
@inject('healthStore', 'onboardingStore')
handleResize = (_, height) => {
if (!electron) {
return;
}
// Send height to main process
Axel Chalon
committed
electron.ipcRenderer.send('asynchronous-message', 'app-resize', height);
Axel Chalon
committed
render () {
<ReactResizeDetector handleHeight onResize={this.handleResize}>
<Router>
Axel Chalon
committed
<div className='content'>{this.renderScreen()}</div>
Axel Chalon
committed
renderScreen () {
healthStore: {
health: { status }
}
} = this.props;
Axel Chalon
committed
<div className='window'>
<Onboarding />
</div>
);
Axel Chalon
committed
<div className='window'>
Axel Chalon
committed
<Redirect exact from='/' to='/accounts' />
<Route path='/accounts' component={Accounts} />
<Route path='/onboarding' component={Onboarding} />
<Route path='/tokens/:accountAddress' component={Tokens} />
<Route path='/whitelist/:accountAddress' component={Whitelist} />
<Route
path='/send/:tokenAddress/from/:accountAddress'
component={Send}
/>
Axel Chalon
committed
<Redirect from='*' to='/' />