summaryrefslogtreecommitdiff
path: root/store
diff options
context:
space:
mode:
Diffstat (limited to 'store')
-rw-r--r--store/users.js24
-rw-r--r--store/warnings.js33
2 files changed, 55 insertions, 2 deletions
diff --git a/store/users.js b/store/users.js
index 90e4dad..df2b596 100644
--- a/store/users.js
+++ b/store/users.js
@@ -143,4 +143,28 @@ export const actions = {
return res;
},
+ // Get users
+ async getUsers({ commit, rootGetters }, data) {
+ commit("loadingStatus", true, { root: true });
+ let res = { status: 0, data: null };
+ let api = this.$config.api;
+ const page = data.page ? data.page : 0;
+
+ await fetch(`${api}/v1/users?page=${page}`, {
+ headers: {
+ "Content-Type": "application/json",
+ Authorization: `Bearer ${rootGetters["auth/accessToken"]}`,
+ },
+ })
+ .then(async (response) => {
+ res.status = response.status;
+ res.data = await response.json();
+ commit("saveUsers", res.data.results);
+ })
+ .catch((e) => {
+ res.status = e.status;
+ });
+
+ commit("loadingStatus", false, { root: true });
+ },
};
diff --git a/store/warnings.js b/store/warnings.js
index 4c94459..2d3aa99 100644
--- a/store/warnings.js
+++ b/store/warnings.js
@@ -6,15 +6,44 @@ export const getters = {
warnings: (state) => {
return state.warnings;
},
+ count: (state) => {
+ return state.count;
+ },
};
export const mutations = {
saveWarnings: (state, value) => {
- state.warnings = value;
+ state.warnings = value.results;
+ state.count = value.count;
},
};
export const actions = {
+ // Get warnings
+ async getWarnings({ commit, rootGetters }, page) {
+ commit("loadingStatus", true, { root: true });
+ let res = { status: 0, data: null };
+ let api = this.$config.api;
+
+ await fetch(`${api}/v1/warnings?page=${page}`, {
+ headers: {
+ "Content-Type": "application/json",
+ Authorization: `Bearer ${rootGetters["auth/accessToken"]}`,
+ },
+ })
+ .then(async (response) => {
+ res.status = response.status;
+ const data = await response.json();
+ if (res.status == 200) {
+ commit("saveWarnings", data);
+ }
+ })
+ .catch((e) => {
+ res.status = e.status;
+ });
+
+ commit("loadingStatus", false, { root: true });
+ },
// Filter warnings
async filterWarnings({ commit, rootGetters }, payload) {
commit("loadingStatus", true, { root: true });
@@ -33,7 +62,7 @@ export const actions = {
res.status = response.status;
const data = await response.json();
if (res.status == 200) {
- commit("saveWarnings", data.results);
+ commit("saveWarnings", { results: data.results });
}
})
.catch((e) => {