From 0fd04776ec9f20329461d9f13e37aa04da30e83f Mon Sep 17 00:00:00 2001 From: John Cruz Date: Wed, 21 Aug 2024 12:05:08 -0600 Subject: [PATCH 01/99] 10437: Type the helper; --- .../computeds/blockedCasesReportHelper.ts | 98 +++++++++++++------ 1 file changed, 70 insertions(+), 28 deletions(-) diff --git a/web-client/src/presenter/computeds/blockedCasesReportHelper.ts b/web-client/src/presenter/computeds/blockedCasesReportHelper.ts index cae8244c8c0..319c8dda13a 100644 --- a/web-client/src/presenter/computeds/blockedCasesReportHelper.ts +++ b/web-client/src/presenter/computeds/blockedCasesReportHelper.ts @@ -7,40 +7,76 @@ import { state } from '@web-client/presenter/app.cerebral'; * @param {object} applicationContext the application context * @returns {object} {blockedCasesFormatted: *[], blockedCasesCount: number} */ +import { CaseStatus } from '@shared/business/entities/EntityConstants'; import { ClientApplicationContext } from '@web-client/applicationContext'; import { Get } from 'cerebral'; -export const blockedCasesReportHelper = ( - get: Get, - applicationContext: ClientApplicationContext, -): any => { - const blockedCases = get(state.blockedCases); - const procedureTypeFilter = get(state.form.procedureType); - let blockedCasesFormatted = []; - let displayMessage; +type BlockedFormattedCase = { + docketNumber: string; + inConsolidatedGroup: boolean; + consolidatedIconTooltipText: string; + isLeadCase: boolean; + blockedDateEarliest: string; + caseTitle: string; + procedureType: string; + status: CaseStatus; + blockedReason?: string; + automaticBlockedReason?: string; + docketNumberWithSuffix?: string; +}; - const setFormattedBlockDates = blockedCase => { - if (blockedCase.blockedDate && blockedCase.automaticBlocked) { - if (blockedCase.blockedDate < blockedCase.automaticBlockedDate) { - blockedCase.blockedDateEarliest = applicationContext - .getUtilities() - .formatDateString(blockedCase.blockedDate, 'MMDDYY'); - } else { - blockedCase.blockedDateEarliest = applicationContext - .getUtilities() - .formatDateString(blockedCase.automaticBlockedDate, 'MMDDYY'); - } - } else if (blockedCase.blocked) { - blockedCase.blockedDateEarliest = applicationContext +type BlockedCaseReportHelperResults = { + blockedCasesCount: number; + blockedCasesFormatted: BlockedFormattedCase[]; + displayMessage: string | undefined; +}; + +const setFormattedBlockDates = ( + blockedCase: RawCase & { + inConsolidatedGroup: boolean; + consolidatedIconTooltipText: string; + shouldIndent: boolean; + isLeadCase: boolean; + }, + applicationContext: ClientApplicationContext, +): BlockedFormattedCase => { + const blockedFormattedCase: BlockedFormattedCase = { + ...blockedCase, + blockedDateEarliest: '', + caseTitle: '', + }; + + if (blockedCase.blockedDate && blockedCase.automaticBlocked) { + if (blockedCase.blockedDate < blockedCase.automaticBlockedDate!) { + blockedFormattedCase.blockedDateEarliest = applicationContext .getUtilities() .formatDateString(blockedCase.blockedDate, 'MMDDYY'); - } else if (blockedCase.automaticBlocked) { - blockedCase.blockedDateEarliest = applicationContext + } else { + blockedFormattedCase.blockedDateEarliest = applicationContext .getUtilities() - .formatDateString(blockedCase.automaticBlockedDate, 'MMDDYY'); + .formatDateString(blockedCase.automaticBlockedDate!, 'MMDDYY'); } - return blockedCase; - }; + } else if (blockedCase.blocked) { + blockedFormattedCase.blockedDateEarliest = applicationContext + .getUtilities() + .formatDateString(blockedCase.blockedDate!, 'MMDDYY'); + } else if (blockedCase.automaticBlocked) { + blockedFormattedCase.blockedDateEarliest = applicationContext + .getUtilities() + .formatDateString(blockedCase.automaticBlockedDate!, 'MMDDYY'); + } + return blockedFormattedCase; +}; + +export const blockedCasesReportHelper = ( + get: Get, + applicationContext: ClientApplicationContext, +): BlockedCaseReportHelperResults => { + const blockedCases: RawCase[] = get(state.blockedCases); + const procedureTypeFilter = get(state.form.procedureType); + + let blockedCasesFormatted: BlockedFormattedCase[] = []; + let displayMessage: string | undefined; if (blockedCases && blockedCases.length) { blockedCasesFormatted = blockedCases @@ -49,13 +85,19 @@ export const blockedCasesReportHelper = ( const blockedCaseWithConsolidatedProperties = applicationContext .getUtilities() .setConsolidationFlagsForDisplay(blockedCase); - return { - ...setFormattedBlockDates(blockedCaseWithConsolidatedProperties), + + const updatedCase = { + ...setFormattedBlockDates( + blockedCaseWithConsolidatedProperties, + applicationContext, + ), caseTitle: applicationContext.getCaseTitle( blockedCase.caseCaption || '', ), docketNumberWithSuffix: blockedCase.docketNumberWithSuffix, }; + + return updatedCase; }) .filter(blockedCase => { return procedureTypeFilter && procedureTypeFilter !== 'All' From e3f5e9a23692fa8ca29f740820e0889f4caf94f2 Mon Sep 17 00:00:00 2001 From: John Cruz Date: Wed, 21 Aug 2024 12:47:39 -0600 Subject: [PATCH 02/99] 10437: Filter blocked case report by case status; --- .../actions/setFormValueAction.test.ts | 15 +++++ .../presenter/actions/setFormValueAction.ts | 10 +-- .../blockedCasesReportHelper.test.ts | 62 +++++++++++++++++++ .../computeds/blockedCasesReportHelper.ts | 5 ++ .../sequences/updateFormValueSequence.ts | 1 + web-client/src/presenter/state.ts | 11 +++- .../BlockedCasesReport/SelectCriteria.tsx | 34 +++++++++- 7 files changed, 132 insertions(+), 6 deletions(-) diff --git a/web-client/src/presenter/actions/setFormValueAction.test.ts b/web-client/src/presenter/actions/setFormValueAction.test.ts index edf4aa1ff9e..02a23020aa4 100644 --- a/web-client/src/presenter/actions/setFormValueAction.test.ts +++ b/web-client/src/presenter/actions/setFormValueAction.test.ts @@ -77,4 +77,19 @@ describe('setFormValueAction', () => { }); expect(result.state.form.appleType).toEqual(undefined); }); + + describe('root', () => { + it('should save to the specified root level of state', async () => { + const TEST_ROOT = 'TEST_ROOT'; + const result = await runAction(setFormValueAction, { + props: { + key: 'hasApples', + root: TEST_ROOT, + value: true, + }, + state: {}, + }); + expect(result.state[TEST_ROOT].hasApples).toEqual(true); + }); + }); }); diff --git a/web-client/src/presenter/actions/setFormValueAction.ts b/web-client/src/presenter/actions/setFormValueAction.ts index 45b851cd412..54b4b8b2c6e 100644 --- a/web-client/src/presenter/actions/setFormValueAction.ts +++ b/web-client/src/presenter/actions/setFormValueAction.ts @@ -6,18 +6,20 @@ export const setFormValueAction = ({ }: ActionProps<{ allowEmptyString?: boolean; index?: number; + root?: string; key: string; value: any; }>) => { - const { allowEmptyString, index, key, value } = props; + const { allowEmptyString, index, key, root, value } = props; + const stateRoot = root || 'form'; if ((!allowEmptyString && value === '') || value === null) { - return store.unset(state.form[key]); + return store.unset(state[stateRoot][key]); } if (typeof index === 'number') { - return store.set(state.form[key][index], value); + return store.set(state[stateRoot][key][index], value); } - store.set(state.form[key], value); + store.set(state[stateRoot][key], value); }; diff --git a/web-client/src/presenter/computeds/blockedCasesReportHelper.test.ts b/web-client/src/presenter/computeds/blockedCasesReportHelper.test.ts index cac42d692d9..8ef05ce5e82 100644 --- a/web-client/src/presenter/computeds/blockedCasesReportHelper.test.ts +++ b/web-client/src/presenter/computeds/blockedCasesReportHelper.test.ts @@ -419,4 +419,66 @@ describe('blockedCasesReportHelper', () => { }); expect(result.displayMessage).toEqual(noBlockedCasesLocationMessage); }); + + describe('filters', () => { + it('should return all the blocked cases when "caseStatusFilter" is not defined', () => { + const TEST_CASES = [ + { docketNumber: '101-19' }, + { docketNumber: '102-19' }, + { docketNumber: '103-19' }, + ]; + + const result = runCompute(blockedCasesReportHelper, { + state: { + blockedCaseReportFilter: { + caseStatusFilter: undefined, + }, + blockedCases: TEST_CASES, + }, + }); + expect(result.blockedCasesFormatted.length).toEqual(TEST_CASES.length); + }); + + it('should return all the blocked cases when "caseStatusFilter" is set to "All', () => { + const TEST_CASES = [ + { docketNumber: '101-19' }, + { docketNumber: '102-19' }, + { docketNumber: '103-19' }, + ]; + + const result = runCompute(blockedCasesReportHelper, { + state: { + blockedCaseReportFilter: { + caseStatusFilter: 'All', + }, + blockedCases: TEST_CASES, + }, + }); + expect(result.blockedCasesFormatted.length).toEqual(TEST_CASES.length); + }); + + it('should filter out blocked cases that do not match "caseStatusFilter"', () => { + const TEST_STATUS = 'TEST_STATUS'; + const TEST_CASES = [ + { docketNumber: '101-19', status: 'RANDOM' }, + { docketNumber: '102-19', status: TEST_STATUS }, + { docketNumber: '103-19', status: 'RANDOM' }, + ]; + + const result = runCompute(blockedCasesReportHelper, { + state: { + blockedCaseReportFilter: { + caseStatusFilter: TEST_STATUS, + }, + blockedCases: TEST_CASES, + }, + }); + + expect(result.blockedCasesFormatted.length).toEqual(1); + expect(result.blockedCasesFormatted[0]).toMatchObject({ + docketNumber: '102-19', + status: TEST_STATUS, + }); + }); + }); }); diff --git a/web-client/src/presenter/computeds/blockedCasesReportHelper.ts b/web-client/src/presenter/computeds/blockedCasesReportHelper.ts index 319c8dda13a..9c9cf185206 100644 --- a/web-client/src/presenter/computeds/blockedCasesReportHelper.ts +++ b/web-client/src/presenter/computeds/blockedCasesReportHelper.ts @@ -74,6 +74,7 @@ export const blockedCasesReportHelper = ( ): BlockedCaseReportHelperResults => { const blockedCases: RawCase[] = get(state.blockedCases); const procedureTypeFilter = get(state.form.procedureType); + const { caseStatusFilter = 'All' } = get(state.blockedCaseReportFilter) || {}; let blockedCasesFormatted: BlockedFormattedCase[] = []; let displayMessage: string | undefined; @@ -103,6 +104,10 @@ export const blockedCasesReportHelper = ( return procedureTypeFilter && procedureTypeFilter !== 'All' ? blockedCase.procedureType === procedureTypeFilter : true; + }) + .filter(blockedCase => { + if (caseStatusFilter === 'All') return true; + return blockedCase.status === caseStatusFilter; }); } diff --git a/web-client/src/presenter/sequences/updateFormValueSequence.ts b/web-client/src/presenter/sequences/updateFormValueSequence.ts index 7a818fe004d..64c5aff587f 100644 --- a/web-client/src/presenter/sequences/updateFormValueSequence.ts +++ b/web-client/src/presenter/sequences/updateFormValueSequence.ts @@ -4,6 +4,7 @@ export const updateFormValueSequence = [ setFormValueAction, ] as unknown as (props: { index: number; + root?: string; key: string; value: any; allowEmptyString?: boolean; diff --git a/web-client/src/presenter/state.ts b/web-client/src/presenter/state.ts index 7934d399339..cad797feacf 100644 --- a/web-client/src/presenter/state.ts +++ b/web-client/src/presenter/state.ts @@ -150,7 +150,12 @@ import { viewAllDocumentsHelper } from './computeds/viewAllDocumentsHelper'; import { viewCounselHelper } from './computeds/viewCounselHelper'; import { workQueueHelper } from './computeds/workQueueHelper'; -const { ASCENDING, DOCKET_RECORD_FILTER_OPTIONS, IDLE_STATUS } = getConstants(); +const { + ASCENDING, + CASE_STATUS_TYPES, + DOCKET_RECORD_FILTER_OPTIONS, + IDLE_STATUS, +} = getConstants(); export const computeds = { addCourtIssuedDocketEntryHelper: @@ -569,6 +574,7 @@ export const computeds = { }; export const baseState = { + CASE_STATUS_TYPES, advancedSearchForm: {} as any, // form for advanced search screen, TODO: replace with state.form advancedSearchTab: 'case', @@ -601,6 +607,9 @@ export const baseState = { fileCount?: number; title?: string; }, + blockedCaseReportFilter: {} as { + caseStatusFilter: string | undefined; + }, caseDeadlineReport: {} as { caseDeadlines: (RawCaseDeadline & { caseCaption: string; diff --git a/web-client/src/views/BlockedCasesReport/SelectCriteria.tsx b/web-client/src/views/BlockedCasesReport/SelectCriteria.tsx index b9bbfdbe44c..4a1938ce1ac 100644 --- a/web-client/src/views/BlockedCasesReport/SelectCriteria.tsx +++ b/web-client/src/views/BlockedCasesReport/SelectCriteria.tsx @@ -6,12 +6,16 @@ import React from 'react'; export const SelectCriteria = connect( { + CASE_STATUS_TYPES: state.CASE_STATUS_TYPES, + blockedCaseReportFilter: state.blockedCaseReportFilter, form: state.form, getBlockedCasesByTrialLocationSequence: sequences.getBlockedCasesByTrialLocationSequence, updateFormValueSequence: sequences.updateFormValueSequence, }, function SelectCriteria({ + blockedCaseReportFilter, + CASE_STATUS_TYPES, form, getBlockedCasesByTrialLocationSequence, updateFormValueSequence, @@ -42,7 +46,7 @@ export const SelectCriteria = connect( -
+
@@ -64,6 +68,34 @@ export const SelectCriteria = connect(
+
+ + +
); From f4f5e3328a5fd2edcbbeb2e640fa0fac3ca85b83 Mon Sep 17 00:00:00 2001 From: John Cruz Date: Wed, 21 Aug 2024 13:07:19 -0600 Subject: [PATCH 03/99] 10437: Use helper to get case statuses for dropdown; --- .../computeds/selectCriteriaHelper.test.ts | 79 +++++++++++++++++++ .../computeds/selectCriteriaHelper.ts | 24 ++++++ web-client/src/presenter/state.ts | 10 +-- .../BlockedCasesReport/SelectCriteria.tsx | 6 +- 4 files changed, 109 insertions(+), 10 deletions(-) create mode 100644 web-client/src/presenter/computeds/selectCriteriaHelper.test.ts create mode 100644 web-client/src/presenter/computeds/selectCriteriaHelper.ts diff --git a/web-client/src/presenter/computeds/selectCriteriaHelper.test.ts b/web-client/src/presenter/computeds/selectCriteriaHelper.test.ts new file mode 100644 index 00000000000..f2dfb95dc4d --- /dev/null +++ b/web-client/src/presenter/computeds/selectCriteriaHelper.test.ts @@ -0,0 +1,79 @@ +import { applicationContextForClient as applicationContext } from '@web-client/test/createClientTestApplicationContext'; +import { runCompute } from '../test.cerebral'; +import { selectCriteriaHelperInternal } from '@web-client/presenter/computeds/selectCriteriaHelper'; +import { withAppContextDecorator } from '@web-client/withAppContext'; + +describe('selectCriteriaHelper', () => { + const selectCriteriaHelper = withAppContextDecorator( + selectCriteriaHelperInternal, + applicationContext, + ); + + it('should return the case statuses', () => { + const { caseStatuses } = runCompute<{ caseStatuses: any }>( + selectCriteriaHelper, + { + state: {}, + }, + ); + + expect(caseStatuses).toEqual([ + { + key: 'assignedCase', + value: 'Assigned - Case', + }, + { + key: 'assignedMotion', + value: 'Assigned - Motion', + }, + { + key: 'calendared', + value: 'Calendared', + }, + { + key: 'cav', + value: 'CAV', + }, + { + key: 'closed', + value: 'Closed', + }, + { + key: 'closedDismissed', + value: 'Closed - Dismissed', + }, + { + key: 'generalDocket', + value: 'General Docket - Not at Issue', + }, + { + key: 'generalDocketReadyForTrial', + value: 'General Docket - At Issue (Ready for Trial)', + }, + { + key: 'jurisdictionRetained', + value: 'Jurisdiction Retained', + }, + { + key: 'new', + value: 'New', + }, + { + key: 'onAppeal', + value: 'On Appeal', + }, + { + key: 'rule155', + value: 'Rule 155', + }, + { + key: 'submitted', + value: 'Submitted', + }, + { + key: 'submittedRule122', + value: 'Submitted - Rule 122', + }, + ]); + }); +}); diff --git a/web-client/src/presenter/computeds/selectCriteriaHelper.ts b/web-client/src/presenter/computeds/selectCriteriaHelper.ts new file mode 100644 index 00000000000..ff824f94121 --- /dev/null +++ b/web-client/src/presenter/computeds/selectCriteriaHelper.ts @@ -0,0 +1,24 @@ +import { + CASE_STATUS_TYPES, + CaseStatus, +} from '@shared/business/entities/EntityConstants'; + +type SelectCriteriaHelperResults = { + caseStatuses: { key: string; value: CaseStatus }[]; +}; + +export const selectCriteriaHelperInternal = (): SelectCriteriaHelperResults => { + const caseStatuses: { key: string; value: CaseStatus }[] = Object.entries( + CASE_STATUS_TYPES, + ).map(([key, value]) => ({ + key, + value, + })); + + return { + caseStatuses, + }; +}; + +export const selectCriteriaHelper = + selectCriteriaHelperInternal as unknown as SelectCriteriaHelperResults; diff --git a/web-client/src/presenter/state.ts b/web-client/src/presenter/state.ts index cad797feacf..371dfe090ba 100644 --- a/web-client/src/presenter/state.ts +++ b/web-client/src/presenter/state.ts @@ -126,6 +126,7 @@ import { reviewSavedPetitionHelper } from './computeds/reviewSavedPetitionHelper import { scanBatchPreviewerHelper } from './computeds/scanBatchPreviewerHelper'; import { scanHelper } from './computeds/scanHelper'; import { sealedCaseDetailHelper } from './computeds/sealedCaseDetailHelper'; +import { selectCriteriaHelper } from '@web-client/presenter/computeds/selectCriteriaHelper'; import { serveThirtyDayNoticeModalHelper } from './computeds/serveThirtyDayNoticeModalHelper'; import { sessionAssignmentHelper } from './computeds/sessionAssignmentHelper'; import { setForHearingModalHelper } from './computeds/setForHearingModalHelper'; @@ -150,12 +151,7 @@ import { viewAllDocumentsHelper } from './computeds/viewAllDocumentsHelper'; import { viewCounselHelper } from './computeds/viewCounselHelper'; import { workQueueHelper } from './computeds/workQueueHelper'; -const { - ASCENDING, - CASE_STATUS_TYPES, - DOCKET_RECORD_FILTER_OPTIONS, - IDLE_STATUS, -} = getConstants(); +const { ASCENDING, DOCKET_RECORD_FILTER_OPTIONS, IDLE_STATUS } = getConstants(); export const computeds = { addCourtIssuedDocketEntryHelper: @@ -498,6 +494,7 @@ export const computeds = { sealedCaseDetailHelper: sealedCaseDetailHelper as unknown as ReturnType< typeof sealedCaseDetailHelper >, + selectCriteriaHelper, serveThirtyDayNoticeModalHelper: serveThirtyDayNoticeModalHelper as unknown as ReturnType< typeof serveThirtyDayNoticeModalHelper @@ -574,7 +571,6 @@ export const computeds = { }; export const baseState = { - CASE_STATUS_TYPES, advancedSearchForm: {} as any, // form for advanced search screen, TODO: replace with state.form advancedSearchTab: 'case', diff --git a/web-client/src/views/BlockedCasesReport/SelectCriteria.tsx b/web-client/src/views/BlockedCasesReport/SelectCriteria.tsx index 4a1938ce1ac..e2deabae718 100644 --- a/web-client/src/views/BlockedCasesReport/SelectCriteria.tsx +++ b/web-client/src/views/BlockedCasesReport/SelectCriteria.tsx @@ -6,18 +6,18 @@ import React from 'react'; export const SelectCriteria = connect( { - CASE_STATUS_TYPES: state.CASE_STATUS_TYPES, blockedCaseReportFilter: state.blockedCaseReportFilter, form: state.form, getBlockedCasesByTrialLocationSequence: sequences.getBlockedCasesByTrialLocationSequence, + selectCriteriaHelper: state.selectCriteriaHelper, updateFormValueSequence: sequences.updateFormValueSequence, }, function SelectCriteria({ blockedCaseReportFilter, - CASE_STATUS_TYPES, form, getBlockedCasesByTrialLocationSequence, + selectCriteriaHelper, updateFormValueSequence, }) { return ( @@ -87,7 +87,7 @@ export const SelectCriteria = connect( }} > - {Object.entries(CASE_STATUS_TYPES).map(([key, value]) => { + {selectCriteriaHelper.caseStatuses.map(({ key, value }) => { return (