Skip to content

Commit

Permalink
4196 - Show invited users in country collaborators
Browse files Browse the repository at this point in the history
  • Loading branch information
sorja committed Jan 6, 2025
1 parent cb9dcf5 commit 08ca1ee
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/meta/tablePaginated/tablePaginated.ts
Original file line number Diff line number Diff line change
@@ -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',
Expand Down Expand Up @@ -30,4 +30,5 @@ export type UserFilters = {
fullName?: string
roles?: Array<RoleName>
disabled?: boolean
statuses?: Array<UserStatus>
}
5 changes: 4 additions & 1 deletion src/server/api/user/getMany.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}

Expand Down

0 comments on commit 08ca1ee

Please sign in to comment.