Files
freeCodeCamp/common/app/redux/reducer.js

65 lines
1.4 KiB
JavaScript
Raw Normal View History

2016-01-27 11:34:44 -08:00
import { handleActions } from 'redux-actions';
import types from './types';
const initialState = {
title: 'Learn To Code | Free Code Camp',
shouldShowSignIn: false,
user: '',
lang: '',
csrfToken: '',
windowHeight: 0,
2016-06-03 23:34:28 -07:00
navHeight: 0,
isMainChatOpen: false
};
2016-01-27 11:34:44 -08:00
export default handleActions(
{
[types.updateTitle]: (state, { payload = 'Learn To Code' }) => ({
...state,
title: payload + ' | Free Code Camp'
}),
[types.makeToast]: (state, { payload: toast }) => ({
...state,
2016-02-04 15:03:05 -08:00
toast
2016-01-27 11:34:44 -08:00
}),
[types.updateThisUser]: (state, { payload: user }) => ({
2016-06-07 20:41:42 -07:00
...state,
user,
shouldShowSignIn: true
2016-06-07 20:41:42 -07:00
}),
[types.showSignIn]: state => ({
2016-01-27 11:34:44 -08:00
...state,
shouldShowSignIn: true
2016-01-27 11:34:44 -08:00
}),
[types.challengeSaved]: (state, { payload: { points = 0 } }) => ({
2016-01-27 11:34:44 -08:00
...state,
points
2016-03-05 21:06:04 -08:00
}),
[types.updateWindowHeight]: (state, { payload: windowHeight }) => ({
...state,
windowHeight
}),
[types.updateNavHeight]: (state, { payload: navHeight }) => ({
...state,
navHeight
}),
[types.toggleMapDrawer]: state => ({
...state,
isMapAlreadyLoaded: true,
isMapDrawerOpen: !state.isMapDrawerOpen
2016-06-03 23:34:28 -07:00
}),
[types.toggleMainChat]: state => ({
...state,
isMainChatOpen: !state.isMainChatOpen
2016-06-09 16:02:51 -07:00
}),
[types.delayedRedirect]: (state, { payload }) => ({
...state,
delayedRedirect: payload
2016-01-27 11:34:44 -08:00
})
},
initialState
2016-01-27 11:34:44 -08:00
);