Skip to content
Snippets Groups Projects
Commit 9a4209cb authored by Angelina Filippova's avatar Angelina Filippova
Browse files

Fix filtering function in testing mocks

parent 174efc30
No related branches found
No related tags found
2 merge requests!11Add ability to read reports,!10Add more users filters
......@@ -9,10 +9,15 @@ const filterUsers = (str) => {
if (filters.length === 0) {
return users
}
return filters.reduce((acc, filter) => {
const filteredUsers = users.filter(user => user[filter])
return [...acc, ...filteredUsers]
}, [])
const applyFilters = (acc, filters, users) => {
if (filters.length === 0) {
return acc
}
const filteredUsers = users.filter(user => user[filters[0]])
const newAcc = [...filteredUsers]
return applyFilters(newAcc, filters.slice(1), filteredUsers)
}
return applyFilters([], filters, users)
}
export async function fetchUsers(filters, authHost, token, page = 1) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment