Skip to content

Commit

Permalink
10409: Add filtering for unassigned judges
Browse files Browse the repository at this point in the history
  • Loading branch information
Zachary Rogers committed Sep 5, 2024
1 parent e3ba313 commit f4be15c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
21 changes: 21 additions & 0 deletions web-client/src/presenter/computeds/trialSessionsHelper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,27 @@ describe('trialSessionsHelper', () => {
expect(trialSessionsOnly.length).toEqual(1);
});

it('should only show trial sessions who do not have a judge when the judge filter is "unassigned"', () => {
trialSession1.judge = undefined;
trialSession2.judge!.userId = '2';
trialSessionsPageState.trialSessions = [trialSession1, trialSession2];
trialSessionsPageState.filters.judgeId = 'unassigned';

const result = runCompute(trialSessionsHelper, {
state: {
permissions: getUserPermissions(docketClerk1User),
trialSessionsPage: trialSessionsPageState,
},
});

const trialSessionsOnly =
result.trialSessionRows.filter(isTrialSessionRow);
expect(trialSessionsOnly.length).toEqual(1);
expect(trialSessionsOnly[0].trialSessionId).toEqual(
trialSession1.trialSessionId,
);
});

it('should not filter trial sessions by judge when judge filter is All', () => {
trialSessionsPageState.trialSessions = [trialSession1, trialSession2];
trialSessionsPageState.filters.judgeId = 'All';
Expand Down
1 change: 1 addition & 0 deletions web-client/src/presenter/computeds/trialSessionsHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export const trialSessionsHelper = (
})
.filter(trialSession => {
if (filters.judgeId === 'All') return true;
if (filters.judgeId === 'unassigned') return !trialSession.judge?.userId;
return trialSession.judge?.userId === filters.judgeId;
})
.filter(trialSession => {
Expand Down
9 changes: 5 additions & 4 deletions web-client/src/views/TrialSessions/TrialSessions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ const TrialSessionFilters = connect(
<select
aria-label="location"
className="usa-select select-left width-180 inline-select"
value={trialSessionsPage.filters.trialLocation}
onChange={e => {
setTrialSessionsFiltersSequence({
trialLocation: e.target.value,
Expand All @@ -192,6 +193,7 @@ const TrialSessionFilters = connect(
className="usa-select select-left width-180 inline-select margin-left-1pt5rem"
id="proceedingFilter"
name="proceedingType"
value={trialSessionsPage.filters.proceedingType}
onChange={e => {
setTrialSessionsFiltersSequence({
proceedingType: e.target.value as TrialSessionProceedingType,
Expand All @@ -212,6 +214,7 @@ const TrialSessionFilters = connect(
className="usa-select select-left width-180 inline-select margin-left-1pt5rem"
id="sessionFilter"
name="sessionType"
value={trialSessionsPage.filters.sessionType}
onChange={e => {
setTrialSessionsFiltersSequence({
sessionType: e.target.value,
Expand All @@ -230,6 +233,7 @@ const TrialSessionFilters = connect(
className="usa-select select-left width-180 inline-select margin-left-1pt5rem"
id="judgeFilter"
name="judge"
value={trialSessionsPage.filters.judgeId}
onChange={e => {
setTrialSessionsFiltersSequence({
judgeId: e.target.value,
Expand All @@ -244,10 +248,7 @@ const TrialSessionFilters = connect(
))}

{trialSessionsHelper.showUnassignedJudgeFilter && (
<option
key={trialSessionsHelper.trialSessionJudges.length}
value="unassigned"
>
<option key="unassigned" value="unassigned">
Unassigned
</option>
)}
Expand Down

0 comments on commit f4be15c

Please sign in to comment.