Skip to content

Commit

Permalink
corrected the value operator for assignmentHistory
Browse files Browse the repository at this point in the history
Jira ticket: CAMS-488

Co-authored-by: Arthur Morrow <[email protected]>
Co-authored-by: Stanley Smith <[email protected]>
  • Loading branch information
3 people committed Nov 29, 2024
1 parent d56bcf2 commit e479d10
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions user-interface/src/case-detail/panels/CaseDetailAuditHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -42,20 +43,26 @@ export default function CaseDetailAuditHistory(props: CaseDetailAuditHistoryProp
<tr key={idx}>
<td>Staff</td>
<td data-testid={`previous-assignment-${idx}`}>
{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)</>
)}
</td>
<td data-testid={`new-assignment-${idx}`}>
{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)</>
)}
</td>
<td data-testid={`changed-by-${idx}`}>
{history.updatedBy && <>{history.updatedBy.name}</>}
Expand Down Expand Up @@ -90,6 +97,13 @@ export default function CaseDetailAuditHistory(props: CaseDetailAuditHistoryProp
</tr>
);
}
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) => {
Expand Down

0 comments on commit e479d10

Please sign in to comment.