wholesale-vuex
Version:
Commerce vuex module
35 lines (33 loc) • 748 B
JavaScript
import wholesaleRepService from './wholesale_rep.service'
import humps from 'lodash-humps'
const { doFetchList } = wholesaleRepService
export default{
namespaced: true,
state: {
list: [],
inProgress: false
},
mutations: {
inProgress(state, yesOrNo) {
state.inProgress = yesOrNo
},
setList(state, list) {
state.list = list
}
},
actions: {
fetchList: async ({ commit }) => {
/*eslint-disable*/
//debugger
commit('inProgress', true)
const list = await doFetchList()
if (list) {
commit('setList', humps((list)))
commit('inProgress', false)
return list
} else
commit('setList', [])
commit('inProgress', false)
}
}
}