2016-01-27 11:34:44 -08:00
|
|
|
import { handleActions } from 'redux-actions';
|
|
|
|
import types from './types';
|
|
|
|
|
2016-06-03 13:43:42 -07:00
|
|
|
const initialState = {
|
|
|
|
title: 'Learn To Code | Free Code Camp',
|
2016-06-20 11:35:19 -07:00
|
|
|
shouldShowSignIn: false,
|
|
|
|
user: '',
|
2016-06-20 21:01:14 -07:00
|
|
|
lang: '',
|
2016-06-03 13:43:42 -07:00
|
|
|
csrfToken: '',
|
|
|
|
windowHeight: 0,
|
2016-06-03 23:34:28 -07:00
|
|
|
navHeight: 0,
|
|
|
|
isMainChatOpen: false
|
2016-06-03 13:43:42 -07:00
|
|
|
};
|
|
|
|
|
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
|
|
|
}),
|
|
|
|
|
2016-06-20 11:35:19 -07:00
|
|
|
[types.updateThisUser]: (state, { payload: user }) => ({
|
2016-06-07 20:41:42 -07:00
|
|
|
...state,
|
2016-06-20 11:35:19 -07:00
|
|
|
user,
|
|
|
|
shouldShowSignIn: true
|
2016-06-07 20:41:42 -07:00
|
|
|
}),
|
2016-06-20 11:35:19 -07:00
|
|
|
[types.showSignIn]: state => ({
|
2016-01-27 11:34:44 -08:00
|
|
|
...state,
|
2016-06-20 11:35:19 -07:00
|
|
|
shouldShowSignIn: true
|
2016-01-27 11:34:44 -08:00
|
|
|
}),
|
2016-06-20 11:35:19 -07: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
|
2016-06-03 13:43:42 -07:00
|
|
|
}),
|
|
|
|
[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
|
|
|
})
|
|
|
|
},
|
2016-06-03 13:43:42 -07:00
|
|
|
initialState
|
2016-01-27 11:34:44 -08:00
|
|
|
);
|