Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(j-s): Revoke Notifications #15190

Merged
merged 61 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
4b82fdf
Add POSTPONED_TO_VERDICT radio button
oddsson May 28, 2024
538eead
Change Radio to Checkbox
oddsson May 28, 2024
be28358
Merge branch 'main' of github.com:island-is/island.is into j-s/postpo…
oddsson May 28, 2024
43c515a
Add column to Case table -- IndictmentDecision
oddsson May 29, 2024
4a3ec3f
Update IndictmentDecision
oddsson May 29, 2024
dfc970e
Merge branch 'main' of github.com:island-is/island.is into j-s/postpo…
oddsson May 30, 2024
9061138
Postponed until verdict tag in cases
oddsson May 30, 2024
d0ff81b
Disable subpoena screen if a case is postponed until verdict
oddsson May 30, 2024
f9119f8
Add a postpone until verdict tag for defenders
oddsson May 30, 2024
c5e92f5
Checkpoint
oddsson May 30, 2024
d75eeba
Checkpoint
oddsson May 30, 2024
2091f6a
Merge branch 'main' of github.com:island-is/island.is into j-s/postpo…
oddsson May 31, 2024
e73e037
Merge
oddsson May 31, 2024
ed6ba89
Determining when step is valid when postponing until verdict
oddsson May 31, 2024
bffb3f0
Merge branch 'main' of github.com:island-is/island.is into j-s/postpo…
oddsson May 31, 2024
7cf3da0
Checkpoint
oddsson May 31, 2024
2b5c478
Change all instances of Array<something> to something[]
oddsson May 31, 2024
7d24529
Merge branch 'main' into j-s/array-ref
kodiakhq[bot] May 31, 2024
3bc2eda
Merge branch 'main' of github.com:island-is/island.is into j-s/postpo…
oddsson May 31, 2024
44e3501
Merge branch 'j-s/array-ref' of github.com:island-is/island.is into j…
oddsson May 31, 2024
164ea33
Only show InfoCard on summary page if indictment decison is POSTPONIN…
oddsson May 31, 2024
8b6c049
Wipe courtDate out when postponing until verdict
oddsson Jun 3, 2024
a01f34c
Move scheduled info card to overview page
oddsson Jun 3, 2024
048ff3a
Save court date when postponing until verdict
oddsson Jun 3, 2024
68a4de4
Merge branch 'main' of github.com:island-is/island.is into j-s/postpo…
oddsson Jun 3, 2024
1dc584d
Checkpoint
oddsson Jun 3, 2024
ab03621
Merge branch 'main' of github.com:island-is/island.is into j-s/postpo…
oddsson Jun 3, 2024
8649b7b
Fixing update functionality
oddsson Jun 3, 2024
d08c1e3
Fix case state on cases page
oddsson Jun 3, 2024
4bdf63a
Fix migration
oddsson Jun 3, 2024
5ec53d6
Add location to verdict date
oddsson Jun 3, 2024
743cb81
Merge branch 'main' of github.com:island-is/island.is into j-s/postpo…
oddsson Jun 3, 2024
9e77317
Cleanup
oddsson Jun 4, 2024
35feba7
Allow judges to remove set court date
oddsson Jun 4, 2024
fc6b01e
Added test
oddsson Jun 4, 2024
f86f930
Merge branch 'main' of github.com:island-is/island.is into j-s/cancel…
gudjong Jun 4, 2024
36dc8a9
Merge branch 'main' of github.com:island-is/island.is into j-s/cancel…
gudjong Jun 5, 2024
47afac6
Allows prosecutors to cancel submitted indictments
gudjong Jun 5, 2024
74176d6
Hides buttons when prosecutor has asked for cancellation
gudjong Jun 5, 2024
dbab11d
Adds unit tests
gudjong Jun 5, 2024
971cc83
Updates unit tests
gudjong Jun 5, 2024
9cada7e
Merge branch 'main' of github.com:island-is/island.is into j-s/cancel…
gudjong Jun 7, 2024
29d12ac
Fixes unit tests
gudjong Jun 7, 2024
32f8b76
Rewrite open case
gudjong Jun 7, 2024
2df8f90
Adds modal for cancelling case
gudjong Jun 7, 2024
cdad57d
Fixes back navigation
gudjong Jun 7, 2024
e2497c7
Update apps/judicial-system/web/src/routes/Prosecutor/Indictments/Ove…
gudjong Jun 7, 2024
c783160
Refactors code
gudjong Jun 7, 2024
53c4972
Merge branch 'j-s/cancel-submitted-case' of github.com:island-is/isla…
gudjong Jun 7, 2024
b1309f5
Rewrites condition
gudjong Jun 7, 2024
a82a5af
Merge branch 'j-s/cancel-submitted-case' of github.com:island-is/isla…
gudjong Jun 8, 2024
7fcdd3e
Completes cancellation
gudjong Jun 9, 2024
f07c7fc
Removes obsolete unit tests
gudjong Jun 10, 2024
ecb6b5a
Fixes test helpers
gudjong Jun 10, 2024
42664ca
Merge branch 'main' of github.com:island-is/island.is into j-s/comple…
gudjong Jun 10, 2024
26aa64a
Merge branch 'main' of github.com:island-is/island.is into j-s/cancel…
gudjong Jun 11, 2024
e17266b
Modifies revoked notifications for indictments
gudjong Jun 11, 2024
b37c842
Handles indictment deletion whith no case files
gudjong Jun 13, 2024
a27d5e7
Merge branch 'main' into j-s/cancellation-notifications
gudjong Jun 13, 2024
f6da80e
Merge branch 'main' of github.com:island-is/island.is into j-s/cancel…
gudjong Jun 18, 2024
e88ab2f
Fixes unit test
gudjong Jun 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1666,7 +1666,7 @@ describe('formatDefenderRevokedEmailNotification', () => {

// Assert
expect(res).toBe(
'Krafa um gæsluvarðhald sem taka átti fyrir hjá Héraðsdómi Þingvalla sunnudaginn 24. janúar 2021, kl. 08:15, hefur verið afturkölluð.<br /><br />Sakborningur: Gaui Glæpon, kt. 000000-1111.<br /><br />Dómstóllinn hafði skráð þig sem verjanda í málinu.',
'Krafa um gæsluvarðhald sem taka átti fyrir hjá Héraðsdómi Þingvalla sunnudaginn 24. janúar 2021, kl. 08:15, hefur verið afturkölluð.<br /><br />Sakborningur: Gaui Glæpon, kt. 000000-1111.<br /><br />Dómstóllinn hafði skráð þig sem verjanda/talsmann í málinu.',
)
})

Expand All @@ -1692,7 +1692,7 @@ describe('formatDefenderRevokedEmailNotification', () => {

// Assert
expect(res).toBe(
'Krafa um farbann sem taka átti fyrir hjá Héraðsdómi Þingvalla sunnudaginn 24. janúar 2021, kl. 08:15, hefur verið afturkölluð.<br /><br />Sakborningur: Gaui Glæpon, kt. 111100-1111.<br /><br />Dómstóllinn hafði skráð þig sem verjanda í málinu.',
'Krafa um farbann sem taka átti fyrir hjá Héraðsdómi Þingvalla sunnudaginn 24. janúar 2021, kl. 08:15, hefur verið afturkölluð.<br /><br />Sakborningur: Gaui Glæpon, kt. 111100-1111.<br /><br />Dómstóllinn hafði skráð þig sem verjanda/talsmann í málinu.',
)
})

Expand All @@ -1718,7 +1718,7 @@ describe('formatDefenderRevokedEmailNotification', () => {

// Assert
expect(res).toBe(
'Krafa um vistun á viðeigandi stofnun sem taka átti fyrir hjá ótilgreindum dómstóli á ótilgreindum tíma, hefur verið afturkölluð.<br /><br />Sakborningur: Nafn ekki skráð, kt. ekki skráð.<br /><br />Dómstóllinn hafði skráð þig sem verjanda í málinu.',
'Krafa um vistun á viðeigandi stofnun sem taka átti fyrir hjá ótilgreindum dómstóli á ótilgreindum tíma, hefur verið afturkölluð.<br /><br />Sakborningur: Nafn ekki skráð, kt. ekki skráð.<br /><br />Dómstóllinn hafði skráð þig sem verjanda/talsmann í málinu.',
)
})

Expand All @@ -1744,7 +1744,7 @@ describe('formatDefenderRevokedEmailNotification', () => {

// Assert
expect(res).toBe(
'Krafa um rannsóknarheimild (rof bankaleyndar) sem taka átti fyrir hjá Héraðsdómi Þingvalla sunnudaginn 24. janúar 2021, kl. 08:15, hefur verið afturkölluð.<br /><br />Sakborningur: Gaui Glæpon, kt. 111100-1111.<br /><br />Dómstóllinn hafði skráð þig sem verjanda í málinu.',
'Krafa um rannsóknarheimild (rof bankaleyndar) sem taka átti fyrir hjá Héraðsdómi Þingvalla sunnudaginn 24. janúar 2021, kl. 08:15, hefur verið afturkölluð.<br /><br />Sakborningur: Gaui Glæpon, kt. 111100-1111.<br /><br />Dómstóllinn hafði skráð þig sem verjanda/talsmann í málinu.',
)
})

