diff --git a/web-client/src/presenter/actions/CourtIssuedDocketEntry/setCourtIssuedDocumentInitialDataAction.test.ts b/web-client/src/presenter/actions/CourtIssuedDocketEntry/setCourtIssuedDocumentInitialDataAction.test.ts index 6d89a183086..98398ba3e31 100644 --- a/web-client/src/presenter/actions/CourtIssuedDocketEntry/setCourtIssuedDocumentInitialDataAction.test.ts +++ b/web-client/src/presenter/actions/CourtIssuedDocketEntry/setCourtIssuedDocumentInitialDataAction.test.ts @@ -8,6 +8,7 @@ describe('setCourtIssuedDocumentInitialDataAction', () => { const docketEntryIds = [ 'ddfd978d-6be6-4877-b004-2b5735a41fee', '11597d22-0874-4c5e-ac98-a843d1472baf', + '22597d22-0874-4c5e-ac98-a843d1472baf', ]; beforeAll(() => { @@ -22,6 +23,11 @@ describe('setCourtIssuedDocumentInitialDataAction', () => { eventCode: 'O', freeText: 'something', }); + MOCK_CASE.docketEntries.push({ + docketEntryId: docketEntryIds[2], + eventCode: 'OJR', + signedByUserId: '4497d22-0874-4c5e-ac98-a843d1472baf', + }); }); it('should set correct values on state.form for the docketEntryId passed in via props', async () => { @@ -108,4 +114,42 @@ describe('setCourtIssuedDocumentInitialDataAction', () => { expect(result.state.form).toEqual({}); }); + + it('should set the judge name when eventcode is OJR and docketEntry was signed by the judge', async () => { + const result = await runAction(setCourtIssuedDocumentInitialDataAction, { + modules: { + presenter, + }, + props: { + docketEntryId: '22597d22-0874-4c5e-ac98-a843d1472baf', + }, + state: { + caseDetail: MOCK_CASE, + form: {}, + judges: [ + { name: 'Colvin', userId: '4497d22-0874-4c5e-ac98-a843d1472baf' }, + ], + }, + }); + expect(result.state.form.judge).toEqual('Colvin'); + }); + + it('should not set the judge name when eventcode is OJR and docketEntry was signed by a non judge user', async () => { + const result = await runAction(setCourtIssuedDocumentInitialDataAction, { + modules: { + presenter, + }, + props: { + docketEntryId: '22597d22-0874-4c5e-ac98-a843d1472baf', + }, + state: { + caseDetail: MOCK_CASE, + form: {}, + judges: [ + { name: 'Cohen', userId: '3297d22-0874-4c5e-ac98-a843d1472baf' }, + ], + }, + }); + expect(result.state.form.judge).toEqual(undefined); + }); }); diff --git a/web-client/src/presenter/actions/CourtIssuedDocketEntry/setCourtIssuedDocumentInitialDataAction.ts b/web-client/src/presenter/actions/CourtIssuedDocketEntry/setCourtIssuedDocumentInitialDataAction.ts index a99dd05072c..0fbd5c9596a 100644 --- a/web-client/src/presenter/actions/CourtIssuedDocketEntry/setCourtIssuedDocumentInitialDataAction.ts +++ b/web-client/src/presenter/actions/CourtIssuedDocketEntry/setCourtIssuedDocumentInitialDataAction.ts @@ -18,6 +18,8 @@ export const setCourtIssuedDocumentInitialDataAction = ({ }: ActionProps) => { const { docketEntries } = get(state.caseDetail); + const judges = get(state.judges); + const docketEntry = docketEntries.find( item => item.docketEntryId === props.docketEntryId, ); @@ -34,6 +36,15 @@ export const setCourtIssuedDocumentInitialDataAction = ({ store.set(state.form.attachments, false); } + if (docketEntry.eventCode === 'OJR') { + const signingJudge = judges.find(judge => { + return judge.userId === docketEntry.signedByUserId; + }); + if (signingJudge) { + store.set(state.form.judge, signingJudge.name); + } + } + if (docketEntry.freeText) { store.set(state.form.freeText, docketEntry.freeText); }