diff --git a/src/meta/tablePaginated/tablePaginated.ts b/src/meta/tablePaginated/tablePaginated.ts index 14574d3568..b3e32e8a09 100644 --- a/src/meta/tablePaginated/tablePaginated.ts +++ b/src/meta/tablePaginated/tablePaginated.ts @@ -1,5 +1,5 @@ import { CountryIso } from 'meta/area' -import { RoleName } from 'meta/user' +import { RoleName, UserStatus } from 'meta/user' export enum TablePaginatedOrderByDirection { asc = 'asc', @@ -30,4 +30,5 @@ export type UserFilters = { fullName?: string roles?: Array disabled?: boolean + statuses?: Array } diff --git a/src/server/api/user/getMany.ts b/src/server/api/user/getMany.ts index f8e0067e4f..28328c762d 100644 --- a/src/server/api/user/getMany.ts +++ b/src/server/api/user/getMany.ts @@ -1,6 +1,8 @@ import { Response } from 'express' import { CycleRequest } from 'meta/api/request' +import { UserFilters } from 'meta/tablePaginated' +import { UserStatus } from 'meta/user' import { AssessmentController } from 'server/controller/assessment' import { UserController } from 'server/controller/user' @@ -13,7 +15,8 @@ export const getMany = async (req: CycleRequest<{ print: string }>, res: Respons const { assessment, cycle } = await AssessmentController.getOneWithCycle({ assessmentName, cycleName }) - let users = await UserController.getMany({ assessment, cycle, countryIso }) + const filters: UserFilters = { statuses: [UserStatus.active, UserStatus.invitationPending] } + let users = await UserController.getMany({ assessment, cycle, countryIso, filters }) if (print && print === 'true') users = users.filter((user) => !ProcessEnv.fraReportCollaboratorsExcluded.includes(user.email)) diff --git a/src/server/repository/public/user/utils/getPropsToQueryParams.ts b/src/server/repository/public/user/utils/getPropsToQueryParams.ts index 919fd23181..1a9d410c49 100644 --- a/src/server/repository/public/user/utils/getPropsToQueryParams.ts +++ b/src/server/repository/public/user/utils/getPropsToQueryParams.ts @@ -11,7 +11,10 @@ export const getPropsToQueryParams = (props: UsersGetManyProps): Returned => { const { countryIso, filters = {}, limit, offset } = props const { administrators, countries, fullName, roles, disabled } = filters - const statuses = disabled ? [UserStatus.disabled] : [UserStatus.active] + + // Only return users with active status, unless other statuses specified outside + const defaultStatuses = props.filters.statuses ?? [UserStatus.active] + const statuses = disabled ? [UserStatus.disabled] : defaultStatuses const queryParams: UserQueryParams = {}