mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 11:06:40 +07:00
now user can login
This commit is contained in:
parent
e7960a6bf8
commit
e19001ca82
25 changed files with 493 additions and 32844 deletions
0
src/redux/auth/actions.js
Normal file
0
src/redux/auth/actions.js
Normal file
15
src/redux/auth/constants.js
Normal file
15
src/redux/auth/constants.js
Normal file
|
@ -0,0 +1,15 @@
|
|||
export const AUTH_ACTIONS = {
|
||||
|
||||
};
|
||||
|
||||
export const ROLES = {
|
||||
guest: 'guest',
|
||||
vk: 'vk',
|
||||
};
|
||||
|
||||
export const EMPTY_USER = {
|
||||
token: '',
|
||||
name: '',
|
||||
role: ROLES.guest,
|
||||
picture: '',
|
||||
};
|
12
src/redux/auth/reducer.js
Normal file
12
src/redux/auth/reducer.js
Normal file
|
@ -0,0 +1,12 @@
|
|||
import { createReducer } from 'reduxsauce';
|
||||
import { AUTH_ACTIONS, EMPTY_USER } from '$redux/auth/constants';
|
||||
|
||||
const HANDLERS = {
|
||||
|
||||
};
|
||||
|
||||
export const INITIAL_STATE = {
|
||||
...EMPTY_USER
|
||||
};
|
||||
|
||||
export const authReducer = createReducer(INITIAL_STATE, HANDLERS);
|
4
src/redux/auth/sagas.js
Normal file
4
src/redux/auth/sagas.js
Normal file
|
@ -0,0 +1,4 @@
|
|||
export function* authSaga() {
|
||||
// Login
|
||||
// yield takeLatest(AUTH_ACTIONS.SEND_LOGIN_REQUEST, sendLoginRequestSaga);
|
||||
}
|
50
src/redux/store.js
Normal file
50
src/redux/store.js
Normal file
|
@ -0,0 +1,50 @@
|
|||
import { createStore, applyMiddleware, combineReducers, compose } from 'redux';
|
||||
|
||||
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 { authReducer } from '$redux/auth/reducer';
|
||||
import { authSaga } from '$redux/auth/sagas';
|
||||
|
||||
const authPersistConfig = {
|
||||
key: 'auth',
|
||||
blacklist: [],
|
||||
storage,
|
||||
};
|
||||
|
||||
// create the saga middleware
|
||||
export const sagaMiddleware = createSagaMiddleware();
|
||||
|
||||
// redux extension composer
|
||||
/* eslint-disable no-underscore-dangle */
|
||||
const composeEnhancers =
|
||||
typeof window === 'object' &&
|
||||
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
|
||||
? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({})
|
||||
: compose;
|
||||
/* eslint-enable no-underscore-dangle */
|
||||
|
||||
export const history = createHistory();
|
||||
|
||||
export const store = createStore(
|
||||
combineReducers({
|
||||
auth: persistReducer(authPersistConfig, authReducer),
|
||||
routing: routerReducer
|
||||
}),
|
||||
composeEnhancers(applyMiddleware(routerMiddleware(history), sagaMiddleware))
|
||||
);
|
||||
|
||||
export default function configureStore() {
|
||||
// run sagas
|
||||
sagaMiddleware.run(authSaga);
|
||||
|
||||
const persistor = persistStore(store);
|
||||
|
||||
return {
|
||||
store,
|
||||
persistor
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue