on edf00a4 help sign in
bridge/src/walletgen/Walletgen.js
107 lines 2.9 kB history raw
1import React from 'react';
2import { find } from 'lodash';
4import Header from './components/Header';
5import Footer from './components/Footer';
7import { PROFILE_STATES, GEN_STATES } from './lib/constants';
9import PrivacyPolicy from './views/PrivacyPolicy';
10import Welcome from './views/Welcome';
11import Eula from './views/Eula';
12import EulaView from './views/EulaView';
13import Upload from './views/Upload';
14import Understand from './views/Understand';
15import Generate from './views/Generate';
16import Custody from './views/Custody';
17import Download from './views/Download';
18import Done from './views/Done';
20import './style/index.css';
22import { OnlineProvider } from '../bridge/store/online';
24const ROUTES = [
25 { path: '/Welcome', Component: Welcome },
26 { path: '/Eula', Component: Eula },
27 { path: '/Upload', Component: Upload },
28 { path: '/Understand', Component: Understand },
29 { path: '/Custody', Component: Custody },
30 { path: '/Generate', Component: Generate },
31 { path: '/Download', Component: Download },
32 { path: '/Done', Component: Done },
33 { path: '/PrivacyPolicy', Component: PrivacyPolicy },
34 { path: '/EulaView', Component: EulaView },
35];
37const TOTAL_STEPS = 7;
39class Walletgen extends React.Component {
40 constructor(props) {
41 super(props);
42 this.state = {
43 'profile.state': PROFILE_STATES.NOSTART,
44 'profile.value': null,
45 'profile.shipCount': 0,
46 'profile.error': '',
47 'eny.state': GEN_STATES.ENY_NOSTART,
48 'eny.value': [],
49 'eny.error': '',
50 'wallets.state': GEN_STATES.DERIVATION_NOSTART,
51 'wallets.value': null,
52 'wallets.error': '',
53 'wallets.genCounter': 0,
54 'paperCollateral.state': GEN_STATES.PAPER_NOSTART,
55 'paperCollateral.value': null,
56 'paperCollateral.error': '',
57 route: '/Welcome',
58 lastRoute: '/Welcome',
59 currentStep: 1,
60 totalSteps: TOTAL_STEPS,
61 downloaded: false,
62 didClickDownload: false,
63 };
64 }
66 setGlobalState = state => this.setState(state);
68 router = path => {
69 const route = key => {
70 const { Component } = find(ROUTES, { path: key });
71 const globals = {
72 setGlobalState: this.setGlobalState,
73 ...this.state,
74 };
75 return <Component {...globals} />;
76 };
78 return route(path);
79 };
81 render() {
82 const { route, currentStep, lastRoute } = this.state;
84 const routed = this.router(route);
86 return (
87 <OnlineProvider>
88 <main className={'container'}>
89 <Header currentStep={currentStep} totalSteps={TOTAL_STEPS} />
91 <div className={'row wrapper'}>
92 <div className={'col-'}>{routed}</div>
93 <div className={'push'} />
94 </div>
96 <Footer
97 route={route}
98 lastRoute={lastRoute}
99 setGlobalState={this.setGlobalState}
100 />
101 </main>
102 </OnlineProvider>
103 );
104 }
107export default Walletgen;