import axios from 'axios' export default { namespaced: true, state: { roles: [], permissionsList: [], selectedUsers: [], dialog: { show: false, type: null, info: {} } }, mutations: { setRoles (state, value) { state.roles = value }, setSelectedUsers (state, value) { state.selectedUsers = value }, setPermissions (state, value) { state.permissionsList = value }, setDialog (state, { show, type, info }) { if (show !== undefined) state.dialog.show = show if (type !== undefined) state.dialog.type = type if (info !== undefined) state.dialog.info = info } }, actions: { loadRoles (context) { axios.get('/api/roles').then(response => { context.commit('setRoles', response.data) }) }, loadPermissions (context) { axios.get('/api/permissions').then(response => { context.commit('setPermissions', response.data) }) }, loadLists (context) { context.dispatch('loadRoles') context.dispatch('loadPermissions') } } }