2020-07-16 16:07:54 +02:00
|
|
|
import api from './api'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
state: () => ({
|
2020-07-16 16:30:19 +02:00
|
|
|
domains: undefined,
|
|
|
|
users: undefined
|
2020-07-16 16:07:54 +02:00
|
|
|
}),
|
|
|
|
mutations: {
|
2020-07-16 16:30:19 +02:00
|
|
|
'SET_DOMAINS' (state, domains) {
|
|
|
|
state.domains = domains
|
|
|
|
},
|
|
|
|
'SET_USERS' (state, users) {
|
|
|
|
console.log(users)
|
|
|
|
state.users = Object.keys(users).length === 0 ? null : Object.values(users)
|
2020-07-16 16:07:54 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
actions: {
|
|
|
|
async 'FETCH' ({ commit }, uri) {
|
2020-07-16 16:30:19 +02:00
|
|
|
return api.get(uri).then(responseData => {
|
|
|
|
const data = responseData[uri] ? responseData[uri] : responseData
|
|
|
|
commit('SET_' + uri.toUpperCase(), data)
|
2020-07-16 16:07:54 +02:00
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
getters: {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|