import axios from 'axios' export default { namespaced: true, state: { hooks: [], dialog: { show: false, type: null, info: {} } }, mutations: { setHooks (state, hooks) { state.hooks = hooks }, setGroupList (state, groupList) { state.groupList = groupList }, setDialog (state, { show, type, info }) { if (info !== undefined) state.dialog.info = info if (type !== undefined) state.dialog.type = type if (show !== undefined) state.dialog.show = show } }, actions: { loadHooks (context) { axios.get('/api/registration/hooks').then(result => { context.commit('setHooks', result.data) }) }, setHooks (context, hooks) { axios.post('/api/registration/hookorder', { ids: hooks.map(x => x.id) }).then(result => { context.commit('setHooks', hooks) }) } } }