From 2325d12395e0a7e7f944165e7de4d9e88915b4d6 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Thu, 13 Oct 2022 22:35:20 +0200 Subject: Add pagination on admin cp --- store/users.js | 12 ++++++++---- store/warnings.js | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'store') 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 = { -- cgit v1.2.3-18-g5258