mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 11:06:40 +07:00
redux: setMode sagas
This commit is contained in:
parent
dde6cf83e9
commit
0d47cd8773
6 changed files with 127 additions and 51 deletions
|
@ -2,6 +2,7 @@ import { createReducer } from 'reduxsauce';
|
|||
import { ACTIONS } from '$redux/user/constants';
|
||||
import { DEFAULT_USER } from '$constants/auth';
|
||||
import { MODES } from '$constants/modes';
|
||||
import { DEFAULT_LOGO } from '$constants/logos';
|
||||
|
||||
const setUser = (state, { user }) => ({
|
||||
...state,
|
||||
|
@ -26,7 +27,14 @@ export const INITIAL_STATE = {
|
|||
user: { ...DEFAULT_USER },
|
||||
editing: false,
|
||||
mode: MODES.NONE,
|
||||
logo: DEFAULT_LOGO,
|
||||
routerPoints: 0,
|
||||
distance: 0,
|
||||
estimateTime: 0,
|
||||
activeSticker: null,
|
||||
title: 0,
|
||||
address: '',
|
||||
changed: false,
|
||||
};
|
||||
|
||||
export const userReducer = createReducer(INITIAL_STATE, HANDLERS);
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
import { REHYDRATE } from 'redux-persist';
|
||||
import { takeLatest, select, call, put } from 'redux-saga/effects';
|
||||
import { takeLatest, select, call, put, takeEvery } from 'redux-saga/effects';
|
||||
import { checkUserToken, getGuestToken, getStoredMap } from '$utils/api';
|
||||
import { setUser } from '$redux/user/actions';
|
||||
import { getUrlData, pushPath } from '$utils/history';
|
||||
import { editor } from '$modules/Editor';
|
||||
import { ACTIONS } from '$redux/user/constants';
|
||||
|
||||
const getUser = state => (state.user.user);
|
||||
const hideLoader = () => {
|
||||
|
@ -73,8 +74,14 @@ function* authChechSaga() {
|
|||
return yield call(mapInitSaga);
|
||||
}
|
||||
|
||||
function* setModeSaga({ mode }) {
|
||||
return yield editor.changeMode(mode);
|
||||
// console.log('change', mode);
|
||||
}
|
||||
|
||||
export function* userSaga() {
|
||||
// Login
|
||||
// yield takeLatest(AUTH_ACTIONS.SEND_LOGIN_REQUEST, sendLoginRequestSaga);
|
||||
yield takeLatest(REHYDRATE, authChechSaga);
|
||||
yield takeEvery(ACTIONS.SET_MODE, setModeSaga);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue