Newer
Older
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import client from '@/api/loginAPI.js';
import organisationAPI from '@/api/organisationsAPI.js';
import axios from 'axios';
const state = {
organisationsList: [],
organisationsTypes: [],
organisationsRoles: [],
};
const getters = { };
export const GET_ORGANISATIONS_LIST = 'GET_ORGANISATIONS_LIST';
export const GET_ORGANISATIONS_TYPES = 'GET_ORGANISATIONS_TYPES';
export const GET_ORGANISATIONS_ROLES = 'GET_ORGANISATIONS_ROLES';
const actions = {
[GET_ORGANISATIONS_LIST]: async ({ commit }) => {
const organisations = await client.getOrganisationsList();
commit('SET_ORGANISATIONS_LIST', organisations);
},
[GET_ORGANISATIONS_TYPES]: async ({ commit }) => {
const types = await organisationAPI.getOrganisationsTypes();
commit('SET_ORGANISATIONS_TYPES', types);
},
[GET_ORGANISATIONS_ROLES]: async ({ commit }) => {
const roles = await organisationAPI.getOrganisationsRoles();
commit('SET_ORGANISATIONS_ROLES', roles);
}
};
export const SET_ORGANISATIONS_LIST = 'SET_ORGANISATIONS_LIST';
export const SET_ORGANISATIONS_TYPES = 'SET_ORGANISATIONS_TYPES';
export const SET_ORGANISATIONS_ROLES = 'SET_ORGANISATIONS_ROLES';
const mutations = {
[SET_ORGANISATIONS_LIST]: (state, payload) => {
state.organisationsList = payload ? payload.results ? payload.results : payload : [];
},
[SET_ORGANISATIONS_TYPES]: (state, payload) => {
state.organisationsTypes = payload;
},
[SET_ORGANISATIONS_ROLES]: (state, payload) => {
state.organisationsRoles = payload;
},
};
export default {
namespaced: true,
state,
getters,
actions,
mutations,
};