strapi-plugin-config-sync/admin/src/state/reducers/Config/index.js

26 lines
585 B
JavaScript
Raw Normal View History

2021-03-20 00:54:18 +01:00
/**
*
* Main reducer
*
*/
import { fromJS, Map } from 'immutable';
2021-03-24 18:41:03 +01:00
import { SET_CONFIG_DIFF_IN_STATE, SET_LOADING_STATE } from '../../actions/Config';
2021-03-20 00:54:18 +01:00
const initialState = fromJS({
2021-03-24 18:41:03 +01:00
configDiff: Map({}),
2021-03-21 17:55:14 +01:00
isLoading: false,
});
2021-03-20 00:54:18 +01:00
export default function configReducer(state = initialState, action) {
switch (action.type) {
2021-03-24 18:41:03 +01:00
case SET_CONFIG_DIFF_IN_STATE:
return state
2021-03-24 18:41:03 +01:00
.update('configDiff', () => fromJS(action.config))
2021-03-21 17:55:14 +01:00
case SET_LOADING_STATE:
return state
.update('isLoading', () => fromJS(action.value))
2021-03-20 00:54:18 +01:00
default:
return state;
}
}