export const initialState = {
  loading: false,
  loaded: false,
  data: []
};

const setLoading = (loading, state) => ({ ...state, loading });
const setLoaded = (loaded, state) => ({ ...state, loaded });

export default {
  getRegionsInit: state => setLoading(true, state),
  getRegionsReady: (state, { payload }) =>
    setLoaded(true, setLoading(false, { ...state, data: payload }))
};

export const initialState = {
  loading: false,
  loaded: false,
  data: []
};

const setLoading = (state, loading) => ({ ...state, loading });
const setLoaded = (state, loaded) => ({ ...state, loaded });

export default {
  getRegionsInit: state => setLoading(state, true),
  getRegionsReady: (state, { payload }) =>
    setLoaded(setLoading({ ...state, data: payload }, false), true)
};

swap state direction for cleaner function