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

export default {
  namespaced: true,
  state: {
    pages: {}
  },
  mutations: {
    updateList (state, payload) {
      state.pages = payload
    }
  },
  actions: {
    getPagesList ({ commit }, payload) {
      return new Promise((resolve, reject) => {
        Ajax(api.pages.url, {
          method: api.pages.method,
          queryData: { ...payload }
        }).then(res => {
          commit('updateList', res)
          resolve(res)
        }).catch((res) => {
          reject(res)
        })
      })
    }
  }
}
