redux: initial

This commit is contained in:
muerwre 2018-11-26 10:38:21 +07:00
parent 0fcd0bd209
commit dca55a3bc4
6 changed files with 55 additions and 54 deletions

29
package-lock.json generated
View file

@ -10415,11 +10415,6 @@
}
}
},
"react-router-redux": {
"version": "4.0.8",
"resolved": "https://registry.npmjs.org/react-router-redux/-/react-router-redux-4.0.8.tgz",
"integrity": "sha1-InQDWWtRUeGCN32rg1tdRfD4BU4="
},
"read-chunk": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/read-chunk/-/read-chunk-2.1.0.tgz",
@ -10560,11 +10555,11 @@
}
},
"redux": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/redux/-/redux-4.0.0.tgz",
"integrity": "sha512-NnnHF0h0WVE/hXyrB6OlX67LYRuaf/rJcbWvnHHEPCF/Xa/AZpwhs/20WyqzQae5x4SD2F9nPObgBh2rxAgLiA==",
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/redux/-/redux-4.0.1.tgz",
"integrity": "sha512-R7bAtSkk7nY6O/OYMVR9RiBI+XghjF9rlbl5806HJbQph0LJVHZrU5oaO4q70eUKiqMRqm4y07KLTlMZ2BlVmg==",
"requires": {
"loose-envify": "^1.1.0",
"loose-envify": "^1.4.0",
"symbol-observable": "^1.2.0"
},
"dependencies": {
@ -10581,9 +10576,9 @@
"integrity": "sha512-sSJAzNq7zka3qVHKce1hbvqf0Vf5DuTVm7dr4GtsqQVOexnrvbV47RWFiPxQ8fscnyiuWyD2O92DOxPl0tGCRg=="
},
"redux-saga": {
"version": "0.16.0",
"resolved": "https://registry.npmjs.org/redux-saga/-/redux-saga-0.16.0.tgz",
"integrity": "sha1-CiMdsKFIkwHdmA9vL4jYztQY9yQ="
"version": "0.16.2",
"resolved": "https://registry.npmjs.org/redux-saga/-/redux-saga-0.16.2.tgz",
"integrity": "sha512-iIjKnRThI5sKPEASpUvySemjzwqwI13e3qP7oLub+FycCRDysLSAOwt958niZW6LhxfmS6Qm1BzbU70w/Koc4w=="
},
"reduxsauce": {
"version": "1.0.0",
@ -12049,11 +12044,6 @@
"integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=",
"dev": true
},
"typeface-montserrat": {
"version": "0.0.54",
"resolved": "https://registry.npmjs.org/typeface-montserrat/-/typeface-montserrat-0.0.54.tgz",
"integrity": "sha512-Typhap0PWT299+Va0G/8ZtycHMXrH4gBWKfiW977KEBx5rXUUCa70gvqLx1fdA0WAo6bhSAQmo8uc+QFAmjPww=="
},
"ua-parser-js": {
"version": "0.7.18",
"resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.18.tgz",
@ -13124,11 +13114,6 @@
"integrity": "sha512-nqHUnMXmBzT0w570r2JpJxfiSD1IzoI+HGVdd3aZ0yNi3ngvQ4jv1dtHt5VGxfI2yj5yqImPhOK4vmIh2xMbGg==",
"dev": true
},
"wfk-montserrat": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/wfk-montserrat/-/wfk-montserrat-1.0.0.tgz",
"integrity": "sha512-XgRPn20Qp20BHs1UXyvMVQgblHSwl3bMhrNeXF921fqxIOT0ZPMynqWa60q5wU5RkRTxQfZsgv0Rt6prMSpvhQ=="
},
"whatwg-fetch": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz",

View file

@ -64,6 +64,10 @@
"react-hot-loader": "^4.1.1",
"react-redux": "^5.0.7",
"react-router": "^4.3.1",
"redux": "^4.0.1",
"redux-persist": "^5.10.0",
"redux-saga": "^0.16.2",
"reduxsauce": "^1.0.0",
"scrypt": "^6.0.3",
"styled-components": "^3.2.6",
"styled-theming": "^2.2.0",

View file

@ -10,6 +10,12 @@ import { getGuestToken, checkUserToken, getStoredMap } from '$utils/api';
import { storeData, getData } from '$utils/storage';
import { UserPanel } from '$components/panels/UserPanel';
import { getUrlData, pushPath } from '$utils/history';
import { Provider } from 'react-redux';
import { PersistGate } from 'redux-persist/integration/react';
import { configureStore } from '$redux/store';
const { store, persistor } = configureStore();
export class App extends React.Component {
state = {
@ -68,7 +74,6 @@ export class App extends React.Component {
setTitle = title => this.setState({ title });
setAddress = address => {
console.log('SAT', address);
this.setState({ address });
};
@ -204,33 +209,37 @@ export class App extends React.Component {
return (
<div>
<Fills />
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<div>
<Fills />
<UserLocation editor={editor} />
<UserLocation editor={editor} />
<UserPanel
editor={editor}
user={user}
setUser={this.setUser}
userLogout={this.userLogout}
/>
<UserPanel
editor={editor}
user={user}
setUser={this.setUser}
userLogout={this.userLogout}
/>
<EditorPanel
editor={editor}
mode={mode}
routerPoints={routerPoints}
totalDistance={totalDistance}
estimateTime={estimateTime}
activeSticker={activeSticker}
logo={logo}
user={user}
editing={editing}
title={title}
address={address}
changed={changed}
/>
</div>
<EditorPanel
editor={editor}
mode={mode}
routerPoints={routerPoints}
totalDistance={totalDistance}
estimateTime={estimateTime}
activeSticker={activeSticker}
logo={logo}
user={user}
editing={editing}
title={title}
address={address}
changed={changed}
/>
</div>
</PersistGate>
</Provider>
);
}
}

View file

@ -1,4 +1,4 @@
export const AUTH_ACTIONS = {
export const ACTIONS = {
};

View file

@ -1,5 +1,5 @@
import { createReducer } from 'reduxsauce';
import { AUTH_ACTIONS, EMPTY_USER } from '$redux/auth/constants';
import { ACTIONS, EMPTY_USER } from '$redux/auth/constants';
const HANDLERS = {

View file

@ -4,7 +4,7 @@ import { persistStore, persistReducer } from 'redux-persist';
import storage from 'redux-persist/lib/storage';
import createSagaMiddleware from 'redux-saga';
import createHistory from 'history/createBrowserHistory';
import { routerReducer, routerMiddleware } from 'react-router-redux';
// import { routerReducer, routerMiddleware } from 'react-router-redux';
import { authReducer } from '$redux/auth/reducer';
import { authSaga } from '$redux/auth/sagas';
@ -27,17 +27,20 @@ const composeEnhancers =
: compose;
/* eslint-enable no-underscore-dangle */
export const history = createHistory();
// export const history = createHistory();
export const store = createStore(
combineReducers({
auth: persistReducer(authPersistConfig, authReducer),
routing: routerReducer
// routing: routerReducer
}),
composeEnhancers(applyMiddleware(routerMiddleware(history), sagaMiddleware))
composeEnhancers(applyMiddleware(
// routerMiddleware(history),
sagaMiddleware
))
);
export default function configureStore() {
export function configureStore() {
// run sagas
sagaMiddleware.run(authSaga);