Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4196 - Show invited users in country collaborators #4198

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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] }
minotogna marked this conversation as resolved.
Show resolved Hide resolved
minotogna marked this conversation as resolved.
Show resolved Hide resolved
let users = await UserController.getMany({ assessment, cycle, countryIso, filters })

if (print && print === 'true')
users = users.filter((user) => !ProcessEnv.fraReportCollaboratorsExcluded.includes(user.email))
Expand Down
13 changes: 11 additions & 2 deletions src/server/repository/public/user/utils/getPropsToQueryParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,17 @@ type Returned = { whereConditions: Array<string>; queryParams: UserQueryParams }
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]
const {
administrators,
countries,
fullName,
roles,
disabled,
statuses: defaultStatuses = [UserStatus.active],
} = filters

// Only return users with active status, unless other statuses specified outside
const statuses = disabled ? [UserStatus.disabled] : defaultStatuses

const queryParams: UserQueryParams = {}

Expand Down
Loading