Skip to content

Commit

Permalink
Merge pull request #2506 from cisagov/2229-users-page-organizations-e…
Browse files Browse the repository at this point in the history
…xports-broken

Fix Export Users Functionality and Organizations Column on Users Page
  • Loading branch information
Matthew-Grayson authored Feb 5, 2024
2 parents 4c309f2 + 1ded2fa commit 0ae2bd7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 7 additions & 3 deletions backend/src/api/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,13 @@ class UserSearch {
async getResults(event): Promise<[User[], number]> {
const pageSize = this.pageSize || 25;
const sort = this.sort === 'name' ? 'user.fullName' : 'user.' + this.sort;
const qs = User.createQueryBuilder('user').orderBy(sort, this.order);
const results = await qs.getManyAndCount();
return results;
const qs = User.createQueryBuilder('user')
.leftJoinAndSelect('user.roles', 'roles') // Include the roles relation
.leftJoinAndSelect('roles.organization', 'organization') // Include the organization relation
.orderBy(sort, this.order);
const result = await qs.getMany();
const count = await qs.getCount();
return [result, count];
}
}

Expand Down
3 changes: 1 addition & 2 deletions frontend/src/pages/Users/Users.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ import {
ModalRef
} from '@trussworks/react-uswds';
import { ModalToggleButton } from 'components';
import { Organization, Query } from 'types';
import { Table, ImportExport } from 'components';
import { Column, SortingRule } from 'react-table';
import { User } from 'types';
import { Organization, Query, User } from 'types';
import { FaTimes } from 'react-icons/fa';
import { useAuthContext } from 'context';
// @ts-ignore:next-line
Expand Down

0 comments on commit 0ae2bd7

Please sign in to comment.