summaryrefslogtreecommitdiffstats
path: root/webapp/src/store/users.js
blob: 66d41b723cab9709d8d7e4aa5a4e31c8418a8e27 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import axios from 'axios'

export default {
  namespaced: true,
  state: {
    users: [],
    dialog: {
      show: false,
      type: null,
      info: {}
    }
  },
  mutations: {
    setUsers (state, users) { state.users = users },
    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: {
    loadData (context) {
      axios.get('/api/users').then(response => {
        context.commit('setUsers', response.data)
      })
    }
  }
}