import axios from 'axios'

export default {
  namespaced: true,
  state: {
    menu: {},
    options: {}
  },
  mutations: {
    setMenus(state, items) {
      state.menu = items;
    },
    setOptions(state, items) {
      state.options = items;
    }
  },
  getters: {},
  actions: {
    getMenu({
      commit
    }, id) {
      axios
        .get(`/api/menu/${id}`)
        .then(result => commit("setMenus", result.data));
    },
    getOptions({
      commit
    }, item) {
      axios
        .get(`/api/menu/GetOptions/${item.menuId}`)
        .then(result => commit("setOptions", result.data));
    }
  }
}
