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

30 lines
763 B
JavaScript
Raw Normal View History

2021-03-20 00:54:18 +01:00
/**
*
* Main reducer
*
*/
import { fromJS, Map } from 'immutable';
2021-03-21 17:55:14 +01:00
import { SET_DATABASE_CONFIG_IN_STATE, SET_FILE_CONFIG_IN_STATE, SET_LOADING_STATE } from '../../actions/Config';
2021-03-20 00:54:18 +01:00
const initialState = fromJS({
databaseConfig: Map({}),
2021-03-21 17:55:14 +01:00
fileConfig: Map({}),
isLoading: false,
});
2021-03-20 00:54:18 +01:00
export default function configReducer(state = initialState, action) {
switch (action.type) {
case SET_DATABASE_CONFIG_IN_STATE:
return state
.update('databaseConfig', () => fromJS(action.config))
case SET_FILE_CONFIG_IN_STATE:
return state
.update('fileConfig', () => 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;
}
}