now user can login

This commit is contained in:
muerwre 2018-08-28 16:58:36 +07:00
parent e7960a6bf8
commit e19001ca82
25 changed files with 493 additions and 32844 deletions

View file

View 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
View 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
View file

@ -0,0 +1,4 @@
export function* authSaga() {
// Login
// yield takeLatest(AUTH_ACTIONS.SEND_LOGIN_REQUEST, sendLoginRequestSaga);
}

50
src/redux/store.js Normal file
View 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
};
}