From e479d10a0915bb825e63bff857c93dfc2b939f51 Mon Sep 17 00:00:00 2001 From: Arthur Morrow Date: Fri, 29 Nov 2024 12:19:48 -0500 Subject: [PATCH] corrected the value operator for assignmentHistory Jira ticket: CAMS-488 Co-authored-by: Arthur Morrow <133667008+amorrow-flexion@users.noreply.github.com> Co-authored-by: Stanley Smith <8822118+governmentSponsored@users.noreply.github.com> --- .../panels/CaseDetailAuditHistory.tsx | 38 +++++++++++++------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/user-interface/src/case-detail/panels/CaseDetailAuditHistory.tsx b/user-interface/src/case-detail/panels/CaseDetailAuditHistory.tsx index 0d2938df2..06bddc9bd 100644 --- a/user-interface/src/case-detail/panels/CaseDetailAuditHistory.tsx +++ b/user-interface/src/case-detail/panels/CaseDetailAuditHistory.tsx @@ -11,6 +11,7 @@ import { } from '@common/cams/history'; import { useEffect, useState } from 'react'; import Api2 from '@/lib/models/api2'; +import { CaseAssignment } from '@common/cams/assignments'; export interface CaseDetailAuditHistoryProps { caseId: string; @@ -42,20 +43,26 @@ export default function CaseDetailAuditHistory(props: CaseDetailAuditHistoryProp Staff - {history.before.length === 0 && <>(none)} - {history.before - .map((assignment) => { - return assignment.name; - }) - .join(', ')} + {assignmentHistoryHasValue(history.before) ? ( + history.before + .map((assignment) => { + return assignment.name; + }) + .join(', ') + ) : ( + <>(none) + )} - {history.after.length === 0 && <>(none)} - {history.after - .map((assignment) => { - return assignment.name; - }) - .join(', ')} + {assignmentHistoryHasValue(history.after) ? ( + history.after + .map((assignment) => { + return assignment.name; + }) + .join(', ') + ) : ( + <>(none) + )} {history.updatedBy && <>{history.updatedBy.name}} @@ -90,6 +97,13 @@ export default function CaseDetailAuditHistory(props: CaseDetailAuditHistoryProp ); } + function assignmentHistoryHasValue(assignmentHistory: CaseAssignment[] | null): boolean { + let noValue = true; + if (assignmentHistory === null || assignmentHistory.length === 0) { + noValue = false; + } + return noValue; + } function renderCaseHistory() { return caseHistory.map((history, idx: number) => {