From bdc4a5237c3f6b9003170a245fe452c903233d18 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Fri, 30 Aug 2024 10:57:41 -0700 Subject: [PATCH 01/96] 10409: Add new styling for trial sessions. Extract filters to its own component separate from the table --- .../src/views/TrialSessions/TrialSessions.tsx | 194 +++++++++++++++--- .../TrialSessions/TrialSessionsTable.tsx | 82 +------- 2 files changed, 162 insertions(+), 114 deletions(-) diff --git a/web-client/src/views/TrialSessions/TrialSessions.tsx b/web-client/src/views/TrialSessions/TrialSessions.tsx index fc7f48debd4..2f32c8e590b 100644 --- a/web-client/src/views/TrialSessions/TrialSessions.tsx +++ b/web-client/src/views/TrialSessions/TrialSessions.tsx @@ -1,8 +1,14 @@ import { BigHeader } from '../BigHeader'; +import { BindedSelect } from '@web-client/ustc-ui/BindedSelect/BindedSelect'; import { Button } from '../../ustc-ui/Button/Button'; import { ErrorNotification } from '../ErrorNotification'; +import { + SESSION_TYPES, + TRIAL_SESSION_PROCEEDING_TYPES, +} from '@shared/business/entities/EntityConstants'; import { SuccessNotification } from '../SuccessNotification'; import { Tab, Tabs } from '../../ustc-ui/Tabs/Tabs'; +import { TrialCityOptions } from '@web-client/views/TrialCityOptions'; import { TrialSessionsTable } from './TrialSessionsTable'; import { connect } from '@web-client/presenter/shared.cerebral'; import { sequences } from '@web-client/presenter/app.cerebral'; @@ -14,12 +20,12 @@ export const TrialSessions = connect( defaultTab: state.screenMetadata.trialSessionFilters.status, openTrialSessionPlanningModalSequence: sequences.openTrialSessionPlanningModalSequence, - showNewTrialSession: state.trialSessionsHelper.showNewTrialSession, + trialSessionHelper: state.trialSessionsHelper, }, function TrialSessions({ defaultTab, openTrialSessionPlanningModalSequence, - showNewTrialSession, + trialSessionHelper, }) { return ( <> @@ -30,7 +36,7 @@ export const TrialSessions = connect( @@ -44,48 +50,24 @@ export const TrialSessions = connect( Trial Session Planning Report - {showNewTrialSession && ( - - )} - {showNewTrialSession && ( + {trialSessionHelper.showNewTrialSession && ( + )} - - - - - - + @@ -95,4 +77,148 @@ export const TrialSessions = connect( }, ); +const TrialSessionFilters = connect( + { trialSessionsHelper: state.trialSessionsHelper }, + function TrialSessionFilters({ trialSessionsHelper }) { + return ( + <> +
+
+ Session Status + {}} + /> + + {}} + /> + + {}} + /> + +
+
+
+
+ + + + + + + + {Object.values(TRIAL_SESSION_PROCEEDING_TYPES).map( + proceedingType => ( + + ), + )} + + + + {Object.values(SESSION_TYPES).map(sessionType => ( + + ))} + + + + {trialSessionsHelper.trialSessionJudges.map(judge => ( + + ))} + + {trialSessionsHelper.showUnassignedJudgeFilter && ( + + )} + +
+ {trialSessionsHelper.showNewTrialSession && ( + + )} +
+ + ); + }, +); +// }); + TrialSessions.displayName = 'TrialSessions'; diff --git a/web-client/src/views/TrialSessions/TrialSessionsTable.tsx b/web-client/src/views/TrialSessions/TrialSessionsTable.tsx index 8e2875d6591..b46dd42c07f 100644 --- a/web-client/src/views/TrialSessions/TrialSessionsTable.tsx +++ b/web-client/src/views/TrialSessions/TrialSessionsTable.tsx @@ -1,10 +1,4 @@ -import { BindedSelect } from '../../ustc-ui/BindedSelect/BindedSelect'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; -import { - SESSION_TYPES, - TRIAL_SESSION_PROCEEDING_TYPES, -} from '../../../../shared/src/business/entities/EntityConstants'; -import { TrialCityOptions } from '../TrialCityOptions'; import { connect } from '@web-client/presenter/shared.cerebral'; import { props } from 'cerebral'; import { state } from '@web-client/presenter/app.cerebral'; @@ -30,79 +24,7 @@ export const TrialSessionsTable = connect( }; }) { return ( - -
- - - - - - - - {Object.values(TRIAL_SESSION_PROCEEDING_TYPES).map( - proceedingType => ( - - ), - )} - - - - {Object.values(SESSION_TYPES).map(sessionType => ( - - ))} - - - - {trialSessionsHelper.trialSessionJudges.map(judge => ( - - ))} - - {trialSessionsHelper.showUnassignedJudgeFilter && ( - - )} - -
+ <> There are no trial sessions.

)} - + ); }, ); From f93ed2f0a74fd7bab687f6dd92862a1d9eae849e Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Fri, 30 Aug 2024 15:44:32 -0700 Subject: [PATCH 02/96] 10409: Split out state for trialsessionPage into its own page container. --- .../trialSessions/getTrialSessionsProxy.ts | 5 ++- .../setTrialSessionsPageAction.ts | 5 +++ .../sequences/gotoTrialSessionsSequence.ts | 4 +- web-client/src/presenter/state.ts | 2 + .../presenter/state/trialSessionsPageState.ts | 14 ++++++ .../src/views/TrialSessions/TrialSessions.tsx | 43 +++++++++---------- 6 files changed, 47 insertions(+), 26 deletions(-) create mode 100644 web-client/src/presenter/actions/TrialSession/setTrialSessionsPageAction.ts create mode 100644 web-client/src/presenter/state/trialSessionsPageState.ts diff --git a/shared/src/proxies/trialSessions/getTrialSessionsProxy.ts b/shared/src/proxies/trialSessions/getTrialSessionsProxy.ts index b561ff5be22..56456ad8c74 100644 --- a/shared/src/proxies/trialSessions/getTrialSessionsProxy.ts +++ b/shared/src/proxies/trialSessions/getTrialSessionsProxy.ts @@ -1,3 +1,4 @@ +import { TrialSessionInfoDTO } from '@shared/business/dto/trialSessions/TrialSessionInfoDTO'; import { get } from '../requests'; /** @@ -6,7 +7,9 @@ import { get } from '../requests'; * @param {object} applicationContext the application context * @returns {Promise<*>} the promise of the api call */ -export const getTrialSessionsInteractor = applicationContext => { +export const getTrialSessionsInteractor = ( + applicationContext, +): Promise => { return get({ applicationContext, endpoint: '/trial-sessions', diff --git a/web-client/src/presenter/actions/TrialSession/setTrialSessionsPageAction.ts b/web-client/src/presenter/actions/TrialSession/setTrialSessionsPageAction.ts new file mode 100644 index 00000000000..72f2ee896e1 --- /dev/null +++ b/web-client/src/presenter/actions/TrialSession/setTrialSessionsPageAction.ts @@ -0,0 +1,5 @@ +import { state } from '@web-client/presenter/app.cerebral'; + +export const setTrialSessionsPageAction = ({ props, store }: ActionProps) => { + store.set(state.trialSessionsPage.trialSessions, props.trialSessions); +}; diff --git a/web-client/src/presenter/sequences/gotoTrialSessionsSequence.ts b/web-client/src/presenter/sequences/gotoTrialSessionsSequence.ts index 5dd87fa401d..bf83e17b438 100644 --- a/web-client/src/presenter/sequences/gotoTrialSessionsSequence.ts +++ b/web-client/src/presenter/sequences/gotoTrialSessionsSequence.ts @@ -9,8 +9,8 @@ import { parallel } from 'cerebral/factories'; import { setAllAndCurrentJudgesAction } from '../actions/setAllAndCurrentJudgesAction'; import { setJudgeUserAction } from '../actions/setJudgeUserAction'; import { setNotificationsAction } from '../actions/setNotificationsAction'; -import { setTrialSessionsAction } from '../actions/TrialSession/setTrialSessionsAction'; import { setTrialSessionsFiltersAction } from '../actions/TrialSession/setTrialSessionsFiltersAction'; +import { setTrialSessionsPageAction } from '@web-client/presenter/actions/TrialSession/setTrialSessionsPageAction'; import { setupCurrentPageAction } from '../actions/setupCurrentPageAction'; import { startWebSocketConnectionSequenceDecorator } from '../utilities/startWebSocketConnectionSequenceDecorator'; @@ -23,7 +23,7 @@ export const gotoTrialSessionsSequence = parallel([ [getJudgeForCurrentUserAction, setJudgeUserAction], [getNotificationsAction, setNotificationsAction], - [getTrialSessionsAction, setTrialSessionsAction], + [getTrialSessionsAction, setTrialSessionsPageAction], [ getUsersInSectionAction({ section: 'judge' }), setAllAndCurrentJudgesAction, diff --git a/web-client/src/presenter/state.ts b/web-client/src/presenter/state.ts index bc46747db93..fe5039b30cc 100644 --- a/web-client/src/presenter/state.ts +++ b/web-client/src/presenter/state.ts @@ -91,6 +91,7 @@ import { getOrdinalValuesForUploadIteration } from './computeds/selectDocumentTy import { headerHelper } from './computeds/headerHelper'; import { initialCustomCaseReportState } from './customCaseReportState'; import { initialPendingReportsState } from '@web-client/presenter/state/pendingReportState'; +import { initialTrialSessionPageState } from '@web-client/presenter/state/trialSessionsPageState'; import { initialTrialSessionState } from '@web-client/presenter/state/trialSessionState'; import { initialTrialSessionWorkingCopyState } from '@web-client/presenter/state/trialSessionWorkingCopyState'; import { internalPetitionPartiesHelper } from './computeds/internalPetitionPartiesHelper'; @@ -839,6 +840,7 @@ export const baseState = { name: '', }, trialSessionWorkingCopy: cloneDeep(initialTrialSessionWorkingCopyState), + trialSessionsPage: cloneDeep(initialTrialSessionPageState), user: cloneDeep(emptyUserState), userContactEditProgress: {} as { inProgress?: boolean }, users: [] as RawUser[], diff --git a/web-client/src/presenter/state/trialSessionsPageState.ts b/web-client/src/presenter/state/trialSessionsPageState.ts new file mode 100644 index 00000000000..7c90373ab1c --- /dev/null +++ b/web-client/src/presenter/state/trialSessionsPageState.ts @@ -0,0 +1,14 @@ +import { TrialSessionInfoDTO } from '@shared/business/dto/trialSessions/TrialSessionInfoDTO'; +import { TrialSessionProceedingType } from '@shared/business/entities/EntityConstants'; + +export const initialTrialSessionPageState = { + filters: { + isCalendared: true, // This filter is relly just if the user is on the "Calendared" or "New" tab + judgeId: 'All', + proceedingType: 'All' as TrialSessionProceedingType, + sessionStatus: 'All', + sessionType: 'All', + trialLocation: 'All', + }, + trialSessions: [] as TrialSessionInfoDTO[], +}; diff --git a/web-client/src/views/TrialSessions/TrialSessions.tsx b/web-client/src/views/TrialSessions/TrialSessions.tsx index 2f32c8e590b..0d37a937290 100644 --- a/web-client/src/views/TrialSessions/TrialSessions.tsx +++ b/web-client/src/views/TrialSessions/TrialSessions.tsx @@ -1,5 +1,4 @@ import { BigHeader } from '../BigHeader'; -import { BindedSelect } from '@web-client/ustc-ui/BindedSelect/BindedSelect'; import { Button } from '../../ustc-ui/Button/Button'; import { ErrorNotification } from '../ErrorNotification'; import { @@ -141,24 +140,22 @@ const TrialSessionFilters = connect( > Filter by - {}} > - + - - + {}} > {Object.values(SESSION_TYPES).map(sessionType => ( @@ -180,17 +177,17 @@ const TrialSessionFilters = connect( {sessionType} ))} - - + {trialSessionsHelper.showNewTrialSession && (
@@ -44,38 +34,42 @@ export const TrialSessionsTable = connect( {trialSessionsHelper.showSessionStatus && } - {formattedTrialSessions.map(trialDate => ( - - - - - - - {trialDate.sessions.map(item => ( - + {trialSessionsHelper.trialSessionRows.map(row => ( + <> + {isTrialSessionWeek(row) && ( + + + + + + )} + {isTrialSessionRow(row) && ( + - + - - - + + + {trialSessionsHelper.showNoticeIssued && ( - + )} {trialSessionsHelper.showSessionStatus && ( - + )} - ))} - + )} + ))}
Session Status
-

- {'Week of '} - {trialDate.dateFormatted} -

-
+

+ {'Week of '} + {row.dateFormatted} +

+
- {item.showAlertForNOTTReminder && ( + {row.showAlertForNOTTReminder && ( )} - {item.formattedStartDate} + {row.formattedStartDate} {item.formattedEstimatedEndDate}{row.formattedEstimatedEndDate} - {item.swingSession && ( + {row.swingSession && ( - {item.trialLocation} + {row.trialLocation} {item.proceedingType}{item.sessionType}{item.judge && item.judge.name}{row.proceedingType}{row.sessionType}{row.judge && row.judge.name}{item.formattedNoticeIssuedDate}{row.formattedNoticeIssuedDate}{item.sessionStatus}{row.sessionStatus}
- {formattedTrialSessions.length === 0 && ( + {trialSessionsHelper.trialSessionRows.length === 0 && (

There are no trial sessions.

)} From ab196e6ca350996fceb703040eaa0e1f42623f6f Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 3 Sep 2024 10:42:17 -0700 Subject: [PATCH 06/96] 10409: Add sorting --- web-api/storage/fixtures/seed/efcms-local.json | 2 +- .../src/presenter/computeds/trialSessionsHelper.ts | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/web-api/storage/fixtures/seed/efcms-local.json b/web-api/storage/fixtures/seed/efcms-local.json index aef5e5985bb..0558990ebf0 100644 --- a/web-api/storage/fixtures/seed/efcms-local.json +++ b/web-api/storage/fixtures/seed/efcms-local.json @@ -50345,7 +50345,7 @@ { "caseOrder": [], "gsi1pk": "trial-session-catalog", - "sessionStatus": "New", + "sessionStatus": "Open", "trialLocation": "Denver, Colorado", "proceedingType": "In Person", "createdAt": "2019-11-02T05:00:00.000Z", diff --git a/web-client/src/presenter/computeds/trialSessionsHelper.ts b/web-client/src/presenter/computeds/trialSessionsHelper.ts index a9ef10e83be..e8731b94bd5 100644 --- a/web-client/src/presenter/computeds/trialSessionsHelper.ts +++ b/web-client/src/presenter/computeds/trialSessionsHelper.ts @@ -66,7 +66,16 @@ export const trialSessionsHelper = ( .filter(trialSession => { if (filters.trialLocation === 'All') return true; return filters.trialLocation === trialSession.trialLocation; + }) + .sort((sessionA, sessionB) => { + if (sessionA.startDate === sessionB.startDate) { + const sessionATrialLocation = sessionA.trialLocation || ''; + const sessionBTrialLocation = sessionA.trialLocation || ''; + return sessionATrialLocation.localeCompare(sessionBTrialLocation); + } + return sessionA.startDate.localeCompare(sessionB.startDate); }); + const trialSessionRows = formatTrialSessions({ judgeAssociatedToUser: judge, trialSessions: filteredTrialSessions, From 6cb5fde7b62fe8c19f7a86c0a848ab65f65819d5 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 3 Sep 2024 11:51:11 -0700 Subject: [PATCH 07/96] 10409: Add blue rows to display session weeks --- .../computeds/trialSessionsHelper.ts | 47 ++++++++++++++----- .../TrialSessions/TrialSessionsTable.tsx | 6 +-- 2 files changed, 37 insertions(+), 16 deletions(-) diff --git a/web-client/src/presenter/computeds/trialSessionsHelper.ts b/web-client/src/presenter/computeds/trialSessionsHelper.ts index e8731b94bd5..755166e874b 100644 --- a/web-client/src/presenter/computeds/trialSessionsHelper.ts +++ b/web-client/src/presenter/computeds/trialSessionsHelper.ts @@ -1,5 +1,6 @@ import { FORMATS, + createDateAtStartOfWeekEST, formatDateString, } from '@shared/business/utilities/DateHandler'; import { Get } from 'cerebral'; @@ -10,7 +11,6 @@ import { state } from '@web-client/presenter/app.cerebral'; export const trialSessionsHelper = ( get: Get, ): { - additionalColumnsShown: number; showNewTrialSession: boolean; showNoticeIssued: boolean; showSessionStatus: boolean; @@ -27,11 +27,6 @@ export const trialSessionsHelper = ( const isNewTab = tab === 'new'; const isCalendared = tab === 'calendared'; - let additionalColumnsShown = 0; - if (isCalendared) { - additionalColumnsShown = 1; - } - const showCurrentJudgesOnly = isNewTab; let trialSessionJudges; @@ -82,7 +77,6 @@ export const trialSessionsHelper = ( }); return { - additionalColumnsShown, showNewTrialSession: permissions.CREATE_TRIAL_SESSION, showNoticeIssued: isCalendared, showSessionStatus: isCalendared, @@ -96,12 +90,13 @@ type TrialSessionRow = { trialSessionId: string; showAlertForNOTTReminder: boolean; alertMessageForNOTT: string; - formattedStartDate: string; + formattedStartDate: string; //MM/DD/YYYY formattedEstimatedEndDate: string; swingSession: boolean; userIsAssignedToSession: boolean; trialLocation: string; proceedingType: string; + startDate: string; // ISO format sessionType: string; judge?: { name: string; userId: string }; formattedNoticeIssuedDate: string; @@ -109,8 +104,8 @@ type TrialSessionRow = { }; type TrialSessionWeek = { - startOfWeekSortable: string; - dateFormatted: string; + sessionWeekStartDate: string; + formattedSessionWeekStartDate: string; }; export function isTrialSessionRow(item: any): item is TrialSessionRow { @@ -118,7 +113,7 @@ export function isTrialSessionRow(item: any): item is TrialSessionRow { } export function isTrialSessionWeek(item: any): item is TrialSessionWeek { - return !!item?.startOfWeekSortable; + return !!item?.sessionWeekStartDate; } const formatTrialSessions = ({ @@ -168,6 +163,7 @@ const formatTrialSessions = ({ sessionStatus: trialSession.sessionStatus, sessionType: trialSession.sessionType, showAlertForNOTTReminder, + startDate: trialSession.startDate, swingSession: !!trialSession.swingSession, trialLocation: trialSession.trialLocation || '', trialSessionId: trialSession.trialSessionId || '', @@ -176,5 +172,32 @@ const formatTrialSessions = ({ }, ); - return trialSessionRows; + const trialSessionWithStartWeeks: (TrialSessionRow | TrialSessionWeek)[] = []; + + let lastSessionWeek: TrialSessionWeek = { + formattedSessionWeekStartDate: '', + sessionWeekStartDate: '', + }; + trialSessionRows.forEach(trialSession => { + const trialSessionStartOfWeek = createDateAtStartOfWeekEST( + trialSession.startDate, + FORMATS.ISO, + ); + if (lastSessionWeek.sessionWeekStartDate < trialSessionStartOfWeek) { + const formattedSessionWeekStartDate = createDateAtStartOfWeekEST( + trialSession.startDate, + FORMATS.MONTH_DAY_YEAR, + ); + + lastSessionWeek = { + formattedSessionWeekStartDate, + sessionWeekStartDate: trialSessionStartOfWeek, + }; + + trialSessionWithStartWeeks.push(lastSessionWeek); + } + trialSessionWithStartWeeks.push(trialSession); + }); + + return trialSessionWithStartWeeks; }; diff --git a/web-client/src/views/TrialSessions/TrialSessionsTable.tsx b/web-client/src/views/TrialSessions/TrialSessionsTable.tsx index 1ce8175d36c..396b24fd192 100644 --- a/web-client/src/views/TrialSessions/TrialSessionsTable.tsx +++ b/web-client/src/views/TrialSessions/TrialSessionsTable.tsx @@ -39,12 +39,10 @@ export const TrialSessionsTable = connect( {isTrialSessionWeek(row) && ( - +

{'Week of '} - {row.dateFormatted} + {row.formattedSessionWeekStartDate}

From f285df6173c8132a69fc34052509d9f28f0b868b Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 3 Sep 2024 11:52:24 -0700 Subject: [PATCH 08/96] 10409: organize functions --- .../computeds/trialSessionsHelper.ts | 58 +++++++++---------- 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/web-client/src/presenter/computeds/trialSessionsHelper.ts b/web-client/src/presenter/computeds/trialSessionsHelper.ts index 755166e874b..ebdc1e85347 100644 --- a/web-client/src/presenter/computeds/trialSessionsHelper.ts +++ b/web-client/src/presenter/computeds/trialSessionsHelper.ts @@ -86,36 +86,6 @@ export const trialSessionsHelper = ( }; }; -type TrialSessionRow = { - trialSessionId: string; - showAlertForNOTTReminder: boolean; - alertMessageForNOTT: string; - formattedStartDate: string; //MM/DD/YYYY - formattedEstimatedEndDate: string; - swingSession: boolean; - userIsAssignedToSession: boolean; - trialLocation: string; - proceedingType: string; - startDate: string; // ISO format - sessionType: string; - judge?: { name: string; userId: string }; - formattedNoticeIssuedDate: string; - sessionStatus: string; -}; - -type TrialSessionWeek = { - sessionWeekStartDate: string; - formattedSessionWeekStartDate: string; -}; - -export function isTrialSessionRow(item: any): item is TrialSessionRow { - return !!item?.trialSessionId; -} - -export function isTrialSessionWeek(item: any): item is TrialSessionWeek { - return !!item?.sessionWeekStartDate; -} - const formatTrialSessions = ({ judgeAssociatedToUser, trialSessions, @@ -201,3 +171,31 @@ const formatTrialSessions = ({ return trialSessionWithStartWeeks; }; + +type TrialSessionRow = { + trialSessionId: string; + showAlertForNOTTReminder: boolean; + alertMessageForNOTT: string; + formattedStartDate: string; //MM/DD/YYYY + formattedEstimatedEndDate: string; + swingSession: boolean; + userIsAssignedToSession: boolean; + trialLocation: string; + proceedingType: string; + startDate: string; // ISO format + sessionType: string; + judge?: { name: string; userId: string }; + formattedNoticeIssuedDate: string; + sessionStatus: string; +}; +export function isTrialSessionRow(item: any): item is TrialSessionRow { + return !!item?.trialSessionId; +} + +type TrialSessionWeek = { + sessionWeekStartDate: string; + formattedSessionWeekStartDate: string; +}; +export function isTrialSessionWeek(item: any): item is TrialSessionWeek { + return !!item?.sessionWeekStartDate; +} From 59626764eca6ad0f6c2fb6427c8dcadacf240f90 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 3 Sep 2024 13:06:26 -0700 Subject: [PATCH 09/96] 10409: Update Default state of filters --- web-client/src/presenter/state/trialSessionsPageState.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web-client/src/presenter/state/trialSessionsPageState.ts b/web-client/src/presenter/state/trialSessionsPageState.ts index 1643371d0bc..f0c77f51ae2 100644 --- a/web-client/src/presenter/state/trialSessionsPageState.ts +++ b/web-client/src/presenter/state/trialSessionsPageState.ts @@ -5,7 +5,7 @@ const filters: TrialSessionsFilters = { currentTab: 'calendared' as 'calendared' | 'new', judgeId: 'All', proceedingType: 'All' as TrialSessionProceedingType, - sessionStatus: 'All', + sessionStatus: 'Open', sessionType: 'All', trialLocation: 'All', }; From c857773e2cf0aa4a30e2fccf72ce8ee857ff97f1 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 3 Sep 2024 15:35:41 -0700 Subject: [PATCH 10/96] 10409 fix radio buttons --- .../src/views/TrialSessions/TrialSessions.tsx | 130 +++++++++--------- 1 file changed, 67 insertions(+), 63 deletions(-) diff --git a/web-client/src/views/TrialSessions/TrialSessions.tsx b/web-client/src/views/TrialSessions/TrialSessions.tsx index 880c87f4816..8ab91648e5e 100644 --- a/web-client/src/views/TrialSessions/TrialSessions.tsx +++ b/web-client/src/views/TrialSessions/TrialSessions.tsx @@ -97,69 +97,73 @@ const TrialSessionFilters = connect( <>
{trialSessionsHelper.showSessionStatus && ( -
- Session Status - { - setTrialSessionsFiltersSequence({ - sessionStatus: e.target.value, - }); - }} - /> - - { - setTrialSessionsFiltersSequence({ - sessionStatus: e.target.value, - }); - }} - /> - - { - setTrialSessionsFiltersSequence({ - sessionStatus: e.target.value, - }); - }} - /> - -
+
+
+ + Session Status + + { + setTrialSessionsFiltersSequence({ + sessionStatus: e.target.value, + }); + }} + /> + + { + setTrialSessionsFiltersSequence({ + sessionStatus: e.target.value, + }); + }} + /> + + { + setTrialSessionsFiltersSequence({ + sessionStatus: e.target.value, + }); + }} + /> + +
+
)}
From e6d3dbb2613e803ecea55708026499fea14d69f7 Mon Sep 17 00:00:00 2001 From: Javis Sullivan Date: Wed, 4 Sep 2024 11:10:31 -0400 Subject: [PATCH 11/96] 10409 fix setTrialSessionsFiltersActions test --- .../setTrialSessionsFiltersAction.test.ts | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/web-client/src/presenter/actions/TrialSession/setTrialSessionsFiltersAction.test.ts b/web-client/src/presenter/actions/TrialSession/setTrialSessionsFiltersAction.test.ts index dc70b6861ae..130c782be17 100644 --- a/web-client/src/presenter/actions/TrialSession/setTrialSessionsFiltersAction.test.ts +++ b/web-client/src/presenter/actions/TrialSession/setTrialSessionsFiltersAction.test.ts @@ -1,23 +1,16 @@ -import { presenter } from '../../presenter-mock'; import { runAction } from '@web-client/presenter/test.cerebral'; import { setTrialSessionsFiltersAction } from './setTrialSessionsFiltersAction'; describe('setTrialSessionsFiltersAction', () => { it('call the use case to get the eligible cases', async () => { const result = await runAction(setTrialSessionsFiltersAction, { - modules: { - presenter, - }, props: { - query: { - trialLocation: 'Baton Rouge, Louisiana', - trialSessionId: '123', - }, + trialLocation: 'Baton Rouge, Louisiana', }, - state: { screenMetadata: {} }, - }); - expect(result.state.screenMetadata.trialSessionFilters).toEqual({ - trialLocation: 'Baton Rouge, Louisiana', }); + + expect(result.state.trialSessionsPage.filters.trialLocation).toEqual( + 'Baton Rouge, Louisiana', + ); }); }); From 2171a5fc8e9ffc9627673aa5e19323f9f54d3c2c Mon Sep 17 00:00:00 2001 From: Javis Sullivan Date: Thu, 5 Sep 2024 11:13:39 -0400 Subject: [PATCH 12/96] 10409: fix some tests, wip still figuring out purpose of other legacy tests --- .../computeds/trialSessionsHelper.test.ts | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/web-client/src/presenter/computeds/trialSessionsHelper.test.ts b/web-client/src/presenter/computeds/trialSessionsHelper.test.ts index 025c74c8e6c..c67d57abf51 100644 --- a/web-client/src/presenter/computeds/trialSessionsHelper.test.ts +++ b/web-client/src/presenter/computeds/trialSessionsHelper.test.ts @@ -262,11 +262,6 @@ describe('trialSessionsHelper', () => { it('returns only non-legacy judges when state.currentViewMetadata.trialSessions.tab is Open', () => { const result = runCompute(trialSessionsHelper, { state: { - currentViewMetadata: { - trialSessions: { - tab: 'open', - }, - }, judges: [ { name: 'I am not a legacy judge part 2', role: ROLES.judge }, ], @@ -275,6 +270,7 @@ describe('trialSessionsHelper', () => { { name: 'I am a legacy judge', role: ROLES.legacyJudge }, ], permissions: getUserPermissions(docketClerk1User), + trialSessionsPage: { trialSessions: [] }, }, }); @@ -412,12 +408,8 @@ describe('trialSessionsHelper', () => { it('should return showNewTrialSession as true when current user has CREATE_TRIAL_SESSION permission', () => { const result = runCompute(trialSessionsHelper, { state: { - currentViewMetadata: { - trialSessions: { - tab: 'open', - }, - }, permissions: getUserPermissions(docketClerk1User), + trialSessionsPage: { trialSessions: [] }, }, }); @@ -427,12 +419,8 @@ describe('trialSessionsHelper', () => { it('should return showNewTrialSession as false when current user does not have CREATE_TRIAL_SESSION permission', () => { const result = runCompute(trialSessionsHelper, { state: { - currentViewMetadata: { - trialSessions: { - tab: 'open', - }, - }, permissions: getUserPermissions(judgeUser), + trialSessionsPage: { trialSessions: [] }, }, }); From df76cb5da1b1e3c62184ad978874f41d23568a77 Mon Sep 17 00:00:00 2001 From: Javis Sullivan Date: Thu, 5 Sep 2024 13:00:35 -0400 Subject: [PATCH 13/96] 10409 fix trialSessionsHelper.test.ts tests --- .../computeds/trialSessionsHelper.test.ts | 347 +++--------------- 1 file changed, 44 insertions(+), 303 deletions(-) diff --git a/web-client/src/presenter/computeds/trialSessionsHelper.test.ts b/web-client/src/presenter/computeds/trialSessionsHelper.test.ts index c67d57abf51..3c1d0178b50 100644 --- a/web-client/src/presenter/computeds/trialSessionsHelper.test.ts +++ b/web-client/src/presenter/computeds/trialSessionsHelper.test.ts @@ -1,6 +1,8 @@ import { ROLES } from '../../../../shared/src/business/entities/EntityConstants'; +import { cloneDeep } from 'lodash'; import { docketClerk1User, judgeUser } from '@shared/test/mockUsers'; import { getUserPermissions } from '@shared/authorization/getUserPermissions'; +import { initialTrialSessionPageState } from '../state/trialSessionsPageState'; import { runCompute } from '@web-client/presenter/test.cerebral'; import { trialSessionsHelper as trialSessionsHelperComputed } from './trialSessionsHelper'; import { withAppContextDecorator } from '../../withAppContext'; @@ -10,61 +12,31 @@ const trialSessionsHelper = withAppContextDecorator( ); describe('trialSessionsHelper', () => { - describe('showNoticeIssued', () => { - it('should show the Notice Issued column for `open` sessions', () => { - const result = runCompute(trialSessionsHelper, { - state: { - currentViewMetadata: { - trialSessions: { - tab: 'open', - }, - }, - permissions: getUserPermissions(docketClerk1User), - }, - }); - - expect(result.showNoticeIssued).toEqual(true); - }); - - it('should NOT show the Notice Issued column for `new` sessions', () => { - const result = runCompute(trialSessionsHelper, { - state: { - currentViewMetadata: { - trialSessions: { - tab: 'new', - }, - }, - permissions: getUserPermissions(docketClerk1User), - }, - }); + let trialSessionsPageState: typeof initialTrialSessionPageState; + beforeEach(() => { + trialSessionsPageState = cloneDeep(initialTrialSessionPageState); + }); - expect(result.showNoticeIssued).toEqual(false); - }); + describe('showNoticeIssued', () => { + it('should show the Notice Issued column when on the calendared tab', () => { + trialSessionsPageState.filters.currentTab = 'calendared'; - it('should NOT show the Notice Issued column for `closed` sessions', () => { const result = runCompute(trialSessionsHelper, { state: { - currentViewMetadata: { - trialSessions: { - tab: 'closed', - }, - }, permissions: getUserPermissions(docketClerk1User), + trialSessionsPage: trialSessionsPageState, }, }); - expect(result.showNoticeIssued).toEqual(false); + expect(result.showNoticeIssued).toEqual(true); }); - it('should NOT show the Notice Issued column for `all` sessions', () => { + it('should NOT show the Notice Issued column when on the new tab', () => { + trialSessionsPageState.filters.currentTab = 'new'; const result = runCompute(trialSessionsHelper, { state: { - currentViewMetadata: { - trialSessions: { - tab: 'all', - }, - }, permissions: getUserPermissions(docketClerk1User), + trialSessionsPage: trialSessionsPageState, }, }); @@ -73,60 +45,26 @@ describe('trialSessionsHelper', () => { }); describe('showSessionStatus', () => { - it('should show the Session Status column for `all` sessions', () => { - const result = runCompute(trialSessionsHelper, { - state: { - currentViewMetadata: { - trialSessions: { - tab: 'all', - }, - }, - permissions: getUserPermissions(docketClerk1User), - }, - }); + it('should show the Session Status column when on the `calendared` tab', () => { + trialSessionsPageState.filters.currentTab = 'calendared'; - expect(result.showSessionStatus).toEqual(true); - }); - - it('should NOT show the Session Status column for `new` sessions', () => { const result = runCompute(trialSessionsHelper, { state: { - currentViewMetadata: { - trialSessions: { - tab: 'new', - }, - }, permissions: getUserPermissions(docketClerk1User), + trialSessionsPage: trialSessionsPageState, }, }); - expect(result.showSessionStatus).toEqual(false); + expect(result.showSessionStatus).toEqual(true); }); - it('should NOT show the Session Status column for `open` sessions', () => { - const result = runCompute(trialSessionsHelper, { - state: { - currentViewMetadata: { - trialSessions: { - tab: 'open', - }, - }, - permissions: getUserPermissions(docketClerk1User), - }, - }); + it('should NOT show the Session Status column when on the `new` tab', () => { + trialSessionsPageState.filters.currentTab = 'new'; - expect(result.showSessionStatus).toEqual(false); - }); - - it('should NOT show the Session Status column for `closed` sessions', () => { const result = runCompute(trialSessionsHelper, { state: { - currentViewMetadata: { - trialSessions: { - tab: 'closed', - }, - }, permissions: getUserPermissions(docketClerk1User), + trialSessionsPage: trialSessionsPageState, }, }); @@ -134,209 +72,39 @@ describe('trialSessionsHelper', () => { }); }); - describe('additionalColumnsShown', () => { - it('should show 0 additional table columns for `new` sessions', () => { - const result = runCompute(trialSessionsHelper, { - state: { - currentViewMetadata: { - trialSessions: { - tab: 'new', - }, - }, - permissions: getUserPermissions(docketClerk1User), - }, - }); - - expect(result.additionalColumnsShown).toEqual(0); - }); - - it('should show 0 additional table columns for `closed` sessions', () => { - const result = runCompute(trialSessionsHelper, { - state: { - currentViewMetadata: { - trialSessions: { - tab: 'closed', - }, - }, - permissions: getUserPermissions(docketClerk1User), - }, - }); - - expect(result.additionalColumnsShown).toEqual(0); - }); - - it('should show 1 additional table column for `open` sessions', () => { - const result = runCompute(trialSessionsHelper, { - state: { - currentViewMetadata: { - trialSessions: { - tab: 'open', - }, - }, - permissions: getUserPermissions(docketClerk1User), - }, - }); - - expect(result.additionalColumnsShown).toEqual(1); - }); - - it('should show 1 additional table column for `all` sessions', () => { - const result = runCompute(trialSessionsHelper, { - state: { - currentViewMetadata: { - trialSessions: { - tab: 'all', - }, - }, - permissions: getUserPermissions(docketClerk1User), - }, - }); - - expect(result.additionalColumnsShown).toEqual(1); - }); - }); - describe('showUnassignedJudgeFilter', () => { - it('should show the `unassigned` judge filter for `new` sessions', () => { - const result = runCompute(trialSessionsHelper, { - state: { - currentViewMetadata: { - trialSessions: { - tab: 'new', - }, - }, - permissions: getUserPermissions(docketClerk1User), - }, - }); - - expect(result.showUnassignedJudgeFilter).toBeTruthy(); - }); + it('should show the `unassigned` judge filter when on the new tab', () => { + trialSessionsPageState.filters.currentTab = 'new'; - it('should NOT show the `unassigned` judge filter for `open` sessions', () => { const result = runCompute(trialSessionsHelper, { state: { - currentViewMetadata: { - trialSessions: { - tab: 'open', - }, - }, permissions: getUserPermissions(docketClerk1User), + trialSessionsPage: trialSessionsPageState, }, }); - expect(result.showUnassignedJudgeFilter).toBeFalsy(); + expect(result.showUnassignedJudgeFilter).toBeTruthy(); }); - it('should NOT show the `unassigned` judge filter for `closed` sessions', () => { - const result = runCompute(trialSessionsHelper, { - state: { - currentViewMetadata: { - trialSessions: { - tab: 'close', - }, - }, - permissions: getUserPermissions(docketClerk1User), - }, - }); + it('should show the `unassigned` judge filter when on the calendared tab', () => { + trialSessionsPageState.filters.currentTab = 'calendared'; - expect(result.showUnassignedJudgeFilter).toBeFalsy(); - }); - - it('should NOT show the `unassigned` judge filter for `all` sessions', () => { const result = runCompute(trialSessionsHelper, { state: { - currentViewMetadata: { - trialSessions: { - tab: 'all', - }, - }, permissions: getUserPermissions(docketClerk1User), + trialSessionsPage: trialSessionsPageState, }, }); - expect(result.showUnassignedJudgeFilter).toBeFalsy(); + expect(result.showUnassignedJudgeFilter).toEqual(false); }); }); describe('trialSessionJudges', () => { - it('returns only non-legacy judges when state.currentViewMetadata.trialSessions.tab is Open', () => { - const result = runCompute(trialSessionsHelper, { - state: { - judges: [ - { name: 'I am not a legacy judge part 2', role: ROLES.judge }, - ], - legacyAndCurrentJudges: [ - { name: 'I am not a legacy judge', role: ROLES.judge }, - { name: 'I am a legacy judge', role: ROLES.legacyJudge }, - ], - permissions: getUserPermissions(docketClerk1User), - trialSessionsPage: { trialSessions: [] }, - }, - }); - - expect(result.trialSessionJudges).toMatchObject( - expect.arrayContaining([ - expect.objectContaining({ - name: 'I am not a legacy judge part 2', - role: ROLES.judge, - }), - ]), - ); - expect(result.trialSessionJudges).not.toMatchObject( - expect.arrayContaining([ - expect.objectContaining({ - name: 'I am a legacy judge', - role: ROLES.legacyJudge, - }), - ]), - ); - }); - - it('returns only non-legacy judges when state.currentViewMetadata.trialSessions.tab is New', () => { - const result = runCompute(trialSessionsHelper, { - state: { - currentViewMetadata: { - trialSessions: { - tab: 'new', - }, - }, - judges: [ - { name: 'I am not a legacy judge part 2', role: ROLES.judge }, - ], - legacyAndCurrentJudges: [ - { name: 'I am not a legacy judge', role: ROLES.judge }, - { name: 'I am a legacy judge', role: ROLES.legacyJudge }, - ], - permissions: getUserPermissions(docketClerk1User), - }, - }); - - expect(result.trialSessionJudges).toMatchObject( - expect.arrayContaining([ - expect.objectContaining({ - name: 'I am not a legacy judge part 2', - role: ROLES.judge, - }), - ]), - ); - expect(result.trialSessionJudges).not.toMatchObject( - expect.arrayContaining([ - expect.objectContaining({ - name: 'I am a legacy judge', - role: ROLES.legacyJudge, - }), - ]), - ); - }); - - it('returns all current and legacy judges when state.currentViewMetadata.trialSessions.tab is Closed', () => { + it('returns all current and legacy judges when the current tab is calendared', () => { + trialSessionsPageState.filters.currentTab = 'calendared'; const result = runCompute(trialSessionsHelper, { state: { - currentViewMetadata: { - trialSessions: { - tab: 'closed', - }, - }, judges: [ { name: 'I am not a legacy judge part 2', role: ROLES.judge }, ], @@ -345,35 +113,20 @@ describe('trialSessionsHelper', () => { { name: 'I am a legacy judge', role: ROLES.legacyJudge }, ], permissions: getUserPermissions(docketClerk1User), + trialSessionsPage: trialSessionsPageState, }, }); - expect(result.trialSessionJudges).toMatchObject( - expect.arrayContaining([ - expect.objectContaining({ - name: 'I am not a legacy judge', - role: ROLES.judge, - }), - ]), - ); - expect(result.trialSessionJudges).toMatchObject( - expect.arrayContaining([ - expect.objectContaining({ - name: 'I am a legacy judge', - role: ROLES.legacyJudge, - }), - ]), - ); + expect(result.trialSessionJudges).toEqual([ + { name: 'I am not a legacy judge', role: ROLES.judge }, + { name: 'I am a legacy judge', role: ROLES.legacyJudge }, + ]); }); - it('returns all current and legacy judges when state.currentViewMetadata.trialSessions.tab is All', () => { + it('returns only non-legacy judges when the current tab is new', () => { + trialSessionsPageState.filters.currentTab = 'new'; const result = runCompute(trialSessionsHelper, { state: { - currentViewMetadata: { - trialSessions: { - tab: 'all', - }, - }, judges: [ { name: 'I am not a legacy judge part 2', role: ROLES.judge }, ], @@ -382,25 +135,13 @@ describe('trialSessionsHelper', () => { { name: 'I am a legacy judge', role: ROLES.legacyJudge }, ], permissions: getUserPermissions(docketClerk1User), + trialSessionsPage: trialSessionsPageState, }, }); - expect(result.trialSessionJudges).toMatchObject( - expect.arrayContaining([ - expect.objectContaining({ - name: 'I am not a legacy judge', - role: ROLES.judge, - }), - ]), - ); - expect(result.trialSessionJudges).toMatchObject( - expect.arrayContaining([ - expect.objectContaining({ - name: 'I am a legacy judge', - role: ROLES.legacyJudge, - }), - ]), - ); + expect(result.trialSessionJudges).toEqual([ + { name: 'I am not a legacy judge part 2', role: ROLES.judge }, + ]); }); }); @@ -409,7 +150,7 @@ describe('trialSessionsHelper', () => { const result = runCompute(trialSessionsHelper, { state: { permissions: getUserPermissions(docketClerk1User), - trialSessionsPage: { trialSessions: [] }, + trialSessionsPage: trialSessionsPageState, }, }); @@ -420,7 +161,7 @@ describe('trialSessionsHelper', () => { const result = runCompute(trialSessionsHelper, { state: { permissions: getUserPermissions(judgeUser), - trialSessionsPage: { trialSessions: [] }, + trialSessionsPage: trialSessionsPageState, }, }); From 17582f8859781572fb6e1489f00dda3e5f2c204d Mon Sep 17 00:00:00 2001 From: Javis Sullivan Date: Thu, 5 Sep 2024 14:04:02 -0400 Subject: [PATCH 14/96] 10409 add some tests for new table functionality --- .../computeds/trialSessionsHelper.test.ts | 121 +++++++++++++++++- 1 file changed, 119 insertions(+), 2 deletions(-) diff --git a/web-client/src/presenter/computeds/trialSessionsHelper.test.ts b/web-client/src/presenter/computeds/trialSessionsHelper.test.ts index 3c1d0178b50..a5567f3574c 100644 --- a/web-client/src/presenter/computeds/trialSessionsHelper.test.ts +++ b/web-client/src/presenter/computeds/trialSessionsHelper.test.ts @@ -1,10 +1,17 @@ -import { ROLES } from '../../../../shared/src/business/entities/EntityConstants'; +import { + ROLES, + TRIAL_SESSION_SCOPE_TYPES, +} from '../../../../shared/src/business/entities/EntityConstants'; +import { TrialSessionInfoDTO } from '@shared/business/dto/trialSessions/TrialSessionInfoDTO'; import { cloneDeep } from 'lodash'; import { docketClerk1User, judgeUser } from '@shared/test/mockUsers'; import { getUserPermissions } from '@shared/authorization/getUserPermissions'; import { initialTrialSessionPageState } from '../state/trialSessionsPageState'; +import { + isTrialSessionRow, + trialSessionsHelper as trialSessionsHelperComputed, +} from './trialSessionsHelper'; import { runCompute } from '@web-client/presenter/test.cerebral'; -import { trialSessionsHelper as trialSessionsHelperComputed } from './trialSessionsHelper'; import { withAppContextDecorator } from '../../withAppContext'; const trialSessionsHelper = withAppContextDecorator( @@ -13,8 +20,36 @@ const trialSessionsHelper = withAppContextDecorator( describe('trialSessionsHelper', () => { let trialSessionsPageState: typeof initialTrialSessionPageState; + let trialSession1: TrialSessionInfoDTO; + let trialSession2: TrialSessionInfoDTO; beforeEach(() => { trialSessionsPageState = cloneDeep(initialTrialSessionPageState); + trialSession1 = { + isCalendared: true, + judge: { name: 'howdy', userId: '1' }, + proceedingType: 'Remote', + sessionScope: TRIAL_SESSION_SCOPE_TYPES.locationBased, + sessionStatus: 'Open', + sessionType: 'Regular', + startDate: '2022-03-01T21:00:00.000Z', + term: 'Winter', + termYear: '2022', + trialLocation: 'Boise', + trialSessionId: '294038', + }; + trialSession2 = { + isCalendared: true, + judge: { name: 'howdy', userId: '2' }, + proceedingType: 'Remote', + sessionScope: TRIAL_SESSION_SCOPE_TYPES.locationBased, + sessionStatus: 'Open', + sessionType: 'Regular', + startDate: '2022-03-01T21:00:00.000Z', + term: 'Winter', + termYear: '2022', + trialLocation: 'Boise', + trialSessionId: '392810', + }; }); describe('showNoticeIssued', () => { @@ -168,4 +203,86 @@ describe('trialSessionsHelper', () => { expect(result.showNewTrialSession).toEqual(false); }); }); + + describe('trialSessionRows', () => { + describe('filters', () => { + it('should filter trial sessions by judge', () => { + trialSession1.judge!.userId = '1'; + trialSession2.judge!.userId = '2'; + trialSessionsPageState.trialSessions = [trialSession1, trialSession2]; + trialSessionsPageState.filters.judgeId = '1'; + + const result = runCompute(trialSessionsHelper, { + state: { + permissions: getUserPermissions(docketClerk1User), + trialSessionsPage: trialSessionsPageState, + }, + }); + + const trialSessionsOnly = + result.trialSessionRows.filter(isTrialSessionRow); + expect(trialSessionsOnly.length).toEqual(1); + }); + + it('should not filter trial sessions by judge when judge filter is All', () => { + trialSessionsPageState.trialSessions = [trialSession1, trialSession2]; + trialSessionsPageState.filters.judgeId = 'All'; + + const result = runCompute(trialSessionsHelper, { + state: { + permissions: getUserPermissions(docketClerk1User), + trialSessionsPage: trialSessionsPageState, + }, + }); + + const trialSessionsOnly = + result.trialSessionRows.filter(isTrialSessionRow); + expect(trialSessionsOnly.length).toEqual(2); + }); + }); + describe('formatting', () => { + it('sets userIsAssignedToSession false for all sessions if there is no associated judgeUser', () => { + trialSessionsPageState.trialSessions = [trialSession1, trialSession2]; + + const result = runCompute(trialSessionsHelper, { + state: { + judgeUser: {}, + permissions: getUserPermissions(docketClerk1User), + trialSessionsPage: trialSessionsPageState, + }, + }); + + const trialSessionsOnly = + result.trialSessionRows.filter(isTrialSessionRow); + trialSessionsOnly.forEach(t => { + expect(t.userIsAssignedToSession).toEqual(false); + }); + }); + it('sets userIsAssignedToSession true for all sessions the judge user is assigned to', () => { + trialSession1.judge!.userId = '1'; + trialSession2.judge!.userId = '2'; + trialSessionsPageState.trialSessions = [trialSession1, trialSession2]; + + const result = runCompute(trialSessionsHelper, { + state: { + judgeUser: { + userId: '1', + }, + permissions: getUserPermissions(docketClerk1User), + trialSessionsPage: trialSessionsPageState, + }, + }); + + const trialSessionsOnly = + result.trialSessionRows.filter(isTrialSessionRow); + trialSessionsOnly.forEach(t => { + if (t.trialSessionId === trialSession1.trialSessionId) { + expect(t.userIsAssignedToSession).toEqual(true); + } else { + expect(t.userIsAssignedToSession).toEqual(false); + } + }); + }); + }); + }); }); From 21ea134edb35f5ace22cdba2a2c699baca849550 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 5 Sep 2024 12:34:12 -0700 Subject: [PATCH 15/96] 10409: Remove unused --- .../src/presenter/computeds/formattedTrialSessions.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/web-client/src/presenter/computeds/formattedTrialSessions.ts b/web-client/src/presenter/computeds/formattedTrialSessions.ts index e33ec8d5669..b36acdb161f 100644 --- a/web-client/src/presenter/computeds/formattedTrialSessions.ts +++ b/web-client/src/presenter/computeds/formattedTrialSessions.ts @@ -181,7 +181,11 @@ const sortSessionsByTerm = ({ export const formattedTrialSessions = ( get: Get, applicationContext: ClientApplicationContext, -): any => { +): { + sessionsByTerm: any[]; + showSwingSessionList: boolean; + showSwingSessionOption: boolean; +} => { const judgeId = get(state.judgeUser.userId); const currentTrialSessionId = get(state.trialSession.trialSessionId); const currentUser = get(state.user); @@ -249,8 +253,6 @@ export const formattedTrialSessions = ( } return { - filteredTrialSessions: filterFormattedSessionsByStatus(formattedSessions), - formattedSessions, sessionsByTerm, showSwingSessionList: get(state.form.swingSession), showSwingSessionOption: sessionsByTerm.length > 0, From fd8aacae24587abbb627f19e9847a40863422883 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 5 Sep 2024 13:53:25 -0700 Subject: [PATCH 16/96] 10409: Add tests for filtering trial sessions --- .../computeds/trialSessionsHelper.test.ts | 159 ++++++++++++++++++ .../computeds/trialSessionsHelper.ts | 5 - 2 files changed, 159 insertions(+), 5 deletions(-) diff --git a/web-client/src/presenter/computeds/trialSessionsHelper.test.ts b/web-client/src/presenter/computeds/trialSessionsHelper.test.ts index a5567f3574c..3caa8da55aa 100644 --- a/web-client/src/presenter/computeds/trialSessionsHelper.test.ts +++ b/web-client/src/presenter/computeds/trialSessionsHelper.test.ts @@ -1,5 +1,8 @@ import { ROLES, + SESSION_STATUS_TYPES, + SESSION_TYPES, + TRIAL_SESSION_PROCEEDING_TYPES, TRIAL_SESSION_SCOPE_TYPES, } from '../../../../shared/src/business/entities/EntityConstants'; import { TrialSessionInfoDTO } from '@shared/business/dto/trialSessions/TrialSessionInfoDTO'; @@ -239,6 +242,162 @@ describe('trialSessionsHelper', () => { result.trialSessionRows.filter(isTrialSessionRow); expect(trialSessionsOnly.length).toEqual(2); }); + + it('should show open and closed trial sessions when the current tab is calendared', () => { + trialSession1.isCalendared = false; + trialSession2.isCalendared = true; + trialSession2.sessionStatus = SESSION_STATUS_TYPES.open; + trialSessionsPageState.trialSessions = [trialSession1, trialSession2]; + + const result = runCompute(trialSessionsHelper, { + state: { + permissions: getUserPermissions(docketClerk1User), + trialSessionsPage: trialSessionsPageState, + }, + }); + + const trialSessionsOnly = + result.trialSessionRows.filter(isTrialSessionRow); + + expect(trialSessionsOnly[0].trialSessionId).toEqual( + trialSession2.trialSessionId, + ); + }); + + it('should show remote proceeding types when proceeding type is remote', () => { + trialSession1.proceedingType = TRIAL_SESSION_PROCEEDING_TYPES.remote; + trialSession2.proceedingType = TRIAL_SESSION_PROCEEDING_TYPES.inPerson; + trialSessionsPageState.trialSessions = [trialSession1, trialSession2]; + + const result = runCompute(trialSessionsHelper, { + state: { + permissions: getUserPermissions(docketClerk1User), + trialSessionsPage: trialSessionsPageState, + }, + }); + + const trialSessionsOnly = + result.trialSessionRows.filter(isTrialSessionRow); + + expect(trialSessionsOnly[0].trialSessionId).toEqual( + trialSession1.trialSessionId, + ); + }); + + it('should show open trial sessions when session status filter is open', () => { + trialSession1.sessionStatus = SESSION_STATUS_TYPES.open; + trialSession1.isCalendared = true; + trialSession2.sessionStatus = SESSION_STATUS_TYPES.closed; + trialSession2.isCalendared = true; + trialSessionsPageState.filters.sessionStatus = + SESSION_STATUS_TYPES.open; + trialSessionsPageState.trialSessions = [trialSession1, trialSession2]; + + 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 show closed trial sessions when session status filter is closed', () => { + trialSession1.sessionStatus = SESSION_STATUS_TYPES.closed; + trialSession1.isCalendared = true; + trialSession2.sessionStatus = SESSION_STATUS_TYPES.open; + trialSession2.isCalendared = true; + trialSessionsPageState.filters.sessionStatus = + SESSION_STATUS_TYPES.closed; + trialSessionsPageState.trialSessions = [trialSession1, trialSession2]; + + 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 ignore session status filter when the current tab is new', () => { + trialSession1.sessionStatus = SESSION_STATUS_TYPES.closed; + trialSession1.isCalendared = true; + trialSession2.sessionStatus = SESSION_STATUS_TYPES.new; + trialSession2.isCalendared = false; + trialSessionsPageState.filters.sessionStatus = + SESSION_STATUS_TYPES.closed; + trialSessionsPageState.filters.currentTab = 'new'; + trialSessionsPageState.trialSessions = [trialSession1, trialSession2]; + + 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( + trialSession2.trialSessionId, + ); + }); + + it('should show regular trial sessions when session type filter is regular', () => { + trialSession1.sessionType = SESSION_TYPES.regular; + trialSession2.sessionType = SESSION_TYPES.hybridSmall; + trialSessionsPageState.filters.sessionType = SESSION_TYPES.regular; + trialSessionsPageState.trialSessions = [trialSession1, trialSession2]; + + 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 show trial sessions in honolulu when trial sessions when trial location filter is honolulu', () => { + trialSession1.trialLocation = 'Honolulu, Hawaii'; + trialSession2.trialLocation = 'Jacksonville, Florida'; + trialSessionsPageState.filters.trialLocation = 'Honolulu, Hawaii'; + trialSessionsPageState.trialSessions = [trialSession1, trialSession2]; + + 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, + ); + }); }); describe('formatting', () => { it('sets userIsAssignedToSession false for all sessions if there is no associated judgeUser', () => { diff --git a/web-client/src/presenter/computeds/trialSessionsHelper.ts b/web-client/src/presenter/computeds/trialSessionsHelper.ts index ebdc1e85347..c68fb57960c 100644 --- a/web-client/src/presenter/computeds/trialSessionsHelper.ts +++ b/web-client/src/presenter/computeds/trialSessionsHelper.ts @@ -63,11 +63,6 @@ export const trialSessionsHelper = ( return filters.trialLocation === trialSession.trialLocation; }) .sort((sessionA, sessionB) => { - if (sessionA.startDate === sessionB.startDate) { - const sessionATrialLocation = sessionA.trialLocation || ''; - const sessionBTrialLocation = sessionA.trialLocation || ''; - return sessionATrialLocation.localeCompare(sessionBTrialLocation); - } return sessionA.startDate.localeCompare(sessionB.startDate); }); From e3ba3138a0b333354d94c4c4147d68730d2025b2 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 5 Sep 2024 15:41:21 -0700 Subject: [PATCH 17/96] 10409: Move trial sessions filtering tests over to trialSessionsHelper --- ...ns.filterFormattedSessionsByStatus.test.ts | 81 ----- ...rmattedTrialSessions.formatSession.test.ts | 101 ------ .../computeds/formattedTrialSessions.test.ts | 326 +----------------- .../computeds/trialSessionsHelper.test.ts | 125 ++++++- 4 files changed, 126 insertions(+), 507 deletions(-) delete mode 100644 web-client/src/presenter/computeds/formattedTrialSessions.filterFormattedSessionsByStatus.test.ts delete mode 100644 web-client/src/presenter/computeds/formattedTrialSessions.formatSession.test.ts diff --git a/web-client/src/presenter/computeds/formattedTrialSessions.filterFormattedSessionsByStatus.test.ts b/web-client/src/presenter/computeds/formattedTrialSessions.filterFormattedSessionsByStatus.test.ts deleted file mode 100644 index 192a278a4e7..00000000000 --- a/web-client/src/presenter/computeds/formattedTrialSessions.filterFormattedSessionsByStatus.test.ts +++ /dev/null @@ -1,81 +0,0 @@ -import { filterFormattedSessionsByStatus } from './formattedTrialSessions'; - -describe('formattedTrialSessions filterFormattedSessionsByStatus', () => { - let TRIAL_SESSIONS_LIST: any[] = []; - let trialTerms; - - beforeEach(() => { - TRIAL_SESSIONS_LIST = [ - { - caseOrder: [], - judge: { name: '1', userId: '1' }, - sessionStatus: 'Open', - startDate: '2019-11-25T15:00:00.000Z', - swingSession: true, - trialLocation: 'Hartford, Connecticut', - }, - { - caseOrder: [], - judge: { name: '2', userId: '2' }, - sessionStatus: 'New', - startDate: '2019-11-25T15:00:00.000Z', - swingSession: true, - trialClerk: { name: '10', userId: '10' }, - trialLocation: 'Knoxville, TN', - }, - { - caseOrder: [], - judge: { name: '3', userId: '3' }, - noticeIssuedDate: '2019-07-25T15:00:00.000Z', - sessionStatus: 'Closed', - startDate: '2019-11-27T15:00:00.000Z', - swingSession: true, - trialLocation: 'Jacksonville, FL', - }, - ]; - - trialTerms = [ - { - dateFormatted: 'October 1, 2022', - sessions: [TRIAL_SESSIONS_LIST[0]], - }, - { - dateFormatted: 'November 1, 2022', - sessions: [TRIAL_SESSIONS_LIST[1]], - }, - { - dateFormatted: 'December 1, 2022', - sessions: [TRIAL_SESSIONS_LIST[2]], - }, - ]; - }); - - it('filters closed cases when all trial session cases are inactive', () => { - const results = filterFormattedSessionsByStatus(trialTerms); - expect(results.Closed.length).toEqual(1); - }); - - it('filters open trial sessions', () => { - const results = filterFormattedSessionsByStatus(trialTerms); - expect(results.Open.length).toEqual(1); - }); - - it('filters new trial sessions', () => { - const results = filterFormattedSessionsByStatus(trialTerms); - expect(results.New.length).toEqual(1); - }); - - it('filters all trial sessions (returns everything) with the sessionStatus on the session', () => { - const results = filterFormattedSessionsByStatus(trialTerms); - - const getSessionCount = trialTermsList => { - let count = 0; - trialTermsList.forEach(term => (count += term.sessions.length)); - return count; - }; - - expect(results.All.length).toEqual(trialTerms.length); - expect(getSessionCount(results.All)).toEqual(getSessionCount(trialTerms)); - expect(results.All[0].sessions[0]).toHaveProperty('sessionStatus'); - }); -}); diff --git a/web-client/src/presenter/computeds/formattedTrialSessions.formatSession.test.ts b/web-client/src/presenter/computeds/formattedTrialSessions.formatSession.test.ts deleted file mode 100644 index b028396fd82..00000000000 --- a/web-client/src/presenter/computeds/formattedTrialSessions.formatSession.test.ts +++ /dev/null @@ -1,101 +0,0 @@ -import { - SESSION_TYPES, - TRIAL_SESSION_PROCEEDING_TYPES, -} from '../../../../shared/src/business/entities/EntityConstants'; -import { applicationContext } from '../../applicationContext'; -import { formatSession } from './formattedTrialSessions'; - -describe('formattedTrialSessions formatSession', () => { - const mockTrialSessions = [ - { - caseOrder: [], - isCalendared: true, - judge: { name: '3', userId: '3' }, - noticeIssuedDate: '2019-07-25T15:00:00.000Z', - proceedingType: TRIAL_SESSION_PROCEEDING_TYPES.inPerson, - sessionType: SESSION_TYPES.regular, - startDate: '2019-11-27T15:00:00.000Z', - swingSession: true, - term: 'Winter', - trialLocation: 'Jacksonville, FL', - }, - { - caseOrder: [], - estimatedEndDate: '2045-02-17T15:00:00.000Z', - judge: { name: '6', userId: '6' }, - proceedingType: TRIAL_SESSION_PROCEEDING_TYPES.inPerson, - sessionType: SESSION_TYPES.regular, - startDate: '2044-02-17T15:00:00.000Z', - swingSession: false, - term: 'Spring', - trialLocation: 'Jacksonville, FL', - }, - ]; - - it('formats trial sessions correctly selecting startOfWeek and formatting start date, startOfWeekSortable, and formattedNoticeIssued', () => { - const result = formatSession(mockTrialSessions[0], applicationContext); - expect(result).toMatchObject({ - formattedNoticeIssuedDate: '07/25/2019', - formattedStartDate: '11/27/19', - judge: { name: '3', userId: '3' }, - startDate: '2019-11-27T15:00:00.000Z', - startOfWeek: 'November 25, 2019', - startOfWeekSortable: '20191125', - }); - }); - - it('should format start date and estimated end date as "MM/DD/YYYY"', () => { - const result = formatSession(mockTrialSessions[1], applicationContext); - expect(result).toMatchObject({ - formattedEstimatedEndDate: '02/17/45', - formattedStartDate: '02/17/44', - }); - }); - - describe('NOTT reminder', () => { - it('should set showAlertForNOTTReminder to true when the alert has not been previously dismissed and isStartDateWithinNOTTReminderRange is true', () => { - const session = formatSession( - { - ...mockTrialSessions[0], - dismissedAlertForNOTT: false, - isStartDateWithinNOTTReminderRange: true, - thirtyDaysBeforeTrialFormatted: '2/2/2022', - }, - applicationContext, - ); - - expect(session.showAlertForNOTTReminder).toBe(true); - expect(session.alertMessageForNOTT).toEqual( - 'The 30-day notice is due by 2/2/2022', - ); - }); - - it('should set showAlertForNOTTReminder to false when the alert has been previously dismissed', () => { - const session = formatSession( - { - ...mockTrialSessions[0], - dismissedAlertForNOTT: true, - isStartDateWithinNOTTReminderRange: true, - }, - applicationContext, - ); - - expect(session.showAlertForNOTTReminder).toBe(false); - expect(session.alertMessageForNOTT).toBeUndefined(); - }); - - it('should set showAlertForNOTTReminder to false when isStartDateWithinNOTTReminderRange is false', () => { - const session = formatSession( - { - ...mockTrialSessions[0], - dismissedAlertForNOTT: true, - isStartDateWithinNOTTReminderRange: false, - }, - applicationContext, - ); - - expect(session.showAlertForNOTTReminder).toBe(false); - expect(session.alertMessageForNOTT).toBeUndefined(); - }); - }); -}); diff --git a/web-client/src/presenter/computeds/formattedTrialSessions.test.ts b/web-client/src/presenter/computeds/formattedTrialSessions.test.ts index c30830cd766..b205166b314 100644 --- a/web-client/src/presenter/computeds/formattedTrialSessions.test.ts +++ b/web-client/src/presenter/computeds/formattedTrialSessions.test.ts @@ -1,12 +1,11 @@ import { FORMATS, formatNow, - prepareDateFromString, } from '../../../../shared/src/business/utilities/DateHandler'; import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; import { formatTrialSessionDisplayOptions } from './addToTrialSessionModalHelper'; import { formattedTrialSessions as formattedTrialSessionsComputed } from './formattedTrialSessions'; -import { judgeUser, petitionsClerkUser } from '@shared/test/mockUsers'; +import { judgeUser } from '@shared/test/mockUsers'; import { runCompute } from '@web-client/presenter/test.cerebral'; import { withAppContextDecorator } from '../../withAppContext'; jest.mock('./addToTrialSessionModalHelper.ts'); @@ -24,17 +23,8 @@ const formattedTrialSessions = withAppContextDecorator( }, ); -const getStartOfWeek = date => { - return prepareDateFromString(date).startOf('week').toFormat('DDD'); -}; - let nextYear; -const testTrialClerkUser = { - role: ROLES.trialClerk, - userId: '10', -}; - const baseState = { constants: { USER_ROLES: ROLES }, judgeUser, @@ -160,110 +150,11 @@ describe('formattedTrialSessions', () => { }, ]; - formatTrialSessionDisplayOptions.mockImplementation(session => session); - }); - - it('does not error if user is undefined', () => { - let error; - try { - runCompute(formattedTrialSessions, { - state: { - ...baseState, - trialSessions: TRIAL_SESSIONS_LIST, - user: judgeUser, - }, - }); - } catch (err) { - error = err; - } - expect(error).toBeUndefined(); - }); - - it('groups trial sessions into arrays according to session weeks', () => { - const result = runCompute(formattedTrialSessions, { - state: { - ...baseState, - trialSessions: TRIAL_SESSIONS_LIST, - user: judgeUser, - }, - }); - - expect(result.filteredTrialSessions).toBeDefined(); - expect(result.formattedSessions.length).toBe(4); - expect(result.formattedSessions[0].dateFormatted).toEqual( - 'November 25, 2019', - ); - expect(result.formattedSessions[1].dateFormatted).toEqual( - getStartOfWeek(result.formattedSessions[1].sessions[0].startDate), + (formatTrialSessionDisplayOptions as jest.Mock).mockImplementation( + session => session, ); }); - it('should filter trial sessions by judge', () => { - const result = runCompute(formattedTrialSessions, { - state: { - ...baseState, - screenMetadata: { - trialSessionFilters: { judge: { userId: judgeUser.userId } }, - }, - trialSessions: TRIAL_SESSIONS_LIST, - user: judgeUser, - }, - }); - expect(result.formattedSessions.length).toBe(1); - }); - - it('should double filter trial sessions', () => { - const result = runCompute(formattedTrialSessions, { - state: { - ...baseState, - screenMetadata: { - trialSessionFilters: { - proceedingType: TRIAL_SESSION_PROCEEDING_TYPES.inPerson, - sessionType: SESSION_TYPES.regular, - }, - }, - trialSessions: TRIAL_SESSIONS_LIST, - user: judgeUser, - }, - }); - const flattenedSessions = result.formattedSessions.flatMap( - week => week.sessions, - ); - expect(flattenedSessions.length).toBe(5); - }); - - it('returns all trial sessions if judge userId trial session filter is an empty string', () => { - const result = runCompute(formattedTrialSessions, { - state: { - ...baseState, - screenMetadata: { trialSessionFilters: { judge: { userId: '' } } }, - trialSessions: TRIAL_SESSIONS_LIST, - user: judgeUser, - }, - }); - expect(result.formattedSessions.length).toBe(4); - }); - - it('does NOT return the unassigned judge filter on trial sessions tabs other than "new"', () => { - let result = runCompute(formattedTrialSessions, { - state: { - ...baseState, - currentViewMetadata: { - trialSessions: { - tab: 'open', - }, - }, - screenMetadata: { - trialSessionFilters: { judge: { userId: 'unassigned' } }, - }, - trialSessions: TRIAL_SESSIONS_LIST, - user: judgeUser, - }, - }); - - expect(result.formattedSessions.length).toBe(4); - }); - it('shows swing session option only if matching term and term year is found', () => { let form = { term: 'Winter', @@ -440,215 +331,4 @@ describe('formattedTrialSessions', () => { ), ).toBeUndefined(); }); - - it('sets userIsAssignedToSession false for all sessions if there is no associated judgeUser', () => { - const result = runCompute(formattedTrialSessions, { - state: { - ...baseState, - judgeUser: undefined, - trialSessions: TRIAL_SESSIONS_LIST, - user: petitionsClerkUser, - }, - }); - - expect(result.formattedSessions[0]).toMatchObject({ - dateFormatted: 'November 25, 2019', - sessions: [ - { - judge: { name: '5', userId: '5' }, - userIsAssignedToSession: false, - }, - { - judge: { name: judgeUser.name, userId: judgeUser.userId }, - userIsAssignedToSession: false, - }, - { - judge: { name: '2', userId: '2' }, - userIsAssignedToSession: false, - }, - { - judge: { name: '3', userId: '3' }, - userIsAssignedToSession: false, - }, - { - judge: { name: '4', userId: '4' }, - userIsAssignedToSession: false, - }, - ], - }); - - expect(result.formattedSessions[1]).toMatchObject({ - dateFormatted: getStartOfWeek( - result.formattedSessions[1].sessions[0].startDate, - ), - sessions: [ - { - judge: { name: '55', userId: '55' }, - userIsAssignedToSession: false, - }, - ], - }); - }); - - it('sets userIsAssignedToSession true for sessions the judge user is assigned to', () => { - const result = runCompute(formattedTrialSessions, { - state: { - ...baseState, - trialSessions: TRIAL_SESSIONS_LIST, - user: judgeUser, - }, - }); - expect(result.formattedSessions).toMatchObject([ - { - dateFormatted: 'November 25, 2019', - sessions: [ - { - judge: { name: '5', userId: '5' }, - userIsAssignedToSession: false, - }, - { - judge: { name: judgeUser.name, userId: judgeUser.userId }, - userIsAssignedToSession: true, - }, - { - judge: { name: '2', userId: '2' }, - userIsAssignedToSession: false, - }, - { - judge: { name: '3', userId: '3' }, - userIsAssignedToSession: false, - }, - { - judge: { name: '4', userId: '4' }, - userIsAssignedToSession: false, - }, - ], - }, - { - dateFormatted: getStartOfWeek( - result.formattedSessions[1].sessions[0].startDate, - ), - sessions: [ - { - judge: { name: '55', userId: '55' }, - userIsAssignedToSession: false, - }, - ], - }, - { - dateFormatted: 'November 23, 2020', - sessions: [ - { - judge: { name: '88', userId: '88' }, - userIsAssignedToSession: false, - }, - ], - }, - { - dateFormatted: 'February 17, 2025', - sessions: [ - { - caseOrder: [], - estimatedEndDate: '2045-02-17T15:00:00.000Z', - formattedEstimatedEndDate: '02/17/45', - formattedNoticeIssuedDate: '', - formattedStartDate: '02/17/25', - isCalendared: true, - judge: { name: '6', userId: '6' }, - proceedingType: 'In Person', - sessionStatus: 'Open', - sessionType: SESSION_TYPES.regular, - showAlertForNOTTReminder: undefined, - startDate: '2025-02-17T15:00:00.000Z', - startOfWeek: 'February 17, 2025', - startOfWeekSortable: '20250217', - swingSession: false, - term: 'Spring', - trialLocation: 'Jacksonville, FL', - userIsAssignedToSession: false, - }, - ], - }, - ]); - }); - - it('sets userIsAssignedToSession true for sessions the current trial clerk user is assigned to', () => { - const result = runCompute(formattedTrialSessions, { - state: { - ...baseState, - judgeUser: undefined, - trialSessions: TRIAL_SESSIONS_LIST, - user: testTrialClerkUser, - }, - }); - - expect(result.formattedSessions[0]).toMatchObject({ - dateFormatted: 'November 25, 2019', - sessions: [ - { - judge: { name: '5', userId: '5' }, - userIsAssignedToSession: false, - }, - { - judge: { name: judgeUser.name, userId: judgeUser.userId }, - userIsAssignedToSession: false, - }, - { - trialClerk: { name: '10', userId: '10' }, - userIsAssignedToSession: true, - }, - { - judge: { name: '3', userId: '3' }, - userIsAssignedToSession: false, - }, - { - judge: { name: '4', userId: '4' }, - userIsAssignedToSession: false, - }, - ], - }); - - expect(result.formattedSessions[1]).toMatchObject({ - dateFormatted: getStartOfWeek( - result.formattedSessions[1].sessions[0].startDate, - ), - sessions: [ - { - judge: { name: '55', userId: '55' }, - userIsAssignedToSession: false, - }, - ], - }); - }); - - it('sets userIsAssignedToSession false if the current user and session have no associated judge', () => { - const startDate = `${nextYear}-02-17T15:00:00.000Z`; - const result = runCompute(formattedTrialSessions, { - state: { - ...baseState, - judgeUser: undefined, - trialSessions: [ - { - caseOrder: [], - judge: undefined, - sessionStatus: 'Open', - startDate, - swingSession: false, - trialLocation: 'Jacksonville, FL', - }, - ], - user: petitionsClerkUser, - }, - }); - expect(result.formattedSessions).toMatchObject([ - { - dateFormatted: getStartOfWeek(startDate), - sessions: [ - { - userIsAssignedToSession: false, - }, - ], - }, - ]); - }); }); diff --git a/web-client/src/presenter/computeds/trialSessionsHelper.test.ts b/web-client/src/presenter/computeds/trialSessionsHelper.test.ts index 3caa8da55aa..50f0d892615 100644 --- a/web-client/src/presenter/computeds/trialSessionsHelper.test.ts +++ b/web-client/src/presenter/computeds/trialSessionsHelper.test.ts @@ -12,6 +12,7 @@ import { getUserPermissions } from '@shared/authorization/getUserPermissions'; import { initialTrialSessionPageState } from '../state/trialSessionsPageState'; import { isTrialSessionRow, + isTrialSessionWeek, trialSessionsHelper as trialSessionsHelperComputed, } from './trialSessionsHelper'; import { runCompute } from '@web-client/presenter/test.cerebral'; @@ -399,8 +400,31 @@ describe('trialSessionsHelper', () => { ); }); }); + describe('formatting', () => { - it('sets userIsAssignedToSession false for all sessions if there is no associated judgeUser', () => { + it('should format trialSessions startDate, endDate, noticeIssuedDate', () => { + trialSession1.noticeIssuedDate = '2020-05-03T21:00:00.000Z'; + trialSession1.startDate = '2020-05-03T21:00:00.000Z'; + trialSession1.estimatedEndDate = '2020-05-03T21:00:00.000Z'; + trialSessionsPageState.trialSessions = [trialSession1]; + + const result = runCompute(trialSessionsHelper, { + state: { + permissions: getUserPermissions(docketClerk1User), + trialSessionsPage: trialSessionsPageState, + }, + }); + + const trialSessionsOnly = + result.trialSessionRows.filter(isTrialSessionRow); + expect(trialSessionsOnly[0]).toMatchObject({ + formattedEstimatedEndDate: '05/03/20', + formattedNoticeIssuedDate: '05/03/2020', + formattedStartDate: '05/03/20', + }); + }); + + it('should set userIsAssignedToSession false for all sessions if there is no associated judgeUser', () => { trialSessionsPageState.trialSessions = [trialSession1, trialSession2]; const result = runCompute(trialSessionsHelper, { @@ -417,7 +441,8 @@ describe('trialSessionsHelper', () => { expect(t.userIsAssignedToSession).toEqual(false); }); }); - it('sets userIsAssignedToSession true for all sessions the judge user is assigned to', () => { + + it('should set userIsAssignedToSession true for all sessions the judge user is assigned to', () => { trialSession1.judge!.userId = '1'; trialSession2.judge!.userId = '2'; trialSessionsPageState.trialSessions = [trialSession1, trialSession2]; @@ -442,6 +467,102 @@ describe('trialSessionsHelper', () => { } }); }); + + it('should show an alertMessage for NOTT reminders when the user has not dismissed the alert and the start day is within the reminder range', () => { + trialSession1.dismissedAlertForNOTT = false; + trialSession1.isStartDateWithinNOTTReminderRange = true; + trialSession1.thirtyDaysBeforeTrialFormatted = '06/03/13'; + trialSessionsPageState.trialSessions = [trialSession1]; + + const result = runCompute(trialSessionsHelper, { + state: { + permissions: getUserPermissions(docketClerk1User), + trialSessionsPage: trialSessionsPageState, + }, + }); + + const trialSessionsOnly = + result.trialSessionRows.filter(isTrialSessionRow); + expect(trialSessionsOnly[0].alertMessageForNOTT).toEqual( + `The 30-day notice is due by ${trialSession1.thirtyDaysBeforeTrialFormatted}`, + ); + expect(trialSessionsOnly[0].showAlertForNOTTReminder).toEqual(true); + }); + }); + + describe('sorting', () => { + it('should order trial sessions by start date from oldest to newest', () => { + trialSession1.startDate = '2022-03-01T21:00:00.000Z'; + trialSession2.startDate = '2020-03-01T21:00:00.000Z'; + trialSessionsPageState.trialSessions = [trialSession1, trialSession2]; + + const result = runCompute(trialSessionsHelper, { + state: { + permissions: getUserPermissions(docketClerk1User), + trialSessionsPage: trialSessionsPageState, + }, + }); + + const trialSessionsOnly = + result.trialSessionRows.filter(isTrialSessionRow); + expect(trialSessionsOnly.length).toEqual(2); + expect(trialSessionsOnly[0].trialSessionId).toEqual( + trialSession2.trialSessionId, + ); + expect(trialSessionsOnly[1].trialSessionId).toEqual( + trialSession1.trialSessionId, + ); + }); + }); + + describe('trial session weeks', () => { + it('should insert one trialSessionWeek row when two trial sessions are within the same week(week starts on Monday EST)', () => { + trialSession1.startDate = '2024-09-03T21:00:00.000Z'; // A Tuesday + trialSession2.startDate = '2024-09-05T21:00:00.000Z'; // A Thursday + trialSessionsPageState.trialSessions = [trialSession1, trialSession2]; + + const result = runCompute(trialSessionsHelper, { + state: { + permissions: getUserPermissions(docketClerk1User), + trialSessionsPage: trialSessionsPageState, + }, + }); + + const trialSessionWeeks = + result.trialSessionRows.filter(isTrialSessionWeek); + expect(trialSessionWeeks).toEqual([ + { + formattedSessionWeekStartDate: 'September 2, 2024', + sessionWeekStartDate: '2024-09-02T04:00:00.000+00:00', + }, + ]); + }); + + it('should insert two trialSessionWeek rows when two trial sessions are not within the same week(week starts on Monday EST)', () => { + trialSession1.startDate = '2024-09-03T21:00:00.000Z'; // A Tuesday + trialSession2.startDate = '2024-09-12T21:00:00.000Z'; // A Thursday next week + trialSessionsPageState.trialSessions = [trialSession1, trialSession2]; + + const result = runCompute(trialSessionsHelper, { + state: { + permissions: getUserPermissions(docketClerk1User), + trialSessionsPage: trialSessionsPageState, + }, + }); + + const trialSessionWeeks = + result.trialSessionRows.filter(isTrialSessionWeek); + expect(trialSessionWeeks).toEqual([ + { + formattedSessionWeekStartDate: 'September 2, 2024', + sessionWeekStartDate: '2024-09-02T04:00:00.000+00:00', + }, + { + formattedSessionWeekStartDate: 'September 9, 2024', + sessionWeekStartDate: '2024-09-09T04:00:00.000+00:00', + }, + ]); + }); }); }); }); From f4be15cdc9acfd57aced09d16c6dbff80d0f3713 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 5 Sep 2024 16:10:38 -0700 Subject: [PATCH 18/96] 10409: Add filtering for unassigned judges --- .../computeds/trialSessionsHelper.test.ts | 21 +++++++++++++++++++ .../computeds/trialSessionsHelper.ts | 1 + .../src/views/TrialSessions/TrialSessions.tsx | 9 ++++---- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/web-client/src/presenter/computeds/trialSessionsHelper.test.ts b/web-client/src/presenter/computeds/trialSessionsHelper.test.ts index 50f0d892615..b8f07bcc8b0 100644 --- a/web-client/src/presenter/computeds/trialSessionsHelper.test.ts +++ b/web-client/src/presenter/computeds/trialSessionsHelper.test.ts @@ -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'; diff --git a/web-client/src/presenter/computeds/trialSessionsHelper.ts b/web-client/src/presenter/computeds/trialSessionsHelper.ts index c68fb57960c..aa7cd6a73f9 100644 --- a/web-client/src/presenter/computeds/trialSessionsHelper.ts +++ b/web-client/src/presenter/computeds/trialSessionsHelper.ts @@ -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 => { diff --git a/web-client/src/views/TrialSessions/TrialSessions.tsx b/web-client/src/views/TrialSessions/TrialSessions.tsx index 8ab91648e5e..34cb2ba0df8 100644 --- a/web-client/src/views/TrialSessions/TrialSessions.tsx +++ b/web-client/src/views/TrialSessions/TrialSessions.tsx @@ -178,6 +178,7 @@ const TrialSessionFilters = connect( From 6a2246b6be53519852c580e82a1055d8367a8314 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 9 Sep 2024 13:32:44 -0700 Subject: [PATCH 22/96] 10409: Update swing session helper. fix sorting --- .../computeds/formattedTrialSessions.ts | 231 +----------------- 1 file changed, 1 insertion(+), 230 deletions(-) diff --git a/web-client/src/presenter/computeds/formattedTrialSessions.ts b/web-client/src/presenter/computeds/formattedTrialSessions.ts index 62f1a63c3e2..c862965248c 100644 --- a/web-client/src/presenter/computeds/formattedTrialSessions.ts +++ b/web-client/src/presenter/computeds/formattedTrialSessions.ts @@ -4,169 +4,6 @@ import { TrialSessionInfoDTO } from '@shared/business/dto/trialSessions/TrialSes import { state } from '@web-client/presenter/app.cerebral'; import { trialSessionOptionText } from './addToTrialSessionModalHelper'; -// export const formatSession = (session, applicationContext) => { -// const { DATE_FORMATS } = applicationContext.getConstants(); - -// session.startOfWeek = createDateAtStartOfWeekEST( -// session.startDate, -// DATE_FORMATS.MONTH_DAY_YEAR, -// ); - -// session.startOfWeekSortable = createDateAtStartOfWeekEST( -// session.startDate, -// DATE_FORMATS.YYYYMMDD_NUMERIC, -// ); - -// session.formattedStartDate = applicationContext -// .getUtilities() -// .formatDateString(session.startDate, DATE_FORMATS.MMDDYY); - -// session.formattedEstimatedEndDate = applicationContext -// .getUtilities() -// .formatDateString(session.estimatedEndDate, DATE_FORMATS.MMDDYY); - -// session.formattedNoticeIssuedDate = applicationContext -// .getUtilities() -// .formatDateString(session.noticeIssuedDate, DATE_FORMATS.MMDDYYYY); - -// session.showAlertForNOTTReminder = -// !session.dismissedAlertForNOTT && -// session.isStartDateWithinNOTTReminderRange; - -// if (session.showAlertForNOTTReminder) { -// session.alertMessageForNOTT = `The 30-day notice is due by ${session.thirtyDaysBeforeTrialFormatted}`; -// } - -// return session; -// }; - -// export const sessionSorter = (sessionList, dateSort = 'asc') => { -// return orderBy( -// sessionList, -// ['startDate', 'trialLocation'], -// [dateSort, 'asc'], -// ); -// }; - -// export const filterFormattedSessionsByStatus = trialTerms => { -// const sessionSort = { -// All: 'desc', -// Closed: 'desc', -// New: 'asc', -// Open: 'asc', -// }; - -// const filteredbyStatusType = { -// All: [], -// Closed: [], -// New: [], -// Open: [], -// }; - -// const initTermIndex = (trialTerm, filtered) => { -// let termIndex = filtered.findIndex( -// term => term.dateFormatted === trialTerm.dateFormatted, -// ); - -// if (termIndex === -1) { -// filtered.push({ -// dateFormatted: trialTerm.dateFormatted, -// sessions: [], -// startOfWeekSortable: trialTerm.startOfWeekSortable, -// }); -// termIndex = filtered.length - 1; -// } - -// return termIndex; -// }; - -// trialTerms.forEach(trialTerm => { -// trialTerm.sessions.forEach(session => { -// const termIndex = initTermIndex( -// trialTerm, -// filteredbyStatusType[session.sessionStatus], -// ); - -// if (!session.judge) { -// session.judge = { -// name: 'Unassigned', -// userId: 'unassigned', -// }; -// } -// // Add session status to filtered session -// filteredbyStatusType[session.sessionStatus][termIndex].sessions.push( -// session, -// ); - -// // Push to all -// const allTermIndex = initTermIndex(trialTerm, filteredbyStatusType.All); -// filteredbyStatusType.All[allTermIndex].sessions.push(session); -// }); -// }); - -// for (let [status, entryTrialTerms] of Object.entries(filteredbyStatusType)) { -// filteredbyStatusType[status] = orderBy( -// entryTrialTerms, -// ['startOfWeekSortable'], -// [sessionSort[status]], -// ); -// entryTrialTerms.forEach(trialTerm => { -// trialTerm.sessions = sessionSorter(trialTerm.sessions, [ -// sessionSort[status], -// ]); -// }); -// } - -// return filteredbyStatusType; -// }; - -// const sortSessionsByTerm = ({ -// applicationContext, -// currentTrialSessionId, -// selectedTerm, -// selectedTermYear, -// sessions, -// }: { -// applicationContext: ClientApplicationContext; -// selectedTermYear: string; -// selectedTerm: string; -// sessions: RawTrialSession[]; -// currentTrialSessionId?: string; -// }) => { -// const sessionsByTermOrderedByTrialLocation = orderBy( -// sessions.filter( -// session => -// session.term === selectedTerm && session.termYear == selectedTermYear, -// ), -// 'trialLocation', -// ); - -// const sessionsGroupedByTrialLocation = groupBy( -// sessionsByTermOrderedByTrialLocation, -// 'trialLocation', -// ); - -// const sessionsOrderedChronologically = flatMap( -// sessionsGroupedByTrialLocation, -// group => { -// return orderBy(group, 'startDate', 'asc'); -// }, -// ); - -// const sessionsByTermFormatted = formatTrialSessionDisplayOptions( -// sessionsOrderedChronologically, -// applicationContext, -// ); - -// if (currentTrialSessionId) { -// return sessionsByTermFormatted.filter( -// session => session.trialSessionId !== currentTrialSessionId, -// ); -// } - -// return sessionsByTermFormatted; -// }; - export const formattedTrialSessions = ( get: Get, ): { @@ -194,7 +31,7 @@ export const formattedTrialSessions = ( ) .sort((sessionA, sessionB) => { const aTrialLocation = sessionA.trialLocation || ''; - const bTrialLocation = sessionA.trialLocation || ''; + const bTrialLocation = sessionB.trialLocation || ''; if (aTrialLocation === bTrialLocation) { return sessionA.startDate.localeCompare(sessionB.startDate); } @@ -208,72 +45,6 @@ export const formattedTrialSessions = ( }; }); - // const judgeId = get(state.judgeUser.userId); - // const currentTrialSessionId = get(state.trialSession.trialSessionId); - // const currentUser = get(state.user); - - // const trialSessionFilters = pickBy( - // omit(get(state.screenMetadata.trialSessionFilters), 'status'), - // identity, - // ); - // const judgeFilter = get( - // state.screenMetadata.trialSessionFilters.judge.userId, - // ); - - // const tab = get(state.currentViewMetadata.trialSessions.tab); - - // if (!judgeFilter || (tab !== 'new' && judgeFilter === 'unassigned')) { - // delete trialSessionFilters.judge; - // } - - // const sessions = filter(get(state.trialSessions), trialSessionFilters); - - // const formattedSessions = []; - // sessions.forEach(session => { - // const isJudgeUserAssigned = !!( - // session.judge?.userId === judgeId && judgeId - // ); - // const isTrialClerkUserAssigned = - // session.trialClerk?.userId === currentUser.userId; - - // session.userIsAssignedToSession = - // isJudgeUserAssigned || isTrialClerkUserAssigned; - - // const formattedSession = formatSession(session, applicationContext); - - // let sessionWeek = find(formattedSessions, { - // startOfWeekSortable: formattedSession.startOfWeekSortable, - // }); - - // if (!sessionWeek) { - // sessionWeek = { - // dateFormatted: formattedSession.startOfWeek, - // sessions: [], - // startOfWeekSortable: formattedSession.startOfWeekSortable, - // }; - // formattedSessions.push(sessionWeek); - // } - // sessionWeek.sessions.push(session); - // }); - - // formattedSessions.forEach( - // week => (week.sessions = sessionSorter(week.sessions)), - // ); - - // const selectedTerm = get(state.form.term); - // let sessionsByTerm: any[] = []; - - // if (selectedTerm) { - // const selectedTermYear = get(state.form.termYear); - // sessionsByTerm = sortSessionsByTerm({ - // applicationContext, - // currentTrialSessionId, - // selectedTerm, - // selectedTermYear, - // sessions, - // }); - // } - return { showSwingSessionList: get(state.form.swingSession), showSwingSessionOption: validSwingSessions.length > 0, From f92de6685fe1f302bd56345c04eeec87384e27f7 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 9 Sep 2024 14:21:48 -0700 Subject: [PATCH 23/96] 10409: Remove formattedTrialSessions and split into trialSessionsPage and add/edit trial sessions --- .../addTrialSessionInformationHelper.test.ts | 231 ++++++++++++++++++ .../addTrialSessionInformationHelper.ts | 43 +++- .../computeds/formattedTrialSessions.ts | 53 ---- web-client/src/presenter/state.ts | 4 - .../TrialSessions/SessionInformationForm.tsx | 24 +- 5 files changed, 285 insertions(+), 70 deletions(-) delete mode 100644 web-client/src/presenter/computeds/formattedTrialSessions.ts diff --git a/web-client/src/presenter/computeds/TrialSession/addTrialSessionInformationHelper.test.ts b/web-client/src/presenter/computeds/TrialSession/addTrialSessionInformationHelper.test.ts index dbc6603e246..c863f19b0d2 100644 --- a/web-client/src/presenter/computeds/TrialSession/addTrialSessionInformationHelper.test.ts +++ b/web-client/src/presenter/computeds/TrialSession/addTrialSessionInformationHelper.test.ts @@ -1,13 +1,46 @@ import { + SESSION_STATUS_TYPES, TRIAL_SESSION_PROCEEDING_TYPES, TRIAL_SESSION_SCOPE_TYPES, } from '../../../../../shared/src/business/entities/EntityConstants'; +import { TrialSessionInfoDTO } from '@shared/business/dto/trialSessions/TrialSessionInfoDTO'; import { addTrialSessionInformationHelper as addTrialSessionInformationHelperComputed } from './addTrialSessionInformationHelper'; import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; +import { docketClerk1User } from '@shared/test/mockUsers'; import { runCompute } from '@web-client/presenter/test.cerebral'; import { withAppContextDecorator } from '../../../withAppContext'; describe('addTrialSessionInformationHelper', () => { + let trialSession1: TrialSessionInfoDTO; + let trialSession2: TrialSessionInfoDTO; + beforeEach(() => { + trialSession1 = { + isCalendared: true, + judge: { name: 'howdy', userId: '1' }, + proceedingType: 'Remote', + sessionScope: TRIAL_SESSION_SCOPE_TYPES.locationBased, + sessionStatus: 'Open', + sessionType: 'Regular', + startDate: '2022-03-01T21:00:00.000Z', + term: 'Winter', + termYear: '2022', + trialLocation: 'Boise', + trialSessionId: '43bc50b8-8b0b-47db-817b-a666af7a703e', + }; + trialSession2 = { + isCalendared: true, + judge: { name: 'howdy', userId: '2' }, + proceedingType: 'Remote', + sessionScope: TRIAL_SESSION_SCOPE_TYPES.locationBased, + sessionStatus: 'Open', + sessionType: 'Regular', + startDate: '2022-03-01T21:00:00.000Z', + term: 'Winter', + termYear: '2022', + trialLocation: 'Boise', + trialSessionId: '933ac8d9-68f0-4bfa-b7be-99c465c6799e', + }; + }); const addTrialSessionInformationHelper = withAppContextDecorator( addTrialSessionInformationHelperComputed, { @@ -171,4 +204,202 @@ describe('addTrialSessionInformationHelper', () => { expect(result.sessionTypes).toEqual(['Special', 'Motion/Hearing']); }); }); + + describe('showSwingSessionList', () => { + it('should show the swing session options list when the user has selected that their trial session is part of a swing session', () => { + const result = runCompute(addTrialSessionInformationHelper, { + state: { + form: { swingSession: true }, + user: docketClerk1User, + }, + }); + + expect(result.showSwingSessionList).toEqual(true); + }); + + it('should not show the swing session options list when the user has not selected that their trial session is part of a swing session', () => { + const result = runCompute(addTrialSessionInformationHelper, { + state: { + form: { swingSession: false }, + user: docketClerk1User, + }, + }); + + expect(result.showSwingSessionList).toEqual(false); + }); + }); + + describe('showSwingSessionOption', () => { + it('should show the option to associate the current trial session with another swing session when there are valid swing session options', () => { + const term = 'Fall'; + const termYear = '2020'; + trialSession1.term = term; + trialSession1.termYear = termYear; + trialSession1.sessionStatus = SESSION_STATUS_TYPES.open; + + const result = runCompute(addTrialSessionInformationHelper, { + state: { + form: { swingSession: true, term, termYear }, + trialSession: { + trialSessionId: '74f24014-2cf1-4e97-b80a-40f970d5376d', + }, + trialSessions: [trialSession1], + user: docketClerk1User, + }, + }); + + expect(result.showSwingSessionOption).toEqual(true); + }); + + it('should not show the option to associate the current trial session with another swing session when there are no valid swing session options', () => { + const term = 'Fall'; + const termYear = '2020'; + + const result = runCompute(addTrialSessionInformationHelper, { + state: { + form: { swingSession: true, term, termYear }, + trialSession: { + trialSessionId: '74f24014-2cf1-4e97-b80a-40f970d5376d', + }, + trialSessions: [], + user: docketClerk1User, + }, + }); + + expect(result.showSwingSessionOption).toEqual(false); + }); + }); + + describe('swingSessions', () => { + describe('valid swing sessions', () => { + it('should show only trial sessions in the same term year as the current trial session', () => { + const term = 'Fall'; + const termYear = '2020'; + trialSession1.term = term; + trialSession1.termYear = termYear; + trialSession1.sessionStatus = SESSION_STATUS_TYPES.open; + trialSession2.term = term; + trialSession2.termYear = '2021'; + trialSession2.sessionStatus = SESSION_STATUS_TYPES.open; + + const result = runCompute(addTrialSessionInformationHelper, { + state: { + form: { swingSession: true, term, termYear }, + trialSession: { + trialSessionId: '74f24014-2cf1-4e97-b80a-40f970d5376d', + }, + trialSessions: [trialSession1, trialSession2], + user: docketClerk1User, + }, + }); + + expect(result.swingSessions[0].trialSessionId).toEqual( + trialSession1.trialSessionId, + ); + expect(result.swingSessions.length).toEqual(1); + }); + + it('should show only trial sessions in the same term as the current trial session', () => { + const term = 'Fall'; + const termYear = '2020'; + trialSession1.term = term; + trialSession1.termYear = termYear; + trialSession1.sessionStatus = SESSION_STATUS_TYPES.open; + trialSession2.term = 'Summer'; + trialSession2.termYear = termYear; + trialSession2.sessionStatus = SESSION_STATUS_TYPES.open; + + const result = runCompute(addTrialSessionInformationHelper, { + state: { + form: { swingSession: true, term, termYear }, + trialSession: { + trialSessionId: '74f24014-2cf1-4e97-b80a-40f970d5376d', + }, + trialSessions: [trialSession1, trialSession2], + user: docketClerk1User, + }, + }); + + expect(result.swingSessions[0].trialSessionId).toEqual( + trialSession1.trialSessionId, + ); + expect(result.swingSessions.length).toEqual(1); + }); + + it('should not show closed trial sessions as valid swing sessions', () => { + const term = 'Fall'; + const termYear = '2020'; + trialSession1.term = term; + trialSession1.termYear = termYear; + trialSession1.sessionStatus = SESSION_STATUS_TYPES.closed; + + const result = runCompute(addTrialSessionInformationHelper, { + state: { + form: { swingSession: true, term, termYear }, + trialSession: { + trialSessionId: '74f24014-2cf1-4e97-b80a-40f970d5376d', + }, + trialSessions: [trialSession1], + user: docketClerk1User, + }, + }); + + expect(result.swingSessions.length).toEqual(0); + }); + + it('should not show the current trial session as a valid trialSession option to create a swing session with', () => { + const term = 'Fall'; + const termYear = '2020'; + trialSession1.term = term; + trialSession1.termYear = termYear; + trialSession1.sessionStatus = SESSION_STATUS_TYPES.open; + + const result = runCompute(addTrialSessionInformationHelper, { + state: { + form: { swingSession: true, term, termYear }, + trialSession: { + trialSessionId: trialSession1.trialSessionId, + }, + trialSessions: [trialSession1, trialSession2], + user: docketClerk1User, + }, + }); + + expect(result.swingSessions.length).toEqual(0); + }); + }); + + describe('sorting', () => { + it('should sort swing session options by trial location', () => { + const term = 'Fall'; + const termYear = '2020'; + trialSession1.term = term; + trialSession1.termYear = termYear; + trialSession1.sessionStatus = SESSION_STATUS_TYPES.open; + trialSession1.trialLocation = 'San Diego, California'; + trialSession2.term = term; + trialSession2.termYear = termYear; + trialSession2.sessionStatus = SESSION_STATUS_TYPES.open; + trialSession2.trialLocation = 'Birmingham, Alabama'; + + const result = runCompute(addTrialSessionInformationHelper, { + state: { + form: { swingSession: true, term, termYear }, + trialSession: { + trialSessionId: '74f24014-2cf1-4e97-b80a-40f970d5376d', + }, + trialSessions: [trialSession1, trialSession2], + user: docketClerk1User, + }, + }); + + expect(result.swingSessions[0].trialSessionId).toEqual( + trialSession2.trialSessionId, + ); + expect(result.swingSessions[1].trialSessionId).toEqual( + trialSession1.trialSessionId, + ); + }); + }); + }); }); diff --git a/web-client/src/presenter/computeds/TrialSession/addTrialSessionInformationHelper.ts b/web-client/src/presenter/computeds/TrialSession/addTrialSessionInformationHelper.ts index 053875fd7db..60c91ea3f86 100644 --- a/web-client/src/presenter/computeds/TrialSession/addTrialSessionInformationHelper.ts +++ b/web-client/src/presenter/computeds/TrialSession/addTrialSessionInformationHelper.ts @@ -2,8 +2,11 @@ import { AuthUser } from '@shared/business/entities/authUser/AuthUser'; import { ClientApplicationContext } from '@web-client/applicationContext'; import { FORMATS } from '../../../../../shared/src/business/utilities/DateHandler'; import { Get } from 'cerebral'; +import { SESSION_STATUS_TYPES } from '@shared/business/entities/EntityConstants'; import { TrialSession } from '../../../../../shared/src/business/entities/trialSessions/TrialSession'; +import { TrialSessionInfoDTO } from '@shared/business/dto/trialSessions/TrialSessionInfoDTO'; import { state } from '@web-client/presenter/app.cerebral'; +import { trialSessionOptionText } from '@web-client/presenter/computeds/addToTrialSessionModalHelper'; export const addTrialSessionInformationHelper = ( get: Get, @@ -14,11 +17,17 @@ export const addTrialSessionInformationHelper = ( sessionTypes: string[]; title: string; today: string; + swingSessions: { trialSessionId: string; swingSessionText: string }[]; + showSwingSessionList: boolean; + showSwingSessionOption: boolean; } => { const { SESSION_TYPES, TRIAL_SESSION_PROCEEDING_TYPES } = applicationContext.getConstants(); - const { proceedingType, sessionScope } = get(state.form); + const trialSessions: TrialSessionInfoDTO[] = get(state.trialSessions) || []; + const selectedTerm = get(state.form.term); + const selectedTermYear = get(state.form.termYear); + const currentTrialSessionId = get(state.trialSession.trialSessionId); const isStandaloneSession = TrialSession.isStandaloneRemote(sessionScope); @@ -49,10 +58,42 @@ export const addTrialSessionInformationHelper = ( }; const today = applicationContext.getUtilities().formatNow(FORMATS.YYYYMMDD); + const validSwingSessions: { + trialSessionId: string; + swingSessionText: string; + }[] = trialSessions + .filter(trialSession => trialSession.termYear === selectedTermYear) + .filter(trialSession => trialSession.term === selectedTerm) + .filter( + trialSession => + trialSession.sessionStatus !== SESSION_STATUS_TYPES.closed, + ) + .filter( + trialSession => trialSession.trialSessionId !== currentTrialSessionId, + ) + .sort((sessionA, sessionB) => { + const aTrialLocation = sessionA.trialLocation || ''; + const bTrialLocation = sessionB.trialLocation || ''; + if (aTrialLocation === bTrialLocation) { + return sessionA.startDate.localeCompare(sessionB.startDate); + } + return aTrialLocation.localeCompare(bTrialLocation); + }) + .map(trialSession => { + const swingSessionText = trialSessionOptionText(trialSession); + return { + swingSessionText, + trialSessionId: trialSession.trialSessionId || '', + }; + }); + return { displayRemoteProceedingForm, isStandaloneSession, sessionTypes: getSessionTypes(get(state.user)), + showSwingSessionList: get(state.form.swingSession), + showSwingSessionOption: validSwingSessions.length > 0, + swingSessions: validSwingSessions, title, today, }; diff --git a/web-client/src/presenter/computeds/formattedTrialSessions.ts b/web-client/src/presenter/computeds/formattedTrialSessions.ts deleted file mode 100644 index c862965248c..00000000000 --- a/web-client/src/presenter/computeds/formattedTrialSessions.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { Get } from 'cerebral'; -import { SESSION_STATUS_TYPES } from '@shared/business/entities/EntityConstants'; -import { TrialSessionInfoDTO } from '@shared/business/dto/trialSessions/TrialSessionInfoDTO'; -import { state } from '@web-client/presenter/app.cerebral'; -import { trialSessionOptionText } from './addToTrialSessionModalHelper'; - -export const formattedTrialSessions = ( - get: Get, -): { - swingSessions: { trialSessionId: string; swingSessionText: string }[]; - showSwingSessionList: boolean; - showSwingSessionOption: boolean; -} => { - const trialSessions: TrialSessionInfoDTO[] = get(state.trialSessions) || []; - const selectedTerm = get(state.form.term); - const selectedTermYear = get(state.form.termYear); - const currentTrialSessionId = get(state.trialSession.trialSessionId); - - const validSwingSessions: { - trialSessionId: string; - swingSessionText: string; - }[] = trialSessions - .filter(trialSession => trialSession.termYear === selectedTermYear) - .filter(trialSession => trialSession.term === selectedTerm) - .filter( - trialSession => - trialSession.sessionStatus !== SESSION_STATUS_TYPES.closed, - ) - .filter( - trialSession => trialSession.trialSessionId !== currentTrialSessionId, - ) - .sort((sessionA, sessionB) => { - const aTrialLocation = sessionA.trialLocation || ''; - const bTrialLocation = sessionB.trialLocation || ''; - if (aTrialLocation === bTrialLocation) { - return sessionA.startDate.localeCompare(sessionB.startDate); - } - return aTrialLocation.localeCompare(bTrialLocation); - }) - .map(trialSession => { - const swingSessionText = trialSessionOptionText(trialSession); - return { - swingSessionText, - trialSessionId: trialSession.trialSessionId || '', - }; - }); - - return { - showSwingSessionList: get(state.form.swingSession), - showSwingSessionOption: validSwingSessions.length > 0, - swingSessions: validSwingSessions, - }; -}; diff --git a/web-client/src/presenter/state.ts b/web-client/src/presenter/state.ts index 1517e8e45f9..3699ccb97a1 100644 --- a/web-client/src/presenter/state.ts +++ b/web-client/src/presenter/state.ts @@ -83,7 +83,6 @@ import { formattedMessageDetail } from './computeds/formattedMessageDetail'; import { formattedMessages } from './computeds/formattedMessages'; import { formattedPendingItemsHelper } from './computeds/formattedPendingItems'; import { formattedTrialSessionDetails } from './computeds/formattedTrialSessionDetails'; -import { formattedTrialSessions } from './computeds/formattedTrialSessions'; import { formattedWorkQueue } from './computeds/formattedWorkQueue'; import { getAllIrsPractitionersForSelectHelper } from '@web-client/presenter/computeds/TrialSession/getAllIrsPractitionersForSelectHelper'; import { getConstants } from '../getConstants'; @@ -377,9 +376,6 @@ export const computeds = { formattedTrialSessionDetails as unknown as ReturnType< typeof formattedTrialSessionDetails >, - formattedTrialSessions: formattedTrialSessions as unknown as ReturnType< - typeof formattedTrialSessions - >, formattedWorkQueue: formattedWorkQueue as unknown as ReturnType< typeof formattedWorkQueue >, diff --git a/web-client/src/views/TrialSessions/SessionInformationForm.tsx b/web-client/src/views/TrialSessions/SessionInformationForm.tsx index c05965cc573..5f3a9e585fb 100644 --- a/web-client/src/views/TrialSessions/SessionInformationForm.tsx +++ b/web-client/src/views/TrialSessions/SessionInformationForm.tsx @@ -15,7 +15,6 @@ const sessionInformationDeps = { form: state.form, formatAndUpdateDateFromDatePickerSequence: sequences.formatAndUpdateDateFromDatePickerSequence, - formattedTrialSessions: state.formattedTrialSessions, updateTrialSessionFormDataSequence: sequences.updateTrialSessionFormDataSequence, user: state.user, @@ -34,7 +33,6 @@ export const SessionInformationForm = connect< DATE_FORMATS, form, formatAndUpdateDateFromDatePickerSequence, - formattedTrialSessions, TRIAL_SESSION_SCOPE_TYPES, updateTrialSessionFormDataSequence, validateTrialSessionSequence, @@ -223,7 +221,7 @@ export const SessionInformationForm = connect<
- {formattedTrialSessions.showSwingSessionOption && + {addTrialSessionInformationHelper.showSwingSessionOption && !addTrialSessionInformationHelper.isStandaloneSession && ( <>
@@ -249,7 +247,7 @@ export const SessionInformationForm = connect<
- {formattedTrialSessions.showSwingSessionList && ( + {addTrialSessionInformationHelper.showSwingSessionList && ( )} From a9968814a48845c33e140fc41c32085894c1b1ae Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 9 Sep 2024 15:29:31 -0700 Subject: [PATCH 24/96] 10409: Update integration tests to reflect new trial sessions page state --- .../dismissNOTTReminder.test.ts | 50 ++++++------------- .../docketClerkViewsTrialSessionList.ts | 16 ++---- .../docketClerkViewsTrialSessionsTab.ts | 50 ++++++------------- .../src/views/TrialSessions/TrialSessions.tsx | 4 +- 4 files changed, 36 insertions(+), 84 deletions(-) diff --git a/web-client/integration-tests/dismissNOTTReminder.test.ts b/web-client/integration-tests/dismissNOTTReminder.test.ts index 8314bc5e827..e113eafa988 100644 --- a/web-client/integration-tests/dismissNOTTReminder.test.ts +++ b/web-client/integration-tests/dismissNOTTReminder.test.ts @@ -2,7 +2,10 @@ import { SESSION_TYPES } from '../../shared/src/business/entities/EntityConstant import { docketClerkCreatesATrialSession } from './journey/docketClerkCreatesATrialSession'; import { docketClerkViewsTrialSessionsTab } from './journey/docketClerkViewsTrialSessionsTab'; import { formattedTrialSessionDetails } from '../src/presenter/computeds/formattedTrialSessionDetails'; -import { formattedTrialSessions } from '../src/presenter/computeds/formattedTrialSessions'; +import { + isTrialSessionRow, + trialSessionsHelper as trialSessionsHelperComputed, +} from '@web-client/presenter/computeds/trialSessionsHelper'; import { loginAs, setupTest } from './helpers'; import { petitionsClerkSetsATrialSessionsSchedule } from './journey/petitionsClerkSetsATrialSessionsSchedule'; import { petitionsClerkViewsNewTrialSession } from './journey/petitionsClerkViewsNewTrialSession'; @@ -58,35 +61,21 @@ describe('Dismiss NOTT reminder on calendared trial session within 30-35 day ran expect(cerebralTest.getState('currentPage')).toEqual('TrialSessions'); - const trialSessionFormatted: any = runCompute( - withAppContextDecorator(formattedTrialSessions), - { - state: cerebralTest.getState(), - }, + const trialSessionsHelper = withAppContextDecorator( + trialSessionsHelperComputed, ); - - const filteredSessions: any[] = - trialSessionFormatted.filteredTrialSessions['Open']; - - let foundSession; - filteredSessions.some(trialSession => { - trialSession.sessions.some(session => { - if ( - session.trialSessionId === cerebralTest.lastCreatedTrialSessionId - ) { - foundSession = session; - return true; - } - }); - if (foundSession) { - return true; - } + const helper = runCompute(trialSessionsHelper, { + state: cerebralTest.getState(), }); + const foundSession = helper.trialSessionRows + .filter(isTrialSessionRow) + .find(t => t.trialSessionId === cerebralTest.lastCreatedTrialSessionId); + expect(foundSession).toBeDefined(); - expect(foundSession.showAlertForNOTTReminder).toEqual(true); - expect(foundSession.alertMessageForNOTT).toEqual( - `The 30-day notice is due by ${foundSession.thirtyDaysBeforeTrialFormatted}`, + expect(foundSession?.showAlertForNOTTReminder).toEqual(true); + expect(foundSession?.alertMessageForNOTT).toContain( + 'The 30-day notice is due by', ); }); @@ -124,16 +113,9 @@ describe('Dismiss NOTT reminder on calendared trial session within 30-35 day ran describe('Petitions clerk views calendared trial session in trial session list', () => { loginAs(cerebralTest, 'petitionsclerk@example.com'); it('should go to the created trial session', async () => { - await cerebralTest.runSequence('gotoTrialSessionsSequence', { - query: { - status: 'Open', - }, - }); + await cerebralTest.runSequence('gotoTrialSessionsSequence'); expect(cerebralTest.getState('currentPage')).toEqual('TrialSessions'); - expect( - cerebralTest.getState('screenMetadata.trialSessionFilters.status'), - ).toEqual('Open'); }); it('should see the alert banner in the latest trial session and can clear it', async () => { diff --git a/web-client/integration-tests/journey/docketClerkViewsTrialSessionList.ts b/web-client/integration-tests/journey/docketClerkViewsTrialSessionList.ts index 26cbd3f5e55..a72b777ca71 100644 --- a/web-client/integration-tests/journey/docketClerkViewsTrialSessionList.ts +++ b/web-client/integration-tests/journey/docketClerkViewsTrialSessionList.ts @@ -1,11 +1,4 @@ import { find } from 'lodash'; -import { formattedTrialSessions as formattedTrialSessionsComputed } from '../../src/presenter/computeds/formattedTrialSessions'; -import { runCompute } from '@web-client/presenter/test.cerebral'; -import { withAppContextDecorator } from '../../src/withAppContext'; - -const formattedTrialSessions = withAppContextDecorator( - formattedTrialSessionsComputed, -); export const docketClerkViewsTrialSessionList = ( cerebralTest, @@ -15,12 +8,11 @@ export const docketClerkViewsTrialSessionList = ( await cerebralTest.runSequence('gotoTrialSessionsSequence'); expect(cerebralTest.getState('currentPage')).toEqual('TrialSessions'); - const formatted = runCompute(formattedTrialSessions, { - state: cerebralTest.getState(), - }); - expect(formatted.sessionsByTerm.length).toBeGreaterThan(0); + const { trialSessions } = cerebralTest.getState().trialSessionsPage; + + expect(trialSessions.length).toBeGreaterThan(0); - const trialSession = find(formatted.sessionsByTerm, { + const trialSession = find(trialSessions, { trialSessionId: cerebralTest.lastCreatedTrialSessionId, }); diff --git a/web-client/integration-tests/journey/docketClerkViewsTrialSessionsTab.ts b/web-client/integration-tests/journey/docketClerkViewsTrialSessionsTab.ts index 1325e2c6629..c319aa023fe 100644 --- a/web-client/integration-tests/journey/docketClerkViewsTrialSessionsTab.ts +++ b/web-client/integration-tests/journey/docketClerkViewsTrialSessionsTab.ts @@ -1,35 +1,26 @@ -import { formattedTrialSessions as formattedTrialSessionsComputed } from '../../src/presenter/computeds/formattedTrialSessions'; +import { + isTrialSessionRow, + trialSessionsHelper as trialSessionsHelperComputed, +} from '@web-client/presenter/computeds/trialSessionsHelper'; import { runCompute } from '@web-client/presenter/test.cerebral'; -import { trialSessionsHelper as trialSessionsHelperComputed } from '../../src/presenter/computeds/trialSessionsHelper'; import { withAppContextDecorator } from '../../src/withAppContext'; -const formattedTrialSessions = withAppContextDecorator( - formattedTrialSessionsComputed, -); - export const docketClerkViewsTrialSessionsTab = ( cerebralTest: any, - overrides: { tab?: string } = { tab: undefined }, + overrides: { tab?: 'calendared' | 'new' } = { tab: 'calendared' }, ) => { - const status = overrides.tab || 'Open'; - return it(`Docket clerk views ${status} Trial Sessions tab`, async () => { - // resetting view metadata to counteract the fact that state is not being reset on login as it would be outside of a test - cerebralTest.setState('currentViewMetadata.trialSessions.tab', undefined); - + const { tab } = overrides; + return it(`Docket clerk views ${tab} Trial Sessions tab`, async () => { await cerebralTest.runSequence('gotoTrialSessionsSequence', { query: { - status, + status: tab, }, }); + await cerebralTest.runSequence('setTrialSessionsFiltersSequence', { + currentTab: tab, + }); expect(cerebralTest.getState('currentPage')).toEqual('TrialSessions'); - expect( - cerebralTest.getState('screenMetadata.trialSessionFilters.status'), - ).toEqual(status); - - const formatted = runCompute(formattedTrialSessions, { - state: cerebralTest.getState(), - }); const trialSessionsHelper = withAppContextDecorator( trialSessionsHelperComputed, @@ -43,26 +34,15 @@ export const docketClerkViewsTrialSessionsTab = ( judge => judge.role === 'legacyJudge', ); - if (status === 'Closed' || status === 'All') { + if (tab === 'calendared') { expect(legacyJudge).toBeTruthy(); } else { expect(legacyJudge).toBeFalsy(); } - const filteredSessions = formatted.sessionsByTerm[status]; - - let foundSession; - filteredSessions.some(trialSession => { - trialSession.sessions.some(session => { - if (session.trialSessionId === cerebralTest.trialSessionId) { - foundSession = session; - return true; - } - }); - if (foundSession) { - return true; - } - }); + const foundSession = helper.trialSessionRows + .filter(isTrialSessionRow) + .find(t => t.trialSessionId === cerebralTest.trialSessionId); expect(foundSession).toBeTruthy(); }); diff --git a/web-client/src/views/TrialSessions/TrialSessions.tsx b/web-client/src/views/TrialSessions/TrialSessions.tsx index 34cb2ba0df8..31b4657ae44 100644 --- a/web-client/src/views/TrialSessions/TrialSessions.tsx +++ b/web-client/src/views/TrialSessions/TrialSessions.tsx @@ -18,14 +18,12 @@ import React from 'react'; export const TrialSessions = connect( { - defaultTab: state.screenMetadata.trialSessionFilters.status, openTrialSessionPlanningModalSequence: sequences.openTrialSessionPlanningModalSequence, setTrialSessionsFiltersSequence: sequences.setTrialSessionsFiltersSequence, trialSessionHelper: state.trialSessionsHelper, }, function TrialSessions({ - defaultTab, openTrialSessionPlanningModalSequence, setTrialSessionsFiltersSequence, trialSessionHelper, @@ -38,7 +36,7 @@ export const TrialSessions = connect( { From 14de069f3610e37155ea581390fdec83e56dab0e Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 9 Sep 2024 15:41:58 -0700 Subject: [PATCH 25/96] 10409: Update integration tests to reflect new trial sessions page state --- .../docketClerkViewsTrialSessionTabs.test.ts | 8 +- ...ClerkClosesStandaloneRemoteTrialSession.ts | 34 +- .../docketClerkVerifiesSessionIsNotClosed.ts | 44 +-- .../computeds/formattedTrialSessions.test.ts | 334 ------------------ 4 files changed, 18 insertions(+), 402 deletions(-) delete mode 100644 web-client/src/presenter/computeds/formattedTrialSessions.test.ts diff --git a/web-client/integration-tests/docketClerkViewsTrialSessionTabs.test.ts b/web-client/integration-tests/docketClerkViewsTrialSessionTabs.test.ts index bc4a582c250..55c3b749588 100644 --- a/web-client/integration-tests/docketClerkViewsTrialSessionTabs.test.ts +++ b/web-client/integration-tests/docketClerkViewsTrialSessionTabs.test.ts @@ -47,7 +47,7 @@ describe('Docket Clerk Views Trial Session Tabs', () => { docketClerkCreatesATrialSession(cerebralTest, overrides); docketClerkViewsTrialSessionList(cerebralTest); // Trial Session should exist in New tab - docketClerkViewsTrialSessionsTab(cerebralTest, { tab: 'New' }); + docketClerkViewsTrialSessionsTab(cerebralTest, { tab: 'new' }); for (let i = 0; i < caseCount; i++) { const id = i + 1; @@ -66,14 +66,14 @@ describe('Docket Clerk Views Trial Session Tabs', () => { loginAs(cerebralTest, 'docketclerk@example.com'); // Trial Session should exist in Open tab - docketClerkViewsTrialSessionsTab(cerebralTest, { tab: 'Open' }); + docketClerkViewsTrialSessionsTab(cerebralTest, { tab: 'calendared' }); loginAs(cerebralTest, 'petitionsclerk@example.com'); petitionsClerkManuallyRemovesCaseFromTrial(cerebralTest); loginAs(cerebralTest, 'docketclerk@example.com'); // Trial Session should exist in Closed tab - docketClerkViewsTrialSessionsTab(cerebralTest, { tab: 'Closed' }); + docketClerkViewsTrialSessionsTab(cerebralTest, { tab: 'calendared' }); // Trial Session should exist in All tab - docketClerkViewsTrialSessionsTab(cerebralTest, { tab: 'All' }); + docketClerkViewsTrialSessionsTab(cerebralTest, { tab: 'calendared' }); }); diff --git a/web-client/integration-tests/journey/docketClerkClosesStandaloneRemoteTrialSession.ts b/web-client/integration-tests/journey/docketClerkClosesStandaloneRemoteTrialSession.ts index a7e116b2b66..2bedb3e3b6f 100644 --- a/web-client/integration-tests/journey/docketClerkClosesStandaloneRemoteTrialSession.ts +++ b/web-client/integration-tests/journey/docketClerkClosesStandaloneRemoteTrialSession.ts @@ -1,12 +1,4 @@ -import { formattedTrialSessions as formattedTrialSessionsComputed } from '../../src/presenter/computeds/formattedTrialSessions'; -import { runCompute } from '@web-client/presenter/test.cerebral'; -import { withAppContextDecorator } from '../../src/withAppContext'; - -const formattedTrialSessions = withAppContextDecorator( - formattedTrialSessionsComputed, -); - -const status = 'Closed'; +import { SESSION_STATUS_TYPES } from '@shared/business/entities/EntityConstants'; export const docketClerkClosesStandaloneRemoteTrialSession = cerebralTest => { return it('Docket Clerk closes the trial session', async () => { @@ -17,25 +9,13 @@ export const docketClerkClosesStandaloneRemoteTrialSession = cerebralTest => { await cerebralTest.runSequence('closeTrialSessionSequence'); - const formatted = runCompute(formattedTrialSessions, { - state: cerebralTest.getState(), - }); - - const filteredSessions = formatted.sessionsByTerm[status]; - - let foundSession; - filteredSessions.some(trialSession => { - trialSession.sessions.some(session => { - if (session.trialSessionId === cerebralTest.lastCreatedTrialSessionId) { - foundSession = session; - return true; - } - }); - if (foundSession) { - return true; - } - }); + const { trialSessions } = cerebralTest.getState().trialSessionsPage; + expect(trialSessions.length).toBeGreaterThan(0); + const foundSession = trialSessions.find( + t => t.trialSessionId === cerebralTest.lastCreatedTrialSessionId, + ); expect(foundSession).toBeTruthy(); + expect(foundSession.sessionStatus).toEqual(SESSION_STATUS_TYPES.closed); }); }; diff --git a/web-client/integration-tests/journey/docketClerkVerifiesSessionIsNotClosed.ts b/web-client/integration-tests/journey/docketClerkVerifiesSessionIsNotClosed.ts index da83ab802d8..9bbd194db78 100644 --- a/web-client/integration-tests/journey/docketClerkVerifiesSessionIsNotClosed.ts +++ b/web-client/integration-tests/journey/docketClerkVerifiesSessionIsNotClosed.ts @@ -1,45 +1,15 @@ -import { formattedTrialSessions as formattedTrialSessionsComputed } from '../../src/presenter/computeds/formattedTrialSessions'; -import { runCompute } from '@web-client/presenter/test.cerebral'; -import { withAppContextDecorator } from '../../src/withAppContext'; - -const formattedTrialSessions = withAppContextDecorator( - formattedTrialSessionsComputed, -); - -const status = 'Closed'; +import { SESSION_STATUS_TYPES } from '@shared/business/entities/EntityConstants'; export const docketClerkVerifiesSessionIsNotClosed = cerebralTest => { return it('Docket Clerk verifies session is not closed', async () => { - await cerebralTest.runSequence('gotoTrialSessionsSequence', { - query: { - status, - }, - }); + await cerebralTest.runSequence('gotoTrialSessionsSequence'); expect(cerebralTest.getState('currentPage')).toEqual('TrialSessions'); - expect( - cerebralTest.getState('screenMetadata.trialSessionFilters.status'), - ).toEqual(status); - - const formatted = runCompute(formattedTrialSessions, { - state: cerebralTest.getState(), - }); - - const filteredSessions = formatted.sessionsByTerm[status]; - - let foundSession; - filteredSessions.some(trialSession => { - trialSession.sessions.some(session => { - if (session.trialSessionId === cerebralTest.lastCreatedTrialSessionId) { - foundSession = session; - return true; - } - }); - if (foundSession) { - return true; - } - }); - expect(foundSession).toBeFalsy(); + const { trialSessions } = cerebralTest.getState().trialSessionsPage; + const foundSession = trialSessions.find( + t => t.trialSessionId === cerebralTest.lastCreatedTrialSessionId, + ); + expect(foundSession.sessionStatus).not.toEqual(SESSION_STATUS_TYPES.closed); }); }; diff --git a/web-client/src/presenter/computeds/formattedTrialSessions.test.ts b/web-client/src/presenter/computeds/formattedTrialSessions.test.ts deleted file mode 100644 index b205166b314..00000000000 --- a/web-client/src/presenter/computeds/formattedTrialSessions.test.ts +++ /dev/null @@ -1,334 +0,0 @@ -import { - FORMATS, - formatNow, -} from '../../../../shared/src/business/utilities/DateHandler'; -import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; -import { formatTrialSessionDisplayOptions } from './addToTrialSessionModalHelper'; -import { formattedTrialSessions as formattedTrialSessionsComputed } from './formattedTrialSessions'; -import { judgeUser } from '@shared/test/mockUsers'; -import { runCompute } from '@web-client/presenter/test.cerebral'; -import { withAppContextDecorator } from '../../withAppContext'; -jest.mock('./addToTrialSessionModalHelper.ts'); - -const { - SESSION_TYPES, - TRIAL_SESSION_PROCEEDING_TYPES, - USER_ROLES: ROLES, -} = applicationContext.getConstants(); - -const formattedTrialSessions = withAppContextDecorator( - formattedTrialSessionsComputed, - { - ...applicationContext, - }, -); - -let nextYear; - -const baseState = { - constants: { USER_ROLES: ROLES }, - judgeUser, -}; - -let TRIAL_SESSIONS_LIST: any[] = []; - -describe('formattedTrialSessions', () => { - beforeAll(() => { - nextYear = (parseInt(formatNow(FORMATS.YEAR)) + 1).toString(); - }); - - beforeEach(() => { - TRIAL_SESSIONS_LIST = [ - { - caseOrder: [], - isCalendared: true, - judge: { name: judgeUser.name, userId: judgeUser.userId }, - proceedingType: TRIAL_SESSION_PROCEEDING_TYPES.inPerson, - sessionStatus: 'Open', - sessionType: SESSION_TYPES.regular, - startDate: '2019-11-25T15:00:00.000Z', - swingSession: true, - term: 'Fall', - termYear: '2019', - trialLocation: 'Hartford, Connecticut', - trialSessionId: '1', - }, - { - caseOrder: [], - isCalendared: false, - judge: { name: '2', userId: '2' }, - proceedingType: TRIAL_SESSION_PROCEEDING_TYPES.remote, - sessionStatus: 'New', - sessionType: SESSION_TYPES.small, - startDate: '2019-11-25T15:00:00.000Z', - swingSession: true, - term: 'Winter', - trialClerk: { name: '10', userId: '10' }, - trialLocation: 'Knoxville, TN', - trialSessionId: '2', - }, - { - caseOrder: [], - isCalendared: false, - judge: { name: '3', userId: '3' }, - noticeIssuedDate: '2019-07-25T15:00:00.000Z', - proceedingType: TRIAL_SESSION_PROCEEDING_TYPES.inPerson, - sessionStatus: 'New', - sessionType: SESSION_TYPES.regular, - startDate: '2019-11-27T15:00:00.000Z', - swingSession: true, - term: 'Winter', - trialLocation: 'Jacksonville, FL', - trialSessionId: '3', - }, - { - caseOrder: [], - isCalendared: false, - judge: { name: '55', userId: '55' }, - noticeIssuedDate: '2019-07-25T15:00:00.000Z', - proceedingType: TRIAL_SESSION_PROCEEDING_TYPES.inPerson, - sessionStatus: 'New', - sessionType: SESSION_TYPES.regular, - startDate: '2019-10-27T15:00:00.000Z', - swingSession: true, - term: 'Winter', - trialLocation: 'Jacksonville, FL', - trialSessionId: '5', - }, - { - caseOrder: [], - isCalendared: false, - judge: { name: '88', userId: '88' }, - noticeIssuedDate: '2020-07-26T15:00:00.000Z', - proceedingType: TRIAL_SESSION_PROCEEDING_TYPES.inPerson, - sessionStatus: 'New', - sessionType: SESSION_TYPES.regular, - startDate: '2020-11-26T15:00:00.000Z', - swingSession: true, - term: 'Winter', - trialLocation: 'Jacksonville, FL', - trialSessionId: '8', - }, - { - caseOrder: [], - isCalendared: true, - judge: { name: '4', userId: '4' }, - proceedingType: TRIAL_SESSION_PROCEEDING_TYPES.inPerson, - sessionStatus: 'Open', - sessionType: SESSION_TYPES.hybrid, - startDate: '2019-11-27T15:00:00.000Z', - swingSession: true, - term: 'Summer', - trialLocation: 'Memphis, TN', - trialSessionId: '4', - }, - { - caseOrder: [], - isCalendared: true, - judge: { name: '5', userId: '5' }, - proceedingType: TRIAL_SESSION_PROCEEDING_TYPES.remote, - sessionStatus: 'Open', - sessionType: SESSION_TYPES.hybrid, - startDate: '2019-11-25T15:00:00.000Z', - swingSession: false, - term: 'Spring', - termYear: '2019', - trialLocation: 'Anchorage, AK', - }, - { - caseOrder: [], - estimatedEndDate: '2045-02-17T15:00:00.000Z', - isCalendared: true, - judge: { name: '6', userId: '6' }, - proceedingType: TRIAL_SESSION_PROCEEDING_TYPES.inPerson, - sessionStatus: 'Open', - sessionType: SESSION_TYPES.regular, - startDate: `${nextYear}-02-17T15:00:00.000Z`, - swingSession: false, - term: 'Spring', - trialLocation: 'Jacksonville, FL', - }, - ]; - - (formatTrialSessionDisplayOptions as jest.Mock).mockImplementation( - session => session, - ); - }); - - it('shows swing session option only if matching term and term year is found', () => { - let form = { - term: 'Winter', - termYear: '2019', - }; - let result = runCompute(formattedTrialSessions, { - state: { - ...baseState, - form, - trialSessions: TRIAL_SESSIONS_LIST, - user: judgeUser, - }, - }); - expect(result.sessionsByTerm.length).toEqual(0); - expect(result.showSwingSessionOption).toBeFalsy(); - - form.term = 'Spring'; - result = runCompute(formattedTrialSessions, { - state: { - ...baseState, - form, - trialSessions: TRIAL_SESSIONS_LIST, - user: judgeUser, - }, - }); - expect(result.sessionsByTerm.length).toEqual(1); - expect(result.showSwingSessionOption).toBeTruthy(); - - form.termYear = '2011'; // similar term but not a matching year - result = runCompute(formattedTrialSessions, { - state: { - ...baseState, - form, - trialSessions: TRIAL_SESSIONS_LIST, - user: judgeUser, - }, - }); - expect(result.sessionsByTerm.length).toEqual(0); - expect(result.showSwingSessionOption).toBeFalsy(); - }); - - it('returns sessionsByTerm with only sessions in that term sorted chronologically if form.term is set', () => { - const result = runCompute(formattedTrialSessions, { - state: { - ...baseState, - form: { - term: 'Winter', - }, - trialSessions: TRIAL_SESSIONS_LIST, - user: judgeUser, - }, - }); - - expect(result.sessionsByTerm).toEqual([ - { - caseOrder: [], - formattedEstimatedEndDate: '', - formattedNoticeIssuedDate: '07/25/2019', - formattedStartDate: '10/27/19', - isCalendared: false, - judge: { name: '55', userId: '55' }, - noticeIssuedDate: '2019-07-25T15:00:00.000Z', - proceedingType: 'In Person', - sessionStatus: 'New', - sessionType: SESSION_TYPES.regular, - showAlertForNOTTReminder: undefined, - startDate: '2019-10-27T15:00:00.000Z', - startOfWeek: 'October 21, 2019', - startOfWeekSortable: '20191021', - swingSession: true, - term: 'Winter', - trialLocation: 'Jacksonville, FL', - trialSessionId: '5', - userIsAssignedToSession: false, - }, - { - caseOrder: [], - formattedEstimatedEndDate: '', - formattedNoticeIssuedDate: '07/25/2019', - formattedStartDate: '11/27/19', - isCalendared: false, - judge: { name: '3', userId: '3' }, - noticeIssuedDate: '2019-07-25T15:00:00.000Z', - proceedingType: 'In Person', - sessionStatus: 'New', - sessionType: SESSION_TYPES.regular, - showAlertForNOTTReminder: undefined, - startDate: '2019-11-27T15:00:00.000Z', - startOfWeek: 'November 25, 2019', - startOfWeekSortable: '20191125', - swingSession: true, - term: 'Winter', - trialLocation: 'Jacksonville, FL', - trialSessionId: '3', - userIsAssignedToSession: false, - }, - { - caseOrder: [], - formattedEstimatedEndDate: '', - formattedNoticeIssuedDate: '07/26/2020', - formattedStartDate: '11/26/20', - isCalendared: false, - judge: { name: '88', userId: '88' }, - noticeIssuedDate: '2020-07-26T15:00:00.000Z', - proceedingType: 'In Person', - sessionStatus: 'New', - sessionType: SESSION_TYPES.regular, - showAlertForNOTTReminder: undefined, - startDate: '2020-11-26T15:00:00.000Z', - startOfWeek: 'November 23, 2020', - startOfWeekSortable: '20201123', - swingSession: true, - term: 'Winter', - trialLocation: 'Jacksonville, FL', - trialSessionId: '8', - userIsAssignedToSession: false, - }, - { - caseOrder: [], - formattedEstimatedEndDate: '', - formattedNoticeIssuedDate: '', - formattedStartDate: '11/25/19', - isCalendared: false, - judge: { name: '2', userId: '2' }, - proceedingType: 'Remote', - sessionStatus: 'New', - sessionType: SESSION_TYPES.small, - showAlertForNOTTReminder: undefined, - startDate: '2019-11-25T15:00:00.000Z', - startOfWeek: 'November 25, 2019', - startOfWeekSortable: '20191125', - swingSession: true, - term: 'Winter', - trialClerk: { name: '10', userId: '10' }, - trialLocation: 'Knoxville, TN', - trialSessionId: '2', - userIsAssignedToSession: false, - }, - ]); - }); - - it('makes a call to format display text on sessionsByTerm', () => { - runCompute(formattedTrialSessions, { - state: { - ...baseState, - form: { - term: 'Winter', - }, - trialSessions: TRIAL_SESSIONS_LIST, - user: judgeUser, - }, - }); - - expect(formatTrialSessionDisplayOptions).toHaveBeenCalled(); - }); - - it('removes the current trial session from the sessionsByTerm when state.trialSession.trialSessionId is defined', () => { - const { sessionsByTerm } = runCompute(formattedTrialSessions, { - state: { - ...baseState, - form: { - term: 'Winter', - }, - trialSession: { trialSessionId: TRIAL_SESSIONS_LIST[1].trialSessionId }, - trialSessions: TRIAL_SESSIONS_LIST, - user: judgeUser, - }, - }); - - expect( - sessionsByTerm.find( - session => - session.trialSessionId === TRIAL_SESSIONS_LIST[1].trialSessionId, - ), - ).toBeUndefined(); - }); -}); From b3e05a3115c963f33edb35d0ef3498db4c9e4996 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 9 Sep 2024 17:59:27 -0700 Subject: [PATCH 26/96] 10409: Update integration tests to reflect new trial sessions page state --- .../docketClerkViewsTrialSessionTabs.test.ts | 26 ++++++++++++++----- .../docketClerkViewsTrialSessionsTab.ts | 17 +++++++----- web-client/src/presenter/presenter.ts | 2 +- .../sequences/gotoTrialSessionsSequence.ts | 2 +- 4 files changed, 32 insertions(+), 15 deletions(-) diff --git a/web-client/integration-tests/docketClerkViewsTrialSessionTabs.test.ts b/web-client/integration-tests/docketClerkViewsTrialSessionTabs.test.ts index 55c3b749588..92e0e24de72 100644 --- a/web-client/integration-tests/docketClerkViewsTrialSessionTabs.test.ts +++ b/web-client/integration-tests/docketClerkViewsTrialSessionTabs.test.ts @@ -47,7 +47,10 @@ describe('Docket Clerk Views Trial Session Tabs', () => { docketClerkCreatesATrialSession(cerebralTest, overrides); docketClerkViewsTrialSessionList(cerebralTest); // Trial Session should exist in New tab - docketClerkViewsTrialSessionsTab(cerebralTest, { tab: 'new' }); + docketClerkViewsTrialSessionsTab(cerebralTest, { + sessionStatus: 'All', + tab: 'new', + }); for (let i = 0; i < caseCount; i++) { const id = i + 1; @@ -65,15 +68,24 @@ describe('Docket Clerk Views Trial Session Tabs', () => { petitionsClerkSetsATrialSessionsSchedule(cerebralTest); loginAs(cerebralTest, 'docketclerk@example.com'); - // Trial Session should exist in Open tab - docketClerkViewsTrialSessionsTab(cerebralTest, { tab: 'calendared' }); + // Trial Session should exist in Open + docketClerkViewsTrialSessionsTab(cerebralTest, { + sessionStatus: 'Open', + tab: 'calendared', + }); loginAs(cerebralTest, 'petitionsclerk@example.com'); petitionsClerkManuallyRemovesCaseFromTrial(cerebralTest); loginAs(cerebralTest, 'docketclerk@example.com'); - // Trial Session should exist in Closed tab - docketClerkViewsTrialSessionsTab(cerebralTest, { tab: 'calendared' }); - // Trial Session should exist in All tab - docketClerkViewsTrialSessionsTab(cerebralTest, { tab: 'calendared' }); + // Trial Session should exist in Closed + docketClerkViewsTrialSessionsTab(cerebralTest, { + sessionStatus: 'Closed', + tab: 'calendared', + }); + // Trial Session should exist in All + docketClerkViewsTrialSessionsTab(cerebralTest, { + sessionStatus: 'All', + tab: 'calendared', + }); }); diff --git a/web-client/integration-tests/journey/docketClerkViewsTrialSessionsTab.ts b/web-client/integration-tests/journey/docketClerkViewsTrialSessionsTab.ts index c319aa023fe..1f164955c95 100644 --- a/web-client/integration-tests/journey/docketClerkViewsTrialSessionsTab.ts +++ b/web-client/integration-tests/journey/docketClerkViewsTrialSessionsTab.ts @@ -7,18 +7,23 @@ import { withAppContextDecorator } from '../../src/withAppContext'; export const docketClerkViewsTrialSessionsTab = ( cerebralTest: any, - overrides: { tab?: 'calendared' | 'new' } = { tab: 'calendared' }, + overrides: { + tab?: 'calendared' | 'new'; + sessionStatus?: 'Closed' | 'Open' | 'All'; + } = { + sessionStatus: 'Open', + tab: 'calendared', + }, ) => { const { tab } = overrides; return it(`Docket clerk views ${tab} Trial Sessions tab`, async () => { - await cerebralTest.runSequence('gotoTrialSessionsSequence', { - query: { - status: tab, - }, - }); + await cerebralTest.runSequence('gotoTrialSessionsSequence'); await cerebralTest.runSequence('setTrialSessionsFiltersSequence', { currentTab: tab, }); + await cerebralTest.runSequence('setTrialSessionsFiltersSequence', { + sessionStatus: overrides.sessionStatus, + }); expect(cerebralTest.getState('currentPage')).toEqual('TrialSessions'); diff --git a/web-client/src/presenter/presenter.ts b/web-client/src/presenter/presenter.ts index 47926d7c6f4..a9025f28fd1 100644 --- a/web-client/src/presenter/presenter.ts +++ b/web-client/src/presenter/presenter.ts @@ -953,7 +953,7 @@ export const presenterSequences = { gotoTrialSessionPlanningReportSequence as unknown as Function, gotoTrialSessionWorkingCopySequence: gotoTrialSessionWorkingCopySequence as unknown as Function, - gotoTrialSessionsSequence: gotoTrialSessionsSequence as unknown as Function, + gotoTrialSessionsSequence, gotoUpdatedPetitionFlowSequence: gotoUpdatedPetitionFlowSequence as unknown as Function, gotoUploadCorrespondenceDocumentSequence: diff --git a/web-client/src/presenter/sequences/gotoTrialSessionsSequence.ts b/web-client/src/presenter/sequences/gotoTrialSessionsSequence.ts index 4d798aadf6b..c8cb98091a7 100644 --- a/web-client/src/presenter/sequences/gotoTrialSessionsSequence.ts +++ b/web-client/src/presenter/sequences/gotoTrialSessionsSequence.ts @@ -29,4 +29,4 @@ export const gotoTrialSessionsSequence = ], ]), setupCurrentPageAction('TrialSessions'), - ]); + ]) as unknown as () => void; From bec25470664533eb68974b79535f11b1b31919cb Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 10 Sep 2024 07:11:39 -0700 Subject: [PATCH 27/96] 10409: Update integration tests to reflect new trial sessions page state --- web-client/src/presenter/state.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/web-client/src/presenter/state.ts b/web-client/src/presenter/state.ts index 3699ccb97a1..dd52fc2c9cd 100644 --- a/web-client/src/presenter/state.ts +++ b/web-client/src/presenter/state.ts @@ -836,6 +836,7 @@ export const baseState = { name: '', }, trialSessionWorkingCopy: cloneDeep(initialTrialSessionWorkingCopyState), + trialSessions: [] as any[], // Sometimes trialSessions, sometimes TrialSessionInfoDTO, sometimes ad-hoc trial sessions trialSessionsPage: cloneDeep(initialTrialSessionPageState), user: cloneDeep(emptyUserState), userContactEditProgress: {} as { inProgress?: boolean }, From 9237d95a51adacb11611bced002ed65a3fd2c63b Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 10 Sep 2024 09:54:17 -0700 Subject: [PATCH 28/96] 10409: Remove validation before returning trial sessions. --- .../getTrialSessionsInteractor.test.ts | 15 +-------------- .../trialSessions/getTrialSessionsInteractor.ts | 5 +---- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/web-api/src/business/useCases/trialSessions/getTrialSessionsInteractor.test.ts b/web-api/src/business/useCases/trialSessions/getTrialSessionsInteractor.test.ts index 60e283bdd13..a6784a3fc35 100644 --- a/web-api/src/business/useCases/trialSessions/getTrialSessionsInteractor.test.ts +++ b/web-api/src/business/useCases/trialSessions/getTrialSessionsInteractor.test.ts @@ -10,7 +10,6 @@ import { mockPetitionerUser, mockPetitionsClerkUser, } from '@shared/test/mockAuthUsers'; -import { omit } from 'lodash'; describe('getTrialSessionsInteractor', () => { it('should throw an unauthorized error when the user does not have permission to view trial sessions', async () => { @@ -19,19 +18,7 @@ describe('getTrialSessionsInteractor', () => { ).rejects.toThrow(new UnauthorizedError('Unauthorized')); }); - it('should throw an error when the entity returned from persistence is invalid', async () => { - applicationContext - .getPersistenceGateway() - .getTrialSessions.mockResolvedValue([ - omit(MOCK_TRIAL_INPERSON, 'maxCases'), - ]); - - await expect( - getTrialSessionsInteractor(applicationContext, mockPetitionsClerkUser), - ).rejects.toThrow('The TrialSession entity was invalid.'); - }); - - it('should return a list of validated trial sessions', async () => { + it('should return a list of trial sessions', async () => { applicationContext .getPersistenceGateway() .getTrialSessions.mockResolvedValue([ diff --git a/web-api/src/business/useCases/trialSessions/getTrialSessionsInteractor.ts b/web-api/src/business/useCases/trialSessions/getTrialSessionsInteractor.ts index 854d6a181f6..fc5d1288edd 100644 --- a/web-api/src/business/useCases/trialSessions/getTrialSessionsInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/getTrialSessionsInteractor.ts @@ -3,7 +3,6 @@ import { isAuthorized, } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; -import { TrialSession } from '../../../../../shared/src/business/entities/trialSessions/TrialSession'; import { TrialSessionInfoDTO } from '../../../../../shared/src/business/dto/trialSessions/TrialSessionInfoDTO'; import { UnauthorizedError } from '@web-api/errors/errors'; import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; @@ -22,9 +21,7 @@ export const getTrialSessionsInteractor = async ( applicationContext, }); - const validatedSessions = TrialSession.validateRawCollection(trialSessions); - - return validatedSessions.map( + return trialSessions.map( trialSession => new TrialSessionInfoDTO(trialSession), ); }; From f79288c38b1b7874fa1ca1f6e8cd2b5de050da3e Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 10 Sep 2024 13:19:19 -0700 Subject: [PATCH 29/96] 10409: Make a new trialSession before turning into DTO so the NOTT can be recalculated --- .../useCases/trialSessions/getTrialSessionsInteractor.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/web-api/src/business/useCases/trialSessions/getTrialSessionsInteractor.ts b/web-api/src/business/useCases/trialSessions/getTrialSessionsInteractor.ts index fc5d1288edd..54491f7e430 100644 --- a/web-api/src/business/useCases/trialSessions/getTrialSessionsInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/getTrialSessionsInteractor.ts @@ -3,6 +3,7 @@ import { isAuthorized, } from '../../../../../shared/src/authorization/authorizationClientService'; import { ServerApplicationContext } from '@web-api/applicationContext'; +import { TrialSession } from '@shared/business/entities/trialSessions/TrialSession'; import { TrialSessionInfoDTO } from '../../../../../shared/src/business/dto/trialSessions/TrialSessionInfoDTO'; import { UnauthorizedError } from '@web-api/errors/errors'; import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser'; @@ -21,7 +22,7 @@ export const getTrialSessionsInteractor = async ( applicationContext, }); - return trialSessions.map( - trialSession => new TrialSessionInfoDTO(trialSession), - ); + return trialSessions + .map(t => new TrialSession(t).toRawObject()) + .map(trialSession => new TrialSessionInfoDTO(trialSession)); }; From c85f58e0e4b579830d9e8f3ea4d3178171201372 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 10 Sep 2024 14:49:37 -0700 Subject: [PATCH 30/96] 10409 calculate isStartDateWithinNOTTReminderRange --- .../dto/trialSessions/TrialSessionInfoDTO.ts | 3 -- ...TrialSession.noticeOfTrialReminder.test.ts | 20 ++++++--- .../entities/trialSessions/TrialSession.ts | 41 +++++++++++++------ .../formattedTrialSessionDetails.test.ts | 14 ++++--- .../computeds/formattedTrialSessionDetails.ts | 6 ++- .../computeds/trialSessionsHelper.test.ts | 7 +++- .../computeds/trialSessionsHelper.ts | 6 ++- 7 files changed, 67 insertions(+), 30 deletions(-) diff --git a/shared/src/business/dto/trialSessions/TrialSessionInfoDTO.ts b/shared/src/business/dto/trialSessions/TrialSessionInfoDTO.ts index f3291519721..87ae68e9b11 100644 --- a/shared/src/business/dto/trialSessions/TrialSessionInfoDTO.ts +++ b/shared/src/business/dto/trialSessions/TrialSessionInfoDTO.ts @@ -21,15 +21,12 @@ export class TrialSessionInfoDTO { public sessionStatus: string; public swingSession?: boolean; public dismissedAlertForNOTT?: boolean; - public isStartDateWithinNOTTReminderRange?: boolean; public thirtyDaysBeforeTrialFormatted?: string; constructor(rawTrialSession: RawTrialSession) { this.estimatedEndDate = rawTrialSession.estimatedEndDate; this.isCalendared = rawTrialSession.isCalendared; this.judge = rawTrialSession.judge; - this.isStartDateWithinNOTTReminderRange = - rawTrialSession.isStartDateWithinNOTTReminderRange; this.thirtyDaysBeforeTrialFormatted = rawTrialSession.thirtyDaysBeforeTrialFormatted; this.proceedingType = rawTrialSession.proceedingType; diff --git a/shared/src/business/entities/trialSessions/TrialSession.noticeOfTrialReminder.test.ts b/shared/src/business/entities/trialSessions/TrialSession.noticeOfTrialReminder.test.ts index 3e0ff04614b..da856eb91c8 100644 --- a/shared/src/business/entities/trialSessions/TrialSession.noticeOfTrialReminder.test.ts +++ b/shared/src/business/entities/trialSessions/TrialSession.noticeOfTrialReminder.test.ts @@ -20,17 +20,22 @@ describe('TrialSession entity', () => { { daysFromToday: 34, expectedOutput: true }, { daysFromToday: 35, expectedOutput: false }, ]; - it('should set isStartDateWithinNOTTReminderRange to false when the trial session is not calendared', () => { + it('should return false when the trial session is not calendared', () => { const trialSession = new TrialSession({ ...MOCK_TRIAL_REGULAR, isCalendared: false, }); - expect(trialSession.isStartDateWithinNOTTReminderRange).toBe(false); + expect( + TrialSession.isStartDateWithinNOTTReminderRange({ + isCalendared: trialSession.isCalendared, + startDate: trialSession.startDate, + }), + ).toBe(false); }); tests.forEach(({ daysFromToday, expectedOutput }) => { - it(`should set isStartDateWithinNOTTReminderRange to ${expectedOutput} when the trial session is calendared and the start date is ${daysFromToday} days from today`, () => { + it(`should return ${expectedOutput} when the trial session is calendared and the start date is ${daysFromToday} days from today`, () => { const thirtyDaysFromToday = today.plus({ ['days']: daysFromToday }); const trialSession = new TrialSession({ @@ -39,9 +44,12 @@ describe('TrialSession entity', () => { startDate: thirtyDaysFromToday, }); - expect(trialSession.isStartDateWithinNOTTReminderRange).toBe( - expectedOutput, - ); + expect( + TrialSession.isStartDateWithinNOTTReminderRange({ + isCalendared: trialSession.isCalendared, + startDate: trialSession.startDate, + }), + ).toBe(expectedOutput); }); }); }); diff --git a/shared/src/business/entities/trialSessions/TrialSession.ts b/shared/src/business/entities/trialSessions/TrialSession.ts index 570050287da..d46335e5b8c 100644 --- a/shared/src/business/entities/trialSessions/TrialSession.ts +++ b/shared/src/business/entities/trialSessions/TrialSession.ts @@ -87,7 +87,6 @@ export class TrialSession extends JoiValidationEntity { public irsCalendarAdministratorInfo?: RawIrsCalendarAdministratorInfo; public isCalendared: boolean; public isClosed?: boolean; - public isStartDateWithinNOTTReminderRange?: boolean; public joinPhoneNumber?: string; public judge?: TJudge; public maxCases?: number; @@ -200,8 +199,6 @@ export class TrialSession extends JoiValidationEntity { if (rawSession.isCalendared && rawSession.startDate) { this.setNoticeOfTrialReminderAlert(); - } else { - this.isStartDateWithinNOTTReminderRange = false; } if (rawSession.trialClerk && rawSession.trialClerk.name) { @@ -216,6 +213,33 @@ export class TrialSession extends JoiValidationEntity { return sessionScope === TRIAL_SESSION_SCOPE_TYPES.standaloneRemote; } + static isStartDateWithinNOTTReminderRange({ + isCalendared, + startDate, + }: { + isCalendared?: boolean; + startDate?: string; + }): boolean { + if (!isCalendared || !startDate) { + return false; + } + + const formattedStartDate = formatDateString(startDate, FORMATS.MMDDYY); + const trialStartDateString = prepareDateFromString( + formattedStartDate, + FORMATS.MMDDYY, + ); + + return isTodayWithinGivenInterval({ + intervalEndDate: trialStartDateString.minus({ + ['days']: 24, // luxon's interval end date is not inclusive + }), + intervalStartDate: trialStartDateString.minus({ + ['days']: 34, + }), + }); + } + static validationRules = { COMMON: { address1: JoiValidationConstants.STRING.max(100).allow('').optional(), @@ -408,20 +432,11 @@ export class TrialSession extends JoiValidationEntity { setNoticeOfTrialReminderAlert() { const formattedStartDate = formatDateString(this.startDate, FORMATS.MMDDYY); - const trialStartDateString: any = prepareDateFromString( + const trialStartDateString = prepareDateFromString( formattedStartDate, FORMATS.MMDDYY, ); - this.isStartDateWithinNOTTReminderRange = isTodayWithinGivenInterval({ - intervalEndDate: trialStartDateString.minus({ - ['days']: 24, // luxon's interval end date is not inclusive - }), - intervalStartDate: trialStartDateString.minus({ - ['days']: 34, - }), - }); - const thirtyDaysBeforeTrialInclusive: any = trialStartDateString.minus({ ['days']: 29, }); diff --git a/web-client/src/presenter/computeds/formattedTrialSessionDetails.test.ts b/web-client/src/presenter/computeds/formattedTrialSessionDetails.test.ts index 5f7ac902ce3..b6d1ca36b6d 100644 --- a/web-client/src/presenter/computeds/formattedTrialSessionDetails.test.ts +++ b/web-client/src/presenter/computeds/formattedTrialSessionDetails.test.ts @@ -6,6 +6,7 @@ import { TRIAL_SESSION_SCOPE_TYPES, } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; +import { calculateISODate } from '@shared/business/utilities/DateHandler'; import { colvinsChambersUser, docketClerkUser, @@ -522,11 +523,12 @@ describe('formattedTrialSessionDetails', () => { }); describe('NOTT reminder', () => { - it('should set showAlertForNOTTReminder to true when the alert has not been previously dismissed and isStartDateWithinNOTTReminderRange is true', () => { + it('should set showAlertForNOTTReminder to true when the alert has not been previously dismissed and start date is within NOTT reminder range', () => { mockTrialSession = { ...TRIAL_SESSION, dismissedAlertForNOTT: false, - isStartDateWithinNOTTReminderRange: true, + isCalendared: true, + startDate: calculateISODate({ howMuch: 30, units: 'days' }), thirtyDaysBeforeTrialFormatted: '2/2/2022', }; @@ -549,7 +551,8 @@ describe('formattedTrialSessionDetails', () => { mockTrialSession = { ...TRIAL_SESSION, dismissedAlertForNOTT: true, - isStartDateWithinNOTTReminderRange: true, + isCalendared: true, + startDate: calculateISODate({ howMuch: 30, units: 'days' }), }; const result: any = runCompute(formattedTrialSessionDetails, { @@ -565,11 +568,12 @@ describe('formattedTrialSessionDetails', () => { expect(result.alertMessageForNOTT).toBeUndefined(); }); - it('should set showAlertForNOTTReminder to false when isStartDateWithinNOTTReminderRange is false', () => { + it('should set showAlertForNOTTReminder to false when start date is within NOTT reminder range', () => { mockTrialSession = { ...TRIAL_SESSION, dismissedAlertForNOTT: true, - isStartDateWithinNOTTReminderRange: false, + isCalendared: true, + startDate: calculateISODate({ howMuch: 60, units: 'days' }), }; const result: any = runCompute(formattedTrialSessionDetails, { diff --git a/web-client/src/presenter/computeds/formattedTrialSessionDetails.ts b/web-client/src/presenter/computeds/formattedTrialSessionDetails.ts index f4f17cbfb68..90a7e6b3037 100644 --- a/web-client/src/presenter/computeds/formattedTrialSessionDetails.ts +++ b/web-client/src/presenter/computeds/formattedTrialSessionDetails.ts @@ -1,6 +1,7 @@ import { ClientApplicationContext } from '@web-client/applicationContext'; import { FormattedTrialSessionDetailsType } from '@shared/business/utilities/getFormattedTrialSessionDetails'; import { Get } from 'cerebral'; +import { TrialSession } from '@shared/business/entities/trialSessions/TrialSession'; import { isEmpty, isEqual } from 'lodash'; import { state } from '@web-client/presenter/app.cerebral'; @@ -58,7 +59,10 @@ export const formattedTrialSessionDetails = ( showAlertForNOTTReminder = !formattedTrialSession.dismissedAlertForNOTT && - !!formattedTrialSession.isStartDateWithinNOTTReminderRange && + TrialSession.isStartDateWithinNOTTReminderRange({ + isCalendared: formattedTrialSession.isCalendared, + startDate: formattedTrialSession.startDate, + }) && formattedTrialSession.sessionStatus !== SESSION_STATUS_TYPES.closed; if (showAlertForNOTTReminder) { diff --git a/web-client/src/presenter/computeds/trialSessionsHelper.test.ts b/web-client/src/presenter/computeds/trialSessionsHelper.test.ts index c4acd6171e4..69fa7724e74 100644 --- a/web-client/src/presenter/computeds/trialSessionsHelper.test.ts +++ b/web-client/src/presenter/computeds/trialSessionsHelper.test.ts @@ -6,6 +6,7 @@ import { TRIAL_SESSION_SCOPE_TYPES, } from '../../../../shared/src/business/entities/EntityConstants'; import { TrialSessionInfoDTO } from '@shared/business/dto/trialSessions/TrialSessionInfoDTO'; +import { calculateISODate } from '@shared/business/utilities/DateHandler'; import { cloneDeep } from 'lodash'; import { docketClerk1User, judgeUser } from '@shared/test/mockUsers'; import { getUserPermissions } from '@shared/authorization/getUserPermissions'; @@ -513,7 +514,11 @@ describe('trialSessionsHelper', () => { it('should show an alertMessage for NOTT reminders when the user has not dismissed the alert and the start day is within the reminder range', () => { trialSession1.dismissedAlertForNOTT = false; - trialSession1.isStartDateWithinNOTTReminderRange = true; + trialSession1.isCalendared = true; + trialSession1.startDate = calculateISODate({ + howMuch: 30, + units: 'days', + }); trialSession1.thirtyDaysBeforeTrialFormatted = '06/03/13'; trialSessionsPageState.trialSessions = [trialSession1]; diff --git a/web-client/src/presenter/computeds/trialSessionsHelper.ts b/web-client/src/presenter/computeds/trialSessionsHelper.ts index aa7cd6a73f9..56ade66e792 100644 --- a/web-client/src/presenter/computeds/trialSessionsHelper.ts +++ b/web-client/src/presenter/computeds/trialSessionsHelper.ts @@ -5,6 +5,7 @@ import { } from '@shared/business/utilities/DateHandler'; import { Get } from 'cerebral'; import { RawUser } from '@shared/business/entities/User'; +import { TrialSession } from '@shared/business/entities/trialSessions/TrialSession'; import { TrialSessionInfoDTO } from '@shared/business/dto/trialSessions/TrialSessionInfoDTO'; import { state } from '@web-client/presenter/app.cerebral'; @@ -93,7 +94,10 @@ const formatTrialSessions = ({ trialSession => { const showAlertForNOTTReminder = !trialSession.dismissedAlertForNOTT && - !!trialSession.isStartDateWithinNOTTReminderRange; + TrialSession.isStartDateWithinNOTTReminderRange({ + isCalendared: trialSession.isCalendared, + startDate: trialSession.startDate, + }); const alertMessageForNOTT = showAlertForNOTTReminder ? `The 30-day notice is due by ${trialSession.thirtyDaysBeforeTrialFormatted}` From 91c670c70f512630f89af9f522867b606159c7c5 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 10 Sep 2024 15:39:03 -0700 Subject: [PATCH 31/96] 10409 calculate thirtyDaysBeforeTrialFormatted instead of storing on entity. Move to presenter layer --- .../dto/trialSessions/TrialSessionInfoDTO.ts | 3 --- ...ion.thirtyDaysBeforeTrialFormatted.test.ts | 18 --------------- .../entities/trialSessions/TrialSession.ts | 22 ------------------- .../dismissNOTTReminder.test.ts | 14 ++++++++---- .../serveNOTTsFromReminder.test.ts | 9 +++++--- .../formattedTrialSessionDetails.test.ts | 11 ++++++---- .../computeds/formattedTrialSessionDetails.ts | 3 ++- .../computeds/trialSessionsHelper.test.ts | 11 ++++++---- .../computeds/trialSessionsHelper.ts | 10 ++++++++- 9 files changed, 41 insertions(+), 60 deletions(-) delete mode 100644 shared/src/business/entities/trialSessions/TrialSession.thirtyDaysBeforeTrialFormatted.test.ts diff --git a/shared/src/business/dto/trialSessions/TrialSessionInfoDTO.ts b/shared/src/business/dto/trialSessions/TrialSessionInfoDTO.ts index 87ae68e9b11..fca87992417 100644 --- a/shared/src/business/dto/trialSessions/TrialSessionInfoDTO.ts +++ b/shared/src/business/dto/trialSessions/TrialSessionInfoDTO.ts @@ -21,14 +21,11 @@ export class TrialSessionInfoDTO { public sessionStatus: string; public swingSession?: boolean; public dismissedAlertForNOTT?: boolean; - public thirtyDaysBeforeTrialFormatted?: string; constructor(rawTrialSession: RawTrialSession) { this.estimatedEndDate = rawTrialSession.estimatedEndDate; this.isCalendared = rawTrialSession.isCalendared; this.judge = rawTrialSession.judge; - this.thirtyDaysBeforeTrialFormatted = - rawTrialSession.thirtyDaysBeforeTrialFormatted; this.proceedingType = rawTrialSession.proceedingType; this.sessionType = rawTrialSession.sessionType; this.startDate = rawTrialSession.startDate; diff --git a/shared/src/business/entities/trialSessions/TrialSession.thirtyDaysBeforeTrialFormatted.test.ts b/shared/src/business/entities/trialSessions/TrialSession.thirtyDaysBeforeTrialFormatted.test.ts deleted file mode 100644 index 4e4c6d00d6e..00000000000 --- a/shared/src/business/entities/trialSessions/TrialSession.thirtyDaysBeforeTrialFormatted.test.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { MOCK_TRIAL_REGULAR } from '../../../test/mockTrial'; -import { TrialSession } from './TrialSession'; - -describe('TrialSession entity', () => { - describe('thirtyDaysBeforeTrialFormatted', () => { - // this is how the court was calculating the duration days between dates - // https://www.timeanddate.com/date/durationresult.html?m1=5&d1=17&y1=2023&m2=6&d2=15&y2=2023&ti=on - it("should set thirtyDaysBeforeTrialFormatted to 30 days prior to the trial's startDate, inclusive of the startDate, when the trial session is calendared", () => { - const trialSession = new TrialSession({ - ...MOCK_TRIAL_REGULAR, - isCalendared: true, - startDate: '2023-06-15', - }); - - expect(trialSession.thirtyDaysBeforeTrialFormatted).toBe('05/17/23'); - }); - }); -}); diff --git a/shared/src/business/entities/trialSessions/TrialSession.ts b/shared/src/business/entities/trialSessions/TrialSession.ts index d46335e5b8c..bba85f21107 100644 --- a/shared/src/business/entities/trialSessions/TrialSession.ts +++ b/shared/src/business/entities/trialSessions/TrialSession.ts @@ -106,7 +106,6 @@ export class TrialSession extends JoiValidationEntity { public swingSessionId?: string; public term: string; public termYear: string; - public thirtyDaysBeforeTrialFormatted?: string; public trialClerk?: TTrialClerk; public trialLocation?: string; public trialSessionId?: string; @@ -197,10 +196,6 @@ export class TrialSession extends JoiValidationEntity { }; } - if (rawSession.isCalendared && rawSession.startDate) { - this.setNoticeOfTrialReminderAlert(); - } - if (rawSession.trialClerk && rawSession.trialClerk.name) { this.trialClerk = { name: rawSession.trialClerk.name, @@ -430,23 +425,6 @@ export class TrialSession extends JoiValidationEntity { return skPrefix; } - setNoticeOfTrialReminderAlert() { - const formattedStartDate = formatDateString(this.startDate, FORMATS.MMDDYY); - const trialStartDateString = prepareDateFromString( - formattedStartDate, - FORMATS.MMDDYY, - ); - - const thirtyDaysBeforeTrialInclusive: any = trialStartDateString.minus({ - ['days']: 29, - }); - - this.thirtyDaysBeforeTrialFormatted = formatDateString( - thirtyDaysBeforeTrialInclusive, - FORMATS.MMDDYY, - ); - } - setAsCalendared() { this.isCalendared = true; this.sessionStatus = SESSION_STATUS_TYPES.open; diff --git a/web-client/integration-tests/dismissNOTTReminder.test.ts b/web-client/integration-tests/dismissNOTTReminder.test.ts index e113eafa988..10d50993a69 100644 --- a/web-client/integration-tests/dismissNOTTReminder.test.ts +++ b/web-client/integration-tests/dismissNOTTReminder.test.ts @@ -93,8 +93,11 @@ describe('Dismiss NOTT reminder on calendared trial session within 30-35 day ran }, ); - expect(trialSessionDetailsFormatted.alertMessageForNOTT).toEqual( - `30-day trial notices are due by ${trialSessionDetailsFormatted.thirtyDaysBeforeTrialFormatted}. Have notices been served?`, + expect(trialSessionDetailsFormatted.alertMessageForNOTT).toContain( + '30-day trial notices are due by', + ); + expect(trialSessionDetailsFormatted.alertMessageForNOTT).toContain( + 'Have notices been served?', ); let trialSessionDetailsHelperComputed: any = runCompute( @@ -130,8 +133,11 @@ describe('Dismiss NOTT reminder on calendared trial session within 30-35 day ran }, ); - expect(trialSessionDetailsFormatted.alertMessageForNOTT).toEqual( - `30-day trial notices are due by ${trialSessionDetailsFormatted.thirtyDaysBeforeTrialFormatted}. Have notices been served?`, + expect(trialSessionDetailsFormatted.alertMessageForNOTT).toContain( + '30-day trial notices are due by', + ); + expect(trialSessionDetailsFormatted.alertMessageForNOTT).toContain( + 'Have notices been served?', ); let trialSessionDetailsHelperComputed: any = runCompute( diff --git a/web-client/integration-tests/serveNOTTsFromReminder.test.ts b/web-client/integration-tests/serveNOTTsFromReminder.test.ts index 3f380a9b8c8..298b9496e83 100644 --- a/web-client/integration-tests/serveNOTTsFromReminder.test.ts +++ b/web-client/integration-tests/serveNOTTsFromReminder.test.ts @@ -107,15 +107,18 @@ describe('Serve NOTTs from reminder on calendared trial session detail page', () trialSessionId: cerebralTest.trialSessionId, }); - const trialSessionDetailsFormatted: any = runCompute( + const trialSessionDetailsFormatted = runCompute( withAppContextDecorator(formattedTrialSessionDetails), { state: cerebralTest.getState(), }, ); - expect(trialSessionDetailsFormatted.alertMessageForNOTT).toEqual( - `30-day trial notices are due by ${trialSessionDetailsFormatted.thirtyDaysBeforeTrialFormatted}. Have notices been served?`, + expect(trialSessionDetailsFormatted.alertMessageForNOTT).toContain( + '30-day trial notices are due by', + ); + expect(trialSessionDetailsFormatted.alertMessageForNOTT).toContain( + 'Have notices been served?', ); }); diff --git a/web-client/src/presenter/computeds/formattedTrialSessionDetails.test.ts b/web-client/src/presenter/computeds/formattedTrialSessionDetails.test.ts index b6d1ca36b6d..cd255d525bb 100644 --- a/web-client/src/presenter/computeds/formattedTrialSessionDetails.test.ts +++ b/web-client/src/presenter/computeds/formattedTrialSessionDetails.test.ts @@ -1,3 +1,8 @@ +import { + FORMATS, + calculateISODate, + formatNow, +} from '@shared/business/utilities/DateHandler'; import { HYBRID_SESSION_TYPES, SESSION_STATUS_GROUPS, @@ -6,7 +11,6 @@ import { TRIAL_SESSION_SCOPE_TYPES, } from '../../../../shared/src/business/entities/EntityConstants'; import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; -import { calculateISODate } from '@shared/business/utilities/DateHandler'; import { colvinsChambersUser, docketClerkUser, @@ -528,8 +532,7 @@ describe('formattedTrialSessionDetails', () => { ...TRIAL_SESSION, dismissedAlertForNOTT: false, isCalendared: true, - startDate: calculateISODate({ howMuch: 30, units: 'days' }), - thirtyDaysBeforeTrialFormatted: '2/2/2022', + startDate: calculateISODate({ howMuch: 29, units: 'days' }), }; const result: any = runCompute(formattedTrialSessionDetails, { @@ -543,7 +546,7 @@ describe('formattedTrialSessionDetails', () => { expect(result.showAlertForNOTTReminder).toBe(true); expect(result.alertMessageForNOTT).toEqual( - '30-day trial notices are due by 2/2/2022. Have notices been served?', + `30-day trial notices are due by ${formatNow(FORMATS.MMDDYY)}. Have notices been served?`, ); }); diff --git a/web-client/src/presenter/computeds/formattedTrialSessionDetails.ts b/web-client/src/presenter/computeds/formattedTrialSessionDetails.ts index 90a7e6b3037..ff5d83d8434 100644 --- a/web-client/src/presenter/computeds/formattedTrialSessionDetails.ts +++ b/web-client/src/presenter/computeds/formattedTrialSessionDetails.ts @@ -4,6 +4,7 @@ import { Get } from 'cerebral'; import { TrialSession } from '@shared/business/entities/trialSessions/TrialSession'; import { isEmpty, isEqual } from 'lodash'; import { state } from '@web-client/presenter/app.cerebral'; +import { thirtyDaysBeforeTrial } from '@web-client/presenter/computeds/trialSessionsHelper'; type FormatTrialSessionHelperType = FormattedTrialSessionDetailsType & { alertMessageForNOTT?: string; @@ -66,7 +67,7 @@ export const formattedTrialSessionDetails = ( formattedTrialSession.sessionStatus !== SESSION_STATUS_TYPES.closed; if (showAlertForNOTTReminder) { - alertMessageForNOTT = `30-day trial notices are due by ${formattedTrialSession.thirtyDaysBeforeTrialFormatted}. Have notices been served?`; + alertMessageForNOTT = `30-day trial notices are due by ${thirtyDaysBeforeTrial(formattedTrialSession.startDate)}. Have notices been served?`; } if (formattedTrialSession.chambersPhoneNumber) { diff --git a/web-client/src/presenter/computeds/trialSessionsHelper.test.ts b/web-client/src/presenter/computeds/trialSessionsHelper.test.ts index 69fa7724e74..d2b814c8e81 100644 --- a/web-client/src/presenter/computeds/trialSessionsHelper.test.ts +++ b/web-client/src/presenter/computeds/trialSessionsHelper.test.ts @@ -1,3 +1,8 @@ +import { + FORMATS, + calculateISODate, + formatNow, +} from '@shared/business/utilities/DateHandler'; import { ROLES, SESSION_STATUS_TYPES, @@ -6,7 +11,6 @@ import { TRIAL_SESSION_SCOPE_TYPES, } from '../../../../shared/src/business/entities/EntityConstants'; import { TrialSessionInfoDTO } from '@shared/business/dto/trialSessions/TrialSessionInfoDTO'; -import { calculateISODate } from '@shared/business/utilities/DateHandler'; import { cloneDeep } from 'lodash'; import { docketClerk1User, judgeUser } from '@shared/test/mockUsers'; import { getUserPermissions } from '@shared/authorization/getUserPermissions'; @@ -516,10 +520,9 @@ describe('trialSessionsHelper', () => { trialSession1.dismissedAlertForNOTT = false; trialSession1.isCalendared = true; trialSession1.startDate = calculateISODate({ - howMuch: 30, + howMuch: 29, units: 'days', }); - trialSession1.thirtyDaysBeforeTrialFormatted = '06/03/13'; trialSessionsPageState.trialSessions = [trialSession1]; const result = runCompute(trialSessionsHelper, { @@ -532,7 +535,7 @@ describe('trialSessionsHelper', () => { const trialSessionsOnly = result.trialSessionRows.filter(isTrialSessionRow); expect(trialSessionsOnly[0].alertMessageForNOTT).toEqual( - `The 30-day notice is due by ${trialSession1.thirtyDaysBeforeTrialFormatted}`, + `The 30-day notice is due by ${formatNow(FORMATS.MMDDYY)}`, ); expect(trialSessionsOnly[0].showAlertForNOTTReminder).toEqual(true); }); diff --git a/web-client/src/presenter/computeds/trialSessionsHelper.ts b/web-client/src/presenter/computeds/trialSessionsHelper.ts index 56ade66e792..3ce8a569ee8 100644 --- a/web-client/src/presenter/computeds/trialSessionsHelper.ts +++ b/web-client/src/presenter/computeds/trialSessionsHelper.ts @@ -2,6 +2,7 @@ import { FORMATS, createDateAtStartOfWeekEST, formatDateString, + subtractISODates, } from '@shared/business/utilities/DateHandler'; import { Get } from 'cerebral'; import { RawUser } from '@shared/business/entities/User'; @@ -100,7 +101,7 @@ const formatTrialSessions = ({ }); const alertMessageForNOTT = showAlertForNOTTReminder - ? `The 30-day notice is due by ${trialSession.thirtyDaysBeforeTrialFormatted}` + ? `The 30-day notice is due by ${thirtyDaysBeforeTrial(trialSession.startDate)}` : ''; const formattedEstimatedEndDate = formatDateString( trialSession.estimatedEndDate, @@ -172,6 +173,13 @@ const formatTrialSessions = ({ return trialSessionWithStartWeeks; }; +export const thirtyDaysBeforeTrial = (startDate?: string): string => { + if (!startDate) return ''; + const thirtyDaysBeforeTrialIso = subtractISODates(startDate, { day: 29 }); + + return formatDateString(thirtyDaysBeforeTrialIso, FORMATS.MMDDYY); +}; + type TrialSessionRow = { trialSessionId: string; showAlertForNOTTReminder: boolean; From 3ed8edbc86bf4862aafcd44b4e3198b5d3c0e664 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Wed, 11 Sep 2024 10:29:26 -0700 Subject: [PATCH 32/96] 10409 always route the user to the new tab once they have created a trial session --- .../setActiveTrialSessionsTabAction.test.ts | 19 ++----------------- .../setActiveTrialSessionsTabAction.ts | 13 ++----------- 2 files changed, 4 insertions(+), 28 deletions(-) diff --git a/web-client/src/presenter/actions/TrialSession/setActiveTrialSessionsTabAction.test.ts b/web-client/src/presenter/actions/TrialSession/setActiveTrialSessionsTabAction.test.ts index b1358480693..c1a64879083 100644 --- a/web-client/src/presenter/actions/TrialSession/setActiveTrialSessionsTabAction.test.ts +++ b/web-client/src/presenter/actions/TrialSession/setActiveTrialSessionsTabAction.test.ts @@ -1,27 +1,12 @@ -import { TRIAL_SESSION_SCOPE_TYPES } from '@shared/business/entities/EntityConstants'; import { runAction } from '@web-client/presenter/test.cerebral'; import { setActiveTrialSessionsTabAction } from '@web-client/presenter/actions/TrialSession/setActiveTrialSessionsTabAction'; describe('setActiveTrialSessionsTabAction', () => { - it('sets state.currentViewMetadata.tab to new when props.sessionScope location-based', async () => { + it('sets the trial sessions page tab to new after creating a trial session so the user can see their newly created trial sesison', async () => { const result = await runAction(setActiveTrialSessionsTabAction, { - props: { - sessionScope: TRIAL_SESSION_SCOPE_TYPES.locationBased, - }, state: {}, }); - expect(result.state.currentViewMetadata.trialSessions.tab).toEqual('new'); - }); - - it('sets state.currentViewMetadata.tab to open when props.sessionScope is not location-based', async () => { - const result = await runAction(setActiveTrialSessionsTabAction, { - props: { - sessionScope: TRIAL_SESSION_SCOPE_TYPES.standaloneRemote, - }, - state: {}, - }); - - expect(result.state.currentViewMetadata.trialSessions.tab).toEqual('open'); + expect(result.state.trialSessionsPage.filters.currentTab).toEqual('new'); }); }); diff --git a/web-client/src/presenter/actions/TrialSession/setActiveTrialSessionsTabAction.ts b/web-client/src/presenter/actions/TrialSession/setActiveTrialSessionsTabAction.ts index 6c1da46e62a..0d66660a724 100644 --- a/web-client/src/presenter/actions/TrialSession/setActiveTrialSessionsTabAction.ts +++ b/web-client/src/presenter/actions/TrialSession/setActiveTrialSessionsTabAction.ts @@ -1,17 +1,8 @@ -import { - TRIAL_SESSION_SCOPE_TYPES, - TrialSessionScope, -} from '@shared/business/entities/EntityConstants'; +import { TrialSessionScope } from '@shared/business/entities/EntityConstants'; import { state } from '@web-client/presenter/app.cerebral'; export const setActiveTrialSessionsTabAction = ({ - props, store, }: ActionProps<{ sessionScope: TrialSessionScope }>) => { - const activeTab = - props.sessionScope === TRIAL_SESSION_SCOPE_TYPES.locationBased - ? 'new' - : 'open'; - - store.set(state.currentViewMetadata.trialSessions.tab, activeTab); + store.set(state.trialSessionsPage.filters.currentTab, 'new'); }; From a7bf3dda352d7e6f11c5ac710d77bf625cf579a8 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Wed, 11 Sep 2024 10:57:01 -0700 Subject: [PATCH 33/96] 10409 add query params back when navigating to trial sessions --- .../src/presenter/sequences/gotoTrialSessionsSequence.ts | 5 ++++- web-client/src/router.ts | 3 ++- web-client/src/views/TrialSessions/TrialSessionsSummary.tsx | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/web-client/src/presenter/sequences/gotoTrialSessionsSequence.ts b/web-client/src/presenter/sequences/gotoTrialSessionsSequence.ts index c8cb98091a7..3a11c70f1eb 100644 --- a/web-client/src/presenter/sequences/gotoTrialSessionsSequence.ts +++ b/web-client/src/presenter/sequences/gotoTrialSessionsSequence.ts @@ -1,3 +1,4 @@ +import { TrialSessionsFilters } from '@web-client/presenter/state/trialSessionsPageState'; import { clearErrorAlertsAction } from '../actions/clearErrorAlertsAction'; import { clearScreenMetadataAction } from '../actions/clearScreenMetadataAction'; import { closeMobileMenuAction } from '../actions/closeMobileMenuAction'; @@ -9,6 +10,7 @@ import { parallel } from 'cerebral/factories'; import { setAllAndCurrentJudgesAction } from '../actions/setAllAndCurrentJudgesAction'; import { setJudgeUserAction } from '../actions/setJudgeUserAction'; import { setNotificationsAction } from '../actions/setNotificationsAction'; +import { setTrialSessionsFiltersAction } from '@web-client/presenter/actions/TrialSession/setTrialSessionsFiltersAction'; import { setTrialSessionsPageAction } from '@web-client/presenter/actions/TrialSession/setTrialSessionsPageAction'; import { setupCurrentPageAction } from '../actions/setupCurrentPageAction'; import { startWebSocketConnectionSequenceDecorator } from '../utilities/startWebSocketConnectionSequenceDecorator'; @@ -19,6 +21,7 @@ export const gotoTrialSessionsSequence = clearScreenMetadataAction, closeMobileMenuAction, clearErrorAlertsAction, + setTrialSessionsFiltersAction, parallel([ [getJudgeForCurrentUserAction, setJudgeUserAction], [getNotificationsAction, setNotificationsAction], @@ -29,4 +32,4 @@ export const gotoTrialSessionsSequence = ], ]), setupCurrentPageAction('TrialSessions'), - ]) as unknown as () => void; + ]) as unknown as (props: ActionProps>) => void; diff --git a/web-client/src/router.ts b/web-client/src/router.ts index 0418fe1c75f..4b6788787bf 100644 --- a/web-client/src/router.ts +++ b/web-client/src/router.ts @@ -1147,8 +1147,9 @@ const router = { ifHasAccess( { app, permissionToCheck: ROLE_PERMISSIONS.TRIAL_SESSIONS }, () => { + const queryParams = route.query(); setPageTitle('Trial sessions'); - return app.getSequence('gotoTrialSessionsSequence')(); + return app.getSequence('gotoTrialSessionsSequence')(queryParams); }, ), ); diff --git a/web-client/src/views/TrialSessions/TrialSessionsSummary.tsx b/web-client/src/views/TrialSessions/TrialSessionsSummary.tsx index e587f21740c..14fdf373f5d 100644 --- a/web-client/src/views/TrialSessions/TrialSessionsSummary.tsx +++ b/web-client/src/views/TrialSessions/TrialSessionsSummary.tsx @@ -24,7 +24,7 @@ export const TrialSessionsSummary = connect( link className="margin-left-205" data-testid="view-all-trial-sessions-button" - href={`/trial-sessions?judge[userId]=${trialSessionsSummaryHelper.judgeUserId}`} + href={`/trial-sessions?judgeId=${trialSessionsSummaryHelper.judgeUserId}`} > View All From 4451202333b55a140292eed099ee968a3ac36bb1 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Wed, 11 Sep 2024 11:52:54 -0700 Subject: [PATCH 34/96] 10409 look at calendared trial sessions after making one --- web-client/integration-tests/dismissNOTTReminder.test.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/web-client/integration-tests/dismissNOTTReminder.test.ts b/web-client/integration-tests/dismissNOTTReminder.test.ts index 10d50993a69..33c6ed0dcf2 100644 --- a/web-client/integration-tests/dismissNOTTReminder.test.ts +++ b/web-client/integration-tests/dismissNOTTReminder.test.ts @@ -58,6 +58,9 @@ describe('Dismiss NOTT reminder on calendared trial session within 30-35 day ran loginAs(cerebralTest, 'docketclerk@example.com'); it('should see the NOTT reminder icon on the trial session list', async () => { await cerebralTest.runSequence('gotoTrialSessionsSequence'); + await cerebralTest.runSequence('setTrialSessionsFiltersSequence', { + currentTab: 'calendared', + }); expect(cerebralTest.getState('currentPage')).toEqual('TrialSessions'); From b1a01da35dfbbf66fcfb21602b66a9b1e87820c9 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 12 Sep 2024 14:55:41 -0700 Subject: [PATCH 35/96] 10409: Reset state when a user signs out. Only show inactive judges on All/Closed trial sessions. --- .../Login/resetToBaseStateAction.test.ts | 28 +++++++++++++++++++ .../actions/Login/resetToBaseStateAction.ts | 18 ++++++++++++ .../resetTrialSessionsFiltersAction.test.ts | 15 ++++++++++ .../resetTrialSessionsFiltersAction.ts | 7 +++++ .../actions/clearLoginFormAction.test.ts | 19 ------------- .../presenter/actions/clearLoginFormAction.ts | 13 --------- .../computeds/trialSessionsHelper.test.ts | 27 ++++++++++++++++-- .../computeds/trialSessionsHelper.ts | 15 +++++----- web-client/src/presenter/presenter.ts | 3 +- .../sequences/gotoTrialSessionsSequence.ts | 4 +-- .../presenter/sequences/signOutSequence.ts | 4 +-- 11 files changed, 106 insertions(+), 47 deletions(-) create mode 100644 web-client/src/presenter/actions/Login/resetToBaseStateAction.test.ts create mode 100644 web-client/src/presenter/actions/Login/resetToBaseStateAction.ts create mode 100644 web-client/src/presenter/actions/TrialSession/resetTrialSessionsFiltersAction.test.ts create mode 100644 web-client/src/presenter/actions/TrialSession/resetTrialSessionsFiltersAction.ts delete mode 100644 web-client/src/presenter/actions/clearLoginFormAction.test.ts delete mode 100644 web-client/src/presenter/actions/clearLoginFormAction.ts diff --git a/web-client/src/presenter/actions/Login/resetToBaseStateAction.test.ts b/web-client/src/presenter/actions/Login/resetToBaseStateAction.test.ts new file mode 100644 index 00000000000..0c175f35fee --- /dev/null +++ b/web-client/src/presenter/actions/Login/resetToBaseStateAction.test.ts @@ -0,0 +1,28 @@ +import { baseState } from '@web-client/presenter/state'; +import { resetToBaseStateAction } from '@web-client/presenter/actions/Login/resetToBaseStateAction'; +import { runAction } from '@web-client/presenter/test.cerebral'; + +describe('resetToBaseStateAction', () => { + it('should reset state to baseState except for a few state slices', async () => { + const stateThatShouldNotBeReset = { + featureFlags: {}, + header: {}, + idleLogoutState: {}, + idleStatus: {}, + lastIdleAction: {}, + maintenanceMode: {}, + }; + + const result = await runAction(resetToBaseStateAction, { + state: { + ...stateThatShouldNotBeReset, + trialSessionsPage: { stuff: 'this should be reset' }, + }, + }); + + expect(result.state).toEqual({ + ...baseState, + ...stateThatShouldNotBeReset, + }); + }); +}); diff --git a/web-client/src/presenter/actions/Login/resetToBaseStateAction.ts b/web-client/src/presenter/actions/Login/resetToBaseStateAction.ts new file mode 100644 index 00000000000..061feac1fe6 --- /dev/null +++ b/web-client/src/presenter/actions/Login/resetToBaseStateAction.ts @@ -0,0 +1,18 @@ +import { baseState } from '@web-client/presenter/state'; +import { cloneDeep } from 'lodash'; +import { state } from '@web-client/presenter/app.cerebral'; + +export const resetToBaseStateAction = ({ store }: ActionProps) => { + Object.entries(cloneDeep(baseState)).forEach(([key, value]) => { + const stateSlicesToPersist = [ + 'maintenanceMode', + 'featureFlags', + 'idleLogoutState', + 'idleStatus', + 'lastIdleAction', + 'header', + ]; + if (stateSlicesToPersist.includes(key)) return; + store.set(state[key], value); + }); +}; diff --git a/web-client/src/presenter/actions/TrialSession/resetTrialSessionsFiltersAction.test.ts b/web-client/src/presenter/actions/TrialSession/resetTrialSessionsFiltersAction.test.ts new file mode 100644 index 00000000000..487f0db01e4 --- /dev/null +++ b/web-client/src/presenter/actions/TrialSession/resetTrialSessionsFiltersAction.test.ts @@ -0,0 +1,15 @@ +import { initialTrialSessionPageState } from '@web-client/presenter/state/trialSessionsPageState'; +import { resetTrialSessionsFiltersAction } from '@web-client/presenter/actions/TrialSession/resetTrialSessionsFiltersAction'; +import { runAction } from '@web-client/presenter/test.cerebral'; + +describe('resetTrialSessionsFiltersAction', () => { + it('should reset the trialSessions filters', async () => { + const result = await runAction(resetTrialSessionsFiltersAction, { + state: {}, + }); + + expect(result.state.trialSessionsPage).toEqual( + initialTrialSessionPageState, + ); + }); +}); diff --git a/web-client/src/presenter/actions/TrialSession/resetTrialSessionsFiltersAction.ts b/web-client/src/presenter/actions/TrialSession/resetTrialSessionsFiltersAction.ts new file mode 100644 index 00000000000..57f6678c48e --- /dev/null +++ b/web-client/src/presenter/actions/TrialSession/resetTrialSessionsFiltersAction.ts @@ -0,0 +1,7 @@ +import { cloneDeep } from 'lodash'; +import { initialTrialSessionPageState } from '@web-client/presenter/state/trialSessionsPageState'; +import { state } from '@web-client/presenter/app.cerebral'; + +export const resetTrialSessionsFiltersAction = ({ store }: ActionProps) => { + store.set(state.trialSessionsPage, cloneDeep(initialTrialSessionPageState)); +}; diff --git a/web-client/src/presenter/actions/clearLoginFormAction.test.ts b/web-client/src/presenter/actions/clearLoginFormAction.test.ts deleted file mode 100644 index 4a84513be8d..00000000000 --- a/web-client/src/presenter/actions/clearLoginFormAction.test.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { clearLoginFormAction } from './clearLoginFormAction'; -import { runAction } from '@web-client/presenter/test.cerebral'; - -describe('clearLoginFormAction', () => { - it('should reset the form state', async () => { - const result = await runAction(clearLoginFormAction, { - state: { - form: { - name: 'Joe', - nature: 'Exotic', - }, - }, - }); - - expect(result.state.form).toMatchObject({ - email: '', - }); - }); -}); diff --git a/web-client/src/presenter/actions/clearLoginFormAction.ts b/web-client/src/presenter/actions/clearLoginFormAction.ts deleted file mode 100644 index 676d1fe3370..00000000000 --- a/web-client/src/presenter/actions/clearLoginFormAction.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { state } from '@web-client/presenter/app.cerebral'; - -/** - * resets the form. - * state.form is used throughout the app for storing html form values - * @param {object} providers the providers object - * @param {object} providers.store the cerebral store object used for setting the form - */ -export const clearLoginFormAction = ({ store }: ActionProps) => { - store.set(state.form, { - email: '', - }); -}; diff --git a/web-client/src/presenter/computeds/trialSessionsHelper.test.ts b/web-client/src/presenter/computeds/trialSessionsHelper.test.ts index d2b814c8e81..249900ed39a 100644 --- a/web-client/src/presenter/computeds/trialSessionsHelper.test.ts +++ b/web-client/src/presenter/computeds/trialSessionsHelper.test.ts @@ -145,8 +145,10 @@ describe('trialSessionsHelper', () => { }); describe('trialSessionJudges', () => { - it('returns all current and legacy judges when the current tab is calendared', () => { + it('returns all current and legacy judges when the session status is closed', () => { trialSessionsPageState.filters.currentTab = 'calendared'; + trialSessionsPageState.filters.sessionStatus = + SESSION_STATUS_TYPES.closed; const result = runCompute(trialSessionsHelper, { state: { judges: [ @@ -167,7 +169,7 @@ describe('trialSessionsHelper', () => { ]); }); - it('returns only non-legacy judges when the current tab is new', () => { + it('returns only current judges when the current tab is new', () => { trialSessionsPageState.filters.currentTab = 'new'; const result = runCompute(trialSessionsHelper, { state: { @@ -187,6 +189,27 @@ describe('trialSessionsHelper', () => { { name: 'I am not a legacy judge part 2', role: ROLES.judge }, ]); }); + + it('returns only current judges when the session status is open', () => { + trialSessionsPageState.filters.sessionStatus = SESSION_STATUS_TYPES.open; + const result = runCompute(trialSessionsHelper, { + state: { + judges: [ + { name: 'I am not a legacy judge part 2', role: ROLES.judge }, + ], + legacyAndCurrentJudges: [ + { name: 'I am not a legacy judge', role: ROLES.judge }, + { name: 'I am a legacy judge', role: ROLES.legacyJudge }, + ], + permissions: getUserPermissions(docketClerk1User), + trialSessionsPage: trialSessionsPageState, + }, + }); + + expect(result.trialSessionJudges).toEqual([ + { name: 'I am not a legacy judge part 2', role: ROLES.judge }, + ]); + }); }); describe('showNewTrialSession', () => { diff --git a/web-client/src/presenter/computeds/trialSessionsHelper.ts b/web-client/src/presenter/computeds/trialSessionsHelper.ts index 3ce8a569ee8..5ab8fe8ce8a 100644 --- a/web-client/src/presenter/computeds/trialSessionsHelper.ts +++ b/web-client/src/presenter/computeds/trialSessionsHelper.ts @@ -6,6 +6,7 @@ import { } from '@shared/business/utilities/DateHandler'; import { Get } from 'cerebral'; import { RawUser } from '@shared/business/entities/User'; +import { SESSION_STATUS_TYPES } from '@shared/business/entities/EntityConstants'; import { TrialSession } from '@shared/business/entities/trialSessions/TrialSession'; import { TrialSessionInfoDTO } from '@shared/business/dto/trialSessions/TrialSessionInfoDTO'; import { state } from '@web-client/presenter/app.cerebral'; @@ -21,15 +22,13 @@ export const trialSessionsHelper = ( trialSessionRows: (TrialSessionRow | TrialSessionWeek)[]; } => { const permissions = get(state.permissions)!; - const tab = get(state.trialSessionsPage.filters.currentTab); const trialSessions = get(state.trialSessionsPage.trialSessions); const filters = get(state.trialSessionsPage.filters); const judge = get(state.judgeUser); - const isNewTab = tab === 'new'; - const isCalendared = tab === 'calendared'; - - const showCurrentJudgesOnly = isNewTab; + const showCurrentJudgesOnly = + filters.currentTab === 'new' || + filters.sessionStatus === SESSION_STATUS_TYPES.open; let trialSessionJudges; if (showCurrentJudgesOnly) { @@ -76,9 +75,9 @@ export const trialSessionsHelper = ( return { showNewTrialSession: permissions.CREATE_TRIAL_SESSION, - showNoticeIssued: isCalendared, - showSessionStatus: isCalendared, - showUnassignedJudgeFilter: isNewTab, + showNoticeIssued: filters.currentTab === 'calendared', + showSessionStatus: filters.currentTab === 'calendared', + showUnassignedJudgeFilter: filters.currentTab === 'new', trialSessionJudges, trialSessionRows, }; diff --git a/web-client/src/presenter/presenter.ts b/web-client/src/presenter/presenter.ts index a9025f28fd1..1269daa6121 100644 --- a/web-client/src/presenter/presenter.ts +++ b/web-client/src/presenter/presenter.ts @@ -67,6 +67,7 @@ import { clearPreferredTrialCitySequence } from './sequences/clearPreferredTrial import { clearSelectedWorkItemsSequence } from './sequences/clearSelectedWorkItemsSequence'; import { clearStatusReportOrderFormSequence } from './sequences/StatusReportOrder/clearStatusReportOrderFormSequence'; import { clearViewerDocumentToDisplaySequence } from './sequences/clearViewerDocumentToDisplaySequence'; +import { cloneDeep } from 'lodash'; import { closeModalAndNavigateBackSequence } from './sequences/closeModalAndNavigateBackSequence'; import { closeModalAndNavigateSequence } from './sequences/closeModalAndNavigateSequence'; import { closeModalAndNavigateToMaintenanceSequence } from './sequences/closeModalAndNavigateToMaintenanceSequence'; @@ -1664,7 +1665,7 @@ export const presenter = { ], providers: {} as { applicationContext: ClientApplicationContext; router: {} }, sequences: presenterSequences, - state: initialState, + state: cloneDeep(initialState), }; export type Sequences = typeof presenterSequences; diff --git a/web-client/src/presenter/sequences/gotoTrialSessionsSequence.ts b/web-client/src/presenter/sequences/gotoTrialSessionsSequence.ts index 3a11c70f1eb..1e1fd2e0a17 100644 --- a/web-client/src/presenter/sequences/gotoTrialSessionsSequence.ts +++ b/web-client/src/presenter/sequences/gotoTrialSessionsSequence.ts @@ -1,12 +1,12 @@ import { TrialSessionsFilters } from '@web-client/presenter/state/trialSessionsPageState'; import { clearErrorAlertsAction } from '../actions/clearErrorAlertsAction'; -import { clearScreenMetadataAction } from '../actions/clearScreenMetadataAction'; import { closeMobileMenuAction } from '../actions/closeMobileMenuAction'; import { getJudgeForCurrentUserAction } from '../actions/getJudgeForCurrentUserAction'; import { getNotificationsAction } from '../actions/getNotificationsAction'; import { getTrialSessionsAction } from '../actions/TrialSession/getTrialSessionsAction'; import { getUsersInSectionAction } from '../actions/getUsersInSectionAction'; import { parallel } from 'cerebral/factories'; +import { resetTrialSessionsFiltersAction } from '@web-client/presenter/actions/TrialSession/resetTrialSessionsFiltersAction'; import { setAllAndCurrentJudgesAction } from '../actions/setAllAndCurrentJudgesAction'; import { setJudgeUserAction } from '../actions/setJudgeUserAction'; import { setNotificationsAction } from '../actions/setNotificationsAction'; @@ -18,7 +18,7 @@ import { startWebSocketConnectionSequenceDecorator } from '../utilities/startWeb export const gotoTrialSessionsSequence = startWebSocketConnectionSequenceDecorator([ setupCurrentPageAction('Interstitial'), - clearScreenMetadataAction, + resetTrialSessionsFiltersAction, closeMobileMenuAction, clearErrorAlertsAction, setTrialSessionsFiltersAction, diff --git a/web-client/src/presenter/sequences/signOutSequence.ts b/web-client/src/presenter/sequences/signOutSequence.ts index 709b012240b..d9afcf9c0e4 100644 --- a/web-client/src/presenter/sequences/signOutSequence.ts +++ b/web-client/src/presenter/sequences/signOutSequence.ts @@ -1,11 +1,11 @@ import { broadcastLogoutAction } from '../actions/broadcastLogoutAction'; import { clearAlertsAction } from '../actions/clearAlertsAction'; -import { clearLoginFormAction } from '../actions/clearLoginFormAction'; import { clearLogoutTypeAction } from '@web-client/presenter/actions/clearLogoutTypeAction'; import { clearMaintenanceModeAction } from '../actions/clearMaintenanceModeAction'; import { clearUserAction } from '../actions/clearUserAction'; import { deleteAuthCookieAction } from '../actions/deleteAuthCookieAction'; import { resetIdleTimerAction } from '@web-client/presenter/actions/resetIdleTimerAction'; +import { resetToBaseStateAction } from '@web-client/presenter/actions/Login/resetToBaseStateAction'; import { setupCurrentPageAction } from '../actions/setupCurrentPageAction'; import { stopWebSocketConnectionAction } from '../actions/WebSocketConnection/stopWebSocketConnectionAction'; @@ -17,7 +17,7 @@ export const signOutSequence = [ clearAlertsAction, clearUserAction, clearMaintenanceModeAction, - clearLoginFormAction, clearLogoutTypeAction, resetIdleTimerAction, + resetToBaseStateAction, ]; From 63cdd9b3dae7f3af107a737fc90440117073c144 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 12 Sep 2024 14:56:30 -0700 Subject: [PATCH 36/96] 10409: Update text --- web-client/src/views/TrialSessions/TrialSessionsTable.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web-client/src/views/TrialSessions/TrialSessionsTable.tsx b/web-client/src/views/TrialSessions/TrialSessionsTable.tsx index 396b24fd192..f97331bc764 100644 --- a/web-client/src/views/TrialSessions/TrialSessionsTable.tsx +++ b/web-client/src/views/TrialSessions/TrialSessionsTable.tsx @@ -105,7 +105,7 @@ export const TrialSessionsTable = connect( ))} {trialSessionsHelper.trialSessionRows.length === 0 && ( -

There are no trial sessions.

+

There are no trial sessions for the selected filters.

)} ); From 102bdba6699709fd8b29a63732be3f15cd5d1be1 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 12 Sep 2024 15:23:00 -0700 Subject: [PATCH 37/96] 10409: Remove reset to base state --- web-client/src/presenter/sequences/signOutSequence.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/web-client/src/presenter/sequences/signOutSequence.ts b/web-client/src/presenter/sequences/signOutSequence.ts index d9afcf9c0e4..c6fa7d2f221 100644 --- a/web-client/src/presenter/sequences/signOutSequence.ts +++ b/web-client/src/presenter/sequences/signOutSequence.ts @@ -5,7 +5,6 @@ import { clearMaintenanceModeAction } from '../actions/clearMaintenanceModeActio import { clearUserAction } from '../actions/clearUserAction'; import { deleteAuthCookieAction } from '../actions/deleteAuthCookieAction'; import { resetIdleTimerAction } from '@web-client/presenter/actions/resetIdleTimerAction'; -import { resetToBaseStateAction } from '@web-client/presenter/actions/Login/resetToBaseStateAction'; import { setupCurrentPageAction } from '../actions/setupCurrentPageAction'; import { stopWebSocketConnectionAction } from '../actions/WebSocketConnection/stopWebSocketConnectionAction'; @@ -19,5 +18,4 @@ export const signOutSequence = [ clearMaintenanceModeAction, clearLogoutTypeAction, resetIdleTimerAction, - resetToBaseStateAction, ]; From 52349ba186a246aa04d0dd4d89343643e16b3e1c Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Fri, 13 Sep 2024 08:19:46 -0700 Subject: [PATCH 38/96] 10409: Update tests for legacy judges only showing on closed and all --- .../journey/docketClerkViewsTrialSessionsTab.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/web-client/integration-tests/journey/docketClerkViewsTrialSessionsTab.ts b/web-client/integration-tests/journey/docketClerkViewsTrialSessionsTab.ts index 1f164955c95..7b71a99491f 100644 --- a/web-client/integration-tests/journey/docketClerkViewsTrialSessionsTab.ts +++ b/web-client/integration-tests/journey/docketClerkViewsTrialSessionsTab.ts @@ -1,3 +1,4 @@ +import { SESSION_STATUS_TYPES } from '@shared/business/entities/EntityConstants'; import { isTrialSessionRow, trialSessionsHelper as trialSessionsHelperComputed, @@ -39,10 +40,13 @@ export const docketClerkViewsTrialSessionsTab = ( judge => judge.role === 'legacyJudge', ); - if (tab === 'calendared') { - expect(legacyJudge).toBeTruthy(); - } else { + if ( + tab === 'new' || + overrides.sessionStatus === SESSION_STATUS_TYPES.open + ) { expect(legacyJudge).toBeFalsy(); + } else { + expect(legacyJudge).toBeTruthy(); } const foundSession = helper.trialSessionRows From b85426986de19e491891a16225cf2924fa423d7a Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Fri, 13 Sep 2024 16:07:46 -0700 Subject: [PATCH 39/96] 10409: temp docs --- 10409_validation_delete_me.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 10409_validation_delete_me.md diff --git a/10409_validation_delete_me.md b/10409_validation_delete_me.md new file mode 100644 index 00000000000..44ba212c975 --- /dev/null +++ b/10409_validation_delete_me.md @@ -0,0 +1,26 @@ +Problem statement: How can we detect when making a validation changes to entities, we do not create invalid data in the database? + +- Pull all validation rules into a single file, if they change in any way, a validation sweep must be run on the database +- Continue validating before we return inside all of our interactors but instead of exploding just silently log which entities are now invalid. +- On each deployment validate all data in the database. + + +Assumptions +- Not all business rules can or should live inside of the persistence layer. + - For example when a trialSession is calendared it should have a sessionType +- What is and what is not a valid entity can only be expressed inside of functions. + - Is it possible to tell if a function has been modified between different git commits? + - If it is a pure function that does not modify any external state + + +shared/src/business/entities/contacts/Contact.ts getValidationRules depends on instance.countryType + + +Thoughts +- If validation rules are expressed inside of functions it is impossible to tell if a function has changed its behavior from one release to another. If it is impossible to tell if validation rules have changed then maybe defensively checking if they have changed, and running a validation sweep on the DB is not the correct approach +- Another option is better warnings to devs about making validation changes. +- Another option is continue validating, but only log invalid values instead of throwing errors to reduce application impact. + + +Resources +- Validate at input time. Validate again before you put it in the database. And have database constraints to prevent bad input. And you can bet in spite of all that, bad data will still get into your database, so validate it again when you use it. \ No newline at end of file From 4d404102a780a731d7777673b7b55907216bdccb Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 17 Sep 2024 15:55:05 -0700 Subject: [PATCH 40/96] 10409: WIP adding inputs for new select dropdowns on trial sessions --- web-client/src/styles/_index.scss | 1 + web-client/src/styles/utility-classes.scss | 14 ++ .../src/views/TrialSessions/TrialSessions.tsx | 238 ++++++++++-------- 3 files changed, 152 insertions(+), 101 deletions(-) create mode 100644 web-client/src/styles/utility-classes.scss diff --git a/web-client/src/styles/_index.scss b/web-client/src/styles/_index.scss index 0c6c375a3af..ca82403b7a6 100644 --- a/web-client/src/styles/_index.scss +++ b/web-client/src/styles/_index.scss @@ -13,3 +13,4 @@ @forward './tables'; @forward './tabs'; @forward './typography'; +@forward './utility-classes'; diff --git a/web-client/src/styles/utility-classes.scss b/web-client/src/styles/utility-classes.scss new file mode 100644 index 00000000000..4b19f6728d6 --- /dev/null +++ b/web-client/src/styles/utility-classes.scss @@ -0,0 +1,14 @@ +@use '../uswds' as *; +@use '../variables' as *; + +.gap-1 { + gap: 8px; +} + +.gap-2 { + gap: 16px; +} + +.gap-3 { + gap: 24px; +} \ No newline at end of file diff --git a/web-client/src/views/TrialSessions/TrialSessions.tsx b/web-client/src/views/TrialSessions/TrialSessions.tsx index 31b4657ae44..d252d363f99 100644 --- a/web-client/src/views/TrialSessions/TrialSessions.tsx +++ b/web-client/src/views/TrialSessions/TrialSessions.tsx @@ -1,15 +1,15 @@ import { BigHeader } from '../BigHeader'; import { Button } from '../../ustc-ui/Button/Button'; +import { DateRangePickerComponent } from '@web-client/ustc-ui/DateInput/DateRangePickerComponent'; import { ErrorNotification } from '../ErrorNotification'; import { SESSION_STATUS_TYPES, - SESSION_TYPES, TRIAL_SESSION_PROCEEDING_TYPES, TrialSessionProceedingType, } from '@shared/business/entities/EntityConstants'; +import { SelectSearch } from '@web-client/ustc-ui/Select/SelectSearch'; import { SuccessNotification } from '../SuccessNotification'; import { Tab, Tabs } from '../../ustc-ui/Tabs/Tabs'; -import { TrialCityOptions } from '@web-client/views/TrialCityOptions'; import { TrialSessionsTable } from './TrialSessionsTable'; import { connect } from '@web-client/presenter/shared.cerebral'; import { sequences } from '@web-client/presenter/app.cerebral'; @@ -21,12 +21,12 @@ export const TrialSessions = connect( openTrialSessionPlanningModalSequence: sequences.openTrialSessionPlanningModalSequence, setTrialSessionsFiltersSequence: sequences.setTrialSessionsFiltersSequence, - trialSessionHelper: state.trialSessionsHelper, + trialSessionsHelper: state.trialSessionsHelper, }, function TrialSessions({ openTrialSessionPlanningModalSequence, setTrialSessionsFiltersSequence, - trialSessionHelper, + trialSessionsHelper, }) { return ( <> @@ -52,8 +52,17 @@ export const TrialSessions = connect( > Trial Session Planning Report + {trialSessionsHelper.showNewTrialSession && ( + + )} - {trialSessionHelper.showNewTrialSession && ( + {trialSessionsHelper.showNewTrialSession && ( -
+
{trialSessionsHelper.showSessionStatus && (
+ Session Status
- - Session Status -
)} +
+ Proceeding Type +
+ { + setTrialSessionsFiltersSequence({ + proceedingType: e.target.value as 'All', + }); + }} + /> + + { + setTrialSessionsFiltersSequence({ + proceedingType: e.target + .value as TrialSessionProceedingType, + }); + }} + /> + + { + setTrialSessionsFiltersSequence({ + proceedingType: e.target + .value as TrialSessionProceedingType, + }); + }} + /> + +
+
+ { + console.log('onChangeEnd', e.target.value); + }} + onChangeStart={e => { + console.log('onChangeStart', e.target.value); + }} + />
-
-
- {showDateHint && MM/DD/YYYY}
@@ -172,6 +174,8 @@ export const DateRangePickerComponent = ({
+ {/* {to && to} */} +
- {endLabel || 'End date'}{' '} + {endLabel}{' '} {showDateHint && MM/DD/YYYY}
diff --git a/web-client/src/views/TrialSessions/TrialSessions.tsx b/web-client/src/views/TrialSessions/TrialSessions.tsx index d252d363f99..44672ede328 100644 --- a/web-client/src/views/TrialSessions/TrialSessions.tsx +++ b/web-client/src/views/TrialSessions/TrialSessions.tsx @@ -243,11 +243,18 @@ const TrialSessionFilters = connect( endValue="" formGroupCls="margin-bottom-0" maxDate={''} - rangePickerCls={'grid-row '} + rangePickerCls={'display-flex flex-align-end'} startDateErrorText={''} + startLabel={ + + Trial Start Date range{' '} + (optional) + + } startName="trialSessionEndDate" startPickerCls="padding-right-2" startValue="" + to={true} onChangeEnd={e => { console.log('onChangeEnd', e.target.value); }} From d498a9e790d112601134fc2023c4f4b81908aedb Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Wed, 18 Sep 2024 11:43:33 -0700 Subject: [PATCH 42/96] 10409: Remove temp styling --- .../src/ustc-ui/DateInput/DateRangePickerComponent.tsx | 5 ----- web-client/src/views/TrialSessions/TrialSessions.tsx | 1 - 2 files changed, 6 deletions(-) diff --git a/web-client/src/ustc-ui/DateInput/DateRangePickerComponent.tsx b/web-client/src/ustc-ui/DateInput/DateRangePickerComponent.tsx index cd52c69f1ea..184ccfc756c 100644 --- a/web-client/src/ustc-ui/DateInput/DateRangePickerComponent.tsx +++ b/web-client/src/ustc-ui/DateInput/DateRangePickerComponent.tsx @@ -22,7 +22,6 @@ export const DateRangePickerComponent = ({ startName, startPickerCls, startValue, - to = false, }: { showDateHint?: boolean; endDateErrorText?: string; @@ -37,7 +36,6 @@ export const DateRangePickerComponent = ({ startDateErrorText?: string; startPickerCls?: string; startLabel?: string | React.ReactNode; - to?: boolean; omitFormGroupClass?: boolean; startName: string; startValue: string; @@ -173,9 +171,6 @@ export const DateRangePickerComponent = ({
- - {/* {to && to} */} -
{ console.log('onChangeEnd', e.target.value); }} From d0ac90e9ebdddf0e12c6eab8d4be6ccaace22122 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Wed, 18 Sep 2024 11:59:06 -0700 Subject: [PATCH 43/96] 10409: WIP start adding options to trial sessions --- .../computeds/trialSessionsHelper.ts | 43 ++++++++++++++++++- .../src/views/TrialSessions/TrialSessions.tsx | 8 +++- 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/web-client/src/presenter/computeds/trialSessionsHelper.ts b/web-client/src/presenter/computeds/trialSessionsHelper.ts index 5ab8fe8ce8a..eeb9a85ad19 100644 --- a/web-client/src/presenter/computeds/trialSessionsHelper.ts +++ b/web-client/src/presenter/computeds/trialSessionsHelper.ts @@ -5,10 +5,16 @@ import { subtractISODates, } from '@shared/business/utilities/DateHandler'; import { Get } from 'cerebral'; +import { InputOption } from '@web-client/ustc-ui/Utils/types'; import { RawUser } from '@shared/business/entities/User'; -import { SESSION_STATUS_TYPES } from '@shared/business/entities/EntityConstants'; +import { + SESSION_STATUS_TYPES, + SESSION_TYPES, + TRIAL_CITIES, +} from '@shared/business/entities/EntityConstants'; import { TrialSession } from '@shared/business/entities/trialSessions/TrialSession'; import { TrialSessionInfoDTO } from '@shared/business/dto/trialSessions/TrialSessionInfoDTO'; +import { sortBy } from 'lodash'; import { state } from '@web-client/presenter/app.cerebral'; export const trialSessionsHelper = ( @@ -20,6 +26,8 @@ export const trialSessionsHelper = ( showUnassignedJudgeFilter: boolean; trialSessionJudges: RawUser[]; trialSessionRows: (TrialSessionRow | TrialSessionWeek)[]; + sessionTypeOptions: InputOption[]; + trialLocationOptions: InputOption[]; } => { const permissions = get(state.permissions)!; const trialSessions = get(state.trialSessionsPage.trialSessions); @@ -37,6 +45,38 @@ export const trialSessionsHelper = ( trialSessionJudges = get(state.legacyAndCurrentJudges); } + const sessionTypeOptions = Object.values(SESSION_TYPES).map(sessionType => ({ + label: sessionType, + value: sessionType, + })); + + const trialCities = sortBy(TRIAL_CITIES.ALL, ['state', 'city']); + const trialLocationOptions: InputOption[] = []; + + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const states: InputOption[] = trialCities.reduce( + (listOfStates: InputOption[], cityStatePair) => { + const existingState = listOfStates.find( + trialState => trialState.label === cityStatePair.state, + ); + const cityOption: InputOption = { + label: `${cityStatePair.city}, ${cityStatePair.state}`, + value: `${cityStatePair.city}, ${cityStatePair.state}`, + }; + if (existingState) { + existingState.options?.push(cityOption); + } else { + listOfStates.push({ + label: cityStatePair.state, + options: [cityOption], + }); + } + trialLocationOptions.push(cityOption); + return listOfStates; + }, + [], + ); + const filteredTrialSessions = trialSessions .filter(trialSession => { const isCalendaredFilter = filters.currentTab === 'calendared'; @@ -74,6 +114,7 @@ export const trialSessionsHelper = ( }); return { + sessionTypeOptions, showNewTrialSession: permissions.CREATE_TRIAL_SESSION, showNoticeIssued: filters.currentTab === 'calendared', showSessionStatus: filters.currentTab === 'calendared', diff --git a/web-client/src/views/TrialSessions/TrialSessions.tsx b/web-client/src/views/TrialSessions/TrialSessions.tsx index 7acc2ea41a6..684766dcad9 100644 --- a/web-client/src/views/TrialSessions/TrialSessions.tsx +++ b/web-client/src/views/TrialSessions/TrialSessions.tsx @@ -271,7 +271,9 @@ const TrialSessionFilters = connect( { console.log('session type', inputValue); }} @@ -285,6 +287,8 @@ const TrialSessionFilters = connect( id="location-filter" name="location" options={[]} + placeholder="- Select one or more -" + value="Select one or more" onChange={inputValue => { console.log('location', inputValue); }} @@ -298,6 +302,8 @@ const TrialSessionFilters = connect( id="judge-filter" name="judgeId" options={[]} + placeholder="- Select one or more -" + value="Select one or more" onChange={inputValue => { console.log('judgeId', inputValue); }} From e1f8cae36a139465ae0981ea2e0f89f338b9a6ef Mon Sep 17 00:00:00 2001 From: Nechama Krigsman Date: Wed, 18 Sep 2024 16:10:32 -0400 Subject: [PATCH 44/96] 10409: add options to filter dropdowns; --- .../setTrialSessionsFiltersAction.ts | 28 ++++++++++++++----- .../computeds/trialSessionsHelper.ts | 17 +++++++++-- .../setTrialSessionsFiltersSequence.ts | 8 ++++-- .../presenter/state/trialSessionsPageState.ts | 4 +-- .../src/views/TrialSessions/TrialSessions.tsx | 20 +++++++++---- 5 files changed, 58 insertions(+), 19 deletions(-) diff --git a/web-client/src/presenter/actions/TrialSession/setTrialSessionsFiltersAction.ts b/web-client/src/presenter/actions/TrialSession/setTrialSessionsFiltersAction.ts index 1fe75fa28db..dffce64f177 100644 --- a/web-client/src/presenter/actions/TrialSession/setTrialSessionsFiltersAction.ts +++ b/web-client/src/presenter/actions/TrialSession/setTrialSessionsFiltersAction.ts @@ -1,16 +1,30 @@ -import { TrialSessionsFilters } from '@web-client/presenter/state/trialSessionsPageState'; import { state } from '@web-client/presenter/app.cerebral'; export const setTrialSessionsFiltersAction = ({ + get, props, store, -}: ActionProps>) => { +}: ActionProps) => { + const currentFilters = get(state.trialSessionsPage.filters); + if (props.currentTab) { store.set(state.trialSessionsPage.filters.currentTab, props.currentTab); } - - if (props.judgeId) { - store.set(state.trialSessionsPage.filters.judgeId, props.judgeId); + // Update for Trial Sessions Page + if (props.judges) { + if ( + props.judges.action === 'add' && + !currentFilters.judges.includes(props.judges.judge) + ) { + currentFilters.judges.push(props.judges.judge); + store.merge(state.trialSessionsPage.filters, currentFilters); + } else if (props.judges.action === 'remove') { + const foundIndex = currentFilters.judges.findIndex( + caseType => caseType === props.judges!.judge, + ); + currentFilters.judges.splice(foundIndex, 1); + store.merge(state.trialSessionsPage.filters, currentFilters); + } } if (props.proceedingType) { @@ -26,11 +40,11 @@ export const setTrialSessionsFiltersAction = ({ props.sessionStatus, ); } - + // Update for Trial Sessions Page if (props.sessionType) { store.set(state.trialSessionsPage.filters.sessionType, props.sessionType); } - + // Update for Trial Sessions Page if (props.trialLocation) { store.set( state.trialSessionsPage.filters.trialLocation, diff --git a/web-client/src/presenter/computeds/trialSessionsHelper.ts b/web-client/src/presenter/computeds/trialSessionsHelper.ts index eeb9a85ad19..4c3a41aaed6 100644 --- a/web-client/src/presenter/computeds/trialSessionsHelper.ts +++ b/web-client/src/presenter/computeds/trialSessionsHelper.ts @@ -25,9 +25,11 @@ export const trialSessionsHelper = ( showSessionStatus: boolean; showUnassignedJudgeFilter: boolean; trialSessionJudges: RawUser[]; + trialSessionJudgeOptions: InputOption[]; trialSessionRows: (TrialSessionRow | TrialSessionWeek)[]; sessionTypeOptions: InputOption[]; - trialLocationOptions: InputOption[]; + searchableTrialLocationOptions: InputOption[]; + trialCitiesByState: InputOption[]; } => { const permissions = get(state.permissions)!; const trialSessions = get(state.trialSessionsPage.trialSessions); @@ -50,8 +52,14 @@ export const trialSessionsHelper = ( value: sessionType, })); + const trialSessionJudgeOptions = trialSessionJudges.map( + trialSessionJudge => ({ + label: trialSessionJudge.name, + value: trialSessionJudge.name, + }), + ); const trialCities = sortBy(TRIAL_CITIES.ALL, ['state', 'city']); - const trialLocationOptions: InputOption[] = []; + const searchableTrialLocationOptions: InputOption[] = []; // eslint-disable-next-line @typescript-eslint/no-unused-vars const states: InputOption[] = trialCities.reduce( @@ -71,7 +79,7 @@ export const trialSessionsHelper = ( options: [cityOption], }); } - trialLocationOptions.push(cityOption); + searchableTrialLocationOptions.push(cityOption); return listOfStates; }, [], @@ -114,11 +122,14 @@ export const trialSessionsHelper = ( }); return { + searchableTrialLocationOptions, sessionTypeOptions, showNewTrialSession: permissions.CREATE_TRIAL_SESSION, showNoticeIssued: filters.currentTab === 'calendared', showSessionStatus: filters.currentTab === 'calendared', showUnassignedJudgeFilter: filters.currentTab === 'new', + trialCitiesByState: states, + trialSessionJudgeOptions, trialSessionJudges, trialSessionRows, }; diff --git a/web-client/src/presenter/sequences/setTrialSessionsFiltersSequence.ts b/web-client/src/presenter/sequences/setTrialSessionsFiltersSequence.ts index 294f2fe20ed..b357d594f2d 100644 --- a/web-client/src/presenter/sequences/setTrialSessionsFiltersSequence.ts +++ b/web-client/src/presenter/sequences/setTrialSessionsFiltersSequence.ts @@ -1,6 +1,10 @@ -import { TrialSessionsFilters } from '@web-client/presenter/state/trialSessionsPageState'; import { setTrialSessionsFiltersAction } from '@web-client/presenter/actions/TrialSession/setTrialSessionsFiltersAction'; export const setTrialSessionsFiltersSequence = [ setTrialSessionsFiltersAction, -] as unknown as (props: Partial) => void; +] as unknown as (props: { + currentTab?: string; + proceedingType?: string; + sessionStatus?: string; + judges?: { action: 'add' | 'remove'; judge: string }; +}) => void; diff --git a/web-client/src/presenter/state/trialSessionsPageState.ts b/web-client/src/presenter/state/trialSessionsPageState.ts index f0c77f51ae2..956ddeb09a8 100644 --- a/web-client/src/presenter/state/trialSessionsPageState.ts +++ b/web-client/src/presenter/state/trialSessionsPageState.ts @@ -3,7 +3,7 @@ import { TrialSessionProceedingType } from '@shared/business/entities/EntityCons const filters: TrialSessionsFilters = { currentTab: 'calendared' as 'calendared' | 'new', - judgeId: 'All', + judges: [], proceedingType: 'All' as TrialSessionProceedingType, sessionStatus: 'Open', sessionType: 'All', @@ -17,7 +17,7 @@ export const initialTrialSessionPageState = { export type TrialSessionsFilters = { currentTab: 'calendared' | 'new'; - judgeId: string; + judges: string[]; proceedingType: TrialSessionProceedingType | 'All'; sessionStatus: string; sessionType: string; diff --git a/web-client/src/views/TrialSessions/TrialSessions.tsx b/web-client/src/views/TrialSessions/TrialSessions.tsx index 684766dcad9..f62b8d0999c 100644 --- a/web-client/src/views/TrialSessions/TrialSessions.tsx +++ b/web-client/src/views/TrialSessions/TrialSessions.tsx @@ -286,8 +286,11 @@ const TrialSessionFilters = connect( { console.log('location', inputValue); @@ -299,13 +302,20 @@ const TrialSessionFilters = connect( Judge (optional) { - console.log('judgeId', inputValue); + if (inputValue) { + setTrialSessionsFiltersSequence({ + judges: { + action: 'add', + judge: inputValue.value, + }, + }); + } }} />
From 16d090ffb7e40be8e91b5293dcfebb75b073ba3b Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Wed, 18 Sep 2024 14:22:59 -0700 Subject: [PATCH 45/96] 10409: WIP Converting judgeIds into a multi select --- .../setTrialSessionsFiltersAction.ts | 36 ++++++++++--------- .../computeds/trialSessionsHelper.ts | 18 ++++++---- .../setTrialSessionsFiltersSequence.ts | 12 +++---- .../presenter/state/trialSessionsPageState.ts | 4 +-- .../src/views/TrialSessions/TrialSessions.tsx | 5 +-- 5 files changed, 42 insertions(+), 33 deletions(-) diff --git a/web-client/src/presenter/actions/TrialSession/setTrialSessionsFiltersAction.ts b/web-client/src/presenter/actions/TrialSession/setTrialSessionsFiltersAction.ts index dffce64f177..765b2531883 100644 --- a/web-client/src/presenter/actions/TrialSession/setTrialSessionsFiltersAction.ts +++ b/web-client/src/presenter/actions/TrialSession/setTrialSessionsFiltersAction.ts @@ -1,30 +1,34 @@ +import { TrialSessionProceedingType } from '@shared/business/entities/EntityConstants'; import { state } from '@web-client/presenter/app.cerebral'; +export type SetTrialSessionsFilters = Partial<{ + currentTab: 'calendared' | 'new'; + judgeIds: { action: 'add' | 'remove'; judgeId: string }; + proceedingType: TrialSessionProceedingType | 'All'; + sessionStatus: string; + sessionType: string; + trialLocation: string; +}>; + export const setTrialSessionsFiltersAction = ({ get, props, store, -}: ActionProps) => { +}: ActionProps) => { const currentFilters = get(state.trialSessionsPage.filters); if (props.currentTab) { store.set(state.trialSessionsPage.filters.currentTab, props.currentTab); } - // Update for Trial Sessions Page - if (props.judges) { - if ( - props.judges.action === 'add' && - !currentFilters.judges.includes(props.judges.judge) - ) { - currentFilters.judges.push(props.judges.judge); - store.merge(state.trialSessionsPage.filters, currentFilters); - } else if (props.judges.action === 'remove') { - const foundIndex = currentFilters.judges.findIndex( - caseType => caseType === props.judges!.judge, - ); - currentFilters.judges.splice(foundIndex, 1); - store.merge(state.trialSessionsPage.filters, currentFilters); - } + + if (props.judgeIds) { + const newJudgeIds = + props.judgeIds.action === 'add' + ? currentFilters.judgeIds.concat([props.judgeIds.judgeId]) + : currentFilters.judgeIds.filter( + (id: string) => id !== props.judgeIds!.judgeId, + ); + store.set(state.trialSessionsPage.filters.judgeIds, newJudgeIds); } if (props.proceedingType) { diff --git a/web-client/src/presenter/computeds/trialSessionsHelper.ts b/web-client/src/presenter/computeds/trialSessionsHelper.ts index 4c3a41aaed6..0f659e633e4 100644 --- a/web-client/src/presenter/computeds/trialSessionsHelper.ts +++ b/web-client/src/presenter/computeds/trialSessionsHelper.ts @@ -40,11 +40,13 @@ export const trialSessionsHelper = ( filters.currentTab === 'new' || filters.sessionStatus === SESSION_STATUS_TYPES.open; - let trialSessionJudges; + let trialSessionJudges; // 10409 TODO BUG. The judge options is not updating correctly. Showing legacy when it should not. if (showCurrentJudgesOnly) { trialSessionJudges = get(state.judges); + console.log('current length: ', trialSessionJudges.length); } else { trialSessionJudges = get(state.legacyAndCurrentJudges); + console.log('legecy length: ', trialSessionJudges.length); } const sessionTypeOptions = Object.values(SESSION_TYPES).map(sessionType => ({ @@ -52,10 +54,10 @@ export const trialSessionsHelper = ( value: sessionType, })); - const trialSessionJudgeOptions = trialSessionJudges.map( + const trialSessionJudgeOptions: InputOption[] = trialSessionJudges.map( trialSessionJudge => ({ label: trialSessionJudge.name, - value: trialSessionJudge.name, + value: trialSessionJudge.userId, }), ); const trialCities = sortBy(TRIAL_CITIES.ALL, ['state', 'city']); @@ -91,9 +93,13 @@ export const trialSessionsHelper = ( return trialSession.isCalendared === isCalendaredFilter; }) .filter(trialSession => { - if (filters.judgeId === 'All') return true; - if (filters.judgeId === 'unassigned') return !trialSession.judge?.userId; - return trialSession.judge?.userId === filters.judgeId; + if (filters.judgeIds.length === 0) return true; + const trialSessionHasJudge = filters.judgeIds.some(judgeIdFilter => { + if (judgeIdFilter === 'unassigned') return !trialSession.judge?.userId; + return judgeIdFilter === trialSession.judge?.userId; + }); + + return trialSessionHasJudge; }) .filter(trialSession => { if (filters.proceedingType === 'All') return true; diff --git a/web-client/src/presenter/sequences/setTrialSessionsFiltersSequence.ts b/web-client/src/presenter/sequences/setTrialSessionsFiltersSequence.ts index b357d594f2d..9016d6c9974 100644 --- a/web-client/src/presenter/sequences/setTrialSessionsFiltersSequence.ts +++ b/web-client/src/presenter/sequences/setTrialSessionsFiltersSequence.ts @@ -1,10 +1,8 @@ -import { setTrialSessionsFiltersAction } from '@web-client/presenter/actions/TrialSession/setTrialSessionsFiltersAction'; +import { + SetTrialSessionsFilters, + setTrialSessionsFiltersAction, +} from '@web-client/presenter/actions/TrialSession/setTrialSessionsFiltersAction'; export const setTrialSessionsFiltersSequence = [ setTrialSessionsFiltersAction, -] as unknown as (props: { - currentTab?: string; - proceedingType?: string; - sessionStatus?: string; - judges?: { action: 'add' | 'remove'; judge: string }; -}) => void; +] as unknown as (props: SetTrialSessionsFilters) => void; diff --git a/web-client/src/presenter/state/trialSessionsPageState.ts b/web-client/src/presenter/state/trialSessionsPageState.ts index 956ddeb09a8..c7e96b4dd66 100644 --- a/web-client/src/presenter/state/trialSessionsPageState.ts +++ b/web-client/src/presenter/state/trialSessionsPageState.ts @@ -3,7 +3,7 @@ import { TrialSessionProceedingType } from '@shared/business/entities/EntityCons const filters: TrialSessionsFilters = { currentTab: 'calendared' as 'calendared' | 'new', - judges: [], + judgeIds: [], proceedingType: 'All' as TrialSessionProceedingType, sessionStatus: 'Open', sessionType: 'All', @@ -17,7 +17,7 @@ export const initialTrialSessionPageState = { export type TrialSessionsFilters = { currentTab: 'calendared' | 'new'; - judges: string[]; + judgeIds: string[]; proceedingType: TrialSessionProceedingType | 'All'; sessionStatus: string; sessionType: string; diff --git a/web-client/src/views/TrialSessions/TrialSessions.tsx b/web-client/src/views/TrialSessions/TrialSessions.tsx index f62b8d0999c..0083b6aeff2 100644 --- a/web-client/src/views/TrialSessions/TrialSessions.tsx +++ b/web-client/src/views/TrialSessions/TrialSessions.tsx @@ -100,6 +100,7 @@ const TrialSessionFilters = connect( trialSessionsHelper, trialSessionsPage, }) { + console.log(trialSessionsPage.filters); return ( <>
@@ -310,9 +311,9 @@ const TrialSessionFilters = connect( onChange={inputValue => { if (inputValue) { setTrialSessionsFiltersSequence({ - judges: { + judgeIds: { action: 'add', - judge: inputValue.value, + judgeId: inputValue.value, }, }); } From 289d7fb6b6ac33f8a3634a09dce3a98aa4a67463 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Wed, 18 Sep 2024 15:30:25 -0700 Subject: [PATCH 46/96] 10409: WIP Converting TrialLocations into a multi select --- .../setTrialSessionsFiltersAction.test.ts | 2 +- .../setTrialSessionsFiltersAction.ts | 39 ++++--- .../computeds/trialSessionsHelper.test.ts | 2 +- .../computeds/trialSessionsHelper.ts | 25 +++-- .../presenter/state/trialSessionsPageState.ts | 8 +- web-client/src/ustc-ui/Utils/types.ts | 4 +- .../src/views/TrialSessions/TrialSessions.tsx | 106 ++++++++++++------ 7 files changed, 121 insertions(+), 65 deletions(-) diff --git a/web-client/src/presenter/actions/TrialSession/setTrialSessionsFiltersAction.test.ts b/web-client/src/presenter/actions/TrialSession/setTrialSessionsFiltersAction.test.ts index 130c782be17..ff73e9884f1 100644 --- a/web-client/src/presenter/actions/TrialSession/setTrialSessionsFiltersAction.test.ts +++ b/web-client/src/presenter/actions/TrialSession/setTrialSessionsFiltersAction.test.ts @@ -9,7 +9,7 @@ describe('setTrialSessionsFiltersAction', () => { }, }); - expect(result.state.trialSessionsPage.filters.trialLocation).toEqual( + expect(result.state.trialSessionsPage.filters.trialLocations).toEqual( 'Baton Rouge, Louisiana', ); }); diff --git a/web-client/src/presenter/actions/TrialSession/setTrialSessionsFiltersAction.ts b/web-client/src/presenter/actions/TrialSession/setTrialSessionsFiltersAction.ts index 765b2531883..4cc186ab76b 100644 --- a/web-client/src/presenter/actions/TrialSession/setTrialSessionsFiltersAction.ts +++ b/web-client/src/presenter/actions/TrialSession/setTrialSessionsFiltersAction.ts @@ -3,11 +3,17 @@ import { state } from '@web-client/presenter/app.cerebral'; export type SetTrialSessionsFilters = Partial<{ currentTab: 'calendared' | 'new'; - judgeIds: { action: 'add' | 'remove'; judgeId: string }; + judges: { + action: 'add' | 'remove'; + judge: { name: string; userId: string }; + }; proceedingType: TrialSessionProceedingType | 'All'; sessionStatus: string; sessionType: string; - trialLocation: string; + trialLocations: { + action: 'add' | 'remove'; + trialLocation: string; + }; }>; export const setTrialSessionsFiltersAction = ({ @@ -21,14 +27,14 @@ export const setTrialSessionsFiltersAction = ({ store.set(state.trialSessionsPage.filters.currentTab, props.currentTab); } - if (props.judgeIds) { - const newJudgeIds = - props.judgeIds.action === 'add' - ? currentFilters.judgeIds.concat([props.judgeIds.judgeId]) - : currentFilters.judgeIds.filter( - (id: string) => id !== props.judgeIds!.judgeId, - ); - store.set(state.trialSessionsPage.filters.judgeIds, newJudgeIds); + if (props.judges) { + if (props.judges.action === 'add') { + currentFilters.judges[props.judges.judge.userId] = props.judges.judge; + } else { + delete currentFilters.judges[props.judges.judge.userId]; + } + + store.set(state.trialSessionsPage.filters.judges, currentFilters.judges); } if (props.proceedingType) { @@ -49,10 +55,17 @@ export const setTrialSessionsFiltersAction = ({ store.set(state.trialSessionsPage.filters.sessionType, props.sessionType); } // Update for Trial Sessions Page - if (props.trialLocation) { + if (props.trialLocations) { + const { action, trialLocation } = props.trialLocations; + if (action === 'add') { + currentFilters.trialLocations[trialLocation] = trialLocation; + } else { + delete currentFilters.trialLocations[trialLocation]; + } + store.set( - state.trialSessionsPage.filters.trialLocation, - props.trialLocation, + state.trialSessionsPage.filters.trialLocations, + currentFilters.trialLocations, ); } }; diff --git a/web-client/src/presenter/computeds/trialSessionsHelper.test.ts b/web-client/src/presenter/computeds/trialSessionsHelper.test.ts index 249900ed39a..952177f5f08 100644 --- a/web-client/src/presenter/computeds/trialSessionsHelper.test.ts +++ b/web-client/src/presenter/computeds/trialSessionsHelper.test.ts @@ -453,7 +453,7 @@ describe('trialSessionsHelper', () => { it('should show trial sessions in honolulu when trial sessions when trial location filter is honolulu', () => { trialSession1.trialLocation = 'Honolulu, Hawaii'; trialSession2.trialLocation = 'Jacksonville, Florida'; - trialSessionsPageState.filters.trialLocation = 'Honolulu, Hawaii'; + trialSessionsPageState.filters.trialLocations = 'Honolulu, Hawaii'; trialSessionsPageState.trialSessions = [trialSession1, trialSession2]; const result = runCompute(trialSessionsHelper, { diff --git a/web-client/src/presenter/computeds/trialSessionsHelper.ts b/web-client/src/presenter/computeds/trialSessionsHelper.ts index 0f659e633e4..2489afc1536 100644 --- a/web-client/src/presenter/computeds/trialSessionsHelper.ts +++ b/web-client/src/presenter/computeds/trialSessionsHelper.ts @@ -24,8 +24,7 @@ export const trialSessionsHelper = ( showNoticeIssued: boolean; showSessionStatus: boolean; showUnassignedJudgeFilter: boolean; - trialSessionJudges: RawUser[]; - trialSessionJudgeOptions: InputOption[]; + trialSessionJudgeOptions: InputOption<{ name: string; userId: string }>[]; trialSessionRows: (TrialSessionRow | TrialSessionWeek)[]; sessionTypeOptions: InputOption[]; searchableTrialLocationOptions: InputOption[]; @@ -40,7 +39,7 @@ export const trialSessionsHelper = ( filters.currentTab === 'new' || filters.sessionStatus === SESSION_STATUS_TYPES.open; - let trialSessionJudges; // 10409 TODO BUG. The judge options is not updating correctly. Showing legacy when it should not. + let trialSessionJudges: { name: string; userId: string }[]; // 10409 TODO BUG. The judge options is not updating correctly. Showing legacy when it should not. if (showCurrentJudgesOnly) { trialSessionJudges = get(state.judges); console.log('current length: ', trialSessionJudges.length); @@ -54,10 +53,10 @@ export const trialSessionsHelper = ( value: sessionType, })); - const trialSessionJudgeOptions: InputOption[] = trialSessionJudges.map( + const trialSessionJudgeOptions = trialSessionJudges.map( trialSessionJudge => ({ label: trialSessionJudge.name, - value: trialSessionJudge.userId, + value: { name: trialSessionJudge.name, userId: trialSessionJudge.userId }, }), ); const trialCities = sortBy(TRIAL_CITIES.ALL, ['state', 'city']); @@ -93,10 +92,13 @@ export const trialSessionsHelper = ( return trialSession.isCalendared === isCalendaredFilter; }) .filter(trialSession => { - if (filters.judgeIds.length === 0) return true; - const trialSessionHasJudge = filters.judgeIds.some(judgeIdFilter => { - if (judgeIdFilter === 'unassigned') return !trialSession.judge?.userId; - return judgeIdFilter === trialSession.judge?.userId; + const selectedJudges = Object.values(filters.judges); + if (selectedJudges.length === 0) return true; + const trialSessionHasJudge = selectedJudges.some(judgeFilter => { + if (judgeFilter.userId === 'unassigned') { + return !trialSession.judge?.userId; + } + return judgeFilter.userId === trialSession.judge?.userId; }); return trialSessionHasJudge; @@ -115,8 +117,8 @@ export const trialSessionsHelper = ( return filters.sessionType === trialSession.sessionType; }) .filter(trialSession => { - if (filters.trialLocation === 'All') return true; - return filters.trialLocation === trialSession.trialLocation; + if (Object.values(filters.trialLocations).length === 0) return true; + return !!filters.trialLocations[trialSession.trialLocation || '']; }) .sort((sessionA, sessionB) => { return sessionA.startDate.localeCompare(sessionB.startDate); @@ -136,7 +138,6 @@ export const trialSessionsHelper = ( showUnassignedJudgeFilter: filters.currentTab === 'new', trialCitiesByState: states, trialSessionJudgeOptions, - trialSessionJudges, trialSessionRows, }; }; diff --git a/web-client/src/presenter/state/trialSessionsPageState.ts b/web-client/src/presenter/state/trialSessionsPageState.ts index c7e96b4dd66..95d69df4891 100644 --- a/web-client/src/presenter/state/trialSessionsPageState.ts +++ b/web-client/src/presenter/state/trialSessionsPageState.ts @@ -3,11 +3,11 @@ import { TrialSessionProceedingType } from '@shared/business/entities/EntityCons const filters: TrialSessionsFilters = { currentTab: 'calendared' as 'calendared' | 'new', - judgeIds: [], + judges: {}, proceedingType: 'All' as TrialSessionProceedingType, sessionStatus: 'Open', sessionType: 'All', - trialLocation: 'All', + trialLocations: {}, }; export const initialTrialSessionPageState = { @@ -17,9 +17,9 @@ export const initialTrialSessionPageState = { export type TrialSessionsFilters = { currentTab: 'calendared' | 'new'; - judgeIds: string[]; + judges: Record; proceedingType: TrialSessionProceedingType | 'All'; sessionStatus: string; sessionType: string; - trialLocation: string; + trialLocations: Record; }; diff --git a/web-client/src/ustc-ui/Utils/types.ts b/web-client/src/ustc-ui/Utils/types.ts index 300cea8b962..d9c0cd43583 100644 --- a/web-client/src/ustc-ui/Utils/types.ts +++ b/web-client/src/ustc-ui/Utils/types.ts @@ -4,9 +4,9 @@ import { GetCasesByStatusAndByJudgeResponse } from '@web-api/business/useCases/j import { JudgeActivityReportFilters } from '@web-api/business/useCases/judgeActivityReport/getCountOfCaseDocumentsFiledByJudgesInteractor'; import { TrialSessionReturnType } from '@web-api/business/useCases/judgeActivityReport/getTrialSessionsForJudgeActivityReportInteractor'; -export type InputOption = { +export type InputOption = { label: string; - value?: string; + value?: T; options?: InputOption[]; }; diff --git a/web-client/src/views/TrialSessions/TrialSessions.tsx b/web-client/src/views/TrialSessions/TrialSessions.tsx index 0083b6aeff2..ff31e2b076f 100644 --- a/web-client/src/views/TrialSessions/TrialSessions.tsx +++ b/web-client/src/views/TrialSessions/TrialSessions.tsx @@ -2,6 +2,7 @@ import { BigHeader } from '../BigHeader'; import { Button } from '../../ustc-ui/Button/Button'; import { DateRangePickerComponent } from '@web-client/ustc-ui/DateInput/DateRangePickerComponent'; import { ErrorNotification } from '../ErrorNotification'; +import { PillButton } from '@web-client/ustc-ui/Button/PillButton'; import { SESSION_STATUS_TYPES, TRIAL_SESSION_PROCEEDING_TYPES, @@ -281,44 +282,85 @@ const TrialSessionFilters = connect( />
- - { - console.log('location', inputValue); - }} - /> +
+ + { + setTrialSessionsFiltersSequence({ + trialLocations: { + action: 'add', + trialLocation: location.value, + }, + }); + }} + /> +
+
+ {Object.values(trialSessionsPage.filters.trialLocations).map( + location => ( + { + setTrialSessionsFiltersSequence({ + trialLocations: { + action: 'remove', + trialLocation: location, + }, + }); + }} + /> + ), + )} +
- - { - if (inputValue) { +
+ + { setTrialSessionsFiltersSequence({ - judgeIds: { + judges: { action: 'add', - judgeId: inputValue.value, + judge: inputValue.value, }, }); - } - }} - /> + }} + /> +
+
+ {Object.values(trialSessionsPage.filters.judges).map(judge => ( + { + setTrialSessionsFiltersSequence({ + judges: { + action: 'remove', + judge, + }, + }); + }} + /> + ))} +
From 8935f7b0b3536a23f1f82464f2fa01b5972b39ea Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Wed, 18 Sep 2024 16:06:04 -0700 Subject: [PATCH 47/96] 10409: WIP Converting session types to multi select filter --- .../setTrialSessionsFiltersAction.ts | 32 ++++++++--- .../computeds/trialSessionsHelper.test.ts | 2 +- .../computeds/trialSessionsHelper.ts | 4 +- .../presenter/state/trialSessionsPageState.ts | 9 ++- .../src/views/TrialSessions/TrialSessions.tsx | 57 +++++++++++++------ 5 files changed, 73 insertions(+), 31 deletions(-) diff --git a/web-client/src/presenter/actions/TrialSession/setTrialSessionsFiltersAction.ts b/web-client/src/presenter/actions/TrialSession/setTrialSessionsFiltersAction.ts index 4cc186ab76b..744b609691d 100644 --- a/web-client/src/presenter/actions/TrialSession/setTrialSessionsFiltersAction.ts +++ b/web-client/src/presenter/actions/TrialSession/setTrialSessionsFiltersAction.ts @@ -1,4 +1,7 @@ -import { TrialSessionProceedingType } from '@shared/business/entities/EntityConstants'; +import { + TrialSessionProceedingType, + TrialSessionTypes, +} from '@shared/business/entities/EntityConstants'; import { state } from '@web-client/presenter/app.cerebral'; export type SetTrialSessionsFilters = Partial<{ @@ -9,7 +12,7 @@ export type SetTrialSessionsFilters = Partial<{ }; proceedingType: TrialSessionProceedingType | 'All'; sessionStatus: string; - sessionType: string; + sessionTypes: { action: 'add' | 'remove'; sessionType: TrialSessionTypes }; trialLocations: { action: 'add' | 'remove'; trialLocation: string; @@ -28,10 +31,11 @@ export const setTrialSessionsFiltersAction = ({ } if (props.judges) { - if (props.judges.action === 'add') { - currentFilters.judges[props.judges.judge.userId] = props.judges.judge; + const { action, judge } = props.judges; + if (action === 'add') { + currentFilters.judges[judge.userId] = judge; } else { - delete currentFilters.judges[props.judges.judge.userId]; + delete currentFilters.judges[judge.userId]; } store.set(state.trialSessionsPage.filters.judges, currentFilters.judges); @@ -50,11 +54,21 @@ export const setTrialSessionsFiltersAction = ({ props.sessionStatus, ); } - // Update for Trial Sessions Page - if (props.sessionType) { - store.set(state.trialSessionsPage.filters.sessionType, props.sessionType); + + if (props.sessionTypes) { + const { action, sessionType } = props.sessionTypes; + if (action === 'add') { + currentFilters.sessionTypes[sessionType] = sessionType; + } else { + delete currentFilters.sessionTypes[sessionType]; + } + + store.set( + state.trialSessionsPage.filters.sessionTypes, + currentFilters.sessionTypes, + ); } - // Update for Trial Sessions Page + if (props.trialLocations) { const { action, trialLocation } = props.trialLocations; if (action === 'add') { diff --git a/web-client/src/presenter/computeds/trialSessionsHelper.test.ts b/web-client/src/presenter/computeds/trialSessionsHelper.test.ts index 952177f5f08..f4da90fbc14 100644 --- a/web-client/src/presenter/computeds/trialSessionsHelper.test.ts +++ b/web-client/src/presenter/computeds/trialSessionsHelper.test.ts @@ -432,7 +432,7 @@ describe('trialSessionsHelper', () => { it('should show regular trial sessions when session type filter is regular', () => { trialSession1.sessionType = SESSION_TYPES.regular; trialSession2.sessionType = SESSION_TYPES.hybridSmall; - trialSessionsPageState.filters.sessionType = SESSION_TYPES.regular; + trialSessionsPageState.filters.sessionTypes = SESSION_TYPES.regular; trialSessionsPageState.trialSessions = [trialSession1, trialSession2]; const result = runCompute(trialSessionsHelper, { diff --git a/web-client/src/presenter/computeds/trialSessionsHelper.ts b/web-client/src/presenter/computeds/trialSessionsHelper.ts index 2489afc1536..66ecddf5f37 100644 --- a/web-client/src/presenter/computeds/trialSessionsHelper.ts +++ b/web-client/src/presenter/computeds/trialSessionsHelper.ts @@ -113,8 +113,8 @@ export const trialSessionsHelper = ( return filters.sessionStatus === trialSession.sessionStatus; }) .filter(trialSession => { - if (filters.sessionType === 'All') return true; - return filters.sessionType === trialSession.sessionType; + if (Object.values(filters.sessionTypes).length === 0) return true; + return !!filters.sessionTypes[trialSession.sessionType]; }) .filter(trialSession => { if (Object.values(filters.trialLocations).length === 0) return true; diff --git a/web-client/src/presenter/state/trialSessionsPageState.ts b/web-client/src/presenter/state/trialSessionsPageState.ts index 95d69df4891..a8a6a05dad6 100644 --- a/web-client/src/presenter/state/trialSessionsPageState.ts +++ b/web-client/src/presenter/state/trialSessionsPageState.ts @@ -1,12 +1,15 @@ import { TrialSessionInfoDTO } from '@shared/business/dto/trialSessions/TrialSessionInfoDTO'; -import { TrialSessionProceedingType } from '@shared/business/entities/EntityConstants'; +import { + TrialSessionProceedingType, + TrialSessionTypes, +} from '@shared/business/entities/EntityConstants'; const filters: TrialSessionsFilters = { currentTab: 'calendared' as 'calendared' | 'new', judges: {}, proceedingType: 'All' as TrialSessionProceedingType, sessionStatus: 'Open', - sessionType: 'All', + sessionTypes: {}, trialLocations: {}, }; @@ -20,6 +23,6 @@ export type TrialSessionsFilters = { judges: Record; proceedingType: TrialSessionProceedingType | 'All'; sessionStatus: string; - sessionType: string; + sessionTypes: Record; trialLocations: Record; }; diff --git a/web-client/src/views/TrialSessions/TrialSessions.tsx b/web-client/src/views/TrialSessions/TrialSessions.tsx index ff31e2b076f..f93ffce2830 100644 --- a/web-client/src/views/TrialSessions/TrialSessions.tsx +++ b/web-client/src/views/TrialSessions/TrialSessions.tsx @@ -266,23 +266,48 @@ const TrialSessionFilters = connect(
- - { - console.log('session type', inputValue); - }} - /> +
+ + { + setTrialSessionsFiltersSequence({ + sessionTypes: { + action: 'add', + sessionType: sessionType.value, + }, + }); + }} + /> +
+
+ {Object.values(trialSessionsPage.filters.sessionTypes).map( + sessionType => ( + { + setTrialSessionsFiltersSequence({ + sessionTypes: { + action: 'remove', + sessionType, + }, + }); + }} + /> + ), + )} +
-
+
@@ -325,7 +350,7 @@ const TrialSessionFilters = connect(
-
+
From f03ecee228639ea0219f65a49888189c544d7e85 Mon Sep 17 00:00:00 2001 From: Nechama Krigsman Date: Thu, 19 Sep 2024 00:07:18 -0400 Subject: [PATCH 48/96] 10409: add clear trial session filter button; --- .../resetTrialSessionsFiltersAction.test.ts | 4 ++-- .../TrialSession/resetTrialSessionsFiltersAction.ts | 5 ++++- web-client/src/presenter/presenter.ts | 2 ++ .../sequences/resetTrialSessionsFiltersSequence.ts | 5 +++++ .../src/presenter/state/trialSessionsPageState.ts | 5 +++-- web-client/src/views/TrialSessions/TrialSessions.tsx | 11 +++++++++++ 6 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 web-client/src/presenter/sequences/resetTrialSessionsFiltersSequence.ts diff --git a/web-client/src/presenter/actions/TrialSession/resetTrialSessionsFiltersAction.test.ts b/web-client/src/presenter/actions/TrialSession/resetTrialSessionsFiltersAction.test.ts index 487f0db01e4..bd3bd8e4239 100644 --- a/web-client/src/presenter/actions/TrialSession/resetTrialSessionsFiltersAction.test.ts +++ b/web-client/src/presenter/actions/TrialSession/resetTrialSessionsFiltersAction.test.ts @@ -8,8 +8,8 @@ describe('resetTrialSessionsFiltersAction', () => { state: {}, }); - expect(result.state.trialSessionsPage).toEqual( - initialTrialSessionPageState, + expect(result.state.trialSessionsPage.filters).toEqual( + initialTrialSessionPageState.filters, ); }); }); diff --git a/web-client/src/presenter/actions/TrialSession/resetTrialSessionsFiltersAction.ts b/web-client/src/presenter/actions/TrialSession/resetTrialSessionsFiltersAction.ts index 57f6678c48e..41263650a1d 100644 --- a/web-client/src/presenter/actions/TrialSession/resetTrialSessionsFiltersAction.ts +++ b/web-client/src/presenter/actions/TrialSession/resetTrialSessionsFiltersAction.ts @@ -3,5 +3,8 @@ import { initialTrialSessionPageState } from '@web-client/presenter/state/trialS import { state } from '@web-client/presenter/app.cerebral'; export const resetTrialSessionsFiltersAction = ({ store }: ActionProps) => { - store.set(state.trialSessionsPage, cloneDeep(initialTrialSessionPageState)); + store.set( + state.trialSessionsPage.filters, + cloneDeep(initialTrialSessionPageState.filters), + ); }; diff --git a/web-client/src/presenter/presenter.ts b/web-client/src/presenter/presenter.ts index 24f204a483f..725df48df61 100644 --- a/web-client/src/presenter/presenter.ts +++ b/web-client/src/presenter/presenter.ts @@ -353,6 +353,7 @@ import { resetHeaderAccordionsSequence } from './sequences/resetHeaderAccordions import { resetIdleTimerSequence } from './sequences/resetIdleTimerSequence'; import { resetPasswordSequence } from '@web-client/presenter/sequences/Login/resetPasswordSequence'; import { resetSecondaryAddressSequence } from './sequences/resetSecondaryAddressSequence'; +import { resetTrialSessionsFiltersSequence } from '@web-client/presenter/sequences/resetTrialSessionsFiltersSequence'; import { retryAsyncRequestSequence } from './sequences/retryAsyncRequestSequence'; import { reviewCaseAssociationRequestSequence } from './sequences/reviewCaseAssociationRequestSequence'; import { reviewExternalDocumentInformationSequence } from './sequences/reviewExternalDocumentInformationSequence'; @@ -1195,6 +1196,7 @@ export const presenterSequences = { resetIdleTimerSequence: resetIdleTimerSequence as unknown as Function, resetPasswordSequence, resetSecondaryAddressSequence, + resetTrialSessionsFiltersSequence, retryAsyncRequestSequence: retryAsyncRequestSequence as unknown as Function, reviewCaseAssociationRequestSequence: reviewCaseAssociationRequestSequence as unknown as Function, diff --git a/web-client/src/presenter/sequences/resetTrialSessionsFiltersSequence.ts b/web-client/src/presenter/sequences/resetTrialSessionsFiltersSequence.ts new file mode 100644 index 00000000000..375941b2292 --- /dev/null +++ b/web-client/src/presenter/sequences/resetTrialSessionsFiltersSequence.ts @@ -0,0 +1,5 @@ +import { resetTrialSessionsFiltersAction } from '@web-client/presenter/actions/TrialSession/resetTrialSessionsFiltersAction'; + +export const resetTrialSessionsFiltersSequence = [ + resetTrialSessionsFiltersAction, +] as unknown as () => void; diff --git a/web-client/src/presenter/state/trialSessionsPageState.ts b/web-client/src/presenter/state/trialSessionsPageState.ts index a8a6a05dad6..6ef0a53653e 100644 --- a/web-client/src/presenter/state/trialSessionsPageState.ts +++ b/web-client/src/presenter/state/trialSessionsPageState.ts @@ -1,14 +1,15 @@ -import { TrialSessionInfoDTO } from '@shared/business/dto/trialSessions/TrialSessionInfoDTO'; import { + SESSION_STATUS_TYPES, TrialSessionProceedingType, TrialSessionTypes, } from '@shared/business/entities/EntityConstants'; +import { TrialSessionInfoDTO } from '@shared/business/dto/trialSessions/TrialSessionInfoDTO'; const filters: TrialSessionsFilters = { currentTab: 'calendared' as 'calendared' | 'new', judges: {}, proceedingType: 'All' as TrialSessionProceedingType, - sessionStatus: 'Open', + sessionStatus: SESSION_STATUS_TYPES.open, sessionTypes: {}, trialLocations: {}, }; diff --git a/web-client/src/views/TrialSessions/TrialSessions.tsx b/web-client/src/views/TrialSessions/TrialSessions.tsx index f93ffce2830..f7e6e3a06d1 100644 --- a/web-client/src/views/TrialSessions/TrialSessions.tsx +++ b/web-client/src/views/TrialSessions/TrialSessions.tsx @@ -92,11 +92,14 @@ export const TrialSessions = connect( const TrialSessionFilters = connect( { + resetTrialSessionsFiltersSequence: + sequences.resetTrialSessionsFiltersSequence, setTrialSessionsFiltersSequence: sequences.setTrialSessionsFiltersSequence, trialSessionsHelper: state.trialSessionsHelper, trialSessionsPage: state.trialSessionsPage, }, function TrialSessionFilters({ + resetTrialSessionsFiltersSequence, setTrialSessionsFiltersSequence, trialSessionsHelper, trialSessionsPage, @@ -388,6 +391,14 @@ const TrialSessionFilters = connect(
+ ); }, From f8f76ba77313fd8b70115c45e8de3b207f72233e Mon Sep 17 00:00:00 2001 From: Nechama Krigsman Date: Thu, 19 Sep 2024 10:23:30 -0400 Subject: [PATCH 49/96] 10409: disable clear filters button when no optional filters are selected; --- web-client/src/presenter/computeds/trialSessionsHelper.ts | 8 ++++++++ web-client/src/views/TrialSessions/TrialSessions.tsx | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/web-client/src/presenter/computeds/trialSessionsHelper.ts b/web-client/src/presenter/computeds/trialSessionsHelper.ts index 66ecddf5f37..76451ce9441 100644 --- a/web-client/src/presenter/computeds/trialSessionsHelper.ts +++ b/web-client/src/presenter/computeds/trialSessionsHelper.ts @@ -20,6 +20,7 @@ import { state } from '@web-client/presenter/app.cerebral'; export const trialSessionsHelper = ( get: Get, ): { + isClearFiltersDisabled: boolean; showNewTrialSession: boolean; showNoticeIssued: boolean; showSessionStatus: boolean; @@ -129,7 +130,14 @@ export const trialSessionsHelper = ( trialSessions: filteredTrialSessions, }); + const isClearFiltersDisabled = ![ + ...Object.keys(filters.judges), + ...Object.keys(filters.sessionTypes), + ...Object.keys(filters.trialLocations), + ].length; + return { + isClearFiltersDisabled, searchableTrialLocationOptions, sessionTypeOptions, showNewTrialSession: permissions.CREATE_TRIAL_SESSION, diff --git a/web-client/src/views/TrialSessions/TrialSessions.tsx b/web-client/src/views/TrialSessions/TrialSessions.tsx index f7e6e3a06d1..498b3ac4225 100644 --- a/web-client/src/views/TrialSessions/TrialSessions.tsx +++ b/web-client/src/views/TrialSessions/TrialSessions.tsx @@ -393,7 +393,7 @@ const TrialSessionFilters = connect(
); From e26678740d9df7d91f7dcf99e4e43a03c31991fb Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 19 Sep 2024 11:30:19 -0700 Subject: [PATCH 53/96] 10409: fix warnings --- web-client/src/ustc-ui/Tabs/Tabs.tsx | 2 +- .../src/views/TrialSessions/TrialSessions.tsx | 2 + .../TrialSessions/TrialSessionsTable.tsx | 119 +++++++++--------- 3 files changed, 60 insertions(+), 63 deletions(-) diff --git a/web-client/src/ustc-ui/Tabs/Tabs.tsx b/web-client/src/ustc-ui/Tabs/Tabs.tsx index 10d09f3a8dc..52c2726101d 100644 --- a/web-client/src/ustc-ui/Tabs/Tabs.tsx +++ b/web-client/src/ustc-ui/Tabs/Tabs.tsx @@ -82,7 +82,7 @@ export function Tab(properties: { const HeadingElement = ({ children, level }) => { return React.createElement( `h${level}`, - { ariaHidden: 'false', className: 'sr-only' }, + { 'aria-hidden': 'false', className: 'sr-only' }, children, ); }; diff --git a/web-client/src/views/TrialSessions/TrialSessions.tsx b/web-client/src/views/TrialSessions/TrialSessions.tsx index 1a70b17cee6..8f6cb8ec955 100644 --- a/web-client/src/views/TrialSessions/TrialSessions.tsx +++ b/web-client/src/views/TrialSessions/TrialSessions.tsx @@ -67,6 +67,7 @@ export const TrialSessions = connect( @@ -77,6 +78,7 @@ export const TrialSessions = connect( diff --git a/web-client/src/views/TrialSessions/TrialSessionsTable.tsx b/web-client/src/views/TrialSessions/TrialSessionsTable.tsx index f97331bc764..4cda7a2b5a2 100644 --- a/web-client/src/views/TrialSessions/TrialSessionsTable.tsx +++ b/web-client/src/views/TrialSessions/TrialSessionsTable.tsx @@ -1,9 +1,6 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { connect } from '@web-client/presenter/shared.cerebral'; -import { - isTrialSessionRow, - isTrialSessionWeek, -} from '@web-client/presenter/computeds/trialSessionsHelper'; +import { isTrialSessionWeek } from '@web-client/presenter/computeds/trialSessionsHelper'; import { state } from '@web-client/presenter/app.cerebral'; import React from 'react'; @@ -34,10 +31,10 @@ export const TrialSessionsTable = connect( {trialSessionsHelper.showSessionStatus && Session Status} - {trialSessionsHelper.trialSessionRows.map(row => ( - <> - {isTrialSessionWeek(row) && ( - + {trialSessionsHelper.trialSessionRows.map(row => { + if (isTrialSessionWeek(row)) { + return ( +

@@ -47,62 +44,60 @@ export const TrialSessionsTable = connect( - )} - {isTrialSessionRow(row) && ( - - - - {row.showAlertForNOTTReminder && ( - - )} - {row.formattedStartDate} - - {row.formattedEstimatedEndDate} - - {row.swingSession && ( - - )} - - - - {row.trialLocation} - - - {row.proceedingType} - {row.sessionType} - {row.judge && row.judge.name} - {trialSessionsHelper.showNoticeIssued && ( - {row.formattedNoticeIssuedDate} + ); + } + return ( + + + + {row.showAlertForNOTTReminder && ( + )} - {trialSessionsHelper.showSessionStatus && ( - {row.sessionStatus} + {row.formattedStartDate} + + {row.formattedEstimatedEndDate} + + {row.swingSession && ( + )} - - - )} - - ))} + + + + {row.trialLocation} + + + {row.proceedingType} + {row.sessionType} + {row.judge && row.judge.name} + {trialSessionsHelper.showNoticeIssued && ( + {row.formattedNoticeIssuedDate} + )} + {trialSessionsHelper.showSessionStatus && ( + {row.sessionStatus} + )} + + + ); + })} {trialSessionsHelper.trialSessionRows.length === 0 && (

There are no trial sessions for the selected filters.

From 242f45849cfd1ba11ffd721b92888d76eade5cb2 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 19 Sep 2024 12:00:38 -0700 Subject: [PATCH 54/96] 10409: fix reseet filters on tab change --- .../resetTrialSessionsFiltersAction.ts | 9 ++++++++- .../resetTrialSessionsFiltersSequence.ts | 8 +++++++- .../src/views/TrialSessions/TrialSessions.tsx | 15 +++++++++++---- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/web-client/src/presenter/actions/TrialSession/resetTrialSessionsFiltersAction.ts b/web-client/src/presenter/actions/TrialSession/resetTrialSessionsFiltersAction.ts index 41263650a1d..ae70b2b33e2 100644 --- a/web-client/src/presenter/actions/TrialSession/resetTrialSessionsFiltersAction.ts +++ b/web-client/src/presenter/actions/TrialSession/resetTrialSessionsFiltersAction.ts @@ -1,10 +1,17 @@ +import { ResetTrialSessionsFiltersSequence } from '@web-client/presenter/sequences/resetTrialSessionsFiltersSequence'; import { cloneDeep } from 'lodash'; import { initialTrialSessionPageState } from '@web-client/presenter/state/trialSessionsPageState'; import { state } from '@web-client/presenter/app.cerebral'; -export const resetTrialSessionsFiltersAction = ({ store }: ActionProps) => { +export const resetTrialSessionsFiltersAction = ({ + props, + store, +}: ActionProps) => { store.set( state.trialSessionsPage.filters, cloneDeep(initialTrialSessionPageState.filters), ); + if (props?.currentTab) { + store.set(state.trialSessionsPage.filters.currentTab, props.currentTab); + } }; diff --git a/web-client/src/presenter/sequences/resetTrialSessionsFiltersSequence.ts b/web-client/src/presenter/sequences/resetTrialSessionsFiltersSequence.ts index 375941b2292..f9ac27dac2f 100644 --- a/web-client/src/presenter/sequences/resetTrialSessionsFiltersSequence.ts +++ b/web-client/src/presenter/sequences/resetTrialSessionsFiltersSequence.ts @@ -2,4 +2,10 @@ import { resetTrialSessionsFiltersAction } from '@web-client/presenter/actions/T export const resetTrialSessionsFiltersSequence = [ resetTrialSessionsFiltersAction, -] as unknown as () => void; +] as unknown as (props?: ResetTrialSessionsFiltersSequence) => void; + +export type ResetTrialSessionsFiltersSequence = + | undefined + | { + currentTab: 'calendared' | 'new'; + }; diff --git a/web-client/src/views/TrialSessions/TrialSessions.tsx b/web-client/src/views/TrialSessions/TrialSessions.tsx index 8f6cb8ec955..a2d6bc6f7f7 100644 --- a/web-client/src/views/TrialSessions/TrialSessions.tsx +++ b/web-client/src/views/TrialSessions/TrialSessions.tsx @@ -21,12 +21,13 @@ export const TrialSessions = connect( { openTrialSessionPlanningModalSequence: sequences.openTrialSessionPlanningModalSequence, - setTrialSessionsFiltersSequence: sequences.setTrialSessionsFiltersSequence, + resetTrialSessionsFiltersSequence: + sequences.resetTrialSessionsFiltersSequence, trialSessionsHelper: state.trialSessionsHelper, }, function TrialSessions({ openTrialSessionPlanningModalSequence, - setTrialSessionsFiltersSequence, + resetTrialSessionsFiltersSequence, trialSessionsHelper, }) { return ( @@ -41,7 +42,7 @@ export const TrialSessions = connect( headingLevel="2" id="trial-sessions-tabs" onSelect={tabName => { - setTrialSessionsFiltersSequence({ currentTab: tabName }); + resetTrialSessionsFiltersSequence({ currentTab: tabName }); }} >
@@ -245,6 +246,12 @@ const TrialSessionFilters = connect( + Last start date{' '} + (optional) + + } endName="trialSessionStartDate" endValue={trialSessionsPage.filters.endDate} formGroupCls="margin-bottom-0" @@ -253,7 +260,7 @@ const TrialSessionFilters = connect( startDateErrorText={''} startLabel={ - Trial Start Date range{' '} + First start date{' '} (optional) } From ae79b248a4244c01d244ed4d45dcd6285a922546 Mon Sep 17 00:00:00 2001 From: Nechama Krigsman Date: Thu, 19 Sep 2024 15:27:23 -0400 Subject: [PATCH 55/96] 10409: add trial session count; --- web-client/src/presenter/computeds/trialSessionsHelper.ts | 3 ++- web-client/src/views/TrialSessions/TrialSessionsTable.tsx | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/web-client/src/presenter/computeds/trialSessionsHelper.ts b/web-client/src/presenter/computeds/trialSessionsHelper.ts index 6f5346de6fd..c3e2285cb7f 100644 --- a/web-client/src/presenter/computeds/trialSessionsHelper.ts +++ b/web-client/src/presenter/computeds/trialSessionsHelper.ts @@ -32,6 +32,7 @@ export const trialSessionsHelper = ( sessionTypeOptions: InputOption[]; searchableTrialLocationOptions: InputOption[]; trialCitiesByState: InputOption[]; + trialSessionsCount: number; } => { const permissions = get(state.permissions)!; const trialSessions = get(state.trialSessionsPage.trialSessions); @@ -140,7 +141,6 @@ export const trialSessionsHelper = ( .sort((sessionA, sessionB) => { return sessionA.startDate.localeCompare(sessionB.startDate); }); - const trialSessionRows = formatTrialSessions({ judgeAssociatedToUser: judge, trialSessions: filteredTrialSessions, @@ -168,6 +168,7 @@ export const trialSessionsHelper = ( trialCitiesByState: states, trialSessionJudgeOptions, trialSessionRows, + trialSessionsCount: filteredTrialSessions.length, }; }; diff --git a/web-client/src/views/TrialSessions/TrialSessionsTable.tsx b/web-client/src/views/TrialSessions/TrialSessionsTable.tsx index 4cda7a2b5a2..ed3b0b41087 100644 --- a/web-client/src/views/TrialSessions/TrialSessionsTable.tsx +++ b/web-client/src/views/TrialSessions/TrialSessionsTable.tsx @@ -12,6 +12,12 @@ export const TrialSessionsTable = connect( function TrialSessionsTable({ trialSessionsHelper, trialSessionsPage }) { return ( <> +
+ Count:{' '} + + {trialSessionsHelper.trialSessionsCount} + +
Date: Thu, 19 Sep 2024 17:03:48 -0400 Subject: [PATCH 56/96] 10409: wip --- .../setTrialSessionsFiltersAction.ts | 9 +- .../computeds/trialSessionsHelper.ts | 10 +- .../presenter/state/trialSessionsPageState.ts | 2 + .../src/ustc-ui/Pagination/Paginator.tsx | 290 ++++++++++++++---- .../src/views/TrialSessions/TrialSessions.tsx | 8 + 5 files changed, 258 insertions(+), 61 deletions(-) diff --git a/web-client/src/presenter/actions/TrialSession/setTrialSessionsFiltersAction.ts b/web-client/src/presenter/actions/TrialSession/setTrialSessionsFiltersAction.ts index e4b50a26c2a..868c0bc9e10 100644 --- a/web-client/src/presenter/actions/TrialSession/setTrialSessionsFiltersAction.ts +++ b/web-client/src/presenter/actions/TrialSession/setTrialSessionsFiltersAction.ts @@ -17,8 +17,9 @@ export type SetTrialSessionsFilters = Partial<{ action: 'add' | 'remove'; trialLocation: string; }; - startDate?: string; - endDate?: string; + pageNumber: number; + startDate: string; + endDate: string; }>; export const setTrialSessionsFiltersAction = ({ @@ -85,6 +86,10 @@ export const setTrialSessionsFiltersAction = ({ ); } + if (props.pageNumber || props.pageNumber === 0) { + store.set(state.trialSessionsPage.filters.pageNumber, props.pageNumber); + } + if (props.startDate || props.startDate === '') { store.set(state.trialSessionsPage.filters.startDate, props.startDate); } diff --git a/web-client/src/presenter/computeds/trialSessionsHelper.ts b/web-client/src/presenter/computeds/trialSessionsHelper.ts index c3e2285cb7f..aacd345fd45 100644 --- a/web-client/src/presenter/computeds/trialSessionsHelper.ts +++ b/web-client/src/presenter/computeds/trialSessionsHelper.ts @@ -33,12 +33,15 @@ export const trialSessionsHelper = ( searchableTrialLocationOptions: InputOption[]; trialCitiesByState: InputOption[]; trialSessionsCount: number; + totalPages: number; } => { const permissions = get(state.permissions)!; const trialSessions = get(state.trialSessionsPage.trialSessions); const filters = get(state.trialSessionsPage.filters); const judge = get(state.judgeUser); + const pageSize = 5; + const showCurrentJudgesOnly = filters.currentTab === 'new' || filters.sessionStatus === SESSION_STATUS_TYPES.open; @@ -140,7 +143,11 @@ export const trialSessionsHelper = ( }) .sort((sessionA, sessionB) => { return sessionA.startDate.localeCompare(sessionB.startDate); - }); + }) + .slice( + filters.pageNumber * pageSize, + filters.pageNumber * pageSize + pageSize, + ); const trialSessionRows = formatTrialSessions({ judgeAssociatedToUser: judge, trialSessions: filteredTrialSessions, @@ -165,6 +172,7 @@ export const trialSessionsHelper = ( showNoticeIssued: filters.currentTab === 'calendared', showSessionStatus: filters.currentTab === 'calendared', showUnassignedJudgeFilter: filters.currentTab === 'new', + totalPages: Math.ceil(filteredTrialSessions.length / pageSize), trialCitiesByState: states, trialSessionJudgeOptions, trialSessionRows, diff --git a/web-client/src/presenter/state/trialSessionsPageState.ts b/web-client/src/presenter/state/trialSessionsPageState.ts index 40f856227c6..a198a815870 100644 --- a/web-client/src/presenter/state/trialSessionsPageState.ts +++ b/web-client/src/presenter/state/trialSessionsPageState.ts @@ -9,6 +9,7 @@ const filters: TrialSessionsFilters = { currentTab: 'calendared' as 'calendared' | 'new', endDate: '', judges: {}, + pageNumber: 0, proceedingType: 'All' as TrialSessionProceedingType, sessionStatus: SESSION_STATUS_TYPES.open, sessionTypes: {}, @@ -24,6 +25,7 @@ export const initialTrialSessionPageState = { export type TrialSessionsFilters = { currentTab: 'calendared' | 'new'; endDate: string; + pageNumber: number; judges: Record; proceedingType: TrialSessionProceedingType | 'All'; sessionStatus: string; diff --git a/web-client/src/ustc-ui/Pagination/Paginator.tsx b/web-client/src/ustc-ui/Pagination/Paginator.tsx index 1beb6346bc7..7965e1f6317 100644 --- a/web-client/src/ustc-ui/Pagination/Paginator.tsx +++ b/web-client/src/ustc-ui/Pagination/Paginator.tsx @@ -1,74 +1,248 @@ -import { Button } from '@web-client/ustc-ui/Button/Button'; import React from 'react'; import classNames from 'classnames'; -export const Paginator = ({ +const numberOfPaginatorSlots = 7; +const PageButton = (props: { + pageNumber: number; + selected: boolean; + onClick: (selectedPage: number) => void; +}) => { + return ( + <> +
  • + +
  • + + ); +}; + +const PreviousPage = (props: { onPreviousClick: Function }) => { + return ( + <> +
  • + +
  • + + ); +}; + +const NextPage = (props: { onNextClick: Function }) => { + return ( + <> +
  • + +
  • + + ); +}; + +const PageEllipsis = () => { + return ( + <> +
  • + … +
  • + + ); +}; + +function getSlotComponent({ currentPageIndex, onPageChange, + slotNumber, totalPages, }: { + currentPageIndex: number; + onPageChange: (selectedPage: number) => any; + slotNumber: number; totalPages: number; +}) { + const isHidingPreviousOptions = + currentPageIndex > 3 && totalPages > numberOfPaginatorSlots; + const isHidingFutureOptions = + totalPages - currentPageIndex > 4 && totalPages > numberOfPaginatorSlots; + if (slotNumber === 0) { + return ( + { + onPageChange(selectedPage); + }} + /> + ); + } + if (slotNumber === 1) { + if (isHidingPreviousOptions) { + return ; + } else { + return ( + { + onPageChange(selectedPage); + }} + /> + ); + } + } + if (slotNumber === 2 || slotNumber === 3 || slotNumber === 4) { + if (!isHidingPreviousOptions) { + return ( + { + onPageChange(selectedPage); + }} + /> + ); + } + if (!isHidingFutureOptions) { + return ( + { + onPageChange(selectedPage); + }} + /> + ); + } + return ( + { + onPageChange(selectedPage); + }} + /> + ); + } + if (slotNumber === 5) { + if (isHidingFutureOptions) { + return ; + } else { + const subtractor = totalPages >= 7 ? 2 : 1; + return ( + { + onPageChange(selectedPage); + }} + /> + ); + } + } + if (slotNumber === 6) { + return ( + { + onPageChange(selectedPage); + }} + /> + ); + } +} + +/* +This component is based off of USWDS implementation of a paginator: https://designsystem.digital.gov/components/pagination/ +The totalPages and selected page work similarly to counting arrays. TotalPages is similar to array.length and selectedPage is 0 based indexing. +totalPages could be 20 but the maximum value selectedPage could be is 19 and the lowest pages is 0. +*/ + +export const Paginator = ({ + currentPageIndex, + onPageChange, + totalPages, +}: { currentPageIndex: number; - onPageChange: (currentPage: number) => void; + totalPages: number; + onPageChange: (selectedPage: number) => any; }) => { - let currentPage = currentPageIndex + 1; + const sevenDisplayedSlots = []; + console.log('selected page number: ', currentPageIndex); + // 1. Should it render the slot at all? + // 2. Should it render a page button or an ellipse? + // 3. Should it render The slot number it is or should it add some extras? - const nextDisabled = currentPage >= totalPages; - const previousDisabled = currentPage <= 1; + for (let slotNumber = 0; slotNumber < numberOfPaginatorSlots; slotNumber++) { + if (slotNumber >= totalPages) { + continue; + } + const slotComponent = getSlotComponent({ + currentPageIndex, + onPageChange, + slotNumber, + totalPages, + }); + sevenDisplayedSlots.push(slotComponent); + } return ( - + <> + + ); }; diff --git a/web-client/src/views/TrialSessions/TrialSessions.tsx b/web-client/src/views/TrialSessions/TrialSessions.tsx index a2d6bc6f7f7..a622d6c2c41 100644 --- a/web-client/src/views/TrialSessions/TrialSessions.tsx +++ b/web-client/src/views/TrialSessions/TrialSessions.tsx @@ -2,6 +2,7 @@ import { BigHeader } from '../BigHeader'; import { Button } from '../../ustc-ui/Button/Button'; import { DateRangePickerComponent } from '@web-client/ustc-ui/DateInput/DateRangePickerComponent'; import { ErrorNotification } from '../ErrorNotification'; +import { Paginator } from '@web-client/ustc-ui/Pagination/Paginator'; import { PillButton } from '@web-client/ustc-ui/Button/PillButton'; import { SESSION_STATUS_TYPES, @@ -411,6 +412,13 @@ const TrialSessionFilters = connect( > Reset Filters + { + setTrialSessionsFiltersSequence({ pageNumber: selectedPage }); + }} + /> ); }, From 2fd8290c0b088fd3a9ef624200a285a99de395a0 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 19 Sep 2024 15:08:13 -0700 Subject: [PATCH 57/96] 10409: Add pagination support for trial sessions --- .../computeds/trialSessionsHelper.ts | 90 +++++++++++-------- 1 file changed, 53 insertions(+), 37 deletions(-) diff --git a/web-client/src/presenter/computeds/trialSessionsHelper.ts b/web-client/src/presenter/computeds/trialSessionsHelper.ts index aacd345fd45..6317aa738b7 100644 --- a/web-client/src/presenter/computeds/trialSessionsHelper.ts +++ b/web-client/src/presenter/computeds/trialSessionsHelper.ts @@ -15,7 +15,10 @@ import { } from '@shared/business/entities/EntityConstants'; import { TrialSession } from '@shared/business/entities/trialSessions/TrialSession'; import { TrialSessionInfoDTO } from '@shared/business/dto/trialSessions/TrialSessionInfoDTO'; -import { initialTrialSessionPageState } from '@web-client/presenter/state/trialSessionsPageState'; +import { + TrialSessionsFilters, + initialTrialSessionPageState, +} from '@web-client/presenter/state/trialSessionsPageState'; import { sortBy } from 'lodash'; import { state } from '@web-client/presenter/app.cerebral'; @@ -53,6 +56,17 @@ export const trialSessionsHelper = ( trialSessionJudges = get(state.legacyAndCurrentJudges); } + const userHasSelectedAFilter = + filters.proceedingType !== + initialTrialSessionPageState.filters.proceedingType || + filters.sessionStatus !== + initialTrialSessionPageState.filters.sessionStatus || + Object.keys(filters.judges).length > 0 || + Object.keys(filters.sessionTypes).length > 0 || + Object.keys(filters.trialLocations).length > 0 || + !!filters.startDate || + !!filters.endDate; + const sessionTypeOptions = Object.values(SESSION_TYPES).map(sessionType => ({ label: sessionType, value: sessionType, @@ -91,7 +105,43 @@ export const trialSessionsHelper = ( [], ); - const filteredTrialSessions = trialSessions + const filteredTrialSessions = filterAndSortTrialSessions({ + filters, + trialSessions, + }); + const trialSessionPage = filteredTrialSessions.slice( + filters.pageNumber * pageSize, + filters.pageNumber * pageSize + pageSize, + ); + const trialSessionRows = formatTrialSessions({ + judgeAssociatedToUser: judge, + trialSessions: trialSessionPage, + }); + + return { + isResetFiltersDisabled: !userHasSelectedAFilter, + searchableTrialLocationOptions, + sessionTypeOptions, + showNewTrialSession: permissions.CREATE_TRIAL_SESSION, + showNoticeIssued: filters.currentTab === 'calendared', + showSessionStatus: filters.currentTab === 'calendared', + showUnassignedJudgeFilter: filters.currentTab === 'new', + totalPages: Math.ceil(filteredTrialSessions.length / pageSize), + trialCitiesByState: states, + trialSessionJudgeOptions, + trialSessionRows, + trialSessionsCount: filteredTrialSessions.length, + }; +}; + +const filterAndSortTrialSessions = ({ + filters, + trialSessions, +}: { + trialSessions: TrialSessionInfoDTO[]; + filters: TrialSessionsFilters; +}): TrialSessionInfoDTO[] => { + return trialSessions .filter(trialSession => { const isCalendaredFilter = filters.currentTab === 'calendared'; return trialSession.isCalendared === isCalendaredFilter; @@ -143,41 +193,7 @@ export const trialSessionsHelper = ( }) .sort((sessionA, sessionB) => { return sessionA.startDate.localeCompare(sessionB.startDate); - }) - .slice( - filters.pageNumber * pageSize, - filters.pageNumber * pageSize + pageSize, - ); - const trialSessionRows = formatTrialSessions({ - judgeAssociatedToUser: judge, - trialSessions: filteredTrialSessions, - }); - - const userHasSelectedAFilter = - filters.proceedingType !== - initialTrialSessionPageState.filters.proceedingType || - filters.sessionStatus !== - initialTrialSessionPageState.filters.sessionStatus || - Object.keys(filters.judges).length > 0 || - Object.keys(filters.sessionTypes).length > 0 || - Object.keys(filters.trialLocations).length > 0 || - !!filters.startDate || - !!filters.endDate; - - return { - isResetFiltersDisabled: !userHasSelectedAFilter, - searchableTrialLocationOptions, - sessionTypeOptions, - showNewTrialSession: permissions.CREATE_TRIAL_SESSION, - showNoticeIssued: filters.currentTab === 'calendared', - showSessionStatus: filters.currentTab === 'calendared', - showUnassignedJudgeFilter: filters.currentTab === 'new', - totalPages: Math.ceil(filteredTrialSessions.length / pageSize), - trialCitiesByState: states, - trialSessionJudgeOptions, - trialSessionRows, - trialSessionsCount: filteredTrialSessions.length, - }; + }); }; const formatTrialSessions = ({ From 88ec347ea8a7cff85fd1eece8bf07b1d97365a86 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 19 Sep 2024 15:24:04 -0700 Subject: [PATCH 58/96] 10409: Change paginator location --- .../src/ustc-ui/Pagination/Paginator.tsx | 121 +++++++++--------- .../src/views/TrialSessions/TrialSessions.tsx | 8 -- .../TrialSessions/TrialSessionsTable.tsx | 17 ++- 3 files changed, 75 insertions(+), 71 deletions(-) diff --git a/web-client/src/ustc-ui/Pagination/Paginator.tsx b/web-client/src/ustc-ui/Pagination/Paginator.tsx index 7965e1f6317..6aa10397584 100644 --- a/web-client/src/ustc-ui/Pagination/Paginator.tsx +++ b/web-client/src/ustc-ui/Pagination/Paginator.tsx @@ -2,6 +2,64 @@ import React from 'react'; import classNames from 'classnames'; const numberOfPaginatorSlots = 7; + +/* +This component is based off of USWDS implementation of a paginator: https://designsystem.digital.gov/components/pagination/ +The totalPages and selected page work similarly to counting arrays. TotalPages is similar to array.length and selectedPage is 0 based indexing. +totalPages could be 20 but the maximum value selectedPage could be is 19 and the lowest pages is 0. +*/ + +export const Paginator = ({ + currentPageIndex, + onPageChange, + totalPages, +}: { + currentPageIndex: number; + totalPages: number; + onPageChange: (selectedPage: number) => any; +}) => { + const sevenDisplayedSlots: React.JSX.Element[] = []; + + for (let slotNumber = 0; slotNumber < numberOfPaginatorSlots; slotNumber++) { + if (slotNumber >= totalPages) { + continue; + } + const slotComponent = getSlotComponent({ + currentPageIndex, + onPageChange, + slotNumber, + totalPages, + }); + sevenDisplayedSlots.push(slotComponent); + } + + return ( + <> + + + ); +}; + +Paginator.displayName = 'Paginator'; + const PageButton = (props: { pageNumber: number; selected: boolean; @@ -185,65 +243,6 @@ function getSlotComponent({ /> ); } -} - -/* -This component is based off of USWDS implementation of a paginator: https://designsystem.digital.gov/components/pagination/ -The totalPages and selected page work similarly to counting arrays. TotalPages is similar to array.length and selectedPage is 0 based indexing. -totalPages could be 20 but the maximum value selectedPage could be is 19 and the lowest pages is 0. -*/ -export const Paginator = ({ - currentPageIndex, - onPageChange, - totalPages, -}: { - currentPageIndex: number; - totalPages: number; - onPageChange: (selectedPage: number) => any; -}) => { - const sevenDisplayedSlots = []; - console.log('selected page number: ', currentPageIndex); - // 1. Should it render the slot at all? - // 2. Should it render a page button or an ellipse? - // 3. Should it render The slot number it is or should it add some extras? - - for (let slotNumber = 0; slotNumber < numberOfPaginatorSlots; slotNumber++) { - if (slotNumber >= totalPages) { - continue; - } - const slotComponent = getSlotComponent({ - currentPageIndex, - onPageChange, - slotNumber, - totalPages, - }); - sevenDisplayedSlots.push(slotComponent); - } - - return ( - <> - - - ); -}; - -Paginator.displayName = 'Paginator'; + return <>; +} diff --git a/web-client/src/views/TrialSessions/TrialSessions.tsx b/web-client/src/views/TrialSessions/TrialSessions.tsx index a622d6c2c41..a2d6bc6f7f7 100644 --- a/web-client/src/views/TrialSessions/TrialSessions.tsx +++ b/web-client/src/views/TrialSessions/TrialSessions.tsx @@ -2,7 +2,6 @@ import { BigHeader } from '../BigHeader'; import { Button } from '../../ustc-ui/Button/Button'; import { DateRangePickerComponent } from '@web-client/ustc-ui/DateInput/DateRangePickerComponent'; import { ErrorNotification } from '../ErrorNotification'; -import { Paginator } from '@web-client/ustc-ui/Pagination/Paginator'; import { PillButton } from '@web-client/ustc-ui/Button/PillButton'; import { SESSION_STATUS_TYPES, @@ -412,13 +411,6 @@ const TrialSessionFilters = connect( > Reset Filters - { - setTrialSessionsFiltersSequence({ pageNumber: selectedPage }); - }} - /> ); }, diff --git a/web-client/src/views/TrialSessions/TrialSessionsTable.tsx b/web-client/src/views/TrialSessions/TrialSessionsTable.tsx index ed3b0b41087..357b2b00c7b 100644 --- a/web-client/src/views/TrialSessions/TrialSessionsTable.tsx +++ b/web-client/src/views/TrialSessions/TrialSessionsTable.tsx @@ -1,18 +1,31 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { Paginator } from '@web-client/ustc-ui/Pagination/Paginator'; import { connect } from '@web-client/presenter/shared.cerebral'; import { isTrialSessionWeek } from '@web-client/presenter/computeds/trialSessionsHelper'; -import { state } from '@web-client/presenter/app.cerebral'; +import { sequences, state } from '@web-client/presenter/app.cerebral'; import React from 'react'; export const TrialSessionsTable = connect( { + setTrialSessionsFiltersSequence: sequences.setTrialSessionsFiltersSequence, trialSessionsHelper: state.trialSessionsHelper, trialSessionsPage: state.trialSessionsPage, }, - function TrialSessionsTable({ trialSessionsHelper, trialSessionsPage }) { + function TrialSessionsTable({ + setTrialSessionsFiltersSequence, + trialSessionsHelper, + trialSessionsPage, + }) { return ( <>
    + { + setTrialSessionsFiltersSequence({ pageNumber: selectedPage }); + }} + /> Count:{' '} {trialSessionsHelper.trialSessionsCount} From da682b7ff3e5ff745526b4d9a4e1c83604cd0524 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Thu, 19 Sep 2024 16:00:43 -0700 Subject: [PATCH 59/96] 10409: Set page number whenever filters change --- .../setTrialSessionsFiltersAction.ts | 6 ++-- .../computeds/trialSessionsHelper.ts | 2 +- .../src/ustc-ui/Pagination/Paginator.tsx | 23 +++++++++++---- .../src/views/TrialSessions/TrialSessions.tsx | 2 +- .../TrialSessions/TrialSessionsTable.tsx | 29 +++++++++++-------- 5 files changed, 39 insertions(+), 23 deletions(-) diff --git a/web-client/src/presenter/actions/TrialSession/setTrialSessionsFiltersAction.ts b/web-client/src/presenter/actions/TrialSession/setTrialSessionsFiltersAction.ts index 868c0bc9e10..1e32cb67da6 100644 --- a/web-client/src/presenter/actions/TrialSession/setTrialSessionsFiltersAction.ts +++ b/web-client/src/presenter/actions/TrialSession/setTrialSessionsFiltersAction.ts @@ -86,14 +86,12 @@ export const setTrialSessionsFiltersAction = ({ ); } - if (props.pageNumber || props.pageNumber === 0) { - store.set(state.trialSessionsPage.filters.pageNumber, props.pageNumber); - } - if (props.startDate || props.startDate === '') { store.set(state.trialSessionsPage.filters.startDate, props.startDate); } if (props.endDate || props.endDate === '') { store.set(state.trialSessionsPage.filters.endDate, props.endDate); } + + store.set(state.trialSessionsPage.filters.pageNumber, props.pageNumber || 0); // Always reset page number to 0 }; diff --git a/web-client/src/presenter/computeds/trialSessionsHelper.ts b/web-client/src/presenter/computeds/trialSessionsHelper.ts index 6317aa738b7..184bbcd7ea4 100644 --- a/web-client/src/presenter/computeds/trialSessionsHelper.ts +++ b/web-client/src/presenter/computeds/trialSessionsHelper.ts @@ -43,7 +43,7 @@ export const trialSessionsHelper = ( const filters = get(state.trialSessionsPage.filters); const judge = get(state.judgeUser); - const pageSize = 5; + const pageSize = 1; const showCurrentJudgesOnly = filters.currentTab === 'new' || diff --git a/web-client/src/ustc-ui/Pagination/Paginator.tsx b/web-client/src/ustc-ui/Pagination/Paginator.tsx index 6aa10397584..1dea748b15d 100644 --- a/web-client/src/ustc-ui/Pagination/Paginator.tsx +++ b/web-client/src/ustc-ui/Pagination/Paginator.tsx @@ -5,8 +5,8 @@ const numberOfPaginatorSlots = 7; /* This component is based off of USWDS implementation of a paginator: https://designsystem.digital.gov/components/pagination/ -The totalPages and selected page work similarly to counting arrays. TotalPages is similar to array.length and selectedPage is 0 based indexing. -totalPages could be 20 but the maximum value selectedPage could be is 19 and the lowest pages is 0. +The totalPages and selected page work similarly to counting arrays. TotalPages is similar to array.length and currentPageIndex is 0 based indexing. +totalPages could be 20 but the maximum value currentPageIndex could be is 19 and the lowest pages is 0. */ export const Paginator = ({ @@ -18,6 +18,9 @@ export const Paginator = ({ totalPages: number; onPageChange: (selectedPage: number) => any; }) => { + if (totalPages === 0) { + return; + } const sevenDisplayedSlots: React.JSX.Element[] = []; for (let slotNumber = 0; slotNumber < numberOfPaginatorSlots; slotNumber++) { @@ -35,7 +38,10 @@ export const Paginator = ({ return ( <> -
    -
    +
    Date: Fri, 20 Sep 2024 12:26:16 -0400 Subject: [PATCH 60/96] 10409: display chevron on previous and next buttons; fix jumping columns on page change; fix jumping previous and next buttons; --- web-client/src/styles/custom.scss | 16 +++++ .../src/ustc-ui/Pagination/Paginator.tsx | 71 +++++++++++++------ .../TrialSessions/TrialSessionsTable.tsx | 20 +++--- 3 files changed, 76 insertions(+), 31 deletions(-) diff --git a/web-client/src/styles/custom.scss b/web-client/src/styles/custom.scss index b3c54edd1f6..de248eec1eb 100644 --- a/web-client/src/styles/custom.scss +++ b/web-client/src/styles/custom.scss @@ -2407,4 +2407,20 @@ button.change-scanner-button { .stepper-line-height { line-height: 18px; +} + +.visibility-hidden { + visibility: hidden; +} + +.column-width-sm { + width: 150px +} + +.column-width-md { + width: 200px +} + +.column-width-lg { + width: 300px } \ No newline at end of file diff --git a/web-client/src/ustc-ui/Pagination/Paginator.tsx b/web-client/src/ustc-ui/Pagination/Paginator.tsx index 1dea748b15d..16984b14d80 100644 --- a/web-client/src/ustc-ui/Pagination/Paginator.tsx +++ b/web-client/src/ustc-ui/Pagination/Paginator.tsx @@ -43,21 +43,19 @@ export const Paginator = ({ className="usa-pagination margin-bottom-0 margin-top-0" >
      - {currentPageIndex !== 0 && ( - { - onPageChange(currentPageIndex - 1); - }} - /> - )} + { + onPageChange(currentPageIndex - 1); + }} + /> {sevenDisplayedSlots} - {currentPageIndex < totalPages - 1 && ( - { - onPageChange(currentPageIndex + 1); - }} - /> - )} + { + onPageChange(currentPageIndex + 1); + }} + />
    @@ -90,19 +88,34 @@ const PageButton = (props: { ); }; -const PreviousPage = (props: { onPreviousClick: Function }) => { +const PreviousPage = (props: { + onPreviousClick: Function; + isHidden: boolean; +}) => { return ( <>
  • @@ -111,21 +124,33 @@ const PreviousPage = (props: { onPreviousClick: Function }) => { ); }; -const NextPage = (props: { onNextClick: Function }) => { +const NextPage = (props: { onNextClick: Function; isHidden: boolean }) => { return ( <>
  • diff --git a/web-client/src/views/TrialSessions/TrialSessionsTable.tsx b/web-client/src/views/TrialSessions/TrialSessionsTable.tsx index 01c41afaa9f..598f124d164 100644 --- a/web-client/src/views/TrialSessions/TrialSessionsTable.tsx +++ b/web-client/src/views/TrialSessions/TrialSessionsTable.tsx @@ -44,15 +44,19 @@ export const TrialSessionsTable = connect( > - - + + - - - - {trialSessionsHelper.showNoticeIssued && } - {trialSessionsHelper.showSessionStatus && } + + + + + {trialSessionsHelper.showNoticeIssued && ( + + )} + {trialSessionsHelper.showSessionStatus && ( + + )} {trialSessionsHelper.trialSessionRows.map(row => { From 478fd2c28469a395f77d9c83b0b9f5b3e3ba089d Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Fri, 20 Sep 2024 09:43:57 -0700 Subject: [PATCH 61/96] 10409: Add icons --- web-client/src/ustc-ui/Icon/LeftChevron.tsx | 20 +++++++++++++++++ web-client/src/ustc-ui/Icon/RightChevron.tsx | 20 +++++++++++++++++ .../src/ustc-ui/Pagination/Paginator.tsx | 22 ++++--------------- 3 files changed, 44 insertions(+), 18 deletions(-) create mode 100644 web-client/src/ustc-ui/Icon/LeftChevron.tsx create mode 100644 web-client/src/ustc-ui/Icon/RightChevron.tsx diff --git a/web-client/src/ustc-ui/Icon/LeftChevron.tsx b/web-client/src/ustc-ui/Icon/LeftChevron.tsx new file mode 100644 index 00000000000..7d3f7f2e35f --- /dev/null +++ b/web-client/src/ustc-ui/Icon/LeftChevron.tsx @@ -0,0 +1,20 @@ +import React from 'react'; +import classNames from 'classnames'; + +export function LeftChevron({ + className, + ...props +}: { className?: string } & React.SVGProps) { + return ( + + ); +} diff --git a/web-client/src/ustc-ui/Icon/RightChevron.tsx b/web-client/src/ustc-ui/Icon/RightChevron.tsx new file mode 100644 index 00000000000..86a9eb1f696 --- /dev/null +++ b/web-client/src/ustc-ui/Icon/RightChevron.tsx @@ -0,0 +1,20 @@ +import React from 'react'; +import classNames from 'classnames'; + +export function RightChevron({ + className, + ...props +}: { className?: string } & React.SVGProps) { + return ( + + ); +} diff --git a/web-client/src/ustc-ui/Pagination/Paginator.tsx b/web-client/src/ustc-ui/Pagination/Paginator.tsx index 16984b14d80..76c0cf766c7 100644 --- a/web-client/src/ustc-ui/Pagination/Paginator.tsx +++ b/web-client/src/ustc-ui/Pagination/Paginator.tsx @@ -1,3 +1,5 @@ +import { LeftChevron } from '@web-client/ustc-ui/Icon/LeftChevron'; +import { RightChevron } from '@web-client/ustc-ui/Icon/RightChevron'; import React from 'react'; import classNames from 'classnames'; @@ -108,15 +110,7 @@ const PreviousPage = (props: { props.onPreviousClick(); }} > - + Previous @@ -142,15 +136,7 @@ const NextPage = (props: { onNextClick: Function; isHidden: boolean }) => { }} > Next - + From ba8c182c01fbd2e4f25dc0dc6e2940e159cd3051 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Fri, 20 Sep 2024 09:49:49 -0700 Subject: [PATCH 62/96] 10409: Fix grid styling for paginator --- web-client/src/views/TrialSessions/TrialSessionsTable.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web-client/src/views/TrialSessions/TrialSessionsTable.tsx b/web-client/src/views/TrialSessions/TrialSessionsTable.tsx index 598f124d164..0939daaefdb 100644 --- a/web-client/src/views/TrialSessions/TrialSessionsTable.tsx +++ b/web-client/src/views/TrialSessions/TrialSessionsTable.tsx @@ -19,7 +19,7 @@ export const TrialSessionsTable = connect( return ( <>
    -
    +
    -
    +
    Count:{' '} {trialSessionsHelper.trialSessionsCount} From e11c403dbec58ee14efd3946672e343c859556b2 Mon Sep 17 00:00:00 2001 From: Nechama Krigsman Date: Fri, 20 Sep 2024 13:10:16 -0400 Subject: [PATCH 63/96] 10409: add onBlur event listener to DateRangePicker to handle validation on blur; --- .../src/ustc-ui/DateInput/DateRangePickerComponent.tsx | 10 ++++++++++ web-client/src/views/TrialSessions/TrialSessions.tsx | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/web-client/src/ustc-ui/DateInput/DateRangePickerComponent.tsx b/web-client/src/ustc-ui/DateInput/DateRangePickerComponent.tsx index 184ccfc756c..aa66cfb826e 100644 --- a/web-client/src/ustc-ui/DateInput/DateRangePickerComponent.tsx +++ b/web-client/src/ustc-ui/DateInput/DateRangePickerComponent.tsx @@ -13,6 +13,8 @@ export const DateRangePickerComponent = ({ formGroupCls, maxDate, omitFormGroupClass, + onBlurEnd, + onBlurStart, onChangeEnd, onChangeStart, rangePickerCls, @@ -31,6 +33,8 @@ export const DateRangePickerComponent = ({ endValue: string; formGroupCls?: string; rangePickerCls?: string; + onBlurEnd?: (event: React.ChangeEvent) => void; + onBlurStart?: (event: React.ChangeEvent) => void; onChangeEnd: (event: React.ChangeEvent) => void; onChangeStart: (event: React.ChangeEvent) => void; startDateErrorText?: string; @@ -122,6 +126,9 @@ export const DateRangePickerComponent = ({ if (dateEndInput) { dateEndInput.addEventListener('change', onChangeEnd); dateEndInput.addEventListener('input', onChangeEnd); + if (onBlurEnd) { + dateEndInput.addEventListener('blur', onBlurEnd); + } } const dateStartInput = window.document.getElementById( `${startName}-date-start`, @@ -129,6 +136,9 @@ export const DateRangePickerComponent = ({ if (dateStartInput) { dateStartInput.addEventListener('change', onChangeStart); dateStartInput.addEventListener('input', onChangeStart); + if (onBlurStart) { + dateStartInput.addEventListener('blur', onBlurStart); + } } } }, [startDateInputRef, endDateInputRef]); diff --git a/web-client/src/views/TrialSessions/TrialSessions.tsx b/web-client/src/views/TrialSessions/TrialSessions.tsx index 9615094d2c6..1be6915bb65 100644 --- a/web-client/src/views/TrialSessions/TrialSessions.tsx +++ b/web-client/src/views/TrialSessions/TrialSessions.tsx @@ -267,6 +267,14 @@ const TrialSessionFilters = connect( startName="trialSessionEndDate" startPickerCls="padding-right-2" startValue={trialSessionsPage.filters.startDate} + onBlurEnd={e => { + console.log('end we blurred!!', e.target.value); + // run validation + }} + onBlurStart={e => { + console.log('start we blurred!!', e.target.value); + // run validation + }} onChangeEnd={e => { setTrialSessionsFiltersSequence({ endDate: e.target.value, From 5853672763db747b1afc993fa92732412b73ba8b Mon Sep 17 00:00:00 2001 From: Javis Sullivan Date: Fri, 20 Sep 2024 13:19:08 -0400 Subject: [PATCH 64/96] 10409: wip fixing unit tests --- .../computeds/trialSessionsHelper.test.ts | 103 +++++++++++++----- 1 file changed, 73 insertions(+), 30 deletions(-) diff --git a/web-client/src/presenter/computeds/trialSessionsHelper.test.ts b/web-client/src/presenter/computeds/trialSessionsHelper.test.ts index f4da90fbc14..ddd08a8c857 100644 --- a/web-client/src/presenter/computeds/trialSessionsHelper.test.ts +++ b/web-client/src/presenter/computeds/trialSessionsHelper.test.ts @@ -4,7 +4,6 @@ import { formatNow, } from '@shared/business/utilities/DateHandler'; import { - ROLES, SESSION_STATUS_TYPES, SESSION_TYPES, TRIAL_SESSION_PROCEEDING_TYPES, @@ -12,7 +11,12 @@ import { } from '../../../../shared/src/business/entities/EntityConstants'; import { TrialSessionInfoDTO } from '@shared/business/dto/trialSessions/TrialSessionInfoDTO'; import { cloneDeep } from 'lodash'; -import { docketClerk1User, judgeUser } from '@shared/test/mockUsers'; +import { + docketClerk1User, + judgeColvin, + judgeUser, + legacyJudgeUser, +} from '@shared/test/mockUsers'; import { getUserPermissions } from '@shared/authorization/getUserPermissions'; import { initialTrialSessionPageState } from '../state/trialSessionsPageState'; import { @@ -67,6 +71,7 @@ describe('trialSessionsHelper', () => { const result = runCompute(trialSessionsHelper, { state: { + judges: [judgeUser, judgeColvin], permissions: getUserPermissions(docketClerk1User), trialSessionsPage: trialSessionsPageState, }, @@ -79,6 +84,7 @@ describe('trialSessionsHelper', () => { trialSessionsPageState.filters.currentTab = 'new'; const result = runCompute(trialSessionsHelper, { state: { + judges: [judgeUser, judgeColvin], permissions: getUserPermissions(docketClerk1User), trialSessionsPage: trialSessionsPageState, }, @@ -94,6 +100,7 @@ describe('trialSessionsHelper', () => { const result = runCompute(trialSessionsHelper, { state: { + judges: [judgeUser, judgeColvin], permissions: getUserPermissions(docketClerk1User), trialSessionsPage: trialSessionsPageState, }, @@ -107,6 +114,7 @@ describe('trialSessionsHelper', () => { const result = runCompute(trialSessionsHelper, { state: { + judges: [judgeUser, judgeColvin], permissions: getUserPermissions(docketClerk1User), trialSessionsPage: trialSessionsPageState, }, @@ -119,9 +127,11 @@ describe('trialSessionsHelper', () => { describe('showUnassignedJudgeFilter', () => { it('should show the `unassigned` judge filter when on the new tab', () => { trialSessionsPageState.filters.currentTab = 'new'; + console.log('Judge Colvin: ', judgeColvin); const result = runCompute(trialSessionsHelper, { state: { + judges: [judgeUser, judgeColvin], permissions: getUserPermissions(docketClerk1User), trialSessionsPage: trialSessionsPageState, }, @@ -135,6 +145,7 @@ describe('trialSessionsHelper', () => { const result = runCompute(trialSessionsHelper, { state: { + judges: [judgeUser, judgeColvin], permissions: getUserPermissions(docketClerk1User), trialSessionsPage: trialSessionsPageState, }, @@ -151,21 +162,27 @@ describe('trialSessionsHelper', () => { SESSION_STATUS_TYPES.closed; const result = runCompute(trialSessionsHelper, { state: { - judges: [ - { name: 'I am not a legacy judge part 2', role: ROLES.judge }, - ], - legacyAndCurrentJudges: [ - { name: 'I am not a legacy judge', role: ROLES.judge }, - { name: 'I am a legacy judge', role: ROLES.legacyJudge }, - ], + legacyAndCurrentJudges: [judgeUser, legacyJudgeUser], permissions: getUserPermissions(docketClerk1User), trialSessionsPage: trialSessionsPageState, }, }); - expect(result.trialSessionJudges).toEqual([ - { name: 'I am not a legacy judge', role: ROLES.judge }, - { name: 'I am a legacy judge', role: ROLES.legacyJudge }, + expect(result.trialSessionJudgeOptions).toEqual([ + { + label: 'Sotomayor', + value: { + name: 'Sotomayor', + userId: '43b00e5f-b78c-476c-820e-5d6ed1d58828', + }, + }, + { + label: 'Legacy Judge Ginsburg', + value: { + name: 'Legacy Judge Ginsburg', + userId: 'dc67e189-cf3e-4ca3-a33f-91db111ec270', + }, + }, ]); }); @@ -173,20 +190,21 @@ describe('trialSessionsHelper', () => { trialSessionsPageState.filters.currentTab = 'new'; const result = runCompute(trialSessionsHelper, { state: { - judges: [ - { name: 'I am not a legacy judge part 2', role: ROLES.judge }, - ], - legacyAndCurrentJudges: [ - { name: 'I am not a legacy judge', role: ROLES.judge }, - { name: 'I am a legacy judge', role: ROLES.legacyJudge }, - ], + judges: [judgeUser], + legacyAndCurrentJudges: [legacyJudgeUser], permissions: getUserPermissions(docketClerk1User), trialSessionsPage: trialSessionsPageState, }, }); - expect(result.trialSessionJudges).toEqual([ - { name: 'I am not a legacy judge part 2', role: ROLES.judge }, + expect(result.trialSessionJudgeOptions).toEqual([ + { + label: 'Sotomayor', + value: { + name: 'Sotomayor', + userId: '43b00e5f-b78c-476c-820e-5d6ed1d58828', + }, + }, ]); }); @@ -194,28 +212,32 @@ describe('trialSessionsHelper', () => { trialSessionsPageState.filters.sessionStatus = SESSION_STATUS_TYPES.open; const result = runCompute(trialSessionsHelper, { state: { - judges: [ - { name: 'I am not a legacy judge part 2', role: ROLES.judge }, - ], - legacyAndCurrentJudges: [ - { name: 'I am not a legacy judge', role: ROLES.judge }, - { name: 'I am a legacy judge', role: ROLES.legacyJudge }, - ], + judges: [judgeUser], + legacyAndCurrentJudges: [legacyJudgeUser], permissions: getUserPermissions(docketClerk1User), trialSessionsPage: trialSessionsPageState, }, }); - expect(result.trialSessionJudges).toEqual([ - { name: 'I am not a legacy judge part 2', role: ROLES.judge }, + expect(result.trialSessionJudgeOptions).toEqual([ + { + label: 'Sotomayor', + value: { + name: 'Sotomayor', + userId: '43b00e5f-b78c-476c-820e-5d6ed1d58828', + }, + }, ]); }); }); describe('showNewTrialSession', () => { it('should return showNewTrialSession as true when current user has CREATE_TRIAL_SESSION permission', () => { + trialSessionsPageState.filters.currentTab = 'new'; + // TODO: Fix const result = runCompute(trialSessionsHelper, { state: { + jugdes: [judgeUser], permissions: getUserPermissions(docketClerk1User), trialSessionsPage: trialSessionsPageState, }, @@ -227,6 +249,7 @@ describe('trialSessionsHelper', () => { it('should return showNewTrialSession as false when current user does not have CREATE_TRIAL_SESSION permission', () => { const result = runCompute(trialSessionsHelper, { state: { + judges: [judgeUser], permissions: getUserPermissions(judgeUser), trialSessionsPage: trialSessionsPageState, }, @@ -246,6 +269,7 @@ describe('trialSessionsHelper', () => { const result = runCompute(trialSessionsHelper, { state: { + judges: [judgeUser], permissions: getUserPermissions(docketClerk1User), trialSessionsPage: trialSessionsPageState, }, @@ -264,6 +288,7 @@ describe('trialSessionsHelper', () => { const result = runCompute(trialSessionsHelper, { state: { + judges: [judgeUser], permissions: getUserPermissions(docketClerk1User), trialSessionsPage: trialSessionsPageState, }, @@ -277,12 +302,15 @@ describe('trialSessionsHelper', () => { ); }); + // TODO: This test is affectd by pagination now. Ergo, one trial sessionis filtered out + // when it should not be base on this test it('should not filter trial sessions by judge when judge filter is All', () => { trialSessionsPageState.trialSessions = [trialSession1, trialSession2]; trialSessionsPageState.filters.judgeId = 'All'; const result = runCompute(trialSessionsHelper, { state: { + judges: [judgeUser], permissions: getUserPermissions(docketClerk1User), trialSessionsPage: trialSessionsPageState, }, @@ -301,6 +329,7 @@ describe('trialSessionsHelper', () => { const result = runCompute(trialSessionsHelper, { state: { + judges: [judgeUser], permissions: getUserPermissions(docketClerk1User), trialSessionsPage: trialSessionsPageState, }, @@ -322,6 +351,7 @@ describe('trialSessionsHelper', () => { const result = runCompute(trialSessionsHelper, { state: { + judges: [judgeUser], permissions: getUserPermissions(docketClerk1User), trialSessionsPage: trialSessionsPageState, }, @@ -343,6 +373,7 @@ describe('trialSessionsHelper', () => { const result = runCompute(trialSessionsHelper, { state: { + judges: [judgeUser], permissions: getUserPermissions(docketClerk1User), trialSessionsPage: trialSessionsPageState, }, @@ -367,6 +398,7 @@ describe('trialSessionsHelper', () => { const result = runCompute(trialSessionsHelper, { state: { + judges: [judgeUser], permissions: getUserPermissions(docketClerk1User), trialSessionsPage: trialSessionsPageState, }, @@ -391,6 +423,7 @@ describe('trialSessionsHelper', () => { const result = runCompute(trialSessionsHelper, { state: { + judges: [judgeUser], permissions: getUserPermissions(docketClerk1User), trialSessionsPage: trialSessionsPageState, }, @@ -416,6 +449,7 @@ describe('trialSessionsHelper', () => { const result = runCompute(trialSessionsHelper, { state: { + judges: [judgeUser], permissions: getUserPermissions(docketClerk1User), trialSessionsPage: trialSessionsPageState, }, @@ -437,6 +471,7 @@ describe('trialSessionsHelper', () => { const result = runCompute(trialSessionsHelper, { state: { + judges: [judgeUser], permissions: getUserPermissions(docketClerk1User), trialSessionsPage: trialSessionsPageState, }, @@ -458,6 +493,7 @@ describe('trialSessionsHelper', () => { const result = runCompute(trialSessionsHelper, { state: { + judges: [judgeUser], permissions: getUserPermissions(docketClerk1User), trialSessionsPage: trialSessionsPageState, }, @@ -481,6 +517,7 @@ describe('trialSessionsHelper', () => { const result = runCompute(trialSessionsHelper, { state: { + judges: [judgeUser], permissions: getUserPermissions(docketClerk1User), trialSessionsPage: trialSessionsPageState, }, @@ -501,6 +538,7 @@ describe('trialSessionsHelper', () => { const result = runCompute(trialSessionsHelper, { state: { judgeUser: {}, + judges: [judgeUser], permissions: getUserPermissions(docketClerk1User), trialSessionsPage: trialSessionsPageState, }, @@ -523,6 +561,7 @@ describe('trialSessionsHelper', () => { judgeUser: { userId: '1', }, + judges: [judgeUser], permissions: getUserPermissions(docketClerk1User), trialSessionsPage: trialSessionsPageState, }, @@ -550,6 +589,7 @@ describe('trialSessionsHelper', () => { const result = runCompute(trialSessionsHelper, { state: { + judges: [judgeUser], permissions: getUserPermissions(docketClerk1User), trialSessionsPage: trialSessionsPageState, }, @@ -572,6 +612,7 @@ describe('trialSessionsHelper', () => { const result = runCompute(trialSessionsHelper, { state: { + judges: [judgeUser], permissions: getUserPermissions(docketClerk1User), trialSessionsPage: trialSessionsPageState, }, @@ -597,6 +638,7 @@ describe('trialSessionsHelper', () => { const result = runCompute(trialSessionsHelper, { state: { + judges: [judgeUser], permissions: getUserPermissions(docketClerk1User), trialSessionsPage: trialSessionsPageState, }, @@ -619,6 +661,7 @@ describe('trialSessionsHelper', () => { const result = runCompute(trialSessionsHelper, { state: { + judges: [judgeUser], permissions: getUserPermissions(docketClerk1User), trialSessionsPage: trialSessionsPageState, }, From 3ae767d9f9004864d02269e66a0e7c2f5f939cc2 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Fri, 20 Sep 2024 13:19:23 -0700 Subject: [PATCH 65/96] 10409: Add live validation for trial session dates --- .../TrialSessionsPageValidation.ts | 39 +++++++ .../computeds/trialSessionsHelper.ts | 36 ++++++ .../DateInput/DateRangePickerComponent.tsx | 16 ++- .../src/views/TrialSessions/TrialSessions.tsx | 18 +-- .../TrialSessions/TrialSessionsTable.tsx | 107 ++++++++++-------- 5 files changed, 146 insertions(+), 70 deletions(-) create mode 100644 shared/src/business/entities/trialSessions/TrialSessionsPageValidation.ts diff --git a/shared/src/business/entities/trialSessions/TrialSessionsPageValidation.ts b/shared/src/business/entities/trialSessions/TrialSessionsPageValidation.ts new file mode 100644 index 00000000000..a9780187182 --- /dev/null +++ b/shared/src/business/entities/trialSessions/TrialSessionsPageValidation.ts @@ -0,0 +1,39 @@ +import { JoiValidationConstants } from '@shared/business/entities/JoiValidationConstants'; +import { JoiValidationEntity } from '../JoiValidationEntity'; +import joi from 'joi'; + +export class TrialSessionsPageValidation extends JoiValidationEntity { + public endDate: string; + public startDate: string; + + constructor(rawProps) { + super('TrialSessionsPageValidation'); + this.endDate = rawProps.endDate; + this.startDate = rawProps.startDate; + } + + getValidationRules() { + return { + endDate: joi + .alternatives() + .conditional('startDate', { + is: JoiValidationConstants.ISO_DATE.exist().not(null), + otherwise: JoiValidationConstants.ISO_DATE, + then: JoiValidationConstants.ISO_DATE.min( + joi.ref('startDate'), + ).description( + 'The end date search filter must be of valid date format and greater than or equal to the start date', + ), + }) + .messages({ + '*': 'Enter date in format MM/DD/YYYY.', + 'date.min': 'End date cannot be prior to start date.', + }), + startDate: JoiValidationConstants.ISO_DATE.description( + 'The start date to search by, which cannot be greater than the current date, and is required when there is an end date provided', + ).messages({ + '*': 'Enter date in format MM/DD/YYYY.', + }), + }; + } +} diff --git a/web-client/src/presenter/computeds/trialSessionsHelper.ts b/web-client/src/presenter/computeds/trialSessionsHelper.ts index 184bbcd7ea4..23fa227facc 100644 --- a/web-client/src/presenter/computeds/trialSessionsHelper.ts +++ b/web-client/src/presenter/computeds/trialSessionsHelper.ts @@ -19,6 +19,7 @@ import { TrialSessionsFilters, initialTrialSessionPageState, } from '@web-client/presenter/state/trialSessionsPageState'; +import { TrialSessionsPageValidation } from '@shared/business/entities/trialSessions/TrialSessionsPageValidation'; import { sortBy } from 'lodash'; import { state } from '@web-client/presenter/app.cerebral'; @@ -36,6 +37,8 @@ export const trialSessionsHelper = ( searchableTrialLocationOptions: InputOption[]; trialCitiesByState: InputOption[]; trialSessionsCount: number; + endDateErrorMessage?: string; + startDateErrorMessage?: string; totalPages: number; } => { const permissions = get(state.permissions)!; @@ -104,6 +107,11 @@ export const trialSessionsHelper = ( }, [], ); + const { endDateErrorMessage, startDateErrorMessage } = + validateTrialSessionDateRange({ + endDate: filters.endDate, + startDate: filters.startDate, + }); const filteredTrialSessions = filterAndSortTrialSessions({ filters, @@ -119,6 +127,7 @@ export const trialSessionsHelper = ( }); return { + endDateErrorMessage, isResetFiltersDisabled: !userHasSelectedAFilter, searchableTrialLocationOptions, sessionTypeOptions, @@ -126,6 +135,7 @@ export const trialSessionsHelper = ( showNoticeIssued: filters.currentTab === 'calendared', showSessionStatus: filters.currentTab === 'calendared', showUnassignedJudgeFilter: filters.currentTab === 'new', + startDateErrorMessage, totalPages: Math.ceil(filteredTrialSessions.length / pageSize), trialCitiesByState: states, trialSessionJudgeOptions, @@ -319,3 +329,29 @@ type TrialSessionWeek = { export function isTrialSessionWeek(item: any): item is TrialSessionWeek { return !!item?.sessionWeekStartDate; } + +function validateTrialSessionDateRange({ + endDate, + startDate, +}: { + startDate: string; + endDate: string; +}): { startDateErrorMessage?: string; endDateErrorMessage?: string } { + const formattedEndDate = endDate + ? createISODateString(endDate, FORMATS.MMDDYYYY) + : undefined; + + const formattedStartDate = startDate + ? createISODateString(startDate, FORMATS.MMDDYYYY) + : undefined; + + const errors = new TrialSessionsPageValidation({ + endDate: formattedEndDate, + startDate: formattedStartDate, + }).getFormattedValidationErrors(); + + return { + endDateErrorMessage: errors?.endDate, + startDateErrorMessage: errors?.startDate, + }; +} diff --git a/web-client/src/ustc-ui/DateInput/DateRangePickerComponent.tsx b/web-client/src/ustc-ui/DateInput/DateRangePickerComponent.tsx index aa66cfb826e..a6ad1cc31d1 100644 --- a/web-client/src/ustc-ui/DateInput/DateRangePickerComponent.tsx +++ b/web-client/src/ustc-ui/DateInput/DateRangePickerComponent.tsx @@ -35,8 +35,8 @@ export const DateRangePickerComponent = ({ rangePickerCls?: string; onBlurEnd?: (event: React.ChangeEvent) => void; onBlurStart?: (event: React.ChangeEvent) => void; - onChangeEnd: (event: React.ChangeEvent) => void; - onChangeStart: (event: React.ChangeEvent) => void; + onChangeEnd?: (event: React.ChangeEvent) => void; + onChangeStart?: (event: React.ChangeEvent) => void; startDateErrorText?: string; startPickerCls?: string; startLabel?: string | React.ReactNode; @@ -124,8 +124,10 @@ export const DateRangePickerComponent = ({ `${endName}-date-end`, ); if (dateEndInput) { - dateEndInput.addEventListener('change', onChangeEnd); - dateEndInput.addEventListener('input', onChangeEnd); + if (onChangeEnd) { + dateEndInput.addEventListener('change', onChangeEnd); + dateEndInput.addEventListener('input', onChangeEnd); + } if (onBlurEnd) { dateEndInput.addEventListener('blur', onBlurEnd); } @@ -134,8 +136,10 @@ export const DateRangePickerComponent = ({ `${startName}-date-start`, ); if (dateStartInput) { - dateStartInput.addEventListener('change', onChangeStart); - dateStartInput.addEventListener('input', onChangeStart); + if (onChangeStart) { + dateStartInput.addEventListener('change', onChangeStart); + dateStartInput.addEventListener('input', onChangeStart); + } if (onBlurStart) { dateStartInput.addEventListener('blur', onBlurStart); } diff --git a/web-client/src/views/TrialSessions/TrialSessions.tsx b/web-client/src/views/TrialSessions/TrialSessions.tsx index 1be6915bb65..38cd66faa00 100644 --- a/web-client/src/views/TrialSessions/TrialSessions.tsx +++ b/web-client/src/views/TrialSessions/TrialSessions.tsx @@ -245,7 +245,7 @@ const TrialSessionFilters = connect(
    Last start date{' '} @@ -254,10 +254,8 @@ const TrialSessionFilters = connect( } endName="trialSessionStartDate" endValue={trialSessionsPage.filters.endDate} - formGroupCls="margin-bottom-0" - maxDate={''} - rangePickerCls={'display-flex flex-align-end'} - startDateErrorText={''} + rangePickerCls={'display-flex'} + startDateErrorText={trialSessionsHelper.startDateErrorMessage} startLabel={ First start date{' '} @@ -268,19 +266,11 @@ const TrialSessionFilters = connect( startPickerCls="padding-right-2" startValue={trialSessionsPage.filters.startDate} onBlurEnd={e => { - console.log('end we blurred!!', e.target.value); - // run validation - }} - onBlurStart={e => { - console.log('start we blurred!!', e.target.value); - // run validation - }} - onChangeEnd={e => { setTrialSessionsFiltersSequence({ endDate: e.target.value, }); }} - onChangeStart={e => { + onBlurStart={e => { setTrialSessionsFiltersSequence({ startDate: e.target.value, }); diff --git a/web-client/src/views/TrialSessions/TrialSessionsTable.tsx b/web-client/src/views/TrialSessions/TrialSessionsTable.tsx index 0939daaefdb..d52690485fc 100644 --- a/web-client/src/views/TrialSessions/TrialSessionsTable.tsx +++ b/web-client/src/views/TrialSessions/TrialSessionsTable.tsx @@ -1,7 +1,10 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { Paginator } from '@web-client/ustc-ui/Pagination/Paginator'; import { connect } from '@web-client/presenter/shared.cerebral'; -import { isTrialSessionWeek } from '@web-client/presenter/computeds/trialSessionsHelper'; +import { + isTrialSessionRow, + isTrialSessionWeek, +} from '@web-client/presenter/computeds/trialSessionsHelper'; import { sequences, state } from '@web-client/presenter/app.cerebral'; import React from 'react'; @@ -74,57 +77,61 @@ export const TrialSessionsTable = connect( ); } - return ( -
    - - + + + + + + + + + {trialSessionsHelper.showNoticeIssued && ( + )} - {row.formattedStartDate} - - - )} - - - - - - {trialSessionsHelper.showNoticeIssued && ( - - )} - {trialSessionsHelper.showSessionStatus && ( - - )} - - - ); + + + ); + } })}
    Start DateEst. End DateStart DateEst. End Date - LocationProceeding TypeSession TypeJudgeNotice IssuedSession StatusLocationProceeding TypeSession TypeJudgeNotice IssuedSession Status
    - {row.showAlertForNOTTReminder && ( - + if (isTrialSessionRow(row)) { + return ( +
    + {row.showAlertForNOTTReminder && ( + + )} + {row.formattedStartDate} + {row.formattedEstimatedEndDate} + {row.swingSession && ( + + )} + + + {row.trialLocation} + + {row.proceedingType}{row.sessionType}{row.judge && row.judge.name}{row.formattedNoticeIssuedDate}{row.formattedEstimatedEndDate} - {row.swingSession && ( - + {trialSessionsHelper.showSessionStatus && ( + {row.sessionStatus} - - {row.trialLocation} - - {row.proceedingType}{row.sessionType}{row.judge && row.judge.name}{row.formattedNoticeIssuedDate}{row.sessionStatus}
    {trialSessionsHelper.trialSessionRows.length === 0 && ( From 2080ede3ac9afcc8c251f762f2f6c42f92aa8aa5 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Fri, 20 Sep 2024 13:20:11 -0700 Subject: [PATCH 66/96] 10409: remove comment --- web-client/src/presenter/computeds/trialSessionsHelper.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/web-client/src/presenter/computeds/trialSessionsHelper.ts b/web-client/src/presenter/computeds/trialSessionsHelper.ts index 23fa227facc..1fe2665f3a0 100644 --- a/web-client/src/presenter/computeds/trialSessionsHelper.ts +++ b/web-client/src/presenter/computeds/trialSessionsHelper.ts @@ -84,7 +84,6 @@ export const trialSessionsHelper = ( const trialCities = sortBy(TRIAL_CITIES.ALL, ['state', 'city']); const searchableTrialLocationOptions: InputOption[] = []; - // eslint-disable-next-line @typescript-eslint/no-unused-vars const states: InputOption[] = trialCities.reduce( (listOfStates: InputOption[], cityStatePair) => { const existingState = listOfStates.find( From 092dbc9c97dde49a91429666a79cf769c895ba1f Mon Sep 17 00:00:00 2001 From: Javis Sullivan Date: Mon, 23 Sep 2024 00:54:34 -0400 Subject: [PATCH 67/96] 10411: wip fixing tests --- .../presenter/computeds/trialSessionsHelper.test.ts | 12 +++++++----- .../src/presenter/computeds/trialSessionsHelper.ts | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/web-client/src/presenter/computeds/trialSessionsHelper.test.ts b/web-client/src/presenter/computeds/trialSessionsHelper.test.ts index ddd08a8c857..55409b14a20 100644 --- a/web-client/src/presenter/computeds/trialSessionsHelper.test.ts +++ b/web-client/src/presenter/computeds/trialSessionsHelper.test.ts @@ -63,6 +63,7 @@ describe('trialSessionsHelper', () => { trialLocation: 'Boise', trialSessionId: '392810', }; + trialSessionsPageState.trialSessions = [trialSession1, trialSession2]; }); describe('showNoticeIssued', () => { @@ -127,7 +128,6 @@ describe('trialSessionsHelper', () => { describe('showUnassignedJudgeFilter', () => { it('should show the `unassigned` judge filter when on the new tab', () => { trialSessionsPageState.filters.currentTab = 'new'; - console.log('Judge Colvin: ', judgeColvin); const result = runCompute(trialSessionsHelper, { state: { @@ -234,10 +234,10 @@ describe('trialSessionsHelper', () => { describe('showNewTrialSession', () => { it('should return showNewTrialSession as true when current user has CREATE_TRIAL_SESSION permission', () => { trialSessionsPageState.filters.currentTab = 'new'; - // TODO: Fix + const judges = [judgeUser, judgeColvin]; const result = runCompute(trialSessionsHelper, { state: { - jugdes: [judgeUser], + judges, permissions: getUserPermissions(docketClerk1User), trialSessionsPage: trialSessionsPageState, }, @@ -302,19 +302,21 @@ describe('trialSessionsHelper', () => { ); }); + // #ix this // TODO: This test is affectd by pagination now. Ergo, one trial sessionis filtered out // when it should not be base on this test it('should not filter trial sessions by judge when judge filter is All', () => { trialSessionsPageState.trialSessions = [trialSession1, trialSession2]; trialSessionsPageState.filters.judgeId = 'All'; - + console.log('Trial Sessions: ', trialSessionsPageState.trialSessions); const result = runCompute(trialSessionsHelper, { state: { - judges: [judgeUser], + judges: [judgeUser, judgeColvin], permissions: getUserPermissions(docketClerk1User), trialSessionsPage: trialSessionsPageState, }, }); + console.log('TrialSessionRows: ', result.trialSessionRows); const trialSessionsOnly = result.trialSessionRows.filter(isTrialSessionRow); diff --git a/web-client/src/presenter/computeds/trialSessionsHelper.ts b/web-client/src/presenter/computeds/trialSessionsHelper.ts index 1fe2665f3a0..d601b4f38d4 100644 --- a/web-client/src/presenter/computeds/trialSessionsHelper.ts +++ b/web-client/src/presenter/computeds/trialSessionsHelper.ts @@ -45,6 +45,7 @@ export const trialSessionsHelper = ( const trialSessions = get(state.trialSessionsPage.trialSessions); const filters = get(state.trialSessionsPage.filters); const judge = get(state.judgeUser); + const judges = get(state.judges); const pageSize = 1; @@ -54,7 +55,7 @@ export const trialSessionsHelper = ( let trialSessionJudges: { name: string; userId: string }[]; // 10409 TODO BUG. The judge options is not updating correctly. Showing legacy when it should not. if (showCurrentJudgesOnly) { - trialSessionJudges = get(state.judges); + trialSessionJudges = judges; } else { trialSessionJudges = get(state.legacyAndCurrentJudges); } @@ -74,7 +75,6 @@ export const trialSessionsHelper = ( label: sessionType, value: sessionType, })); - const trialSessionJudgeOptions = trialSessionJudges.map( trialSessionJudge => ({ label: trialSessionJudge.name, From c1a68dfa4a3dc1c152213f89cf9ca610717d4d52 Mon Sep 17 00:00:00 2001 From: Nechama Krigsman Date: Mon, 23 Sep 2024 11:44:37 -0400 Subject: [PATCH 68/96] 10409: only show single page paginator when fetching data per page; --- .../src/ustc-ui/Pagination/Paginator.tsx | 20 +++++++++++++++++-- .../PractitionerSearchResults.tsx | 2 ++ .../CustomCaseReport/CustomCaseReport.tsx | 2 ++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/web-client/src/ustc-ui/Pagination/Paginator.tsx b/web-client/src/ustc-ui/Pagination/Paginator.tsx index 76c0cf766c7..50d13d37467 100644 --- a/web-client/src/ustc-ui/Pagination/Paginator.tsx +++ b/web-client/src/ustc-ui/Pagination/Paginator.tsx @@ -3,8 +3,6 @@ import { RightChevron } from '@web-client/ustc-ui/Icon/RightChevron'; import React from 'react'; import classNames from 'classnames'; -const numberOfPaginatorSlots = 7; - /* This component is based off of USWDS implementation of a paginator: https://designsystem.digital.gov/components/pagination/ The totalPages and selected page work similarly to counting arrays. TotalPages is similar to array.length and currentPageIndex is 0 based indexing. @@ -14,15 +12,18 @@ totalPages could be 20 but the maximum value currentPageIndex could be is 19 and export const Paginator = ({ currentPageIndex, onPageChange, + showSinglePage = false, totalPages, }: { currentPageIndex: number; totalPages: number; + showSinglePage?: boolean; onPageChange: (selectedPage: number) => any; }) => { if (totalPages === 0) { return; } + const numberOfPaginatorSlots = showSinglePage ? 1 : 7; const sevenDisplayedSlots: React.JSX.Element[] = []; for (let slotNumber = 0; slotNumber < numberOfPaginatorSlots; slotNumber++) { @@ -31,6 +32,7 @@ export const Paginator = ({ } const slotComponent = getSlotComponent({ currentPageIndex, + numberOfPaginatorSlots, onPageChange, slotNumber, totalPages, @@ -158,6 +160,7 @@ const PageEllipsis = () => { function getSlotComponent({ currentPageIndex, + numberOfPaginatorSlots, onPageChange, slotNumber, totalPages, @@ -166,12 +169,25 @@ function getSlotComponent({ onPageChange: (selectedPage: number) => any; slotNumber: number; totalPages: number; + numberOfPaginatorSlots: number; }) { const isHidingPreviousOptions = currentPageIndex > 3 && totalPages > numberOfPaginatorSlots; const isHidingFutureOptions = totalPages - currentPageIndex > 4 && totalPages > numberOfPaginatorSlots; if (slotNumber === 0) { + if (numberOfPaginatorSlots === 1) { + return ( + { + onPageChange(selectedPage); + }} + /> + ); + } return ( { submitPractitionerNameSearchSequence({ @@ -162,6 +163,7 @@ export const PractitionerSearchResults = connect( {practitionerSearchHelper.showPaginator && ( { submitPractitionerNameSearchSequence({ diff --git a/web-client/src/views/CustomCaseReport/CustomCaseReport.tsx b/web-client/src/views/CustomCaseReport/CustomCaseReport.tsx index 2f3aaa2f1b9..1f5606c7e23 100644 --- a/web-client/src/views/CustomCaseReport/CustomCaseReport.tsx +++ b/web-client/src/views/CustomCaseReport/CustomCaseReport.tsx @@ -469,6 +469,7 @@ export const CustomCaseReport = connect( {customCaseReportHelper.pageCount > 1 && ( { setActivePage(pageChange); @@ -512,6 +513,7 @@ export const CustomCaseReport = connect( {customCaseReportHelper.pageCount > 1 && ( { setActivePage(pageChange); From 7e4f10120a26c8c1ef32465d827fab85db8e396c Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 23 Sep 2024 11:50:17 -0700 Subject: [PATCH 69/96] 10409: WIP trying to type selectsearch --- .../src/ustc-ui/Select/SelectSearch2.tsx | 22 +++++++++++++++++++ .../src/views/TrialSessions/TrialSessions.tsx | 8 +++---- 2 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 web-client/src/ustc-ui/Select/SelectSearch2.tsx diff --git a/web-client/src/ustc-ui/Select/SelectSearch2.tsx b/web-client/src/ustc-ui/Select/SelectSearch2.tsx new file mode 100644 index 00000000000..1d574c53968 --- /dev/null +++ b/web-client/src/ustc-ui/Select/SelectSearch2.tsx @@ -0,0 +1,22 @@ +import React from 'react'; +import ReactSelect, { GroupBase, Props } from 'react-select'; +import classNames from 'classnames'; + +export function SelectSearch2< + Option, + IsMulti extends boolean = false, + Group extends GroupBase
    @@ -329,17 +335,19 @@ const TrialSessionFilters = connect( name="location" options={trialSessionsHelper.trialCitiesByState} placeholder="- Select one or more -" - searchableOptions={ - trialSessionsHelper.searchableTrialLocationOptions - } - value="Select one or more" + value={{ + label: '- Select one or more -', + value: '', + }} onChange={location => { - setTrialSessionsFiltersSequence({ - trialLocations: { - action: 'add', - trialLocation: location.value, - }, - }); + if (location) { + setTrialSessionsFiltersSequence({ + trialLocations: { + action: 'add', + trialLocation: location.value, + }, + }); + } }} />

    @@ -372,14 +380,19 @@ const TrialSessionFilters = connect( name="judges" options={trialSessionsHelper.trialSessionJudgeOptions} placeholder="- Select one or more -" - value="Select one or more" + value={{ + label: '- Select one or more -', + value: { name: '', userId: '' }, + }} onChange={inputValue => { - setTrialSessionsFiltersSequence({ - judges: { - action: 'add', - judge: inputValue.value, - }, - }); + if (inputValue) { + setTrialSessionsFiltersSequence({ + judges: { + action: 'add', + judge: inputValue.value, + }, + }); + } }} /> From cd05f0bb9fa05cf017a8e86944ad0bca3a2c9bf4 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 23 Sep 2024 14:33:39 -0700 Subject: [PATCH 71/96] 10409: Creaate new utils folder for trial sessions --- .../business/entities/cases/CalendaredCase.ts | 2 +- .../test/createTestApplicationContext.ts | 2 +- ...Details.compareCasesByDocketNumber.test.ts | 2 +- ...etails.setPretrialMemorandumFilter.test.ts | 6 +-- .../getFormattedTrialSessionDetails.test.ts | 6 +-- .../getFormattedTrialSessionDetails.ts | 6 +-- .../trialSession/trialCitiesGroupedByState.ts | 38 ++++++++++++++++ .../generateTrialCalendarPdfInteractor.ts | 2 +- web-api/src/getUtilities.ts | 2 +- web-client/src/applicationContext.ts | 2 +- web-client/src/applicationContextPublic.ts | 2 +- .../src/presenter/actions/setCaseAction.ts | 2 +- .../computeds/customCaseReportHelper.ts | 44 +++++-------------- .../computeds/formattedTrialSessionDetails.ts | 2 +- .../trialSessionWorkingCopyHelper.ts | 2 +- .../computeds/trialSessionsHelper.ts | 29 +----------- .../createClientTestApplicationContext.ts | 2 +- 17 files changed, 70 insertions(+), 81 deletions(-) rename shared/src/business/utilities/{ => trialSession}/getFormattedTrialSessionDetails.compareCasesByDocketNumber.test.ts (98%) rename shared/src/business/utilities/{ => trialSession}/getFormattedTrialSessionDetails.setPretrialMemorandumFilter.test.ts (96%) rename shared/src/business/utilities/{ => trialSession}/getFormattedTrialSessionDetails.test.ts (98%) rename shared/src/business/utilities/{ => trialSession}/getFormattedTrialSessionDetails.ts (98%) create mode 100644 shared/src/business/utilities/trialSession/trialCitiesGroupedByState.ts diff --git a/shared/src/business/entities/cases/CalendaredCase.ts b/shared/src/business/entities/cases/CalendaredCase.ts index a27eccc6b7a..ad9fd3cc4b1 100644 --- a/shared/src/business/entities/cases/CalendaredCase.ts +++ b/shared/src/business/entities/cases/CalendaredCase.ts @@ -7,7 +7,7 @@ import { IrsPractitioner } from '../IrsPractitioner'; import { JoiValidationConstants } from '../JoiValidationConstants'; import { JoiValidationEntity } from '../JoiValidationEntity'; import { PrivatePractitioner } from '../PrivatePractitioner'; -import { setPretrialMemorandumFiler } from '../../utilities/getFormattedTrialSessionDetails'; +import { setPretrialMemorandumFiler } from '../../utilities/trialSession/getFormattedTrialSessionDetails'; import joi from 'joi'; export class CalendaredCase extends JoiValidationEntity { diff --git a/shared/src/business/test/createTestApplicationContext.ts b/shared/src/business/test/createTestApplicationContext.ts index f241dc7842a..66c14dda380 100644 --- a/shared/src/business/test/createTestApplicationContext.ts +++ b/shared/src/business/test/createTestApplicationContext.ts @@ -40,7 +40,7 @@ import { compareCasesByDocketNumber, formatCaseForTrialSession, getFormattedTrialSessionDetails, -} from '@shared/business/utilities/getFormattedTrialSessionDetails'; +} from '@shared/business/utilities/trialSession/getFormattedTrialSessionDetails'; import { compareISODateStrings, compareStrings, diff --git a/shared/src/business/utilities/getFormattedTrialSessionDetails.compareCasesByDocketNumber.test.ts b/shared/src/business/utilities/trialSession/getFormattedTrialSessionDetails.compareCasesByDocketNumber.test.ts similarity index 98% rename from shared/src/business/utilities/getFormattedTrialSessionDetails.compareCasesByDocketNumber.test.ts rename to shared/src/business/utilities/trialSession/getFormattedTrialSessionDetails.compareCasesByDocketNumber.test.ts index 0610dc7c634..b77a41f7a3c 100644 --- a/shared/src/business/utilities/getFormattedTrialSessionDetails.compareCasesByDocketNumber.test.ts +++ b/shared/src/business/utilities/trialSession/getFormattedTrialSessionDetails.compareCasesByDocketNumber.test.ts @@ -1,4 +1,4 @@ -import { applicationContext } from '../test/createTestApplicationContext'; +import { applicationContext } from '../../test/createTestApplicationContext'; import { compareCasesByDocketNumber, compareCasesByDocketNumberFactory, diff --git a/shared/src/business/utilities/getFormattedTrialSessionDetails.setPretrialMemorandumFilter.test.ts b/shared/src/business/utilities/trialSession/getFormattedTrialSessionDetails.setPretrialMemorandumFilter.test.ts similarity index 96% rename from shared/src/business/utilities/getFormattedTrialSessionDetails.setPretrialMemorandumFilter.test.ts rename to shared/src/business/utilities/trialSession/getFormattedTrialSessionDetails.setPretrialMemorandumFilter.test.ts index 46f7514f401..55a1de4a6fc 100644 --- a/shared/src/business/utilities/getFormattedTrialSessionDetails.setPretrialMemorandumFilter.test.ts +++ b/shared/src/business/utilities/trialSession/getFormattedTrialSessionDetails.setPretrialMemorandumFilter.test.ts @@ -1,6 +1,6 @@ -import { MOCK_CASE } from '../../test/mockCase'; -import { PARTIES_CODES } from '../entities/EntityConstants'; -import { applicationContext } from '../test/createTestApplicationContext'; +import { MOCK_CASE } from '../../../test/mockCase'; +import { PARTIES_CODES } from '../../entities/EntityConstants'; +import { applicationContext } from '../../test/createTestApplicationContext'; import { setPretrialMemorandumFiler } from './getFormattedTrialSessionDetails'; describe('getFormattedTrialSessionDetails', () => { diff --git a/shared/src/business/utilities/getFormattedTrialSessionDetails.test.ts b/shared/src/business/utilities/trialSession/getFormattedTrialSessionDetails.test.ts similarity index 98% rename from shared/src/business/utilities/getFormattedTrialSessionDetails.test.ts rename to shared/src/business/utilities/trialSession/getFormattedTrialSessionDetails.test.ts index 63481ff20e0..8f96b3b3847 100644 --- a/shared/src/business/utilities/getFormattedTrialSessionDetails.test.ts +++ b/shared/src/business/utilities/trialSession/getFormattedTrialSessionDetails.test.ts @@ -1,8 +1,8 @@ -import { DOCKET_NUMBER_SUFFIXES } from '../entities/EntityConstants'; -import { MOCK_CASE } from '../../../../shared/src/test/mockCase'; +import { DOCKET_NUMBER_SUFFIXES } from '../../entities/EntityConstants'; +import { MOCK_CASE } from '../../../test/mockCase'; import { MOCK_TRIAL_REGULAR } from '@shared/test/mockTrial'; import { TrialSessionState } from '@web-client/presenter/state/trialSessionState'; -import { applicationContext } from '../test/createTestApplicationContext'; +import { applicationContext } from '../../test/createTestApplicationContext'; import { formatCaseForTrialSession, getFormattedTrialSessionDetails, diff --git a/shared/src/business/utilities/getFormattedTrialSessionDetails.ts b/shared/src/business/utilities/trialSession/getFormattedTrialSessionDetails.ts similarity index 98% rename from shared/src/business/utilities/getFormattedTrialSessionDetails.ts rename to shared/src/business/utilities/trialSession/getFormattedTrialSessionDetails.ts index 4b63484ba01..def0d7376d8 100644 --- a/shared/src/business/utilities/getFormattedTrialSessionDetails.ts +++ b/shared/src/business/utilities/trialSession/getFormattedTrialSessionDetails.ts @@ -5,9 +5,9 @@ import { import { DOCKET_NUMBER_SUFFIXES, PARTIES_CODES, -} from '../entities/EntityConstants'; -import { FORMATS } from './DateHandler'; -import { RawEligibleCase } from '../entities/cases/EligibleCase'; +} from '../../entities/EntityConstants'; +import { FORMATS } from '../DateHandler'; +import { RawEligibleCase } from '../../entities/cases/EligibleCase'; import { RawIrsCalendarAdministratorInfo } from '@shared/business/entities/trialSessions/IrsCalendarAdministratorInfo'; import { compact, partition } from 'lodash'; diff --git a/shared/src/business/utilities/trialSession/trialCitiesGroupedByState.ts b/shared/src/business/utilities/trialSession/trialCitiesGroupedByState.ts new file mode 100644 index 00000000000..6ad2ab0aa00 --- /dev/null +++ b/shared/src/business/utilities/trialSession/trialCitiesGroupedByState.ts @@ -0,0 +1,38 @@ +import { TRIAL_CITIES } from '@shared/business/entities/EntityConstants'; +import { sortBy } from 'lodash'; + +export const getTrialCitiesGroupedByState = (): { + label: string; + options: { + label: string; + value: string; + }[]; +}[] => { + const trialCities = sortBy(TRIAL_CITIES.ALL, ['state', 'city']); + const states = trialCities.reduce( + (listOfStates, cityStatePair) => { + const existingState = listOfStates.find( + trialState => trialState.label === cityStatePair.state, + ); + const cityOption = { + label: `${cityStatePair.city}, ${cityStatePair.state}`, + value: `${cityStatePair.city}, ${cityStatePair.state}`, + }; + if (existingState) { + existingState.options.push(cityOption); + } else { + listOfStates.push({ + label: cityStatePair.state, + options: [cityOption], + }); + } + return listOfStates; + }, + [] as { + label: string; + options: { label: string; value: string }[]; + }[], + ); + + return states; +}; diff --git a/web-api/src/business/useCases/trialSessions/generateTrialCalendarPdfInteractor.ts b/web-api/src/business/useCases/trialSessions/generateTrialCalendarPdfInteractor.ts index 11f87c57ebd..2a692339365 100644 --- a/web-api/src/business/useCases/trialSessions/generateTrialCalendarPdfInteractor.ts +++ b/web-api/src/business/useCases/trialSessions/generateTrialCalendarPdfInteractor.ts @@ -1,7 +1,7 @@ import { NotFoundError } from '@web-api/errors/errors'; import { ServerApplicationContext } from '@web-api/applicationContext'; import { compact } from 'lodash'; -import { compareCasesByDocketNumberFactory } from '../../../../../shared/src/business/utilities/getFormattedTrialSessionDetails'; +import { compareCasesByDocketNumberFactory } from '../../../../../shared/src/business/utilities/trialSession/getFormattedTrialSessionDetails'; import { formatDateString } from '@shared/business/utilities/DateHandler'; import { saveFileAndGenerateUrl } from '../../useCaseHelper/saveFileAndGenerateUrl'; diff --git a/web-api/src/getUtilities.ts b/web-api/src/getUtilities.ts index 69f45fee431..2e61d38bfc8 100644 --- a/web-api/src/getUtilities.ts +++ b/web-api/src/getUtilities.ts @@ -16,7 +16,7 @@ import { combineTwoPdfs } from '../../shared/src/business/utilities/documentGene import { compareCasesByDocketNumber, getFormattedTrialSessionDetails, -} from '../../shared/src/business/utilities/getFormattedTrialSessionDetails'; +} from '../../shared/src/business/utilities/trialSession/getFormattedTrialSessionDetails'; import { compareISODateStrings, compareStrings, diff --git a/web-client/src/applicationContext.ts b/web-client/src/applicationContext.ts index 59f66f550a3..7d8f2db04d2 100644 --- a/web-client/src/applicationContext.ts +++ b/web-client/src/applicationContext.ts @@ -77,7 +77,7 @@ import { compareCasesByDocketNumber, formatCaseForTrialSession, getFormattedTrialSessionDetails, -} from '../../shared/src/business/utilities/getFormattedTrialSessionDetails'; +} from '../../shared/src/business/utilities/trialSession/getFormattedTrialSessionDetails'; import { compareISODateStrings, compareStrings, diff --git a/web-client/src/applicationContextPublic.ts b/web-client/src/applicationContextPublic.ts index 6eaa6b508d1..aef367de660 100644 --- a/web-client/src/applicationContextPublic.ts +++ b/web-client/src/applicationContextPublic.ts @@ -42,7 +42,7 @@ import { } from '../../shared/src/sharedAppContext'; import { User } from '../../shared/src/business/entities/User'; import { casePublicSearchInteractor } from '../../shared/src/proxies/casePublicSearchProxy'; -import { compareCasesByDocketNumber } from '../../shared/src/business/utilities/getFormattedTrialSessionDetails'; +import { compareCasesByDocketNumber } from '../../shared/src/business/utilities/trialSession/getFormattedTrialSessionDetails'; import { confirmSignUpInteractor } from '@shared/proxies/auth/confirmSignUpProxy'; import { createISODateString, diff --git a/web-client/src/presenter/actions/setCaseAction.ts b/web-client/src/presenter/actions/setCaseAction.ts index 09099cc2b03..1d2a31ebe5f 100644 --- a/web-client/src/presenter/actions/setCaseAction.ts +++ b/web-client/src/presenter/actions/setCaseAction.ts @@ -1,4 +1,4 @@ -import { compareCasesByDocketNumber } from '@shared/business/utilities/getFormattedTrialSessionDetails'; +import { compareCasesByDocketNumber } from '@shared/business/utilities/trialSession/getFormattedTrialSessionDetails'; import { state } from '@web-client/presenter/app.cerebral'; export const setCaseAction = ({ diff --git a/web-client/src/presenter/computeds/customCaseReportHelper.ts b/web-client/src/presenter/computeds/customCaseReportHelper.ts index bcc2710ef4e..cfc1d6182d5 100644 --- a/web-client/src/presenter/computeds/customCaseReportHelper.ts +++ b/web-client/src/presenter/computeds/customCaseReportHelper.ts @@ -3,7 +3,6 @@ import { CASE_TYPES, CHIEF_JUDGE, CUSTOM_CASE_REPORT_PAGE_SIZE, - TRIAL_CITIES, } from '@shared/business/entities/EntityConstants'; import { Case } from '@shared/business/entities/cases/Case'; import { @@ -14,14 +13,13 @@ import { ClientApplicationContext } from '@web-client/applicationContext'; import { FORMATS } from '@shared/business/utilities/DateHandler'; import { Get } from 'cerebral'; import { InputOption } from '@web-client/ustc-ui/Utils/types'; -import { sortBy } from 'lodash'; +import { getTrialCitiesGroupedByState } from '@shared/business/utilities/trialSession/trialCitiesGroupedByState'; import { state } from '@web-client/presenter/app.cerebral'; export const customCaseReportHelper = ( get: Get, applicationContext: ClientApplicationContext, ): { - activeTrialCities: InputOption[]; caseStatuses: InputOption[]; caseTypes: InputOption[]; cases: (CaseInventory & { @@ -33,9 +31,14 @@ export const customCaseReportHelper = ( clearFiltersIsDisabled: boolean; judges: InputOption[]; pageCount: number; - searchableTrialCities: InputOption[]; today: string; - trialCitiesByState: InputOption[]; + trialCitiesByState: { + label: string; + options: { + label: string; + value: string; + }[]; + }[]; } => { const caseStatuses = Object.values(CASE_STATUS_TYPES).map(status => ({ label: status, @@ -91,43 +94,16 @@ export const customCaseReportHelper = ( const today = applicationContext.getUtilities().formatNow(FORMATS.YYYYMMDD); - const trialCities = sortBy(TRIAL_CITIES.ALL, ['state', 'city']); - - const searchableTrialCities: InputOption[] = []; - - const states: InputOption[] = trialCities.reduce( - (listOfStates: InputOption[], cityStatePair) => { - const existingState = listOfStates.find( - trialState => trialState.label === cityStatePair.state, - ); - const cityOption: InputOption = { - label: `${cityStatePair.city}, ${cityStatePair.state}`, - value: `${cityStatePair.city}, ${cityStatePair.state}`, - }; - if (existingState) { - existingState.options?.push(cityOption); - } else { - listOfStates.push({ - label: cityStatePair.state, - options: [cityOption], - }); - } - searchableTrialCities.push(cityOption); - return listOfStates; - }, - [], - ); + const trialCitiesByState = getTrialCitiesGroupedByState(); return { - activeTrialCities: states, caseStatuses, caseTypes, cases: reportData, clearFiltersIsDisabled, judges, pageCount, - searchableTrialCities, today, - trialCitiesByState: states, + trialCitiesByState, }; }; diff --git a/web-client/src/presenter/computeds/formattedTrialSessionDetails.ts b/web-client/src/presenter/computeds/formattedTrialSessionDetails.ts index ff5d83d8434..f257df9f7ef 100644 --- a/web-client/src/presenter/computeds/formattedTrialSessionDetails.ts +++ b/web-client/src/presenter/computeds/formattedTrialSessionDetails.ts @@ -1,5 +1,5 @@ import { ClientApplicationContext } from '@web-client/applicationContext'; -import { FormattedTrialSessionDetailsType } from '@shared/business/utilities/getFormattedTrialSessionDetails'; +import { FormattedTrialSessionDetailsType } from '@shared/business/utilities/trialSession/getFormattedTrialSessionDetails'; import { Get } from 'cerebral'; import { TrialSession } from '@shared/business/entities/trialSessions/TrialSession'; import { isEmpty, isEqual } from 'lodash'; diff --git a/web-client/src/presenter/computeds/trialSessionWorkingCopyHelper.ts b/web-client/src/presenter/computeds/trialSessionWorkingCopyHelper.ts index b0d86664eed..24a18508d4b 100644 --- a/web-client/src/presenter/computeds/trialSessionWorkingCopyHelper.ts +++ b/web-client/src/presenter/computeds/trialSessionWorkingCopyHelper.ts @@ -2,7 +2,7 @@ import { ClientApplicationContext } from '@web-client/applicationContext'; import { FormattedTrialSessionCase, compareCasesByDocketNumber, -} from '@shared/business/utilities/getFormattedTrialSessionDetails'; +} from '@shared/business/utilities/trialSession/getFormattedTrialSessionDetails'; import { Get } from 'cerebral'; import { TRIAL_STATUS_TYPES } from '@shared/business/entities/EntityConstants'; import { TrialSessionState } from '@web-client/presenter/state/trialSessionState'; diff --git a/web-client/src/presenter/computeds/trialSessionsHelper.ts b/web-client/src/presenter/computeds/trialSessionsHelper.ts index bd941e5b02f..e03bbcbc966 100644 --- a/web-client/src/presenter/computeds/trialSessionsHelper.ts +++ b/web-client/src/presenter/computeds/trialSessionsHelper.ts @@ -10,7 +10,6 @@ import { RawUser } from '@shared/business/entities/User'; import { SESSION_STATUS_TYPES, SESSION_TYPES, - TRIAL_CITIES, TrialSessionTypes, } from '@shared/business/entities/EntityConstants'; import { TrialSession } from '@shared/business/entities/trialSessions/TrialSession'; @@ -20,7 +19,7 @@ import { initialTrialSessionPageState, } from '@web-client/presenter/state/trialSessionsPageState'; import { TrialSessionsPageValidation } from '@shared/business/entities/trialSessions/TrialSessionsPageValidation'; -import { sortBy } from 'lodash'; +import { getTrialCitiesGroupedByState } from '@shared/business/utilities/trialSession/trialCitiesGroupedByState'; import { state } from '@web-client/presenter/app.cerebral'; export const trialSessionsHelper = ( @@ -86,31 +85,7 @@ export const trialSessionsHelper = ( value: { name: trialSessionJudge.name, userId: trialSessionJudge.userId }, }), ); - const trialCities = sortBy(TRIAL_CITIES.ALL, ['state', 'city']); - const states = trialCities.reduce( - (listOfStates, cityStatePair) => { - const existingState = listOfStates.find( - trialState => trialState.label === cityStatePair.state, - ); - const cityOption = { - label: `${cityStatePair.city}, ${cityStatePair.state}`, - value: `${cityStatePair.city}, ${cityStatePair.state}`, - }; - if (existingState) { - existingState.options.push(cityOption); - } else { - listOfStates.push({ - label: cityStatePair.state, - options: [cityOption], - }); - } - return listOfStates; - }, - [] as { - label: string; - options: { label: string; value: string }[]; - }[], - ); + const states = getTrialCitiesGroupedByState(); const { endDateErrorMessage, startDateErrorMessage } = validateTrialSessionDateRange({ diff --git a/web-client/src/test/createClientTestApplicationContext.ts b/web-client/src/test/createClientTestApplicationContext.ts index ccb6d15fb57..890ef12385b 100644 --- a/web-client/src/test/createClientTestApplicationContext.ts +++ b/web-client/src/test/createClientTestApplicationContext.ts @@ -37,7 +37,7 @@ import { compareCasesByDocketNumber, formatCaseForTrialSession, getFormattedTrialSessionDetails, -} from '@shared/business/utilities/getFormattedTrialSessionDetails'; +} from '@shared/business/utilities/trialSession/getFormattedTrialSessionDetails'; import { compareISODateStrings, compareStrings, From 5dc7acea7c51930c9e269ce1a6a54af7203f5b93 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 23 Sep 2024 14:44:30 -0700 Subject: [PATCH 72/96] 10409: Update custom case report to new selector --- .../computeds/customCaseReportHelper.ts | 8 +++--- web-client/src/ustc-ui/Utils/types.ts | 6 ----- .../CustomCaseReport/CustomCaseReport.tsx | 25 ++++++++++--------- 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/web-client/src/presenter/computeds/customCaseReportHelper.ts b/web-client/src/presenter/computeds/customCaseReportHelper.ts index cfc1d6182d5..16f0429ce59 100644 --- a/web-client/src/presenter/computeds/customCaseReportHelper.ts +++ b/web-client/src/presenter/computeds/customCaseReportHelper.ts @@ -3,6 +3,7 @@ import { CASE_TYPES, CHIEF_JUDGE, CUSTOM_CASE_REPORT_PAGE_SIZE, + CaseType, } from '@shared/business/entities/EntityConstants'; import { Case } from '@shared/business/entities/cases/Case'; import { @@ -12,7 +13,6 @@ import { import { ClientApplicationContext } from '@web-client/applicationContext'; import { FORMATS } from '@shared/business/utilities/DateHandler'; import { Get } from 'cerebral'; -import { InputOption } from '@web-client/ustc-ui/Utils/types'; import { getTrialCitiesGroupedByState } from '@shared/business/utilities/trialSession/trialCitiesGroupedByState'; import { state } from '@web-client/presenter/app.cerebral'; @@ -20,8 +20,8 @@ export const customCaseReportHelper = ( get: Get, applicationContext: ClientApplicationContext, ): { - caseStatuses: InputOption[]; - caseTypes: InputOption[]; + caseStatuses: { label: string; value: string }[]; + caseTypes: { label: string; value: CaseType }[]; cases: (CaseInventory & { inConsolidatedGroup: boolean; consolidatedIconTooltipText: string; @@ -29,7 +29,7 @@ export const customCaseReportHelper = ( isLeadCase: boolean; })[]; clearFiltersIsDisabled: boolean; - judges: InputOption[]; + judges: { label: string; value: string }[]; pageCount: number; today: string; trialCitiesByState: { diff --git a/web-client/src/ustc-ui/Utils/types.ts b/web-client/src/ustc-ui/Utils/types.ts index d9c0cd43583..dff89c786f1 100644 --- a/web-client/src/ustc-ui/Utils/types.ts +++ b/web-client/src/ustc-ui/Utils/types.ts @@ -4,12 +4,6 @@ import { GetCasesByStatusAndByJudgeResponse } from '@web-api/business/useCases/j import { JudgeActivityReportFilters } from '@web-api/business/useCases/judgeActivityReport/getCountOfCaseDocumentsFiledByJudgesInteractor'; import { TrialSessionReturnType } from '@web-api/business/useCases/judgeActivityReport/getTrialSessionsForJudgeActivityReportInteractor'; -export type InputOption = { - label: string; - value?: T; - options?: InputOption[]; -}; - type JudgeActivityReportData = { trialSessions: TrialSessionReturnType; casesClosedByJudge: CasesClosedReturnType; diff --git a/web-client/src/views/CustomCaseReport/CustomCaseReport.tsx b/web-client/src/views/CustomCaseReport/CustomCaseReport.tsx index 1f5606c7e23..2c84aac9459 100644 --- a/web-client/src/views/CustomCaseReport/CustomCaseReport.tsx +++ b/web-client/src/views/CustomCaseReport/CustomCaseReport.tsx @@ -2,13 +2,14 @@ import { BigHeader } from '../BigHeader'; import { Button } from '../../ustc-ui/Button/Button'; import { CaseInventory } from '@web-api/business/useCases/caseInventoryReport/getCustomCaseReportInteractor'; import { CaseLink } from '../../ustc-ui/CaseLink/CaseLink'; +import { CaseType } from '@shared/business/entities/EntityConstants'; import { ConsolidatedCaseIcon } from '../../ustc-ui/Icon/ConsolidatedCaseIcon'; import { DateRangePickerComponent } from '../../ustc-ui/DateInput/DateRangePickerComponent'; import { ErrorNotification } from '../ErrorNotification'; import { Icon } from '../../ustc-ui/Icon/Icon'; import { Paginator } from '../../ustc-ui/Pagination/Paginator'; import { PillButton } from '@web-client/ustc-ui/Button/PillButton'; -import { SelectSearch } from '../../ustc-ui/Select/SelectSearch'; +import { SelectSearch2 } from '@web-client/ustc-ui/Select/SelectSearch2'; import { SuccessNotification } from '../SuccessNotification'; import { connect } from '@web-client/presenter/shared.cerebral'; import { focusPaginatorTop } from '@web-client/presenter/utilities/focusPaginatorTop'; @@ -247,13 +248,13 @@ export const CustomCaseReport = connect( Case status{' '} (optional) - { if (inputValue) { setCustomCaseReportFiltersSequence({ @@ -275,13 +276,16 @@ export const CustomCaseReport = connect( Case types{' '} (optional) - { if (inputValue) { setCustomCaseReportFiltersSequence({ @@ -304,13 +308,13 @@ export const CustomCaseReport = connect( Assigned judge{' '} (optional) - { if (inputValue) { setCustomCaseReportFiltersSequence({ @@ -332,16 +336,13 @@ export const CustomCaseReport = connect( Requested place of trial{' '} (optional) - { if (inputValue) { setCustomCaseReportFiltersSequence({ From 55f55a0e4959dd7d131888e720eb30fe5359a8e0 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 23 Sep 2024 15:52:30 -0700 Subject: [PATCH 73/96] 10409: WIP update primaryDocumentForm to new searchSelect --- .../computeds/internalTypesHelper.ts | 11 +++- .../views/PaperFiling/PrimaryDocumentForm.tsx | 66 +++++-------------- 2 files changed, 27 insertions(+), 50 deletions(-) diff --git a/web-client/src/presenter/computeds/internalTypesHelper.ts b/web-client/src/presenter/computeds/internalTypesHelper.ts index 78f0f735f57..9eb91b3fb9e 100644 --- a/web-client/src/presenter/computeds/internalTypesHelper.ts +++ b/web-client/src/presenter/computeds/internalTypesHelper.ts @@ -52,7 +52,16 @@ export const getSortFunction = searchText => { export const internalTypesHelper = ( get: Get, applicationContext: ClientApplicationContext, -): any => { +): { + internalDocumentTypesForSelectSorted: (DocumentTypeBase & { + label: string; + value: string; + })[]; + internalDocumentTypesForSelectWithLegacySorted: (DocumentTypeBase & { + label: string; + value: string; + })[]; +} => { const { INTERNAL_CATEGORY_MAP, LEGACY_DOCUMENT_TYPES, LODGED_EVENT_CODE } = applicationContext.getConstants(); const searchText = get(state.screenMetadata.searchText) || ''; diff --git a/web-client/src/views/PaperFiling/PrimaryDocumentForm.tsx b/web-client/src/views/PaperFiling/PrimaryDocumentForm.tsx index fab805ed4e1..6026e1a31b9 100644 --- a/web-client/src/views/PaperFiling/PrimaryDocumentForm.tsx +++ b/web-client/src/views/PaperFiling/PrimaryDocumentForm.tsx @@ -4,13 +4,8 @@ import { FormGroup } from '../../ustc-ui/FormGroup/FormGroup'; import { Inclusions } from './Inclusions'; import { NonstandardForm } from '../FileDocument/NonstandardForm'; import { SecondaryDocumentForm } from './SecondaryDocumentForm'; -import { SelectSearch } from '../../ustc-ui/Select/SelectSearch'; +import { SelectSearch2 } from '@web-client/ustc-ui/Select/SelectSearch2'; import { connect } from '@web-client/presenter/shared.cerebral'; -import { - docketEntryOnChange, - onInputChange, - reactSelectValue, -} from '../../ustc-ui/Utils/documentTypeSelectHelper'; import { sequences } from '@web-client/presenter/app.cerebral'; import { state } from '@web-client/presenter/app.cerebral'; import React from 'react'; @@ -25,7 +20,6 @@ export const PrimaryDocumentForm = connect( internalTypesHelper: state.internalTypesHelper, updateDocketEntryFormValueSequence: sequences.updateDocketEntryFormValueSequence, - updateScreenMetadataSequence: sequences.updateScreenMetadataSequence, validateDocketEntrySequence: sequences.validateDocketEntrySequence, validationErrors: state.validationErrors, }, @@ -36,7 +30,6 @@ export const PrimaryDocumentForm = connect( formatAndUpdateDateFromDatePickerSequence, internalTypesHelper, updateDocketEntryFormValueSequence, - updateScreenMetadataSequence, validateDocketEntrySequence, validationErrors, }) { @@ -123,34 +116,23 @@ export const PrimaryDocumentForm = connect( or use the dropdown to select your document type. - { - docketEntryOnChange({ - action, - inputName, - inputValue, - updateSequence: updateDocketEntryFormValueSequence, - validateSequence: validateDocketEntrySequence, + onChange={inputValue => { + const value = inputValue?.value || ''; + updateDocketEntryFormValueSequence({ + key: 'eventCode', + value, }); + validateDocketEntrySequence(); return true; }} - onInputChange={(inputText, { action }) => { - onInputChange({ - action, - inputText, - updateSequence: updateScreenMetadataSequence, - }); - }} /> {addDocketEntryHelper.primary.showSecondaryDocumentForm && ( @@ -170,7 +152,7 @@ export const PrimaryDocumentForm = connect( docket entry for it. - { - docketEntryOnChange({ - action, - inputName, - inputValue, - updateSequence: updateDocketEntryFormValueSequence, - validateSequence: validateDocketEntrySequence, + onChange={inputValue => { + const value = inputValue?.value || ''; + updateDocketEntryFormValueSequence({ + key: 'secondaryDocument.eventCode', + value, }); + validateDocketEntrySequence(); return true; }} - onInputChange={(inputText, { action }) => { - onInputChange({ - action, - inputText, - updateSequence: updateScreenMetadataSequence, - }); - }} /> )} From c38fe6571156b463b774a53ab47dfedbf30482a6 Mon Sep 17 00:00:00 2001 From: Javis Sullivan Date: Mon, 23 Sep 2024 19:01:20 -0400 Subject: [PATCH 74/96] 10409: more test fixes --- .../computeds/trialSessionsHelper.test.ts | 16 +++++++++------- .../presenter/computeds/trialSessionsHelper.ts | 5 ++++- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/web-client/src/presenter/computeds/trialSessionsHelper.test.ts b/web-client/src/presenter/computeds/trialSessionsHelper.test.ts index 55409b14a20..a5a0e53f42f 100644 --- a/web-client/src/presenter/computeds/trialSessionsHelper.test.ts +++ b/web-client/src/presenter/computeds/trialSessionsHelper.test.ts @@ -262,14 +262,19 @@ describe('trialSessionsHelper', () => { describe('trialSessionRows', () => { describe('filters', () => { it('should filter trial sessions by judge', () => { - trialSession1.judge!.userId = '1'; - trialSession2.judge!.userId = '2'; + trialSession1.judge!.userId = '43b00e5f-b78c-476c-820e-5d6ed1d58828'; + trialSession2.judge!.userId = 'd17b07dc-6455-447e-bea3-f91d12ac5a6'; trialSessionsPageState.trialSessions = [trialSession1, trialSession2]; - trialSessionsPageState.filters.judgeId = '1'; + trialSessionsPageState.filters.judges = { + 'd17b07dc-6455-447e-bea3-f91d12ac5a6': { + name: 'Colvin', + userId: 'd17b07dc-6455-447e-bea3-f91d12ac5a6', + }, + }; const result = runCompute(trialSessionsHelper, { state: { - judges: [judgeUser], + judges: [judgeUser, judgeColvin], permissions: getUserPermissions(docketClerk1User), trialSessionsPage: trialSessionsPageState, }, @@ -302,9 +307,6 @@ describe('trialSessionsHelper', () => { ); }); - // #ix this - // TODO: This test is affectd by pagination now. Ergo, one trial sessionis filtered out - // when it should not be base on this test it('should not filter trial sessions by judge when judge filter is All', () => { trialSessionsPageState.trialSessions = [trialSession1, trialSession2]; trialSessionsPageState.filters.judgeId = 'All'; diff --git a/web-client/src/presenter/computeds/trialSessionsHelper.ts b/web-client/src/presenter/computeds/trialSessionsHelper.ts index e03bbcbc966..48c0dd28379 100644 --- a/web-client/src/presenter/computeds/trialSessionsHelper.ts +++ b/web-client/src/presenter/computeds/trialSessionsHelper.ts @@ -51,7 +51,7 @@ export const trialSessionsHelper = ( const judge = get(state.judgeUser); const judges = get(state.judges); - const pageSize = 1; + const pageSize = 5; // set this to sane value for testing purposes const showCurrentJudgesOnly = filters.currentTab === 'new' || @@ -79,6 +79,7 @@ export const trialSessionsHelper = ( label: sessionType, value: sessionType, })); + const trialSessionJudgeOptions = trialSessionJudges.map( trialSessionJudge => ({ label: trialSessionJudge.name, @@ -97,10 +98,12 @@ export const trialSessionsHelper = ( filters, trialSessions, }); + const trialSessionPage = filteredTrialSessions.slice( filters.pageNumber * pageSize, filters.pageNumber * pageSize + pageSize, ); + const trialSessionRows = formatTrialSessions({ judgeAssociatedToUser: judge, trialSessions: trialSessionPage, From bb2e7c2d54c80a674c510a878f561a62c2546eb5 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 23 Sep 2024 16:06:14 -0700 Subject: [PATCH 75/96] 10409: WIP update SessionAssignmentForm to new searchSelect --- .../Utils/documentTypeSelectHelper.test.ts | 60 ------------------- .../ustc-ui/Utils/documentTypeSelectHelper.ts | 23 ------- .../TrialSessions/SessionAssignmentsForm.tsx | 40 ++++++------- 3 files changed, 18 insertions(+), 105 deletions(-) diff --git a/web-client/src/ustc-ui/Utils/documentTypeSelectHelper.test.ts b/web-client/src/ustc-ui/Utils/documentTypeSelectHelper.test.ts index 003fc15e6de..47d7189c5fe 100644 --- a/web-client/src/ustc-ui/Utils/documentTypeSelectHelper.test.ts +++ b/web-client/src/ustc-ui/Utils/documentTypeSelectHelper.test.ts @@ -3,7 +3,6 @@ import { docketEntryOnChange, fileDocumentPrimaryOnChange, fileDocumentSecondaryOnChange, - irsCalendarAdminInfoOnChange, onInputChange, reactSelectValue, } from './documentTypeSelectHelper'; @@ -333,63 +332,4 @@ describe('documentTypeSelectHelper', () => { expect(result).toEqual([documentTypes[0]]); }); }); - - describe('irsCalendarAdminInfoOnChange', () => { - it('should call updateTrialSessionFormDataSequence for all properies for contactInfo when action is "select-option"', () => { - const action = 'select-option'; - const inputValue = { - email: 'TEST_EMAIL', - name: 'TEST_NAME', - phone: 'TEST_PHONE', - }; - const updateTrialSessionFormDataSequence = jest.fn(); - - irsCalendarAdminInfoOnChange({ - action, - inputValue, - updateTrialSessionFormDataSequence, - }); - - const { calls } = updateTrialSessionFormDataSequence.mock; - expect(calls.length).toEqual(3); - const [nameCall, emailCall, phoneCall] = calls; - expect(nameCall[0]).toEqual({ - key: 'irsCalendarAdministratorInfo.name', - value: 'TEST_NAME', - }); - - expect(emailCall[0]).toEqual({ - key: 'irsCalendarAdministratorInfo.email', - value: 'TEST_EMAIL', - }); - - expect(phoneCall[0]).toEqual({ - key: 'irsCalendarAdministratorInfo.phone', - value: 'TEST_PHONE', - }); - }); - - it('should call updateTrialSessionFormDataSequence to clear contactInfo when action is "clear"', () => { - const action = 'clear'; - const inputValue = { - email: 'TEST_EMAIL', - name: 'TEST_NAME', - phone: 'TEST_PHONE', - }; - const updateTrialSessionFormDataSequence = jest.fn(); - - irsCalendarAdminInfoOnChange({ - action, - inputValue, - updateTrialSessionFormDataSequence, - }); - - const { calls } = updateTrialSessionFormDataSequence.mock; - expect(calls.length).toEqual(1); - expect(calls[0][0]).toEqual({ - key: 'irsCalendarAdministratorInfo', - value: {}, - }); - }); - }); }); diff --git a/web-client/src/ustc-ui/Utils/documentTypeSelectHelper.ts b/web-client/src/ustc-ui/Utils/documentTypeSelectHelper.ts index ab603352d93..1946b7ab981 100644 --- a/web-client/src/ustc-ui/Utils/documentTypeSelectHelper.ts +++ b/web-client/src/ustc-ui/Utils/documentTypeSelectHelper.ts @@ -114,29 +114,6 @@ export const courtIssuedDocketEntryOnChange = ({ } }; -export const irsCalendarAdminInfoOnChange = ({ - action, - inputValue, - updateTrialSessionFormDataSequence, -}) => { - switch (action) { - case 'select-option': - ['name', 'email', 'phone'].forEach(key => - updateTrialSessionFormDataSequence({ - key: `irsCalendarAdministratorInfo.${key}`, - value: inputValue[key], - }), - ); - break; - case 'clear': - updateTrialSessionFormDataSequence({ - key: 'irsCalendarAdministratorInfo', - value: {}, - }); - break; - } -}; - export const onInputChange = ({ action, inputText, updateSequence }) => { if (action === 'input-change') { updateSequence({ diff --git a/web-client/src/views/TrialSessions/SessionAssignmentsForm.tsx b/web-client/src/views/TrialSessions/SessionAssignmentsForm.tsx index f8e40244b97..98c3636355b 100644 --- a/web-client/src/views/TrialSessions/SessionAssignmentsForm.tsx +++ b/web-client/src/views/TrialSessions/SessionAssignmentsForm.tsx @@ -1,10 +1,6 @@ import { FormGroup } from '@web-client/ustc-ui/FormGroup/FormGroup'; -import { SelectSearch } from '@web-client/ustc-ui/Select/SelectSearch'; +import { SelectSearch2 } from '@web-client/ustc-ui/Select/SelectSearch2'; import { connect } from '@web-client/presenter/shared.cerebral'; -import { - irsCalendarAdminInfoOnChange, - onInputChange, -} from '@web-client/ustc-ui/Utils/documentTypeSelectHelper'; import { sequences } from '@web-client/presenter/app.cerebral'; import { state } from '@web-client/presenter/app.cerebral'; import React from 'react'; @@ -18,7 +14,6 @@ export const SessionAssignmentsForm = connect( state.getAllIrsPractitionersForSelectHelper, judges: state.judges, sessionAssignmentHelper: state.sessionAssignmentHelper, - updateScreenMetadataSequence: sequences.updateScreenMetadataSequence, updateTrialSessionFormDataSequence: sequences.updateTrialSessionFormDataSequence, }, @@ -28,7 +23,6 @@ export const SessionAssignmentsForm = connect( judges, sessionAssignmentHelper, TRIAL_SESSION_PROCEEDING_TYPES, - updateScreenMetadataSequence, updateTrialSessionFormDataSequence, }) { return ( @@ -180,28 +174,30 @@ export const SessionAssignmentsForm = connect( (optional) - { - irsCalendarAdminInfoOnChange({ - action, - inputValue, - updateTrialSessionFormDataSequence, - }); - return true; - }} - onInputChange={(inputText, { action }) => { - onInputChange({ - action, - inputText, - updateSequence: updateScreenMetadataSequence, - }); + onChange={inputValue => { + if (!inputValue) { + updateTrialSessionFormDataSequence({ + key: 'irsCalendarAdministratorInfo', + value: {}, + }); + return; + } + ['name', 'email', 'phone'].forEach(key => + updateTrialSessionFormDataSequence({ + key: `irsCalendarAdministratorInfo.${key}`, + value: inputValue[key], + }), + ); }} /> From cbb979a6adc89405bad0328afe0d47fdb66d8ca0 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 23 Sep 2024 21:17:17 -0700 Subject: [PATCH 76/96] 10409: WIP update CaseAssociationRequest to new searchSelect --- .../CaseAssociationRequest.tsx | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/web-client/src/views/CaseAssociationRequest/CaseAssociationRequest.tsx b/web-client/src/views/CaseAssociationRequest/CaseAssociationRequest.tsx index d2c1ef281f8..7589f692df6 100644 --- a/web-client/src/views/CaseAssociationRequest/CaseAssociationRequest.tsx +++ b/web-client/src/views/CaseAssociationRequest/CaseAssociationRequest.tsx @@ -3,9 +3,8 @@ import { CaseAssociationRequestDocumentForm } from './CaseAssociationRequestDocu import { Focus } from '../../ustc-ui/Focus/Focus'; import { FormGroup } from '../../ustc-ui/FormGroup/FormGroup'; import { PartiesRepresenting } from './PartiesRepresenting'; -import { SelectSearch } from '../../ustc-ui/Select/SelectSearch'; +import { SelectSearch2 } from '@web-client/ustc-ui/Select/SelectSearch2'; import { connect } from '@web-client/presenter/shared.cerebral'; -import { reactSelectValue } from '../../ustc-ui/Utils/documentTypeSelectHelper'; import { sequences } from '@web-client/presenter/app.cerebral'; import { state } from '@web-client/presenter/app.cerebral'; import React from 'react'; @@ -14,7 +13,6 @@ import classNames from 'classnames'; export const CaseAssociationRequest = connect( { caseAssociationRequestHelper: state.caseAssociationRequestHelper, - form: state.form, formCancelToggleCancelSequence: sequences.formCancelToggleCancelSequence, reviewCaseAssociationRequestSequence: sequences.reviewCaseAssociationRequestSequence, @@ -26,7 +24,6 @@ export const CaseAssociationRequest = connect( }, function CaseAssociationRequest({ caseAssociationRequestHelper, - form, formCancelToggleCancelSequence, reviewCaseAssociationRequestSequence, updateCaseAssociationFormValueSequence, @@ -67,36 +64,32 @@ export const CaseAssociationRequest = connect( or use the dropdown to select your document type. - { updateCaseAssociationFormValueSequence({ key: 'documentType', - value: e.label, + value: e?.label, }); updateCaseAssociationFormValueSequence({ key: 'documentTitleTemplate', - value: e.documentTitleTemplate, + value: e?.documentTitleTemplate, }); updateCaseAssociationFormValueSequence({ key: 'eventCode', - value: e.eventCode, + value: e?.eventCode, }); updateCaseAssociationFormValueSequence({ key: 'scenario', - value: e.scenario, + value: e?.scenario, }); validateCaseAssociationRequestSequence(); }} From 8ad32e34891f9997ac03a3bf73d1d55684faaa10 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 23 Sep 2024 21:35:40 -0700 Subject: [PATCH 77/96] 10409: WIP update CourtIssuedDocketEntry to new searchSelect --- .../CourtIssuedDocketEntry.tsx | 42 ++++++------------- 1 file changed, 13 insertions(+), 29 deletions(-) diff --git a/web-client/src/views/CourtIssuedDocketEntry/CourtIssuedDocketEntry.tsx b/web-client/src/views/CourtIssuedDocketEntry/CourtIssuedDocketEntry.tsx index 9a58f5e857a..6d4e2665e7a 100644 --- a/web-client/src/views/CourtIssuedDocketEntry/CourtIssuedDocketEntry.tsx +++ b/web-client/src/views/CourtIssuedDocketEntry/CourtIssuedDocketEntry.tsx @@ -14,11 +14,6 @@ import { SuccessNotification } from '../SuccessNotification'; import { WarningNotificationComponent } from '../WarningNotification'; import { WorkItemAlreadyCompletedModal } from '../DocketEntryQc/WorkItemAlreadyCompletedModal'; import { connect } from '@web-client/presenter/shared.cerebral'; -import { - courtIssuedDocketEntryOnChange, - onInputChange, - reactSelectValue, -} from '../../ustc-ui/Utils/documentTypeSelectHelper'; import { sequences } from '@web-client/presenter/app.cerebral'; import { state } from '@web-client/presenter/app.cerebral'; import React from 'react'; @@ -124,30 +119,19 @@ export const CourtIssuedDocketEntry = connect( id="document-type" name="eventCode" options={addCourtIssuedDocketEntryHelper.documentTypes} - value={reactSelectValue({ - documentTypes: - addCourtIssuedDocketEntryHelper.documentTypes, - selectedEventCode: form.eventCode, - })} - onChange={(inputValue, { action, name }) => { - courtIssuedDocketEntryOnChange({ - action, - inputValue, - name, - updateSequence: - updateCourtIssuedDocketEntryFormValueSequence, - validateSequence: - validateCourtIssuedDocketEntrySequence, - }); - return true; - }} - onInputChange={(inputText, { action }) => { - onInputChange({ - action, - inputText, - updateSequence: - updateCourtIssuedDocketEntryFormValueSequence, - }); + onChange={inputValue => { + [ + 'documentType', + 'documentTitle', + 'eventCode', + 'scenario', + ].forEach(key => + updateCourtIssuedDocketEntryFormValueSequence({ + key, + value: inputValue ? inputValue[key] : '', + }), + ); + validateCourtIssuedDocketEntrySequence(); }} /> From fffc0f0084a7a46ea15b8ed10d748b37c8a6e74c Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 23 Sep 2024 21:38:09 -0700 Subject: [PATCH 78/96] 10409: WIP update CourtIssuedDocketEntry to new searchSelect --- .../views/CourtIssuedDocketEntry/CourtIssuedDocketEntry.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/web-client/src/views/CourtIssuedDocketEntry/CourtIssuedDocketEntry.tsx b/web-client/src/views/CourtIssuedDocketEntry/CourtIssuedDocketEntry.tsx index 6d4e2665e7a..a2aa7253771 100644 --- a/web-client/src/views/CourtIssuedDocketEntry/CourtIssuedDocketEntry.tsx +++ b/web-client/src/views/CourtIssuedDocketEntry/CourtIssuedDocketEntry.tsx @@ -9,7 +9,7 @@ import { DocumentDisplayIframe } from '../DocumentDisplayIframe'; import { ErrorNotification } from '../ErrorNotification'; import { FormGroup } from '../../ustc-ui/FormGroup/FormGroup'; import { Hint } from '../../ustc-ui/Hint/Hint'; -import { SelectSearch } from '../../ustc-ui/Select/SelectSearch'; +import { SelectSearch2 } from '@web-client/ustc-ui/Select/SelectSearch2'; import { SuccessNotification } from '../SuccessNotification'; import { WarningNotificationComponent } from '../WarningNotification'; import { WorkItemAlreadyCompletedModal } from '../DocketEntryQc/WorkItemAlreadyCompletedModal'; @@ -113,10 +113,11 @@ export const CourtIssuedDocketEntry = connect( > Document type - { From 79e9e6f47a70512d066fcb7fb2138b8b6bc1155c Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 23 Sep 2024 21:41:18 -0700 Subject: [PATCH 79/96] 10409: WIP add isClearable to all select searches --- .../EditDocketEntry/EditDocketEntryMetaFormCourtIssued.tsx | 1 + .../EditDocketEntry/EditDocketEntryMetaFormDocument.tsx | 1 + web-client/src/views/EditDocketEntry/PrimaryDocumentForm.tsx | 2 ++ .../src/views/FileDocument/CompleteDocumentTypeSection.tsx | 1 + .../FileDocument/CompleteDocumentTypeSectionRemainder.tsx | 1 + web-client/src/views/StyleGuide/Forms.tsx | 5 +++-- 6 files changed, 9 insertions(+), 2 deletions(-) diff --git a/web-client/src/views/EditDocketEntry/EditDocketEntryMetaFormCourtIssued.tsx b/web-client/src/views/EditDocketEntry/EditDocketEntryMetaFormCourtIssued.tsx index 940bc0d4060..27094e1df5c 100644 --- a/web-client/src/views/EditDocketEntry/EditDocketEntryMetaFormCourtIssued.tsx +++ b/web-client/src/views/EditDocketEntry/EditDocketEntryMetaFormCourtIssued.tsx @@ -65,6 +65,7 @@ export const EditDocketEntryMetaFormCourtIssued = connect( ( @@ -143,8 +143,9 @@ export const Forms = () => ( - Date: Mon, 23 Sep 2024 21:52:28 -0700 Subject: [PATCH 80/96] 10409: WIP update EditDocketEntryMetaFormCourtIssued to new searchSelect --- .../Utils/documentTypeSelectHelper.test.ts | 78 ------------------- .../ustc-ui/Utils/documentTypeSelectHelper.ts | 26 ------- .../EditDocketEntryMetaFormCourtIssued.tsx | 42 ++++------ 3 files changed, 15 insertions(+), 131 deletions(-) diff --git a/web-client/src/ustc-ui/Utils/documentTypeSelectHelper.test.ts b/web-client/src/ustc-ui/Utils/documentTypeSelectHelper.test.ts index 47d7189c5fe..e241c2eb9f1 100644 --- a/web-client/src/ustc-ui/Utils/documentTypeSelectHelper.test.ts +++ b/web-client/src/ustc-ui/Utils/documentTypeSelectHelper.test.ts @@ -1,5 +1,4 @@ import { - courtIssuedDocketEntryOnChange, docketEntryOnChange, fileDocumentPrimaryOnChange, fileDocumentSecondaryOnChange, @@ -208,83 +207,6 @@ describe('documentTypeSelectHelper', () => { }); }); - describe('courtIssuedDocketEntryOnChange', () => { - it('should call update sequence multiple times with correct props followed by validate sequence if "action" is "select-option"', () => { - const inputValue = { - documentTitle: '[Anything]', - documentType: 'Order', - eventCode: 'O', - scenario: 'Type A', - }; - - courtIssuedDocketEntryOnChange({ - action: 'select-option', - inputValue, - updateSequence: updateSequenceSpy, - validateSequence: validateSequenceSpy, - }); - - expect(updateSequenceSpy).toHaveBeenCalled(); - expect(updateSequenceSpy.mock.calls[0][0]).toEqual({ - key: 'documentType', - value: inputValue.documentType, - }); - expect(updateSequenceSpy.mock.calls[1][0]).toEqual({ - key: 'documentTitle', - value: inputValue.documentTitle, - }); - expect(updateSequenceSpy.mock.calls[2][0]).toEqual({ - key: 'eventCode', - value: inputValue.eventCode, - }); - expect(updateSequenceSpy.mock.calls[3][0]).toEqual({ - key: 'scenario', - value: inputValue.scenario, - }); - expect(validateSequenceSpy).toHaveBeenCalled(); - }); - - it('should call update sequence multiple times followed by validate sequence if "action" is "clear"', () => { - courtIssuedDocketEntryOnChange({ - action: 'clear', - inputValue: undefined, - updateSequence: updateSequenceSpy, - validateSequence: validateSequenceSpy, - }); - - expect(updateSequenceSpy).toHaveBeenCalled(); - expect(updateSequenceSpy.mock.calls[0][0]).toEqual({ - key: 'documentType', - value: '', - }); - expect(updateSequenceSpy.mock.calls[1][0]).toEqual({ - key: 'documentTitle', - value: '', - }); - expect(updateSequenceSpy.mock.calls[2][0]).toEqual({ - key: 'eventCode', - value: '', - }); - expect(updateSequenceSpy.mock.calls[3][0]).toEqual({ - key: 'scenario', - value: '', - }); - expect(validateSequenceSpy).toHaveBeenCalled(); - }); - - it('should not call update or validate sequence if "action" is not "select-option" or "clear"', () => { - courtIssuedDocketEntryOnChange({ - action: 'something-else', - inputValue: undefined, - updateSequence: updateSequenceSpy, - validateSequence: validateSequenceSpy, - }); - - expect(updateSequenceSpy).not.toHaveBeenCalled(); - expect(validateSequenceSpy).not.toHaveBeenCalled(); - }); - }); - describe('onInputChange', () => { it('should call update sequence a single time if "action" is "input-change"', () => { onInputChange({ diff --git a/web-client/src/ustc-ui/Utils/documentTypeSelectHelper.ts b/web-client/src/ustc-ui/Utils/documentTypeSelectHelper.ts index 1946b7ab981..2e7e2a1ea1f 100644 --- a/web-client/src/ustc-ui/Utils/documentTypeSelectHelper.ts +++ b/web-client/src/ustc-ui/Utils/documentTypeSelectHelper.ts @@ -88,32 +88,6 @@ export const docketEntryOnChange = ({ return true; }; -export const courtIssuedDocketEntryOnChange = ({ - action, - inputValue, - updateSequence, - validateSequence, -}) => { - const updateFieldsAndValidate = (clearFields = false) => { - ['documentType', 'documentTitle', 'eventCode', 'scenario'].forEach(key => - updateSequence({ - key, - value: clearFields ? '' : inputValue[key], - }), - ); - validateSequence(); - }; - - switch (action) { - case 'select-option': - updateFieldsAndValidate(); - break; - case 'clear': - updateFieldsAndValidate(true); - break; - } -}; - export const onInputChange = ({ action, inputText, updateSequence }) => { if (action === 'input-change') { updateSequence({ diff --git a/web-client/src/views/EditDocketEntry/EditDocketEntryMetaFormCourtIssued.tsx b/web-client/src/views/EditDocketEntry/EditDocketEntryMetaFormCourtIssued.tsx index 27094e1df5c..40402a6edee 100644 --- a/web-client/src/views/EditDocketEntry/EditDocketEntryMetaFormCourtIssued.tsx +++ b/web-client/src/views/EditDocketEntry/EditDocketEntryMetaFormCourtIssued.tsx @@ -1,13 +1,8 @@ import { CourtIssuedNonstandardForm } from '../CourtIssuedDocketEntry/CourtIssuedNonstandardForm'; import { DateSelector } from '@web-client/ustc-ui/DateInput/DateSelector'; import { FormGroup } from '../../ustc-ui/FormGroup/FormGroup'; -import { SelectSearch } from '../../ustc-ui/Select/SelectSearch'; +import { SelectSearch2 } from '@web-client/ustc-ui/Select/SelectSearch2'; import { connect } from '@web-client/presenter/shared.cerebral'; -import { - courtIssuedDocketEntryOnChange, - onInputChange, - reactSelectValue, -} from '../../ustc-ui/Utils/documentTypeSelectHelper'; import { sequences } from '@web-client/presenter/app.cerebral'; import { state } from '@web-client/presenter/app.cerebral'; import React from 'react'; @@ -62,32 +57,25 @@ export const EditDocketEntryMetaFormCourtIssued = connect( Document type {addCourtIssuedDocketEntryHelper.showDocumentTypeDropdown && ( - { - courtIssuedDocketEntryOnChange({ - action, - inputValue, - name, - updateSequence: updateCourtIssuedDocketEntryFormValueSequence, - validateSequence: validateCourtIssuedDocketEntrySequence, - }); - return true; - }} - onInputChange={(inputText, { action }) => { - onInputChange({ - action, - inputText, - updateSequence: updateCourtIssuedDocketEntryFormValueSequence, - }); + onChange={inputValue => { + [ + 'documentType', + 'documentTitle', + 'eventCode', + 'scenario', + ].forEach(key => + updateCourtIssuedDocketEntryFormValueSequence({ + key, + value: inputValue ? inputValue[key] : '', + }), + ); + validateCourtIssuedDocketEntrySequence(); }} /> )} From b82929470d3a3e0c1b0d3f32a17e6cd891d25d22 Mon Sep 17 00:00:00 2001 From: Javis Sullivan Date: Tue, 24 Sep 2024 00:54:52 -0400 Subject: [PATCH 81/96] 10409: wip --- .../presenter/computeds/trialSessionsHelper.test.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/web-client/src/presenter/computeds/trialSessionsHelper.test.ts b/web-client/src/presenter/computeds/trialSessionsHelper.test.ts index a5a0e53f42f..9b21f07de13 100644 --- a/web-client/src/presenter/computeds/trialSessionsHelper.test.ts +++ b/web-client/src/presenter/computeds/trialSessionsHelper.test.ts @@ -285,15 +285,21 @@ describe('trialSessionsHelper', () => { expect(trialSessionsOnly.length).toEqual(1); }); + // NOTE: This test passes, but I am unable to find when the userId for a judge would be set to unassigned 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'; + trialSessionsPageState.filters.judges = { + 'd17b07dc-6455-447e-bea3-f91d12ac5a6a': { + name: 'Colvin', + userId: 'unassigned', + }, + }; const result = runCompute(trialSessionsHelper, { state: { - judges: [judgeUser], + judges: [], permissions: getUserPermissions(docketClerk1User), trialSessionsPage: trialSessionsPageState, }, @@ -310,7 +316,6 @@ describe('trialSessionsHelper', () => { it('should not filter trial sessions by judge when judge filter is All', () => { trialSessionsPageState.trialSessions = [trialSession1, trialSession2]; trialSessionsPageState.filters.judgeId = 'All'; - console.log('Trial Sessions: ', trialSessionsPageState.trialSessions); const result = runCompute(trialSessionsHelper, { state: { judges: [judgeUser, judgeColvin], @@ -318,7 +323,6 @@ describe('trialSessionsHelper', () => { trialSessionsPage: trialSessionsPageState, }, }); - console.log('TrialSessionRows: ', result.trialSessionRows); const trialSessionsOnly = result.trialSessionRows.filter(isTrialSessionRow); From 5b7512810a6126faa452d2e535e298c2ada891e8 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Mon, 23 Sep 2024 22:06:37 -0700 Subject: [PATCH 82/96] 10409: WIP update EditDocketEntryMetaFormDocument to new searchSelect --- .../EditDocketEntryMetaFormDocument.tsx | 66 +++++-------------- 1 file changed, 15 insertions(+), 51 deletions(-) diff --git a/web-client/src/views/EditDocketEntry/EditDocketEntryMetaFormDocument.tsx b/web-client/src/views/EditDocketEntry/EditDocketEntryMetaFormDocument.tsx index e6e0acea134..5be2eba42ab 100644 --- a/web-client/src/views/EditDocketEntry/EditDocketEntryMetaFormDocument.tsx +++ b/web-client/src/views/EditDocketEntry/EditDocketEntryMetaFormDocument.tsx @@ -4,13 +4,8 @@ import { FormGroup } from '../../ustc-ui/FormGroup/FormGroup'; import { Inclusions } from '../PaperFiling/Inclusions'; import { NonstandardForm } from '../FileDocument/NonstandardForm'; import { SecondaryDocumentForm } from '../PaperFiling/SecondaryDocumentForm'; -import { SelectSearch } from '../../ustc-ui/Select/SelectSearch'; +import { SelectSearch2 } from '@web-client/ustc-ui/Select/SelectSearch2'; import { connect } from '@web-client/presenter/shared.cerebral'; -import { - docketEntryOnChange, - onInputChange, - reactSelectValue, -} from '../../ustc-ui/Utils/documentTypeSelectHelper'; import { sequences } from '@web-client/presenter/app.cerebral'; import { state } from '@web-client/presenter/app.cerebral'; import React from 'react'; @@ -93,33 +88,19 @@ export const EditDocketEntryMetaFormDocument = connect( Document type - { - docketEntryOnChange({ - action, - inputName, - inputValue, - updateSequence: updateDocketEntryMetaDocumentFormValueSequence, - validateSequence: validateDocumentSequence, - }); - return true; - }} - onInputChange={(inputText, { action }) => { - onInputChange({ - action, - inputText, - updateSequence: validateDocumentSequence, + onChange={inputValue => { + const value = inputValue?.value || ''; + updateDocketEntryMetaDocumentFormValueSequence({ + key: 'eventCode', + value, }); + validateDocumentSequence(); }} /> @@ -140,36 +121,19 @@ export const EditDocketEntryMetaFormDocument = connect( entry for it. - { - docketEntryOnChange({ - action, - inputName, - inputValue, - updateSequence: - updateDocketEntryMetaDocumentFormValueSequence, - validateSequence: validateDocumentSequence, - }); - return true; - }} - onInputChange={(inputText, { action }) => { - onInputChange({ - action, - inputText, - updateSequence: - updateDocketEntryMetaDocumentFormValueSequence, + onChange={inputValue => { + const value = inputValue?.value || ''; + updateDocketEntryMetaDocumentFormValueSequence({ + key: 'secondaryDocument.eventCode', + value, }); + validateDocumentSequence(); }} /> From 58f0c6a66b57dd3cdc1a7f7e7088f508cd32ae0f Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 24 Sep 2024 06:27:07 -0700 Subject: [PATCH 83/96] 10409: WIP update PrimaryDocumentForm to new searchSelect --- .../EditDocketEntry/PrimaryDocumentForm.tsx | 55 ++++++------------- 1 file changed, 16 insertions(+), 39 deletions(-) diff --git a/web-client/src/views/EditDocketEntry/PrimaryDocumentForm.tsx b/web-client/src/views/EditDocketEntry/PrimaryDocumentForm.tsx index d02d2c97d33..137f05816d3 100644 --- a/web-client/src/views/EditDocketEntry/PrimaryDocumentForm.tsx +++ b/web-client/src/views/EditDocketEntry/PrimaryDocumentForm.tsx @@ -4,13 +4,9 @@ import { FormGroup } from '../../ustc-ui/FormGroup/FormGroup'; import { Inclusions } from '../PaperFiling/Inclusions'; import { NonstandardForm } from '../FileDocument/NonstandardForm'; import { SecondaryDocumentForm } from '../PaperFiling/SecondaryDocumentForm'; -import { SelectSearch } from '../../ustc-ui/Select/SelectSearch'; +import { SelectSearch2 } from '@web-client/ustc-ui/Select/SelectSearch2'; import { connect } from '@web-client/presenter/shared.cerebral'; -import { - docketEntryOnChange, - onInputChange, - reactSelectValue, -} from '../../ustc-ui/Utils/documentTypeSelectHelper'; +import { reactSelectValue } from '../../ustc-ui/Utils/documentTypeSelectHelper'; import { sequences, state } from '@web-client/presenter/app.cerebral'; import React from 'react'; @@ -24,7 +20,6 @@ export const PrimaryDocumentForm = connect( internalTypesHelper: state.internalTypesHelper, updateDocketEntryFormValueSequence: sequences.updateDocketEntryFormValueSequence, - updateScreenMetadataSequence: sequences.updateScreenMetadataSequence, validateDocketEntrySequence: sequences.validateDocketEntrySequence, validationErrors: state.validationErrors, }, @@ -35,7 +30,6 @@ export const PrimaryDocumentForm = connect( formatAndUpdateDateFromDatePickerSequence, internalTypesHelper, updateDocketEntryFormValueSequence, - updateScreenMetadataSequence, validateDocketEntrySequence, validationErrors, }) { @@ -96,7 +90,7 @@ export const PrimaryDocumentForm = connect( Document type - { - docketEntryOnChange({ - action, - inputName, - inputValue, - updateSequence: updateDocketEntryFormValueSequence, - validateSequence: validateDocketEntrySequence, + onChange={inputValue => { + const value = inputValue?.value || ''; + updateDocketEntryFormValueSequence({ + key: 'eventCode', + value, }); + validateDocketEntrySequence(); return true; }} - onInputChange={(inputText, { action }) => { - onInputChange({ - action, - inputText, - updateSequence: updateScreenMetadataSequence, - }); - }} /> {addDocketEntryHelper.primary.showSecondaryDocumentForm && ( @@ -143,7 +129,7 @@ export const PrimaryDocumentForm = connect( docket entry for it. - { - docketEntryOnChange({ - action, - inputName, - inputValue, - updateSequence: updateDocketEntryFormValueSequence, - validateSequence: validateDocketEntrySequence, - }); - return true; - }} - onInputChange={(inputText, { action }) => { - onInputChange({ - action, - inputText, - updateSequence: updateScreenMetadataSequence, + onChange={inputValue => { + const value = inputValue?.value || ''; + updateDocketEntryFormValueSequence({ + key: 'secondaryDocument.eventCode', + value, }); + validateDocketEntrySequence(); }} /> From 3a98fc5bb0c44178a8cc7d52a016b42e12770ceb Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 24 Sep 2024 06:36:01 -0700 Subject: [PATCH 84/96] 10409: WIP Assign a value so that select search knows what value was selected. --- .../CaseAssociationRequest/CaseAssociationRequest.tsx | 7 +++++++ .../CourtIssuedDocketEntry/CourtIssuedDocketEntry.tsx | 6 ++++++ .../EditDocketEntryMetaFormCourtIssued.tsx | 5 +++++ .../EditDocketEntryMetaFormDocument.tsx | 11 +++++++++++ .../src/views/PaperFiling/PrimaryDocumentForm.tsx | 11 +++++++++++ 5 files changed, 40 insertions(+) diff --git a/web-client/src/views/CaseAssociationRequest/CaseAssociationRequest.tsx b/web-client/src/views/CaseAssociationRequest/CaseAssociationRequest.tsx index 7589f692df6..3964cbee337 100644 --- a/web-client/src/views/CaseAssociationRequest/CaseAssociationRequest.tsx +++ b/web-client/src/views/CaseAssociationRequest/CaseAssociationRequest.tsx @@ -5,6 +5,7 @@ import { FormGroup } from '../../ustc-ui/FormGroup/FormGroup'; import { PartiesRepresenting } from './PartiesRepresenting'; import { SelectSearch2 } from '@web-client/ustc-ui/Select/SelectSearch2'; import { connect } from '@web-client/presenter/shared.cerebral'; +import { reactSelectValue } from '@web-client/ustc-ui/Utils/documentTypeSelectHelper'; import { sequences } from '@web-client/presenter/app.cerebral'; import { state } from '@web-client/presenter/app.cerebral'; import React from 'react'; @@ -13,6 +14,7 @@ import classNames from 'classnames'; export const CaseAssociationRequest = connect( { caseAssociationRequestHelper: state.caseAssociationRequestHelper, + form: state.form, formCancelToggleCancelSequence: sequences.formCancelToggleCancelSequence, reviewCaseAssociationRequestSequence: sequences.reviewCaseAssociationRequestSequence, @@ -24,6 +26,7 @@ export const CaseAssociationRequest = connect( }, function CaseAssociationRequest({ caseAssociationRequestHelper, + form, formCancelToggleCancelSequence, reviewCaseAssociationRequestSequence, updateCaseAssociationFormValueSequence, @@ -74,6 +77,10 @@ export const CaseAssociationRequest = connect( isClearable={true} name="documentType" options={caseAssociationRequestHelper.documentsForSelect} + value={reactSelectValue({ + documentTypes: caseAssociationRequestHelper.documentsForSelect, + selectedEventCode: form.eventCode, + })} onChange={e => { updateCaseAssociationFormValueSequence({ key: 'documentType', diff --git a/web-client/src/views/CourtIssuedDocketEntry/CourtIssuedDocketEntry.tsx b/web-client/src/views/CourtIssuedDocketEntry/CourtIssuedDocketEntry.tsx index a2aa7253771..0f7ec14f081 100644 --- a/web-client/src/views/CourtIssuedDocketEntry/CourtIssuedDocketEntry.tsx +++ b/web-client/src/views/CourtIssuedDocketEntry/CourtIssuedDocketEntry.tsx @@ -14,6 +14,7 @@ import { SuccessNotification } from '../SuccessNotification'; import { WarningNotificationComponent } from '../WarningNotification'; import { WorkItemAlreadyCompletedModal } from '../DocketEntryQc/WorkItemAlreadyCompletedModal'; import { connect } from '@web-client/presenter/shared.cerebral'; +import { reactSelectValue } from '@web-client/ustc-ui/Utils/documentTypeSelectHelper'; import { sequences } from '@web-client/presenter/app.cerebral'; import { state } from '@web-client/presenter/app.cerebral'; import React from 'react'; @@ -120,6 +121,11 @@ export const CourtIssuedDocketEntry = connect( isClearable={true} name="eventCode" options={addCourtIssuedDocketEntryHelper.documentTypes} + value={reactSelectValue({ + documentTypes: + addCourtIssuedDocketEntryHelper.documentTypes, + selectedEventCode: form.eventCode, + })} onChange={inputValue => { [ 'documentType', diff --git a/web-client/src/views/EditDocketEntry/EditDocketEntryMetaFormCourtIssued.tsx b/web-client/src/views/EditDocketEntry/EditDocketEntryMetaFormCourtIssued.tsx index 40402a6edee..06f1d6e12e3 100644 --- a/web-client/src/views/EditDocketEntry/EditDocketEntryMetaFormCourtIssued.tsx +++ b/web-client/src/views/EditDocketEntry/EditDocketEntryMetaFormCourtIssued.tsx @@ -3,6 +3,7 @@ import { DateSelector } from '@web-client/ustc-ui/DateInput/DateSelector'; import { FormGroup } from '../../ustc-ui/FormGroup/FormGroup'; import { SelectSearch2 } from '@web-client/ustc-ui/Select/SelectSearch2'; import { connect } from '@web-client/presenter/shared.cerebral'; +import { reactSelectValue } from '@web-client/ustc-ui/Utils/documentTypeSelectHelper'; import { sequences } from '@web-client/presenter/app.cerebral'; import { state } from '@web-client/presenter/app.cerebral'; import React from 'react'; @@ -63,6 +64,10 @@ export const EditDocketEntryMetaFormCourtIssued = connect( isClearable={true} name="eventCode" options={addCourtIssuedDocketEntryHelper.documentTypes} + value={reactSelectValue({ + documentTypes: addCourtIssuedDocketEntryHelper.documentTypes, + selectedEventCode: form.eventCode, + })} onChange={inputValue => { [ 'documentType', diff --git a/web-client/src/views/EditDocketEntry/EditDocketEntryMetaFormDocument.tsx b/web-client/src/views/EditDocketEntry/EditDocketEntryMetaFormDocument.tsx index 5be2eba42ab..ce2f10fc9b3 100644 --- a/web-client/src/views/EditDocketEntry/EditDocketEntryMetaFormDocument.tsx +++ b/web-client/src/views/EditDocketEntry/EditDocketEntryMetaFormDocument.tsx @@ -6,6 +6,7 @@ import { NonstandardForm } from '../FileDocument/NonstandardForm'; import { SecondaryDocumentForm } from '../PaperFiling/SecondaryDocumentForm'; import { SelectSearch2 } from '@web-client/ustc-ui/Select/SelectSearch2'; import { connect } from '@web-client/presenter/shared.cerebral'; +import { reactSelectValue } from '@web-client/ustc-ui/Utils/documentTypeSelectHelper'; import { sequences } from '@web-client/presenter/app.cerebral'; import { state } from '@web-client/presenter/app.cerebral'; import React from 'react'; @@ -94,6 +95,11 @@ export const EditDocketEntryMetaFormDocument = connect( isClearable={true} name="eventCode" options={internalTypesHelper.internalDocumentTypesForSelectSorted} + value={reactSelectValue({ + documentTypes: + internalTypesHelper.internalDocumentTypesForSelectWithLegacySorted, + selectedEventCode: form.eventCode, + })} onChange={inputValue => { const value = inputValue?.value || ''; updateDocketEntryMetaDocumentFormValueSequence({ @@ -127,6 +133,11 @@ export const EditDocketEntryMetaFormDocument = connect( isClearable={true} name="secondaryDocument.eventCode" options={internalTypesHelper.internalDocumentTypesForSelectSorted} + value={reactSelectValue({ + documentTypes: + internalTypesHelper.internalDocumentTypesForSelectWithLegacySorted, + selectedEventCode: form?.secondaryDocument?.eventCode, + })} onChange={inputValue => { const value = inputValue?.value || ''; updateDocketEntryMetaDocumentFormValueSequence({ diff --git a/web-client/src/views/PaperFiling/PrimaryDocumentForm.tsx b/web-client/src/views/PaperFiling/PrimaryDocumentForm.tsx index 6026e1a31b9..c815955c8e1 100644 --- a/web-client/src/views/PaperFiling/PrimaryDocumentForm.tsx +++ b/web-client/src/views/PaperFiling/PrimaryDocumentForm.tsx @@ -6,6 +6,7 @@ import { NonstandardForm } from '../FileDocument/NonstandardForm'; import { SecondaryDocumentForm } from './SecondaryDocumentForm'; import { SelectSearch2 } from '@web-client/ustc-ui/Select/SelectSearch2'; import { connect } from '@web-client/presenter/shared.cerebral'; +import { reactSelectValue } from '@web-client/ustc-ui/Utils/documentTypeSelectHelper'; import { sequences } from '@web-client/presenter/app.cerebral'; import { state } from '@web-client/presenter/app.cerebral'; import React from 'react'; @@ -124,6 +125,11 @@ export const PrimaryDocumentForm = connect( isMulti={false} name="eventCode" options={internalTypesHelper.internalDocumentTypesForSelectSorted} + value={reactSelectValue({ + documentTypes: + internalTypesHelper.internalDocumentTypesForSelectSorted, + selectedEventCode: form.eventCode, + })} onChange={inputValue => { const value = inputValue?.value || ''; updateDocketEntryFormValueSequence({ @@ -161,6 +167,11 @@ export const PrimaryDocumentForm = connect( options={ internalTypesHelper.internalDocumentTypesForSelectSorted } + value={reactSelectValue({ + documentTypes: + internalTypesHelper.internalDocumentTypesForSelectSorted, + selectedEventCode: form?.secondaryDocument?.eventCode, + })} onChange={inputValue => { const value = inputValue?.value || ''; updateDocketEntryFormValueSequence({ From bfe3a993e251d0b79712f15ec9651f077e66e5d2 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 24 Sep 2024 06:46:10 -0700 Subject: [PATCH 85/96] 10409: WIP update CompleteDocumentTypeSelection to new searchSelect --- .../CompleteDocumentTypeSection.tsx | 42 ++++++++----------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/web-client/src/views/FileDocument/CompleteDocumentTypeSection.tsx b/web-client/src/views/FileDocument/CompleteDocumentTypeSection.tsx index 44a6e3ff02f..d475f07e7ae 100644 --- a/web-client/src/views/FileDocument/CompleteDocumentTypeSection.tsx +++ b/web-client/src/views/FileDocument/CompleteDocumentTypeSection.tsx @@ -1,13 +1,9 @@ import { CompleteDocumentTypeSectionRemainder } from './CompleteDocumentTypeSectionRemainder'; import { FormGroup } from '../../ustc-ui/FormGroup/FormGroup'; import { SelectDocumentWizardOverlay } from './SelectDocumentWizardOverlay'; -import { SelectSearch } from '../../ustc-ui/Select/SelectSearch'; +import { SelectSearch2 } from '@web-client/ustc-ui/Select/SelectSearch2'; import { connect } from '@web-client/presenter/shared.cerebral'; -import { - fileDocumentPrimaryOnChange, - onInputChange, - reactSelectValue, -} from '../../ustc-ui/Utils/documentTypeSelectHelper'; +import { reactSelectValue } from '../../ustc-ui/Utils/documentTypeSelectHelper'; import { sequences } from '@web-client/presenter/app.cerebral'; import { state } from '@web-client/presenter/app.cerebral'; import React from 'react'; @@ -19,7 +15,6 @@ export const CompleteDocumentTypeSection = connect( showModal: state.modal.showModal, updateFileDocumentWizardFormValueSequence: sequences.updateFileDocumentWizardFormValueSequence, - updateScreenMetadataSequence: sequences.updateScreenMetadataSequence, validateSelectDocumentTypeSequence: sequences.validateSelectDocumentTypeSequence, validationErrors: state.validationErrors, @@ -29,12 +24,12 @@ export const CompleteDocumentTypeSection = connect( form, showModal, updateFileDocumentWizardFormValueSequence, - updateScreenMetadataSequence, validateSelectDocumentTypeSequence, validationErrors, }) { return ( +

    THIS IS ZACH

    From 32a47c75e597bc74092f88906568a55229c47b02 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 24 Sep 2024 07:33:01 -0700 Subject: [PATCH 86/96] 10409: WIP update CompleteDocumentTypeSectionRemainder to new searchSelect --- .../Utils/documentTypeSelectHelper.test.ts | 71 ------------------- .../ustc-ui/Utils/documentTypeSelectHelper.ts | 32 --------- .../CompleteDocumentTypeSection.tsx | 1 - .../CompleteDocumentTypeSectionRemainder.tsx | 41 +++++------ 4 files changed, 17 insertions(+), 128 deletions(-) diff --git a/web-client/src/ustc-ui/Utils/documentTypeSelectHelper.test.ts b/web-client/src/ustc-ui/Utils/documentTypeSelectHelper.test.ts index e241c2eb9f1..335e8de743b 100644 --- a/web-client/src/ustc-ui/Utils/documentTypeSelectHelper.test.ts +++ b/web-client/src/ustc-ui/Utils/documentTypeSelectHelper.test.ts @@ -1,7 +1,6 @@ import { docketEntryOnChange, fileDocumentPrimaryOnChange, - fileDocumentSecondaryOnChange, onInputChange, reactSelectValue, } from './documentTypeSelectHelper'; @@ -84,76 +83,6 @@ describe('documentTypeSelectHelper', () => { }); }); - describe('fileDocumentSecondaryOnChange', () => { - it('should call update sequence multiple times with correct props followed by validate sequence if "action" is "select-option"', () => { - const inputValue = { - category: 'Answer (filed by respondent only)', - documentTitle: 'Amended Answer', - documentType: 'Amended Answer', - eventCode: 'AA', - scenario: 'Standard', - }; - - fileDocumentSecondaryOnChange({ - action: 'select-option', - inputValue, - updateSequence: updateSequenceSpy, - validateSequence: validateSequenceSpy, - }); - - expect(updateSequenceSpy).toHaveBeenCalled(); - expect(updateSequenceSpy.mock.calls[0][0]).toEqual({ - key: 'secondaryDocument.category', - value: inputValue.category, - }); - expect(updateSequenceSpy.mock.calls[1][0]).toEqual({ - key: 'secondaryDocument.documentType', - value: inputValue.documentType, - }); - expect(updateSequenceSpy.mock.calls[2][0]).toEqual({ - key: 'secondaryDocument.documentTitle', - value: inputValue.documentTitle, - }); - expect(updateSequenceSpy.mock.calls[3][0]).toEqual({ - key: 'secondaryDocument.eventCode', - value: inputValue.eventCode, - }); - expect(updateSequenceSpy.mock.calls[4][0]).toEqual({ - key: 'secondaryDocument.scenario', - value: inputValue.scenario, - }); - expect(validateSequenceSpy).toHaveBeenCalled(); - }); - - it('should call update sequence a single time followed by validate sequence if "action" is "clear"', () => { - fileDocumentSecondaryOnChange({ - action: 'clear', - inputValue: undefined, - updateSequence: updateSequenceSpy, - validateSequence: validateSequenceSpy, - }); - - expect(updateSequenceSpy).toHaveBeenCalled(); - expect(updateSequenceSpy.mock.calls[0][0]).toEqual({ - key: 'secondaryDocument.category', - value: '', - }); - expect(validateSequenceSpy).toHaveBeenCalled(); - }); - - it('should not call update or validate sequence if "action" is not "select-option" or "clear"', () => { - fileDocumentSecondaryOnChange({ - action: 'something-else', - inputValue: undefined, - updateSequence: updateSequenceSpy, - validateSequence: validateSequenceSpy, - }); - - expect(updateSequenceSpy).not.toHaveBeenCalled(); - expect(validateSequenceSpy).not.toHaveBeenCalled(); - }); - }); - describe('docketEntryOnChange', () => { it('should call update sequence multiple times with correct props followed by validate sequence if "action" is "select-option"', () => { const inputValue = { diff --git a/web-client/src/ustc-ui/Utils/documentTypeSelectHelper.ts b/web-client/src/ustc-ui/Utils/documentTypeSelectHelper.ts index 2e7e2a1ea1f..5215b348d98 100644 --- a/web-client/src/ustc-ui/Utils/documentTypeSelectHelper.ts +++ b/web-client/src/ustc-ui/Utils/documentTypeSelectHelper.ts @@ -30,38 +30,6 @@ export const fileDocumentPrimaryOnChange = ({ } }; -export const fileDocumentSecondaryOnChange = ({ - action, - inputValue, - updateSequence, - validateSequence, -}) => { - switch (action) { - case 'select-option': - [ - 'category', - 'documentType', - 'documentTitle', - 'eventCode', - 'scenario', - ].forEach(key => - updateSequence({ - key: `secondaryDocument.${key}`, - value: inputValue[key], - }), - ); - validateSequence(); - break; - case 'clear': - updateSequence({ - key: 'secondaryDocument.category', - value: '', - }); - validateSequence(); - break; - } -}; - export const docketEntryOnChange = ({ action, inputName, diff --git a/web-client/src/views/FileDocument/CompleteDocumentTypeSection.tsx b/web-client/src/views/FileDocument/CompleteDocumentTypeSection.tsx index d475f07e7ae..afae60754e2 100644 --- a/web-client/src/views/FileDocument/CompleteDocumentTypeSection.tsx +++ b/web-client/src/views/FileDocument/CompleteDocumentTypeSection.tsx @@ -29,7 +29,6 @@ export const CompleteDocumentTypeSection = connect( }) { return ( -

    THIS IS ZACH

    From 7d8e835bad5479b350d15aec6b4e795ca9f9fd74 Mon Sep 17 00:00:00 2001 From: Zachary Rogers Date: Tue, 24 Sep 2024 09:18:40 -0700 Subject: [PATCH 87/96] 10409: Delete old SelectSearch in favor of more generic select search --- .../src/ustc-ui/Select/SelectSearch.tsx | 94 +++---------------- .../src/ustc-ui/Select/SelectSearch2.tsx | 22 ----- .../CaseAssociationRequest.tsx | 4 +- .../CourtIssuedDocketEntry.tsx | 4 +- .../CustomCaseReport/CustomCaseReport.tsx | 10 +- .../EditDocketEntryMetaFormCourtIssued.tsx | 4 +- .../EditDocketEntryMetaFormDocument.tsx | 6 +- .../EditDocketEntry/PrimaryDocumentForm.tsx | 6 +- .../CompleteDocumentTypeSection.tsx | 4 +- .../CompleteDocumentTypeSectionRemainder.tsx | 4 +- .../views/PaperFiling/PrimaryDocumentForm.tsx | 6 +- web-client/src/views/StyleGuide/Forms.tsx | 4 +- .../TrialSessions/SessionAssignmentsForm.tsx | 4 +- .../src/views/TrialSessions/TrialSessions.tsx | 8 +- 14 files changed, 44 insertions(+), 136 deletions(-) delete mode 100644 web-client/src/ustc-ui/Select/SelectSearch2.tsx diff --git a/web-client/src/ustc-ui/Select/SelectSearch.tsx b/web-client/src/ustc-ui/Select/SelectSearch.tsx index f4ecbb70191..c0e42d614d1 100644 --- a/web-client/src/ustc-ui/Select/SelectSearch.tsx +++ b/web-client/src/ustc-ui/Select/SelectSearch.tsx @@ -1,92 +1,22 @@ -/* eslint-disable import/named */ -import { getSortedOptions } from '../../ustc-ui/Utils/selectSearchHelper'; -import React, { useState } from 'react'; -import ReactSelect, { - ActionMeta, - GroupBase, - OptionsOrGroups, -} from 'react-select'; +import React from 'react'; +import ReactSelect, { GroupBase, Props } from 'react-select'; import classNames from 'classnames'; -export const SelectSearch = ({ - className, - disabled, - id, - isClearable = true, - name, - onChange, - onInputChange, - options, - placeholder = '- Select -', - searchableOptions, - value, - ...props -}: { - className?: string; - disabled?: boolean; - id?: string; - isClearable?: boolean; - name?: string; - onChange: (newValue: any, actionMeta: ActionMeta) => void; - onInputChange?: Function; - options?: OptionsOrGroups> | undefined; - placeholder?: string; - searchableOptions?: OptionsOrGroups> | undefined; - value?: any; -}) => { - const [inputText, setInputText] = useState(''); - const [selectOptions, setSelectOptions] = useState(options); - - function handleOnInputChange(newInputText, { action }) { - if (action === 'input-change') { - setInputText(newInputText); - if (newInputText === '') { - setSelectOptions(options); - } else if (searchableOptions) { - setSelectOptions(searchableOptions); - } - } - if (typeof onInputChange === 'function') { - onInputChange(newInputText, action); - } - } - - function resetOptions() { - setInputText(''); - setSelectOptions(options); - } - - let sortedOptions = getSortedOptions(selectOptions, inputText); - - const aria = { - 'aria-describedby': props['aria-describedby'], - 'aria-disabled': disabled || props['aria-disabled'], - 'aria-label': props['aria-label'], - 'aria-labelledby': props['aria-labelledby'], - }; - +export function SelectSearch< + Option, + IsMulti extends boolean = false, + Group extends GroupBase