import { SET_MENU_ITEMS, CLEAR_MENU_ITEMS } from '../../utils/types'
import { Hasher } from '@/helpers/hash'

export default {
  [SET_MENU_ITEMS](state, payloads) {
    payloads.forEach(payload => {
      for (var i in payload.items) {
        payload.items[i].hash = Hasher('menuitem' + payload.name + payload.items[i].name)
      }
      state.menus = { ...state.menus, [payload.name]: payload.items }
    })
  },
  [CLEAR_MENU_ITEMS](state, name) {
    state.menus[name] = []
  },
}
