From fe7cf0cd78800e6f5d50978ac497737f57db9044 Mon Sep 17 00:00:00 2001 From: Joshua Kuestersteffen Date: Wed, 17 Apr 2024 09:15:27 -0500 Subject: [PATCH] Fix filtering bug in user-management --- shared-libs/user-management/src/users.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/shared-libs/user-management/src/users.js b/shared-libs/user-management/src/users.js index 93525dc52c4..893eb777d8e 100644 --- a/shared-libs/user-management/src/users.js +++ b/shared-libs/user-management/src/users.js @@ -123,7 +123,7 @@ const getAllUsers = async () => db.users .allDocs({ include_docs: true, start_key: 'org.couchdb.user:', end_key: 'org.couchdb.user:\ufff0' }) .then(({ rows }) => rows.map(({ doc }) => doc)); -const getUsers = async ({ facilityId, contactId }) => { +const getUsers = async (facilityId, contactId) => { if (!contactId) { return queryDocs(db.users, 'users/users_by_field', ['facility_id', facilityId]); } @@ -136,11 +136,11 @@ const getUsers = async ({ facilityId, contactId }) => { return usersForContactId.filter(user => user.facility_id === facilityId); }; -const getUsersAndSettings = async (filters) => { - if (_.isEmpty(filters)) { +const getUsersAndSettings = async ({ facilityId, contactId } = {}) => { + if (!facilityId && !contactId) { return Promise.all([getAllUsers(), getAllUserSettings()]); } - const users = await getUsers(filters); + const users = await getUsers(facilityId, contactId); const ids = users.map(({ _id }) => _id); const settings = await getSettingsByIds(ids); return [users, settings];