sort users (by lastname)

This commit is contained in:
Tim Gröger 2024-04-11 09:57:43 +02:00 committed by Tim Gröger
parent efc7c49a0b
commit ec5458bf7e
1 changed files with 12 additions and 1 deletions

View File

@ -31,7 +31,18 @@ export const useUserStore = defineStore({
getters: {
users(state) {
return state._users.filter((u) => !u.deleted);
const u = state._users.filter((u) => !u.deleted);
u.sort((a, b) => {
const a_lastname = a.lastname.toLowerCase();
const b_lastname = b.lastname.toLowerCase();
const a_firstname = a.firstname.toLowerCase();
const b_firstname = b.firstname.toLowerCase();
if (a_lastname === b_lastname) {
return a_firstname < b_firstname ? -1 : 1;
}
return a_lastname < b_lastname ? -1 : 1;
});
return u;
},
},