Skip to content

Commit

Permalink
VIH-10328 Added null checks to usage of judicary participants list (#…
Browse files Browse the repository at this point in the history
…1306)

* Added null checks to usage of judicary participants list

* flipped if condition

* lint-fix

(cherry picked from commit 1cdb598)
  • Loading branch information
will-craig committed Nov 29, 2023
1 parent 2a3c9d0 commit 5a533ae
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,13 @@ export class ParticipantListComponent implements OnInit, OnChanges, DoCheck {
}

private getJudicialPanelMembers(): ParticipantModel[] {
console.log(this.hearing.judiciaryParticipants);
return this.hearing.judiciaryParticipants
.filter(j => j.roleCode === 'PanelMember')
.sort((a, b) => a.displayName.localeCompare(b.displayName))
.map(h => ParticipantModel.fromJudicialMember(h, false));
if (this.hearing.judiciaryParticipants) {
console.log(this.hearing.judiciaryParticipants);
return this.hearing.judiciaryParticipants
.filter(j => j.roleCode === 'PanelMember')
.sort((a, b) => a.displayName.localeCompare(b.displayName))
.map(h => ParticipantModel.fromJudicialMember(h, false));
}
}

private getPanelMembers() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ describe('SummaryComponent with valid request', () => {
expect(component.hearing.linked_participants).toEqual([]);
expect(component.hearing.participants).toEqual([]);
});

it('should remove interpreter and clear the linked participant list on remove interpreter', () => {
component.ngOnInit();
component.hearing.participants = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export class SummaryComponent implements OnInit, OnDestroy {
}
this.judgeAssigned =
this.hearing.participants.filter(e => e.is_judge).length > 0 ||
this.hearing.judiciaryParticipants.some(e => e.roleCode === 'Judge');
this.hearing.judiciaryParticipants?.some(e => e.roleCode === 'Judge');
}

private checkForExistingRequest() {
Expand Down Expand Up @@ -179,7 +179,7 @@ export class SummaryComponent implements OnInit, OnDestroy {
}
}

const judicalParticipant = this.hearing.judiciaryParticipants.findIndex(x => x.email === this.selectedParticipantEmail);
const judicalParticipant = this.hearing.judiciaryParticipants?.findIndex(x => x.email === this.selectedParticipantEmail);
if (judicalParticipant > -1) {
this.removerFullName = this.hearing.judiciaryParticipants[judicalParticipant].fullName;
this.showConfirmationRemoveParticipant = true;
Expand Down Expand Up @@ -214,7 +214,7 @@ export class SummaryComponent implements OnInit, OnDestroy {
this.hearing = { ...this.hearing };
}

const judicalParticipant = this.hearing.judiciaryParticipants.findIndex(x => x.email === this.selectedParticipantEmail);
const judicalParticipant = this.hearing.judiciaryParticipants?.findIndex(x => x.email === this.selectedParticipantEmail);
if (judicalParticipant > -1) {
this.hearing.judiciaryParticipants.splice(judicalParticipant, 1);
this.hearing = { ...this.hearing };
Expand Down

0 comments on commit 5a533ae

Please sign in to comment.