summaryrefslogtreecommitdiff
path: root/store
diff options
context:
space:
mode:
authorSanto Cariotti <santo@dcariotti.me>2022-10-13 22:35:20 +0200
committerSanto Cariotti <santo@dcariotti.me>2022-10-13 22:35:20 +0200
commit2325d12395e0a7e7f944165e7de4d9e88915b4d6 (patch)
tree991ae85bb8dc9251f83a7055dab2ad183a512af0 /store
parente7051ff7dc705cee2360798df86613632b305ba2 (diff)
Add pagination on admin cp
Diffstat (limited to 'store')
-rw-r--r--store/users.js12
-rw-r--r--store/warnings.js1
2 files changed, 9 insertions, 4 deletions
diff --git a/store/users.js b/store/users.js
index df2b596..44f041c 100644
--- a/store/users.js
+++ b/store/users.js
@@ -1,16 +1,21 @@
export const state = () => ({
users: [],
+ count: 0,
});
export const getters = {
users: (state) => {
return state.users;
},
+ count: (state) => {
+ return state.count;
+ },
};
export const mutations = {
saveUsers: (state, value) => {
- state.users = value;
+ state.users = value.results;
+ state.count = value.count;
},
};
@@ -144,11 +149,10 @@ export const actions = {
return res;
},
// Get users
- async getUsers({ commit, rootGetters }, data) {
+ async getUsers({ commit, rootGetters }, page) {
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: {
@@ -159,7 +163,7 @@ export const actions = {
.then(async (response) => {
res.status = response.status;
res.data = await response.json();
- commit("saveUsers", res.data.results);
+ commit("saveUsers", res.data);
})
.catch((e) => {
res.status = e.status;
diff --git a/store/warnings.js b/store/warnings.js
index 2d3aa99..1e8fe07 100644
--- a/store/warnings.js
+++ b/store/warnings.js
@@ -1,5 +1,6 @@
export const state = () => ({
warnings: [],
+ count: 0,
});
export const getters = {