import { createSlice } from '@reduxjs/toolkit';
import { createSliceHooks } from '@looker/redux';
import { saga } from './sagas';
export var defaultSpecsState = {
  specs: {},
  currentSpecKey: '',
  working: true,
  description: undefined
};
export var specsSlice = createSlice({
  name: 'specs',
  initialState: defaultSpecsState,
  reducers: {
    initSpecsAction(state, _action) {
      state.working = true;
      state.description = 'Fetching specifications...';
    },

    initSpecsSuccessAction(state, action) {
      state.specs = action.payload.specs;
      state.currentSpecKey = action.payload.currentSpecKey;
      state.working = false;
      state.description = undefined;
    },

    initSpecsFailureAction(state, action) {
      state.working = false;
      state.error = action.payload;
    },

    setCurrentSpecAction(state, action) {
      state.working = true;
      state.description = "Fetching API ".concat(action.payload.currentSpecKey, " spec");
    },

    setCurrentSpecSuccessAction(state, action) {
      state.currentSpecKey = action.payload.currentSpecKey;
      state.specs[state.currentSpecKey].api = action.payload.api;
      state.description = undefined;
      state.working = false;
    },

    setCurrentSpecFailureAction(state, action) {
      state.working = false;
      state.error = action.payload;
    }

  }
});
export var specActions = specsSlice.actions;
export var {
  useActions: useSpecActions,
  useStoreState: useSpecStoreState
} = createSliceHooks(specsSlice, saga);
//# sourceMappingURL=slice.js.map