Fix filter logic to work with multiple choice on different pages

This commit is contained in:
Angelina Filippova 2019-05-07 00:56:08 +03:00
parent c425cd8aec
commit 5f0289c363

View file

@ -21,14 +21,9 @@ const users = {
SET_LOADING: (state, status) => {
state.loading = status
},
SWAP_USER: (state, user) => {
const usersWithoutSwapped = state.fetchedUsers.filter(u => {
return u.id !== user.id
})
state.fetchedUsers = [...usersWithoutSwapped, user].sort((a, b) =>
a.nickname.localeCompare(b.nickname)
)
SWAP_USER: (state, updatedUser) => {
const updated = state.fetchedUsers.map(user => user.id === updatedUser.id ? updatedUser : user)
state.fetchedUsers = updated.sort((a, b) => a.nickname.localeCompare(b.nickname))
},
SET_COUNT: (state, count) => {
state.totalUsersCount = count