Expand All @@ -1770,33 +1770,7 @@ describe('formatDefenderRevokedEmailNotification', () => {

// Assert
expect(res).toBe(
'Krafa um rannsóknarheimild sem taka átti fyrir hjá Héraðsdómi Þingvalla sunnudaginn 24. janúar 2021, kl. 08:15, hefur verið afturkölluð.<br /><br />Sakborningur: Gaui Glæpon, fd. 01.01.2022.<br /><br />Dómstóllinn hafði skráð þig sem verjanda í málinu.',
)
})

test('should format revoked notification for indictments', () => {
// Arrange
const type = CaseType.INDICTMENT
const defendantNationalId = '01.01.2022'
const defendantName = 'Gaui Glæpon'
const defendantNoNationalId = true
const court = 'Héraðsdómur Þingvalla'
const courtDate = new Date('2021-01-24T08:15')

// Act
const res = formatDefenderRevokedEmailNotification(
formatMessage,
type,
defendantNationalId,
defendantName,
defendantNoNationalId,
court,
courtDate,
)

// Assert
expect(res).toBe(
'Ákæra sem taka átti fyrir hjá Héraðsdómi Þingvalla sunnudaginn 24. janúar 2021, kl. 08:15, hefur verið afturkölluð.<br /><br />Sakborningur: Gaui Glæpon, fd. 01.01.2022.<br /><br />Dómstóllinn hafði skráð þig sem verjanda í málinu.',
'Krafa um rannsóknarheimild sem taka átti fyrir hjá Héraðsdómi Þingvalla sunnudaginn 24. janúar 2021, kl. 08:15, hefur verið afturkölluð.<br /><br />Sakborningur: Gaui Glæpon, fd. 01.01.2022.<br /><br />Dómstóllinn hafði skráð þig sem verjanda/talsmann í málinu.',
)
})
})
Expand Down
29 changes: 12 additions & 17 deletions apps/judicial-system/backend/src/app/formatters/formatters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -594,22 +594,17 @@ export const formatDefenderRevokedEmailNotification = (
?.replace(' kl.', ', kl.')
: 'NONE',
})
const revokedText = isIndictmentCase(type)
? formatMessage(cf.revokedIndictment, {
courtText,
courtDateText,
})
: formatMessage(cf.revoked, {
courtText,
courtDateText,
investigationPrefix:
type === CaseType.OTHER
? 'onlyPrefix'
: isInvestigationCase(type)
? 'withPrefix'
: 'noPrefix',
courtTypeName: formatCaseType(type),
})
const revokedText = formatMessage(cf.revoked, {
courtText,
courtDateText,
investigationPrefix:
type === CaseType.OTHER
? 'onlyPrefix'
: isInvestigationCase(type)
? 'withPrefix'
: 'noPrefix',
courtTypeName: formatCaseType(type),
})
const defendantNationalIdText = defendantNoNationalId
? defendantNationalId || 'NONE'
: formatNationalId(defendantNationalId || 'NONE')
Expand All @@ -618,7 +613,7 @@ export const formatDefenderRevokedEmailNotification = (
defendantNationalId: defendantNationalIdText,
defendantNoNationalId: defendantNoNationalId ? 'NONE' : 'SOME',
})
const defenderAssignedText = formatMessage(cf.defenderAssignedV2)
const defenderAssignedText = formatMessage(cf.defenderAssigned)

