App.js
5.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
import React, { Component } from 'react';
import Modal from './components/Modal/Modal'
import Profilation from './components/Profilation'
import Activation from './components/Activation'
import ActivationStep from './components/Activation/ActivationStep'
import MobileUpload from './components/Activation/MobileUpload'
import MobileUploadComplete from './components/Activation/MobileUploadComplete'
import ActivationStep5 from './components/Activation/steps/ActivationStep5'
import ActivationCheck from './components/Activation/steps/ActivationCheck'
import ExpiredSolution from './components/Solution/ExpiredSolution'
import Solution from './components/Solution'
import Loader from './components/Loader'
import MobileConnect from './components/MobileConnect'
import { Provider } from 'react-redux';
import ProfilationSelectReducer from './components/reducers/profilationSelect';
import { createStore, combineReducers, applyMiddleware, compose } from 'redux'
import createHistory from 'history/createBrowserHistory'
import Route from 'react-router-dom/Route';
import * as storage from 'redux-storage'
import './styles/style.css'
import { ConnectedRouter, routerReducer, routerMiddleware } from 'react-router-redux'
import createEngine from 'redux-storage-engine-localstorage';
import Header from "./components/header/index";
import Footer from "./components/Footer/index";
import LemaApi from "./service/service.js";
//const history = createHistory();
// If APP installed in a subdirectory
const history = createHistory({
basename: '/Home/Profilation/'
});
const engine = createEngine('pro');
const middlewareRouter = routerMiddleware(history)
const middleware = storage.createMiddleware(engine);
const reducer = storage.reducer(combineReducers({
ProfilationSelectReducer: ProfilationSelectReducer,
router: routerReducer
}));
const store = createStore(
reducer,
compose(applyMiddleware(middlewareRouter), applyMiddleware(middleware))
)
const load = storage.createLoader(engine);
load(store);
load(store)
.then((newState) => console.log('Loaded state:', newState))
.catch(() => console.log('Failed to load previous state'));
class App extends Component {
constructor() {
super();
this.state = { loadingData: true }
}
componentDidMount() {
// Servizio per interazione con il server
var lemaApi = new LemaApi();
// Carico i dati dell'applicazione
lemaApi.loadWebClientConfigData()
.then(response => {
console.log(response);
// Update state component
this.setState({ loadingData: false });
})
.then(() =>{
// Start Session
lemaApi.getSubscriptionSession()
.then(() => {
// Get profilation if exists
lemaApi.getProfilationData().then((data) => {
console.log(data);
// TODO: update Store Redux
});
})
})
.catch(function (error) {
localStorage.clear();
console.error("Loading configuration data failed");
console.log(error);
}
);
}
render() {
return (
<Provider store={store}>
<div className="repower-app" id='wrap' >
<ConnectedRouter history={history} >
<div className={history.location.pathname.substring(1)+'__main-wrapper'}>
<Header history={history} pathname={history.location.pathname}/>
<Modal history={history}/>
<Route exact path="/" component={Profilation}
updatePropValue={this.props.updatePropValue}
history={history} />
<Route path="/loader" render={()=><Loader
goTo={'/solution'}
history={history}
heading={'Ci siamo quasi'}
subHeading={'Stiamo costruendo la soluzione più adatta, basandoci sulle tue abitudini di consumo.'}/>}/>
<Route exact path="/solution" history={history} component={Solution}/>
<Route exact path="/expired-solution" history={history} component={ExpiredSolution}/>
<Route exact path="/activation" component={Activation}/>
<Route exact path="/activation-steps" component={ActivationStep}/>
<Route exact path="/activation-step-5" component={ActivationStep5}/>
<Route exact path="/activation-check" component={ActivationCheck}/>
<Route exact path="/mobile-connect" component={MobileConnect}/>
<Route exact path="/mobile-upload" component={MobileUpload}/>
<Route path="/mobile-upload-loader" render={()=><Loader
goTo={'/mobile-upload-complete'}
history={history}
heading={'Caricamento documenti in corso...'}
subHeading={''}
className={'mobile-upload-loader'}
hideProgressbar={true}
/>}/>
<Route exact path="/mobile-upload-complete" component={MobileUploadComplete}/>
<Footer/>
</div>
</ConnectedRouter>
</div>
</Provider>
);
}
}
export default App;