import { fromJS } from 'immutable';

import {
  GET_CONFIG,
  GET_ERROR_CONFIG,
} from './constants';

export const initialState = fromJS({
  globalConfig: {},
  globalConfigError: ""
});

/* eslint-disable default-case, no-param-reassign */
const appReducer = (state = initialState, action) => {
  switch (action.type) {
    case GET_CONFIG:
      window.__INITIAL_STATE__ = action.data;
      window.globalConfig = require('kit_global_config').default;
      createStoreage.set("globalConfig", window.globalConfig)
      return state.merge({
        globalConfig: createStoreage.get("globalConfig")
      })
    case GET_ERROR_CONFIG:
      return state.merge({
        globalConfigError: action.data
      })
    default:
      return state;
  }
}
export default appReducer;