return formatMessage(cf.body, {
revokedText,
Expand Down
47 changes: 30 additions & 17 deletions apps/judicial-system/backend/src/app/messages/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -529,23 +529,17 @@ export const notifications = {
description:
'Texti í pósti til verjanda/talsmanns sem tilgreinir að krafa sé afturkölluð',
},
revokedIndictment: {
id: 'judicial.system.backend:notifications.defender_revoked_email.revoked_indictment',
defaultMessage:
'Ákæra sem taka átti fyrir hjá {courtText} {courtDateText}, hefur verið afturkölluð.',
description:
'Texti í pósti til verjanda/talsmanns sem tilgreinir að ákæra sé afturkölluð',
},
defendant: {
id: 'judicial.system.backend:notifications.defender_revoked_email.defendant',
defaultMessage:
'Sakborningur: {defendantName, select, NONE {Nafn ekki skráð} other {{defendantName}}}{defendantNoNationalId, select, NONE {{defendantNationalId, select, NONE {} other {, fd. {defendantNationalId}}}} other {, kt. {defendantNationalId, select, NONE {ekki skráð} other {{defendantNationalId}}}}}.',
description:
'Texti í pósti til verjanda/talsmanns sem tilgreinir sakborning',
},
defenderAssignedV2: {
id: 'judicial.system.backend:notifications.defender_revoked_email.defender_assigned_v2',
defaultMessage: 'Dómstóllinn hafði skráð þig sem verjanda í málinu.',
defenderAssigned: {
id: 'judicial.system.backend:notifications.defender_revoked_email.defender_assigned_v3',
defaultMessage:
'Dómstóllinn hafði skráð þig sem verjanda/talsmann í málinu.',
description:
'Texti í pósti til verjanda/talsmanns sem tilgreinir að viðkomandi sé skráður verjandi',
},
Expand All @@ -563,11 +557,17 @@ export const notifications = {
description:
'Fyrirsögn í pósti til verjanda/talsmanns þegar krafa er afturkölluð',
},
indictmentSubject: {
id: 'judicial.system.backend:notifications.defender_revoked_email.indictment_subject',
defaultMessage: 'Ákæra afturkölluð',
indictmentBody: {
id: 'judicial.system.backend:notifications.defender_revoked_email.body_indictment',
defaultMessage:
'Dómstóllinn hafði skráð þig sem verjanda í málinu.<br /><br />{defenderHasAccessToRvg, select, true {Sjá nánar á {linkStart}yfirlitssíðu málsins í Réttarvörslugátt{linkEnd}} other {Þú getur nálgast gögn málsins hjá {courtName} ef þau hafa ekki þegar verið afhent}}.',
description:
'Fyrirsögn í pósti til verjanda/talsmanns þegar ákæra er afturkölluð',
'Notaður sem beinagrind á pósti til verjanda þegar ákæra er afturkölluð',
},
indictmentSubject: {
id: 'judicial.system.backend:notifications.defender_revoked_email.indictment_subject_v2',
defaultMessage: 'Ákæra afturkölluð í máli {courtCaseNumber}',
description: 'Fyrirsögn í pósti til verjanda þegar ákæra er afturkölluð',
},
}),
modified: defineMessages({
Expand All @@ -586,9 +586,9 @@ export const notifications = {
'Notaður sem texti í tölvupósti vegna breytingar á lengd gæslu/farbanns/vistunar þar sem ekki var úrskurðað í einangrun.',
},
htmlDefender: {
id: 'judicial.system.backend:notifications.modified.html_defender',
id: 'judicial.system.backend:notifications.modified.html_defender_v2',
defaultMessage:
'{actorInstitution}, {actorName} {actorTitle}, hefur uppfært lengd {caseType, select, ADMISSION_TO_FACILITY {vistunar} TRAVEL_BAN {farbanns} other {gæsluvarðhalds}} í máli {courtCaseNumber}. <br /><br />{defenderHasAccessToRvg, select, true {Sjá nánar á {linkStart}yfirlitssíðu málsins í Réttarvörslugátt{linkEnd}} other {Þú getur nálgast gögn málsins hjá {courtName} ef þau hafa ekki þegar verið afhent}}.<br /><br />Ný lokadagsetning: {validToDate}.',
'{actorInstitution}, {actorName} {actorTitle}, hefur uppfært lengd {caseType, select, ADMISSION_TO_FACILITY {vistunar} TRAVEL_BAN {farbanns} other {gæsluvarðhalds}} í máli {courtCaseNumber}.<br /><br />{defenderHasAccessToRvg, select, true {Sjá nánar á {linkStart}yfirlitssíðu málsins í Réttarvörslugátt{linkEnd}} other {Þú getur nálgast gögn málsins hjá {courtName} ef þau hafa ekki þegar verið afhent}}.<br /><br />Ný lokadagsetning: {validToDate}.',
gudjong marked this conversation as resolved.
Show resolved Hide resolved
description:
'Notaður sem texti í tölvupósti til verjanda vegna breytingar á lengd gæslu/farbanns/vistunar þar sem ekki var úrskurðað í einangrun.',
},
Expand Down Expand Up @@ -769,7 +769,6 @@ export const notifications = {
description: 'Texti í pósti til aðila máls þegar kæra er afturkölluð',
},
}),

emailNames: defineMessages({
prison: {
id: 'judicial.system.backend:notifications.email_names.prison',
Expand Down Expand Up @@ -834,4 +833,18 @@ export const notifications = {
description: 'Texti í pósti til sækjanda máls þegar ákæra er endursend',
},
}),
courtRevokedIndictmentEmail: defineMessages({
subject: {
id: 'judicial.system.backend:notifications.court_revoked_indictment_email.subject',
defaultMessage:
'Ákæra afturkölluð{courtCaseNumber, select, NONE {} other { í máli {courtCaseNumber}}}',
description: 'Fyrirsögn í pósti til dómstóls þegar ákæra er afturkölluð',
},
body: {
id: 'judicial.system.backend:notifications.court_revoked_indictment_email.body',
defaultMessage:
'{prosecutorsOffice} hefur afturkallað ákæru {courtCaseNumber, select, NONE {í máli sem ekki hefur enn fengið málsnúmer} other {í máli {courtCaseNumber}}}.',
description: 'Texti í pósti til dómstóls þegar ákæra er afturkölluð',
},
}),
}
42 changes: 31 additions & 11 deletions apps/judicial-system/backend/src/app/modules/case/case.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -835,20 +835,33 @@ export class CaseService {
return this.messageService.sendMessagesToQueue(messages)
}

private addMessagesForDeletedCaseToQueue(
theCase: Case,
user: TUser,
): Promise<void> {
const messages: CaseMessage[] = [
private getRevokeMessages(user: TUser, theCase: Case): CaseMessage[] {
return [
{
type: MessageType.NOTIFICATION,
user,
caseId: theCase.id,
body: { type: NotificationType.REVOKED },
},
]
}

return this.messageService.sendMessagesToQueue(messages)
private addMessagesForDeletedCaseToQueue(
theCase: Case,
user: TUser,
): Promise<void> {
return this.messageService.sendMessagesToQueue(
this.getRevokeMessages(user, theCase),
)
}

private addMessagesForRevokedIndictmentCaseToQueue(
theCase: Case,
user: TUser,
): Promise<void> {
return this.messageService.sendMessagesToQueue(
this.getRevokeMessages(user, theCase),
)
}

private async addMessagesForAppealedCaseToQueue(
Expand Down Expand Up @@ -1077,6 +1090,7 @@ export class CaseService {
user: TUser,
): Promise<void> {
const isIndictment = isIndictmentCase(updatedCase.type)

if (updatedCase.state !== theCase.state) {
// New case state
if (
Expand All @@ -1086,13 +1100,17 @@ export class CaseService {
// Only send messages if the case was in a SUBMITTED state - not when reopening a case
await this.addMessagesForReceivedCaseToQueue(updatedCase, user)
} else if (updatedCase.state === CaseState.DELETED) {
await this.addMessagesForDeletedCaseToQueue(updatedCase, user)
if (!isIndictment) {
await this.addMessagesForDeletedCaseToQueue(updatedCase, user)
}
} else if (isCompletedCase(updatedCase.state)) {
if (isIndictment) {
await this.addMessagesForCompletedIndictmentCaseToQueue(
updatedCase,
user,
)
if (theCase.state !== CaseState.WAITING_FOR_CANCELLATION) {
await this.addMessagesForCompletedIndictmentCaseToQueue(
updatedCase,
user,
)
}
} else {
await this.addMessagesForCompletedCaseToQueue(updatedCase, user)
}
Expand All @@ -1116,6 +1134,8 @@ export class CaseService {
updatedCase,
user,
)
} else if (updatedCase.state === CaseState.WAITING_FOR_CANCELLATION) {
await this.addMessagesForRevokedIndictmentCaseToQueue(updatedCase, user)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,10 @@ describe('CaseController - Transition', () => {
},
],
)
} else if (newState === CaseState.DELETED) {
} else if (
newState === CaseState.DELETED &&
!isIndictmentCase(theCase.type)
) {
expect(mockMessageService.sendMessagesToQueue).toHaveBeenCalledWith(
[
{
Expand Down Expand Up @@ -505,6 +508,23 @@ describe('CaseController - Transition', () => {
},
],
)
} else if (
newState === CaseState.WAITING_FOR_CANCELLATION &&
isIndictmentCase(theCase.type)
) {
expect(mockMessageService.sendMessagesToQueue).toHaveBeenCalledWith(
[
{
type: MessageType.NOTIFICATION,
user: {
...defaultUser,
canConfirmIndictment: isIndictmentCase(theCase.type),
},
caseId,
body: { type: NotificationType.REVOKED },
},
],
)
} else {
expect(
mockMessageService.sendMessagesToQueue,
Expand Down
Loading
Loading