forked from algorithm-visualizer/algorithm-visualizer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenv.js
More file actions
30 lines (25 loc) · 607 Bytes
/
env.js
File metadata and controls
30 lines (25 loc) · 607 Bytes
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
import Cookies from 'js-cookie';
import { combineActions, createAction, handleActions } from 'redux-actions';
const prefix = 'ENV';
const setExt = createAction(`${prefix}/SET_EXT`, ext => {
Cookies.set('ext', ext);
return { ext };
});
const setUser = createAction(`${prefix}/SET_USER`, user => ({ user }));
export const actions = {
setExt,
setUser,
};
const defaultState = {
ext: Cookies.get('ext') || 'js',
user: undefined,
};
export default handleActions({
[combineActions(
setExt,
setUser,
)]: (state, { payload }) => ({
...state,
...payload,
}),
}, defaultState);