diff --git a/src/data/pages/users-db.json b/src/data/pages/users-db.json index 1b31ed735..7c3cb6f1b 100644 --- a/src/data/pages/users-db.json +++ b/src/data/pages/users-db.json @@ -210,7 +210,7 @@ "notes": "voluptatibus et soluta" }, { - "id": 21, + "id": 22, "active": true, "fullname": "Raymond Simonis", "email": "Tressie.Bruen45@gmail.com", @@ -220,7 +220,7 @@ "notes": "aut id molestiae" }, { - "id": 22, + "id": 23, "active": true, "fullname": "Janice Sporer", "email": "Anastasia85@hotmail.com", @@ -230,7 +230,7 @@ "notes": "magnam eum aliquam" }, { - "id": 23, + "id": 24, "active": true, "fullname": "Francis Schowalter", "email": "Tess56@gmail.com", @@ -240,7 +240,7 @@ "notes": "similique architecto in" }, { - "id": 24, + "id": 25, "active": true, "fullname": "Emilio Hoppe", "email": "Bruce49@yahoo.com", @@ -250,7 +250,7 @@ "notes": "rerum quae dolorem" }, { - "id": 25, + "id": 26, "active": true, "fullname": "Janice Harber", "email": "Jude38@hotmail.com", @@ -260,7 +260,7 @@ "notes": "iure dolor provident" }, { - "id": 26, + "id": 27, "fullname": "Evelyn Morar", "email": "Laverne.Roberts@hotmail.com", "role": "user", @@ -270,7 +270,7 @@ "notes": "quae eos placeat" }, { - "id": 27, + "id": 28, "fullname": "Antoinette Schneider", "email": "Ambrose_Stehr25@gmail.com", "role": "user", @@ -280,7 +280,7 @@ "notes": "qui cumque unde" }, { - "id": 28, + "id": 29, "fullname": "Ebony Daniel", "email": "Nyah44@hotmail.com", "role": "user", diff --git a/src/data/pages/users.ts b/src/data/pages/users.ts index 5e6988540..259ef6936 100644 --- a/src/data/pages/users.ts +++ b/src/data/pages/users.ts @@ -40,10 +40,10 @@ export const getUsers = async (filters: Partial) const { isActive, search, sortBy, sortingOrder } = filters let filteredUsers = users - filteredUsers = users.filter((user) => user.active === isActive) + filteredUsers = filteredUsers.filter((user) => user.active === isActive) if (search) { - filteredUsers = users.filter((user) => user.fullname.toLowerCase().includes(search.toLowerCase())) + filteredUsers = filteredUsers.filter((user) => user.fullname.toLowerCase().includes(search.toLowerCase())) } if (sortBy && sortingOrder) { diff --git a/src/pages/projects/ProjectsPage.vue b/src/pages/projects/ProjectsPage.vue index 68561012c..ac4ea57ca 100644 --- a/src/pages/projects/ProjectsPage.vue +++ b/src/pages/projects/ProjectsPage.vue @@ -1,5 +1,6 @@ diff --git a/src/pages/users/composables/useUsers.ts b/src/pages/users/composables/useUsers.ts index 0460b5947..1d051f97d 100644 --- a/src/pages/users/composables/useUsers.ts +++ b/src/pages/users/composables/useUsers.ts @@ -61,28 +61,21 @@ export const useUsers = (options?: { async add(user: User) { isLoading.value = true await addUser(user) - users.value.unshift(user) + await fetch() isLoading.value = false }, async update(user: User) { isLoading.value = true await updateUser(user) - users.value = users.value - .map((u) => (u.id === user.id ? user : u)) - .filter((u) => u.active === filters.value.isActive) - .filter((u) => { - if (!filters.value.search) return true - - return u.fullname.toLowerCase().includes(filters.value.search.toLowerCase()) - }) + await fetch() isLoading.value = false }, async remove(user: User) { isLoading.value = true await removeUser(user) - users.value = users.value.filter((u) => u.id !== user.id) + await fetch() isLoading.value = false }, } diff --git a/src/pages/users/widgets/UsersTable.vue b/src/pages/users/widgets/UsersTable.vue index 38255a2a8..9c5e71054 100644 --- a/src/pages/users/widgets/UsersTable.vue +++ b/src/pages/users/widgets/UsersTable.vue @@ -118,8 +118,14 @@ const formatProjectNames = (projects: Project[]) => {