Skip to content

Commit

Permalink
Add null check to actions (#1137)
Browse files Browse the repository at this point in the history
* Add null check to actions
  • Loading branch information
taustad authored Sep 4, 2024
1 parent 6a9c42a commit bd42d62
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions frontend/src/components/ActionTable/ActionTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ const ActionTable = ({ onClickAction, actionsWithAdditionalInfo, personDetailsLi
return 0
case 'project':
if (projects) {
const projectNameA = getFusionProjectName(projects, a.action.question.evaluation.project.fusionProjectId)
const projectNameB = getFusionProjectName(projects, b.action.question.evaluation.project.fusionProjectId)
const projectNameA = getFusionProjectName(projects, a.action?.question?.evaluation?.project?.fusionProjectId)
const projectNameB = getFusionProjectName(projects, b.action?.question?.evaluation?.project?.fusionProjectId)
return projectNameA && projectNameB ? sort(projectNameA.toLowerCase(), projectNameB.toLowerCase(), sortDirection) : 0
}
return 0
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export const selectSeverity = (severityCount: SeverityCount) => {
}

export const getFusionProjectName = (projects: Context[] | undefined, fusionProjectId: string) => {
if (!fusionProjectId || !projects) { return undefined }
const fusionProject = projects?.find(project => project.id === fusionProjectId)
return fusionProject?.title
}
Expand Down Expand Up @@ -102,7 +103,7 @@ export const canSetEvaluationAsIndicator = (evaluation: Evaluation, userRoles: U
let reasonsForNotBeingAbleToSelect = []

if (!isFacilitator && !userIsAdmin) {
reasonsForNotBeingAbleToSelect.push("only facilitators and admins can set an evaluation as active")
reasonsForNotBeingAbleToSelect.push("only facilitators and admins can set an evaluation as active")
}
if (!evaluationIsNotActive) {
reasonsForNotBeingAbleToSelect.push("this evaluation is already active")
Expand Down

0 comments on commit bd42d62

Please sign in to comment.