feat(stores): añadidos parámetros para listado de usuarios y paginación/ordenación

parent fb08cfd3
Showing with 24 additions and 0 deletions
......@@ -4,6 +4,13 @@ import { userService } from '@/services/user';
export const useUserStore = defineStore('user', {
state: () => ({
user: null,
users: [],
currentPage: 0,
pageSize: 5,
totalElements: 0,
totalPages: 0,
sortBy: null,
sortDirection: 'asc'
}),
actions: {
async readUser() {
......@@ -15,6 +22,23 @@ export const useUserStore = defineStore('user', {
this.user = null;
throw error;
}
},
async readAll(page, size, sortBy, sortDirection) {
try {
const response = await userService.readAll(page, size, sortBy, sortDirection);
this.users = response.content;
this.totalElements = response.totalElements;
this.totalPages = response.totalPages;
this.currentPage = response.number;
this.sortBy = sortBy;
this.sortDirection = sortDirection;
} catch (error) {
console.error('Error al obtener la lista de usuarios:', error);
this.users = [];
this.totalElements = 0;
this.totalPages = 0;
throw error;
}
}
}
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment