export default {
  name: "mapLoading",

  getReducer() {
    const initialData = {
      loading: false,
    };

    return (state = initialData, { type, payload }) => {
      switch (type) {
        case "MAP_UPDATED_VIEW_STATE_STARTED":
        case "MAP_LOADING":
          return Object.assign({}, state, {
            loading: true,
          });
        case "MAP_UPDATED_VIEW_STATE_FINISHED":
        case "MAP_LOADED":
        case "LEGEND_LAYERS_UPDATE_ERROR":
          return Object.assign({}, state, {
            loading: false,
          });
        default:
          return state;
      }
    };
  },

  selectMapLoading: (state) => {
    return state.mapLoading.loading;
  },
};
