import * as appService from '../services/customPage'

export default {

  namespace: 'customPage',

  state: {

  },

  subscriptions: {
    setup({ dispatch, history }) {  // eslint-disable-line
    },
  },

  effects: {
    *getCategory({ payload, onOver }, { call, put }) {
      const ret = yield call(appService.getCategory, payload);
      if (typeof onOver === 'function') {
        onOver(ret)
      }
      // yield put({ type: 'save', payload: { btnEntities: ret }})
    },
    *getCustomPageConfigInfo({ payload, onComplete }, { call, put }) {
      const ret = yield call(appService.getCustomPageConfigInfo, payload);
      if (typeof onComplete === 'function') {
        onComplete(ret)
      }
      yield put({ type: 'save', payload: { btnEntities: ret }})
    }
  },

  reducers: {
    save(state, action) {
      return { ...state, ...action.payload };
    }
  },

};
