import ajax from '../../util/ajax'
import api from '../../util/api'

export default {
  namespaced: true,
  state: {
    CalendarList: [],
  },
  mutations: {
    UpdateCalendarList (state, payload) {
      state.CalendarList = payload || []
    },
  },
  actions: {
    getCalendarList ({ commit }, payload) { // 获取日历活动列表
      return new Promise((resolve, reject) => {
        ajax(api.activityManager.getCalendarList.url, {
          method: api.activityManager.getCalendarList.method,
          queryData: {
            ...payload,
          }
        }).then(res => {
          commit('UpdateCalendarList', res)
          resolve(res)
        }).catch(reject)
      })
    },
    changeCalendarStatus ({ commit }, payload) {
      return new Promise((resolve, reject) => {
        ajax(api.activityManager.calendarStausChange.url, {
          method: api.activityManager.calendarStausChange.method,
          urlData: {
            calendarIds: payload.ids
          }
        }).then(res => {
          resolve(res)
        }).catch(reject)
      })
    }
  },
}
