App.js
4.42 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
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 Solution from './components/Solution'
import Loader from './components/Loader'
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()
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)),
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
)
const load = storage.createLoader(engine);
load(store);
// Notice that our load function will return a promise that can also be used
// to respond to the restore event.
load(store)
.then((newState) => console.log('Loaded state:', newState))
.catch(() => console.log('Failed to load previous state'));
/*const store = createStore(
ProfilationSelectReducer
);*/
class App extends Component {
constructor() {
super();
this.state = { loadingData: true }
}
componentDidMount() {
// Servizio per recupero dati di configurazione
var lemaApi = new LemaApi();
// Carico i dati dell'applicazione
lemaApi.getWebClientConfigData()
.then(response => {
// Salvo i dati nel local storage
localStorage.setItem("CONFIG_DATA", JSON.stringify(response.data));
// Update state component
this.setState({ loadingData: false });
})
.catch(function (error) {
console.log(error);
});
}
render() {
/*const { dispatch, steps } = this.props;
const changeValue= bindActionCreators(SelectActionCreators.changeValue, dispatch);*/
return (
<Provider store={store}>
<div className="repower-app" id='wrap' >
<Header/>
<ConnectedRouter history={history} >
<div>
<Modal />
<Route exact path="/" component={Profilation}
updatePropValue={this.props.updatePropValue} />
<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 path="/solution" component={Solution}/>
<Route path="/activation" component={Activation}/>
<Route path="/activation-steps" component={ActivationStep}/>
<Route path="/activation-step-5" component={ActivationStep5}/>
<Route 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'}
/>}/>
<Route path="/mobile-upload-complete" component={MobileUploadComplete}/>
<Footer/>
</div>
</ConnectedRouter>
</div>
</Provider>
);
}
}
export default App;