From e935493c7629b63a0f1a071f1921a45a4283a7fc Mon Sep 17 00:00:00 2001 From: unakb Date: Wed, 25 Sep 2024 22:52:28 +0000 Subject: [PATCH 01/23] fix(j-s): Civil claimant view for courts --- .../defendant/civilClaimant.controller.ts | 18 ++- .../pages/domur/akaera/malflytjendur/[id].ts | 4 +- .../Advocates/Advocates.strings.ts | 58 +++++++++ .../Defender.tsx => Advocates/Advocates.tsx} | 29 ++++- .../Advocates/SelectCivilClaimantAdvocate.tsx | 121 ++++++++++++++++++ .../SelectDefender.tsx | 4 +- .../Indictments/Defender/Defender.strings.ts | 28 ---- 7 files changed, 220 insertions(+), 42 deletions(-) create mode 100644 apps/judicial-system/web/src/routes/Court/Indictments/Advocates/Advocates.strings.ts rename apps/judicial-system/web/src/routes/Court/Indictments/{Defender/Defender.tsx => Advocates/Advocates.tsx} (73%) create mode 100644 apps/judicial-system/web/src/routes/Court/Indictments/Advocates/SelectCivilClaimantAdvocate.tsx rename apps/judicial-system/web/src/routes/Court/Indictments/{Defender => Advocates}/SelectDefender.tsx (96%) delete mode 100644 apps/judicial-system/web/src/routes/Court/Indictments/Defender/Defender.strings.ts diff --git a/apps/judicial-system/backend/src/app/modules/defendant/civilClaimant.controller.ts b/apps/judicial-system/backend/src/app/modules/defendant/civilClaimant.controller.ts index 58cff3c4941b..a16608e8290f 100644 --- a/apps/judicial-system/backend/src/app/modules/defendant/civilClaimant.controller.ts +++ b/apps/judicial-system/backend/src/app/modules/defendant/civilClaimant.controller.ts @@ -19,7 +19,11 @@ import { RolesRules, } from '@island.is/judicial-system/auth' -import { prosecutorRepresentativeRule, prosecutorRule } from '../../guards' +import { + districtCourtJudgeRule, + prosecutorRepresentativeRule, + prosecutorRule, +} from '../../guards' import { Case, CaseExistsGuard, CaseWriteGuard, CurrentCase } from '../case' import { UpdateCivilClaimantDto } from './dto/updateCivilClaimant.dto' import { CivilClaimant } from './models/civilClaimant.model' @@ -36,7 +40,11 @@ export class CivilClaimantController { ) {} @UseGuards(CaseExistsGuard, CaseWriteGuard) - @RolesRules(prosecutorRule, prosecutorRepresentativeRule) + @RolesRules( + prosecutorRule, + prosecutorRepresentativeRule, + districtCourtJudgeRule, + ) @Post() @ApiCreatedResponse({ type: CivilClaimant, @@ -52,7 +60,11 @@ export class CivilClaimantController { } @UseGuards(CaseExistsGuard, CaseWriteGuard) - @RolesRules(prosecutorRule, prosecutorRepresentativeRule) + @RolesRules( + prosecutorRule, + prosecutorRepresentativeRule, + districtCourtJudgeRule, + ) @Patch(':civilClaimantId') @ApiOkResponse({ type: CivilClaimant, diff --git a/apps/judicial-system/web/pages/domur/akaera/malflytjendur/[id].ts b/apps/judicial-system/web/pages/domur/akaera/malflytjendur/[id].ts index 4bf36a18f264..e686009b01a2 100644 --- a/apps/judicial-system/web/pages/domur/akaera/malflytjendur/[id].ts +++ b/apps/judicial-system/web/pages/domur/akaera/malflytjendur/[id].ts @@ -1,3 +1,3 @@ -import HearingArrangements from '@island.is/judicial-system-web/src/routes/Court/Indictments/Defender/Defender' +import Advocates from '@island.is/judicial-system-web/src/routes/Court/Indictments/Advocates/Advocates' -export default HearingArrangements +export default Advocates diff --git a/apps/judicial-system/web/src/routes/Court/Indictments/Advocates/Advocates.strings.ts b/apps/judicial-system/web/src/routes/Court/Indictments/Advocates/Advocates.strings.ts new file mode 100644 index 000000000000..85454f8fa906 --- /dev/null +++ b/apps/judicial-system/web/src/routes/Court/Indictments/Advocates/Advocates.strings.ts @@ -0,0 +1,58 @@ +import { defineMessages } from 'react-intl' + +export const strings = defineMessages({ + title: { + id: 'judicial.system.core:court_indictments.defender.title_v1', + defaultMessage: 'Verjandi', + description: + 'Notaður sem titill á síðu á verjenda skrefi í dómaraflæði í ákærum.', + }, + alertBannerText: { + id: 'judicial.system.core:court_indictments.defender.alert_banner_text_v1', + defaultMessage: + 'Verjendur í sakamálum fá tilkynningu um skráningu í tölvupósti, aðgang að gögnum málsins og boð í þingfestingu.', + description: + 'Notaður sem texti í alert banner á málflytjendurskjá í ákærum.', + }, + selectDefenderHeading: { + id: 'judicial.system.core:court_indictments.defender.select_defender_heading_v1', + defaultMessage: 'Verjandi', + description: 'Notaður sem texti fyrir val á skipaðan verjanda í ákærum.', + }, + defendantWaivesRightToCounsel: { + id: 'judicial.system.core:court_indictments.defender.defendant_waives_right_to_counsel', + defaultMessage: '{accused} óskar ekki eftir að sér sé skipaður verjandi', + description: + 'Notaður sem texti fyrir takka þegar ákærðu óska ekki eftir verjanda í dómaraflæði í ákærum. ', + }, + civilClaimants: { + id: 'judicial.system.core:court_indictments.defender.civil_claimants', + defaultMessage: 'Kröfuhafar', + description: + 'Notaður sem titill á texta um kröfuhafa í dómaraflæði í ákærum.', + }, + shareFilesWithCivilClaimantAdvocate: { + id: 'judicial.system.core:court_indictments.defender.civil_claimant_share_files_with_advocate', + defaultMessage: + 'Deila gögnum með {defenderIsLawyer, select, true {lögmanni} other {réttargæslumanni}} kröfuhafa', + description: 'Notaður sem texti á deila kröfum með kröfuhafa takka.', + }, + shareFilesWithCivilClaimantAdvocateTooltip: { + id: 'judicial.system.core:court_indictments.defender.civil_claimant_share_files_with_advocate_tooltip', + defaultMessage: + 'Ef hakað er í þennan reit fær {defenderIsLawyer, select, true {lögmaður} other {réttargæslumaður}} kröfuhafa aðgang að gögnum málsins', + description: + 'Notaður sem texti í tooltip á deila kröfum með kröfuhafa takka.', + }, + lawyer: { + id: 'judicial.system.core:court_indictments.defender.lawyer', + defaultMessage: 'Lögmaður', + description: 'Notaður sem texti fyrir lögmann í dómaraflæði í ákærum.', + }, + legalRightsProtector: { + id: 'judicial.system.core:court_indictments.defender.legal_rights_protector', + defaultMessage: 'Réttargæslumaður', + description: + 'Notaður sem texti fyrir réttargæslumann í dómaraflæði í ákærum.', + }, +}) diff --git a/apps/judicial-system/web/src/routes/Court/Indictments/Defender/Defender.tsx b/apps/judicial-system/web/src/routes/Court/Indictments/Advocates/Advocates.tsx similarity index 73% rename from apps/judicial-system/web/src/routes/Court/Indictments/Defender/Defender.tsx rename to apps/judicial-system/web/src/routes/Court/Indictments/Advocates/Advocates.tsx index a629abf8760a..707e71ab1685 100644 --- a/apps/judicial-system/web/src/routes/Court/Indictments/Defender/Defender.tsx +++ b/apps/judicial-system/web/src/routes/Court/Indictments/Advocates/Advocates.tsx @@ -20,10 +20,11 @@ import { NotificationType } from '@island.is/judicial-system-web/src/graphql/sch import { useCase } from '@island.is/judicial-system-web/src/utils/hooks' import { isDefenderStepValid } from '@island.is/judicial-system-web/src/utils/validate' +import SelectCivilClaimantAdvocate from './SelectCivilClaimantAdvocate' import SelectDefender from './SelectDefender' -import { defender as m } from './Defender.strings' +import { strings } from './Advocates.strings' -const HearingArrangements = () => { +const Advocates = () => { const { workingCase, isLoadingWorkingCase, caseNotFound } = useContext(FormContext) const router = useRouter() @@ -39,6 +40,7 @@ const HearingArrangements = () => { ) const stepIsValid = !isSendingNotification && isDefenderStepValid(workingCase) + const hasCivilClaimants = (workingCase.civilClaimants?.length ?? 0) > 0 return ( { > - {formatMessage(m.title)} + {formatMessage(strings.title)} - + {workingCase.defendants?.map((defendant, index) => ( ))} + {hasCivilClaimants && ( + + + {workingCase.civilClaimants?.map((civilClaimant, index) => ( + + + + ))} + + )} { ) } -export default HearingArrangements +export default Advocates diff --git a/apps/judicial-system/web/src/routes/Court/Indictments/Advocates/SelectCivilClaimantAdvocate.tsx b/apps/judicial-system/web/src/routes/Court/Indictments/Advocates/SelectCivilClaimantAdvocate.tsx new file mode 100644 index 000000000000..3c3aa43e3d4f --- /dev/null +++ b/apps/judicial-system/web/src/routes/Court/Indictments/Advocates/SelectCivilClaimantAdvocate.tsx @@ -0,0 +1,121 @@ +import { FC, useContext } from 'react' +import { useIntl } from 'react-intl' + +import { Box, Checkbox, RadioButton, Text } from '@island.is/island-ui/core' +import { + BlueBox, + FormContext, + InputAdvocate, +} from '@island.is/judicial-system-web/src/components' +import { + CivilClaimant, + UpdateCivilClaimantInput, +} from '@island.is/judicial-system-web/src/graphql/schema' +import { useCivilClaimants } from '@island.is/judicial-system-web/src/utils/hooks' + +import { strings } from './Advocates.strings' + +interface Props { + civilClaimant: CivilClaimant +} + +const SelectCivilClaimantAdvocate: FC = ({ civilClaimant }) => { + const { setAndSendCivilClaimantToServer } = useCivilClaimants() + const { workingCase, setWorkingCase } = useContext(FormContext) + + const { formatMessage } = useIntl() + + const updateCivilClaimant = (update: UpdateCivilClaimantInput) => { + setAndSendCivilClaimantToServer( + { + ...update, + caseId: workingCase.id, + civilClaimantId: civilClaimant.id, + }, + setWorkingCase, + ) + } + + return ( + + + {civilClaimant.name} + + + + + updateCivilClaimant({ + spokespersonIsLawyer: true, + } as UpdateCivilClaimantInput) + } + /> + + + + updateCivilClaimant({ + spokespersonIsLawyer: false, + } as UpdateCivilClaimantInput) + } + /> + + + + + + { + updateCivilClaimant({ + caseFilesSharedWithSpokesperson: + !civilClaimant.caseFilesSharedWithSpokesperson, + } as UpdateCivilClaimantInput) + }} + tooltip={formatMessage( + strings.shareFilesWithCivilClaimantAdvocateTooltip, + { + defenderIsLawyer: civilClaimant.spokespersonIsLawyer, + }, + )} + backgroundColor="white" + large + filled + /> + + ) +} + +export default SelectCivilClaimantAdvocate diff --git a/apps/judicial-system/web/src/routes/Court/Indictments/Defender/SelectDefender.tsx b/apps/judicial-system/web/src/routes/Court/Indictments/Advocates/SelectDefender.tsx similarity index 96% rename from apps/judicial-system/web/src/routes/Court/Indictments/Defender/SelectDefender.tsx rename to apps/judicial-system/web/src/routes/Court/Indictments/Advocates/SelectDefender.tsx index 824cca080df2..15b455791e48 100644 --- a/apps/judicial-system/web/src/routes/Court/Indictments/Defender/SelectDefender.tsx +++ b/apps/judicial-system/web/src/routes/Court/Indictments/Advocates/SelectDefender.tsx @@ -16,7 +16,7 @@ import { } from '@island.is/judicial-system-web/src/graphql/schema' import { useDefendants } from '@island.is/judicial-system-web/src/utils/hooks' -import { defender as m } from './Defender.strings' +import { strings } from './Advocates.strings' interface Props { defendant: Defendant @@ -80,7 +80,7 @@ const SelectDefender: FC = ({ defendant }) => { dataTestId={`defendantWaivesRightToCounsel-${defendant.id}`} name={`defendantWaivesRightToCounsel-${defendant.id}`} label={capitalize( - formatMessage(m.defendantWaivesRightToCounsel, { + formatMessage(strings.defendantWaivesRightToCounsel, { accused: formatMessage(core.indictmentDefendant, { gender }), }), )} diff --git a/apps/judicial-system/web/src/routes/Court/Indictments/Defender/Defender.strings.ts b/apps/judicial-system/web/src/routes/Court/Indictments/Defender/Defender.strings.ts deleted file mode 100644 index 2c6984795367..000000000000 --- a/apps/judicial-system/web/src/routes/Court/Indictments/Defender/Defender.strings.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { defineMessages } from 'react-intl' - -export const defender = defineMessages({ - title: { - id: 'judicial.system.core:court_indictments.defender.title_v1', - defaultMessage: 'Verjandi', - description: - 'Notaður sem titill á síðu á verjenda skrefi í dómaraflæði í ákærum.', - }, - alertBannerText: { - id: 'judicial.system.core:court_indictments.defender.alert_banner_text_v1', - defaultMessage: - 'Verjendur í sakamálum fá tilkynningu um skráningu í tölvupósti, aðgang að gögnum málsins og boð í þingfestingu.', - description: - 'Notaður sem texti í alert banner á málflytjendurskjá í ákærum.', - }, - selectDefenderHeading: { - id: 'judicial.system.core:court_indictments.defender.select_defender_heading_v1', - defaultMessage: 'Verjandi', - description: 'Notaður sem texti fyrir val á skipaðan verjanda í ákærum.', - }, - defendantWaivesRightToCounsel: { - id: 'judicial.system.core:court_indictments.defender.defendant_waives_right_to_counsel', - defaultMessage: '{accused} óskar ekki eftir að sér sé skipaður verjandi', - description: - 'Notaður sem texti fyrir takka þegar ákærðu óska ekki eftir verjanda í dómaraflæði í ákærum. ', - }, -}) From 8e17b19f59e5c89e9c9b82277305f90ddd1c4d12 Mon Sep 17 00:00:00 2001 From: unakb Date: Thu, 26 Sep 2024 13:51:31 +0000 Subject: [PATCH 02/23] feat(j-s): Judge can add and remove advocates --- .../Advocates/Advocates.strings.ts | 37 +++- .../Advocates/SelectCivilClaimantAdvocate.tsx | 177 +++++++++++------- 2 files changed, 137 insertions(+), 77 deletions(-) diff --git a/apps/judicial-system/web/src/routes/Court/Indictments/Advocates/Advocates.strings.ts b/apps/judicial-system/web/src/routes/Court/Indictments/Advocates/Advocates.strings.ts index 85454f8fa906..1250e9fa97b9 100644 --- a/apps/judicial-system/web/src/routes/Court/Indictments/Advocates/Advocates.strings.ts +++ b/apps/judicial-system/web/src/routes/Court/Indictments/Advocates/Advocates.strings.ts @@ -2,57 +2,76 @@ import { defineMessages } from 'react-intl' export const strings = defineMessages({ title: { - id: 'judicial.system.core:court_indictments.defender.title_v1', + id: 'judicial.system.core:court_indictments.advocates.title', defaultMessage: 'Verjandi', description: 'Notaður sem titill á síðu á verjenda skrefi í dómaraflæði í ákærum.', }, alertBannerText: { - id: 'judicial.system.core:court_indictments.defender.alert_banner_text_v1', + id: 'judicial.system.core:court_indictments.advocates.alert_banner_text', defaultMessage: 'Verjendur í sakamálum fá tilkynningu um skráningu í tölvupósti, aðgang að gögnum málsins og boð í þingfestingu.', description: 'Notaður sem texti í alert banner á málflytjendurskjá í ákærum.', }, selectDefenderHeading: { - id: 'judicial.system.core:court_indictments.defender.select_defender_heading_v1', + id: 'judicial.system.core:court_indictments.advocates.select_defender_heading', defaultMessage: 'Verjandi', description: 'Notaður sem texti fyrir val á skipaðan verjanda í ákærum.', }, defendantWaivesRightToCounsel: { - id: 'judicial.system.core:court_indictments.defender.defendant_waives_right_to_counsel', + id: 'judicial.system.core:court_indictments.advocates.defendant_waives_right_to_counsel', defaultMessage: '{accused} óskar ekki eftir að sér sé skipaður verjandi', description: 'Notaður sem texti fyrir takka þegar ákærðu óska ekki eftir verjanda í dómaraflæði í ákærum. ', }, civilClaimants: { - id: 'judicial.system.core:court_indictments.defender.civil_claimants', + id: 'judicial.system.core:court_indictments.advocates.civil_claimants', defaultMessage: 'Kröfuhafar', description: 'Notaður sem titill á texta um kröfuhafa í dómaraflæði í ákærum.', }, shareFilesWithCivilClaimantAdvocate: { - id: 'judicial.system.core:court_indictments.defender.civil_claimant_share_files_with_advocate', + id: 'judicial.system.core:court_indictments.advocates.civil_claimant_share_files_with_advocate', defaultMessage: 'Deila gögnum með {defenderIsLawyer, select, true {lögmanni} other {réttargæslumanni}} kröfuhafa', description: 'Notaður sem texti á deila kröfum með kröfuhafa takka.', }, shareFilesWithCivilClaimantAdvocateTooltip: { - id: 'judicial.system.core:court_indictments.defender.civil_claimant_share_files_with_advocate_tooltip', + id: 'judicial.system.core:court_indictments.advocates.civil_claimant_share_files_with_advocate_tooltip', defaultMessage: 'Ef hakað er í þennan reit fær {defenderIsLawyer, select, true {lögmaður} other {réttargæslumaður}} kröfuhafa aðgang að gögnum málsins', description: 'Notaður sem texti í tooltip á deila kröfum með kröfuhafa takka.', }, lawyer: { - id: 'judicial.system.core:court_indictments.defender.lawyer', + id: 'judicial.system.core:court_indictments.advocates.lawyer', defaultMessage: 'Lögmaður', description: 'Notaður sem texti fyrir lögmann í dómaraflæði í ákærum.', }, legalRightsProtector: { - id: 'judicial.system.core:court_indictments.defender.legal_rights_protector', + id: 'judicial.system.core:court_indictments.advocates.legal_rights_protector', defaultMessage: 'Réttargæslumaður', description: 'Notaður sem texti fyrir réttargæslumann í dómaraflæði í ákærum.', }, + removeCivilClaimantAdvocate: { + id: 'judicial.system.core:court_indictments.advocates.remove_civil_claimant_advocate', + defaultMessage: + 'Fjarlægja {defenderIsLawyer, select, true {lögmann} other {réttargæslumann}}', + description: + 'Notaður sem texti fyrir eyða kröfuhafa í dómaraflæði í ákærum.', + }, + addCivilClaimantAdvocate: { + id: 'judicial.system.core:court_indictments.advocates.add_civil_claimant', + defaultMessage: 'Bæta við lögmanni kröfuhafa', + description: + 'Notaður sem texti fyrir bæta við kröfuhafa takka í dómaraflæði í ákærum.', + }, + noCivilClaimantAdvocate: { + id: 'judicial.system.core:court_indictments.advocates.no_civil_claimant_advocate', + defaultMessage: 'Enginn lögmaður skráður', + description: + 'Notaður sem texti þegar enginn lögmaður er skráður í dómaraflæði í ákærum.', + }, }) diff --git a/apps/judicial-system/web/src/routes/Court/Indictments/Advocates/SelectCivilClaimantAdvocate.tsx b/apps/judicial-system/web/src/routes/Court/Indictments/Advocates/SelectCivilClaimantAdvocate.tsx index 3c3aa43e3d4f..c79fb2078f01 100644 --- a/apps/judicial-system/web/src/routes/Court/Indictments/Advocates/SelectCivilClaimantAdvocate.tsx +++ b/apps/judicial-system/web/src/routes/Court/Indictments/Advocates/SelectCivilClaimantAdvocate.tsx @@ -1,7 +1,14 @@ import { FC, useContext } from 'react' import { useIntl } from 'react-intl' -import { Box, Checkbox, RadioButton, Text } from '@island.is/island-ui/core' +import { + AlertMessage, + Box, + Button, + Checkbox, + RadioButton, + Text, +} from '@island.is/island-ui/core' import { BlueBox, FormContext, @@ -41,79 +48,113 @@ const SelectCivilClaimantAdvocate: FC = ({ civilClaimant }) => { {civilClaimant.name} - - - - updateCivilClaimant({ - spokespersonIsLawyer: true, - } as UpdateCivilClaimantInput) + {civilClaimant.hasSpokesperson ? ( + <> + + + + updateCivilClaimant({ + spokespersonIsLawyer: true, + } as UpdateCivilClaimantInput) + } + /> + + + + updateCivilClaimant({ + spokespersonIsLawyer: false, + } as UpdateCivilClaimantInput) + } + /> + + + + + + - - - + onChange={() => { updateCivilClaimant({ - spokespersonIsLawyer: false, + caseFilesSharedWithSpokesperson: + !civilClaimant.caseFilesSharedWithSpokesperson, } as UpdateCivilClaimantInput) - } + }} + tooltip={formatMessage( + strings.shareFilesWithCivilClaimantAdvocateTooltip, + { + defenderIsLawyer: civilClaimant.spokespersonIsLawyer, + }, + )} + backgroundColor="white" + large + filled /> - - - - + ) : ( + + )} + + - { - updateCivilClaimant({ - caseFilesSharedWithSpokesperson: - !civilClaimant.caseFilesSharedWithSpokesperson, - } as UpdateCivilClaimantInput) - }} - tooltip={formatMessage( - strings.shareFilesWithCivilClaimantAdvocateTooltip, - { - defenderIsLawyer: civilClaimant.spokespersonIsLawyer, - }, - )} - backgroundColor="white" - large - filled - /> ) } From 1a358c8f8edc0058b67e99d3709ea27147d03f03 Mon Sep 17 00:00:00 2001 From: unakb Date: Thu, 26 Sep 2024 15:21:35 +0000 Subject: [PATCH 03/23] Update civilClaimant.controller.ts --- .../src/app/modules/defendant/civilClaimant.controller.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/judicial-system/backend/src/app/modules/defendant/civilClaimant.controller.ts b/apps/judicial-system/backend/src/app/modules/defendant/civilClaimant.controller.ts index a16608e8290f..439904735d4e 100644 --- a/apps/judicial-system/backend/src/app/modules/defendant/civilClaimant.controller.ts +++ b/apps/judicial-system/backend/src/app/modules/defendant/civilClaimant.controller.ts @@ -20,7 +20,9 @@ import { } from '@island.is/judicial-system/auth' import { + districtCourtAssistantRule, districtCourtJudgeRule, + districtCourtRegistrarRule, prosecutorRepresentativeRule, prosecutorRule, } from '../../guards' @@ -44,6 +46,8 @@ export class CivilClaimantController { prosecutorRule, prosecutorRepresentativeRule, districtCourtJudgeRule, + districtCourtRegistrarRule, + districtCourtAssistantRule, ) @Post() @ApiCreatedResponse({ @@ -64,6 +68,8 @@ export class CivilClaimantController { prosecutorRule, prosecutorRepresentativeRule, districtCourtJudgeRule, + districtCourtRegistrarRule, + districtCourtAssistantRule, ) @Patch(':civilClaimantId') @ApiOkResponse({ From a4d7153e8cd5e2187cdc27b26f389ec5d6d407db Mon Sep 17 00:00:00 2001 From: unakb Date: Thu, 3 Oct 2024 08:55:46 +0000 Subject: [PATCH 04/23] Fixed key on Box --- .../src/routes/Court/Indictments/Advocates/Advocates.tsx | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/apps/judicial-system/web/src/routes/Court/Indictments/Advocates/Advocates.tsx b/apps/judicial-system/web/src/routes/Court/Indictments/Advocates/Advocates.tsx index 707e71ab1685..ffdba0747338 100644 --- a/apps/judicial-system/web/src/routes/Court/Indictments/Advocates/Advocates.tsx +++ b/apps/judicial-system/web/src/routes/Court/Indictments/Advocates/Advocates.tsx @@ -72,12 +72,9 @@ const Advocates = () => { {hasCivilClaimants && ( - {workingCase.civilClaimants?.map((civilClaimant, index) => ( - - + {workingCase.civilClaimants?.map((civilClaimant) => ( + + ))} From 5b9bdea88d6a211af833a56bf854a7a742fdabb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8Dvar=20Oddsson?= Date: Thu, 3 Oct 2024 21:42:10 +0000 Subject: [PATCH 05/23] Change DEFENDER_ASSIGNED to ADVOCATE_ASSIGNED --- .../20241003213354-update-notification.js | 66 +++++++++++++++++++ .../modules/notification/guards/rolesRules.ts | 6 +- .../internalNotification.service.ts | 10 +-- .../notification/notification.service.ts | 4 +- .../sendDefenderAssignedNotifications.spec.ts | 20 +++--- .../sendCourtDateNotification.spec.ts | 2 +- .../sendDefenderAssignedNotifications.spec.ts | 4 +- .../Court/Indictments/Defender/Defender.tsx | 2 +- .../types/src/lib/notification.ts | 2 +- 9 files changed, 91 insertions(+), 25 deletions(-) create mode 100644 apps/judicial-system/backend/migrations/20241003213354-update-notification.js diff --git a/apps/judicial-system/backend/migrations/20241003213354-update-notification.js b/apps/judicial-system/backend/migrations/20241003213354-update-notification.js new file mode 100644 index 000000000000..6447e4b170c3 --- /dev/null +++ b/apps/judicial-system/backend/migrations/20241003213354-update-notification.js @@ -0,0 +1,66 @@ +'use strict' +const replaceEnum = require('sequelize-replace-enum-postgres').default + +module.exports = { + up: (queryInterface) => { + // replaceEnum does not support transactions + return replaceEnum({ + queryInterface, + tableName: 'notification', + columnName: 'type', + newValues: [ + 'HEADS_UP', + 'READY_FOR_COURT', + 'RECEIVED_BY_COURT', + 'COURT_DATE', + 'RULING', + 'MODIFIED', + 'REVOKED', + 'ADVOCATE_ASSIGNED', // Changed value + 'DEFENDANTS_NOT_UPDATED_AT_COURT', + 'APPEAL_TO_COURT_OF_APPEALS', + 'APPEAL_RECEIVED_BY_COURT', + 'APPEAL_STATEMENT', + 'APPEAL_COMPLETED', + 'APPEAL_JUDGES_ASSIGNED', + 'APPEAL_CASE_FILES_UPDATED', + 'APPEAL_WITHDRAWN', + 'INDICTMENT_DENIED', + 'INDICTMENT_RETURNED', + 'INDICTMENTS_WAITING_FOR_CONFIRMATION', + ], + enumName: 'enum_notification_type', + }) + }, + + down: (queryInterface) => { + // replaceEnum does not support transactions + return replaceEnum({ + queryInterface, + tableName: 'notification', + columnName: 'type', + newValues: [ + 'HEADS_UP', + 'READY_FOR_COURT', + 'RECEIVED_BY_COURT', + 'COURT_DATE', + 'RULING', + 'MODIFIED', + 'REVOKED', + 'DEFENDER_ASSIGNED', + 'DEFENDANTS_NOT_UPDATED_AT_COURT', + 'APPEAL_TO_COURT_OF_APPEALS', + 'APPEAL_RECEIVED_BY_COURT', + 'APPEAL_STATEMENT', + 'APPEAL_COMPLETED', + 'APPEAL_JUDGES_ASSIGNED', + 'APPEAL_CASE_FILES_UPDATED', + 'APPEAL_WITHDRAWN', + 'INDICTMENT_DENIED', + 'INDICTMENT_RETURNED', + 'INDICTMENTS_WAITING_FOR_CONFIRMATION', + ], + enumName: 'enum_notification_type', + }) + }, +} diff --git a/apps/judicial-system/backend/src/app/modules/notification/guards/rolesRules.ts b/apps/judicial-system/backend/src/app/modules/notification/guards/rolesRules.ts index d79774fedfeb..284c03caf5c1 100644 --- a/apps/judicial-system/backend/src/app/modules/notification/guards/rolesRules.ts +++ b/apps/judicial-system/backend/src/app/modules/notification/guards/rolesRules.ts @@ -28,7 +28,7 @@ export const districtCourtJudgeNotificationRule: RolesRule = { dtoField: 'type', dtoFieldValues: [ NotificationType.COURT_DATE, - NotificationType.DEFENDER_ASSIGNED, + NotificationType.ADVOCATE_ASSIGNED, ], } @@ -39,7 +39,7 @@ export const districtCourtRegistrarNotificationRule: RolesRule = { dtoField: 'type', dtoFieldValues: [ NotificationType.COURT_DATE, - NotificationType.DEFENDER_ASSIGNED, + NotificationType.ADVOCATE_ASSIGNED, ], } @@ -50,7 +50,7 @@ export const districtCourtAssistantNotificationRule: RolesRule = { dtoField: 'type', dtoFieldValues: [ NotificationType.COURT_DATE, - NotificationType.DEFENDER_ASSIGNED, + NotificationType.ADVOCATE_ASSIGNED, ], } diff --git a/apps/judicial-system/backend/src/app/modules/notification/internalNotification.service.ts b/apps/judicial-system/backend/src/app/modules/notification/internalNotification.service.ts index ebce85337c80..6b257674a63a 100644 --- a/apps/judicial-system/backend/src/app/modules/notification/internalNotification.service.ts +++ b/apps/judicial-system/backend/src/app/modules/notification/internalNotification.service.ts @@ -1518,7 +1518,7 @@ export class InternalNotificationService extends BaseNotificationService { } //#endregion - //#region DEFENDER_ASSIGNED notifications */ + //#region ADVOCATE_ASSIGNED notifications */ private shouldSendDefenderAssignedNotification( theCase: Case, defenderEmail?: string, @@ -1528,7 +1528,7 @@ export class InternalNotificationService extends BaseNotificationService { } if (isIndictmentCase(theCase.type)) { const hasSentNotificationBefore = this.hasReceivedNotification( - NotificationType.DEFENDER_ASSIGNED, + NotificationType.ADVOCATE_ASSIGNED, defenderEmail, theCase.notifications, ) @@ -1550,7 +1550,7 @@ export class InternalNotificationService extends BaseNotificationService { [ NotificationType.READY_FOR_COURT, NotificationType.COURT_DATE, - NotificationType.DEFENDER_ASSIGNED, + NotificationType.ADVOCATE_ASSIGNED, ], theCase.defenderEmail, theCase.notifications, @@ -1636,7 +1636,7 @@ export class InternalNotificationService extends BaseNotificationService { return this.recordNotification( theCase.id, - NotificationType.DEFENDER_ASSIGNED, + NotificationType.ADVOCATE_ASSIGNED, recipients, ) } @@ -2528,7 +2528,7 @@ export class InternalNotificationService extends BaseNotificationService { return this.sendModifiedNotifications(theCase, user) case NotificationType.REVOKED: return this.sendRevokedNotifications(theCase) - case NotificationType.DEFENDER_ASSIGNED: + case NotificationType.ADVOCATE_ASSIGNED: return this.sendDefenderAssignedNotifications(theCase) case NotificationType.DEFENDANTS_NOT_UPDATED_AT_COURT: return this.sendDefendantsNotUpdatedAtCourtNotifications(theCase) diff --git a/apps/judicial-system/backend/src/app/modules/notification/notification.service.ts b/apps/judicial-system/backend/src/app/modules/notification/notification.service.ts index 8103b1106f14..46665cef3181 100644 --- a/apps/judicial-system/backend/src/app/modules/notification/notification.service.ts +++ b/apps/judicial-system/backend/src/app/modules/notification/notification.service.ts @@ -62,7 +62,7 @@ export class NotificationService { // the judge chooses not to send a calendar invitation messages = [ this.getNotificationMessage( - NotificationType.DEFENDER_ASSIGNED, + NotificationType.ADVOCATE_ASSIGNED, user, theCase, ), @@ -72,7 +72,7 @@ export class NotificationService { } break case NotificationType.HEADS_UP: - case NotificationType.DEFENDER_ASSIGNED: + case NotificationType.ADVOCATE_ASSIGNED: case NotificationType.APPEAL_JUDGES_ASSIGNED: case NotificationType.APPEAL_CASE_FILES_UPDATED: messages = [this.getNotificationMessage(type, user, theCase)] diff --git a/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendDefenderAssignedNotifications.spec.ts b/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendDefenderAssignedNotifications.spec.ts index a08f371e4825..7d0ba3cc42d1 100644 --- a/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendDefenderAssignedNotifications.spec.ts +++ b/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendDefenderAssignedNotifications.spec.ts @@ -80,7 +80,7 @@ describe('InternalNotificationController - Send defender assigned notifications' describe('when sending defender assigned notifications', () => { const notificationDto: CaseNotificationDto = { user: { id: userId } as User, - type: NotificationType.DEFENDER_ASSIGNED, + type: NotificationType.ADVOCATE_ASSIGNED, } const caseId = uuid() const defendant = { @@ -128,7 +128,7 @@ describe('InternalNotificationController - Send defender assigned notifications' describe('when sending defender data is missing', () => { const notificationDto: CaseNotificationDto = { user: { id: userId } as User, - type: NotificationType.DEFENDER_ASSIGNED, + type: NotificationType.ADVOCATE_ASSIGNED, } const caseId = uuid() const theCase = { @@ -152,7 +152,7 @@ describe('InternalNotificationController - Send defender assigned notifications' describe('record notification', () => { const notificationDto: CaseNotificationDto = { user: { id: userId } as User, - type: NotificationType.DEFENDER_ASSIGNED, + type: NotificationType.ADVOCATE_ASSIGNED, } const caseId = uuid() const defendant = { @@ -190,7 +190,7 @@ describe('InternalNotificationController - Send defender assigned notifications' describe('returns that the notification was sent', () => { const notificationDto: CaseNotificationDto = { user: { id: userId } as User, - type: NotificationType.DEFENDER_ASSIGNED, + type: NotificationType.ADVOCATE_ASSIGNED, } const caseId = uuid() const theCase = { @@ -220,7 +220,7 @@ describe('InternalNotificationController - Send defender assigned notifications' describe('only send notification once to defender', () => { const notificationDto: CaseNotificationDto = { user: { id: userId } as User, - type: NotificationType.DEFENDER_ASSIGNED, + type: NotificationType.ADVOCATE_ASSIGNED, } const caseId = uuid() const defendant = { @@ -265,7 +265,7 @@ describe('InternalNotificationController - Send defender assigned notifications' describe('should send email to every defender', () => { const notificationDto: CaseNotificationDto = { user: { id: userId } as User, - type: NotificationType.DEFENDER_ASSIGNED, + type: NotificationType.ADVOCATE_ASSIGNED, } const caseId = uuid() const defender1 = { defenderEmail: 'some-email@island.is' } @@ -294,7 +294,7 @@ describe('InternalNotificationController - Send defender assigned notifications' describe('should only send one email to each defender', () => { const notificationDto: CaseNotificationDto = { user: { id: userId } as User, - type: NotificationType.DEFENDER_ASSIGNED, + type: NotificationType.ADVOCATE_ASSIGNED, } const caseId = uuid() const defender1 = { @@ -348,7 +348,7 @@ describe('InternalNotificationController - Send defender assigned notifications' describe('when sending assigned defender notifications in a restriction case', () => { const notificationDto: CaseNotificationDto = { user: { id: userId } as User, - type: NotificationType.DEFENDER_ASSIGNED, + type: NotificationType.ADVOCATE_ASSIGNED, } const caseId = uuid() @@ -395,7 +395,7 @@ describe('InternalNotificationController - Send defender assigned notifications' describe('when sending assigned defender without national id notifications in a restriction case', () => { const notificationDto: CaseNotificationDto = { user: { id: userId } as User, - type: NotificationType.DEFENDER_ASSIGNED, + type: NotificationType.ADVOCATE_ASSIGNED, } const caseId = uuid() @@ -441,7 +441,7 @@ describe('InternalNotificationController - Send defender assigned notifications' describe('when sending notifications in an investigation case', () => { const notificationDto: CaseNotificationDto = { user: { id: userId } as User, - type: NotificationType.DEFENDER_ASSIGNED, + type: NotificationType.ADVOCATE_ASSIGNED, } const caseId = uuid() diff --git a/apps/judicial-system/backend/src/app/modules/notification/test/notificationController/sendCourtDateNotification.spec.ts b/apps/judicial-system/backend/src/app/modules/notification/test/notificationController/sendCourtDateNotification.spec.ts index 4d99bbd951ac..180b8de0934e 100644 --- a/apps/judicial-system/backend/src/app/modules/notification/test/notificationController/sendCourtDateNotification.spec.ts +++ b/apps/judicial-system/backend/src/app/modules/notification/test/notificationController/sendCourtDateNotification.spec.ts @@ -82,7 +82,7 @@ describe('NotificationController - Send court date notification', () => { type: MessageType.NOTIFICATION, user, caseId, - body: { type: NotificationType.DEFENDER_ASSIGNED }, + body: { type: NotificationType.ADVOCATE_ASSIGNED }, }, ]) expect(then.result).toEqual({ notificationSent: true }) diff --git a/apps/judicial-system/backend/src/app/modules/notification/test/notificationController/sendDefenderAssignedNotifications.spec.ts b/apps/judicial-system/backend/src/app/modules/notification/test/notificationController/sendDefenderAssignedNotifications.spec.ts index 9343649fb891..5771be382e93 100644 --- a/apps/judicial-system/backend/src/app/modules/notification/test/notificationController/sendDefenderAssignedNotifications.spec.ts +++ b/apps/judicial-system/backend/src/app/modules/notification/test/notificationController/sendDefenderAssignedNotifications.spec.ts @@ -39,7 +39,7 @@ describe('NotificationController - Send defender assigned notification', () => { await notificationController .sendCaseNotification(caseId, user, { id: caseId } as Case, { - type: NotificationType.DEFENDER_ASSIGNED, + type: NotificationType.ADVOCATE_ASSIGNED, }) .then((result) => (then.result = result)) .catch((error) => (then.error = error)) @@ -61,7 +61,7 @@ describe('NotificationController - Send defender assigned notification', () => { type: MessageType.NOTIFICATION, user, caseId, - body: { type: NotificationType.DEFENDER_ASSIGNED }, + body: { type: NotificationType.ADVOCATE_ASSIGNED }, }, ]) expect(then.result).toEqual({ notificationSent: true }) diff --git a/apps/judicial-system/web/src/routes/Court/Indictments/Defender/Defender.tsx b/apps/judicial-system/web/src/routes/Court/Indictments/Defender/Defender.tsx index a629abf8760a..6bb778d57b20 100644 --- a/apps/judicial-system/web/src/routes/Court/Indictments/Defender/Defender.tsx +++ b/apps/judicial-system/web/src/routes/Court/Indictments/Defender/Defender.tsx @@ -32,7 +32,7 @@ const HearingArrangements = () => { const handleNavigationTo = useCallback( async (destination: string) => { - await sendNotification(workingCase.id, NotificationType.DEFENDER_ASSIGNED) + await sendNotification(workingCase.id, NotificationType.ADVOCATE_ASSIGNED) router.push(`${destination}/${workingCase.id}`) }, [workingCase.id, sendNotification, router], diff --git a/libs/judicial-system/types/src/lib/notification.ts b/libs/judicial-system/types/src/lib/notification.ts index afdf6ec82930..26d38136f834 100644 --- a/libs/judicial-system/types/src/lib/notification.ts +++ b/libs/judicial-system/types/src/lib/notification.ts @@ -6,7 +6,7 @@ export enum NotificationType { RULING = 'RULING', MODIFIED = 'MODIFIED', REVOKED = 'REVOKED', - DEFENDER_ASSIGNED = 'DEFENDER_ASSIGNED', + ADVOCATE_ASSIGNED = 'ADVOCATE_ASSIGNED', DEFENDANTS_NOT_UPDATED_AT_COURT = 'DEFENDANTS_NOT_UPDATED_AT_COURT', APPEAL_TO_COURT_OF_APPEALS = 'APPEAL_TO_COURT_OF_APPEALS', APPEAL_RECEIVED_BY_COURT = 'APPEAL_RECEIVED_BY_COURT', From 1f603d410db0c3b011dd8b271215c3e88e7c4e7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8Dvar=20Oddsson?= Date: Thu, 3 Oct 2024 22:10:58 +0000 Subject: [PATCH 06/23] Checkpoint --- .../internalNotification.service.ts | 46 +++++++++++++++---- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/apps/judicial-system/backend/src/app/modules/notification/internalNotification.service.ts b/apps/judicial-system/backend/src/app/modules/notification/internalNotification.service.ts index 6b257674a63a..f4e15531b8bf 100644 --- a/apps/judicial-system/backend/src/app/modules/notification/internalNotification.service.ts +++ b/apps/judicial-system/backend/src/app/modules/notification/internalNotification.service.ts @@ -1519,17 +1519,17 @@ export class InternalNotificationService extends BaseNotificationService { //#endregion //#region ADVOCATE_ASSIGNED notifications */ - private shouldSendDefenderAssignedNotification( + private shouldSendAdvocateAssignedNotification( theCase: Case, - defenderEmail?: string, + advocateEmail?: string, ): boolean { - if (!defenderEmail) { + if (!advocateEmail) { return false } if (isIndictmentCase(theCase.type)) { const hasSentNotificationBefore = this.hasReceivedNotification( NotificationType.ADVOCATE_ASSIGNED, - defenderEmail, + advocateEmail, theCase.notifications, ) @@ -1564,7 +1564,7 @@ export class InternalNotificationService extends BaseNotificationService { return true } - private sendDefenderAssignedNotification( + private sendAdvocateAssignedNotification( theCase: Case, defenderNationalId?: string, defenderName?: string, @@ -1587,7 +1587,7 @@ export class InternalNotificationService extends BaseNotificationService { ) } - private async sendDefenderAssignedNotifications( + private async sendAdvocateAssignedNotifications( theCase: Case, ): Promise { const promises: Promise[] = [] @@ -1597,17 +1597,18 @@ export class InternalNotificationService extends BaseNotificationService { theCase.defendants ?? [], (d: Defendant) => d.defenderEmail, ) + for (const defendant of uniqDefendants) { const { defenderEmail, defenderNationalId, defenderName } = defendant - const shouldSend = this.shouldSendDefenderAssignedNotification( + const shouldSend = this.shouldSendAdvocateAssignedNotification( theCase, defenderEmail, ) if (shouldSend === true) { promises.push( - this.sendDefenderAssignedNotification( + this.sendAdvocateAssignedNotification( theCase, defenderNationalId, defenderName, @@ -1616,8 +1617,33 @@ export class InternalNotificationService extends BaseNotificationService { ) } } + + if (theCase.civilClaimants) { + for (const civilClaimant of theCase.civilClaimants) { + const { + spokespersonEmail, + spokespersonIsLawyer, + spokespersonName, + spokespersonNationalId, + } = civilClaimant + + const shouldSend = this.shouldSendAdvocateAssignedNotification( + theCase, + spokespersonEmail, + ) + + if (shouldSend === true) { + this.sendAdvocateAssignedNotification( + theCase, + spokespersonNationalId, + spokespersonName, + spokespersonEmail, + ) + } + } + } } else if (DateLog.arraignmentDate(theCase.dateLogs)?.date) { - const shouldSend = this.shouldSendDefenderAssignedNotification( + const shouldSend = this.shouldSendAdvocateAssignedNotification( theCase, theCase.defenderEmail, ) @@ -2529,7 +2555,7 @@ export class InternalNotificationService extends BaseNotificationService { case NotificationType.REVOKED: return this.sendRevokedNotifications(theCase) case NotificationType.ADVOCATE_ASSIGNED: - return this.sendDefenderAssignedNotifications(theCase) + return this.sendAdvocateAssignedNotifications(theCase) case NotificationType.DEFENDANTS_NOT_UPDATED_AT_COURT: return this.sendDefendantsNotUpdatedAtCourtNotifications(theCase) case NotificationType.APPEAL_TO_COURT_OF_APPEALS: From 612e23072b2d7c51718445aba206102abc2ff090 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8Dvar=20Oddsson?= Date: Fri, 4 Oct 2024 10:38:28 +0000 Subject: [PATCH 07/23] Checkpoint --- .../backend/src/app/formatters/formatters.ts | 8 +++++++- .../backend/src/app/messages/notifications.ts | 4 ++-- .../notification/internalNotification.service.ts | 7 +++++++ .../web/src/components/Inputs/InputAdvocate.tsx | 10 +++++----- libs/judicial-system/types/src/index.ts | 2 +- .../types/src/lib/{defender.ts => advocate.ts} | 6 ++++++ 6 files changed, 28 insertions(+), 9 deletions(-) rename libs/judicial-system/types/src/lib/{defender.ts => advocate.ts} (89%) diff --git a/apps/judicial-system/backend/src/app/formatters/formatters.ts b/apps/judicial-system/backend/src/app/formatters/formatters.ts index babb0c0da5e6..1ed0ef319ba5 100644 --- a/apps/judicial-system/backend/src/app/formatters/formatters.ts +++ b/apps/judicial-system/backend/src/app/formatters/formatters.ts @@ -14,7 +14,11 @@ import { laws, readableIndictmentSubtypes, } from '@island.is/judicial-system/formatters' -import type { Gender, UserRole } from '@island.is/judicial-system/types' +import type { + AdvocateType, + Gender, + UserRole, +} from '@island.is/judicial-system/types' import { CaseCustodyRestrictions, CaseLegalProvisions, @@ -667,6 +671,7 @@ export const formatCustodyRestrictions = ( export const formatDefenderAssignedEmailNotification = ( formatMessage: FormatMessage, theCase: Case, + advocateType: AdvocateType, overviewUrl?: string, ): SubjectAndBody => { const subject = formatMessage(notifications.defenderAssignedEmail.subject, { @@ -675,6 +680,7 @@ export const formatDefenderAssignedEmailNotification = ( const body = formatMessage(notifications.defenderAssignedEmail.body, { defenderHasAccessToRVG: Boolean(overviewUrl), + advocateType, courtCaseNumber: capitalize(theCase.courtCaseNumber ?? ''), court: theCase.court?.name ?? '', courtName: theCase.court?.name.replace('dómur', 'dómi') ?? '', diff --git a/apps/judicial-system/backend/src/app/messages/notifications.ts b/apps/judicial-system/backend/src/app/messages/notifications.ts index a8868a3b3595..a0db778a136f 100644 --- a/apps/judicial-system/backend/src/app/messages/notifications.ts +++ b/apps/judicial-system/backend/src/app/messages/notifications.ts @@ -615,9 +615,9 @@ export const notifications = { 'Fyrirsögn í pósti til verjanda þegar hann er skráður á mál.', }, body: { - id: 'judicial.system.backend:notifications.defender_assigned_email.body_v3', + id: 'judicial.system.backend:notifications.defender_assigned_email.body_v4', defaultMessage: - '{court} hefur skráð þig verjanda í máli {courtCaseNumber}.

{defenderHasAccessToRVG, select, true {Gögn málsins eru aðgengileg á {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}}.', + '{court} hefur skráð þig {advocateType, select, LAWYER {lögmann} LEGAL_RIGHTS_PROTECTOR {réttargæslumann einkaréttarkröfuhafa} other {verjanda}} í máli {courtCaseNumber}.

{defenderHasAccessToRVG, select, true {Gögn málsins eru aðgengileg á {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: 'Texti í pósti til verjanda þegar hann er skráður á mál.', }, }), diff --git a/apps/judicial-system/backend/src/app/modules/notification/internalNotification.service.ts b/apps/judicial-system/backend/src/app/modules/notification/internalNotification.service.ts index f4e15531b8bf..43dc8c0da3fb 100644 --- a/apps/judicial-system/backend/src/app/modules/notification/internalNotification.service.ts +++ b/apps/judicial-system/backend/src/app/modules/notification/internalNotification.service.ts @@ -30,6 +30,7 @@ import { lowercase, } from '@island.is/judicial-system/formatters' import { + AdvocateType, CaseAppealRulingDecision, CaseCustodyRestrictions, CaseDecision, @@ -1566,6 +1567,7 @@ export class InternalNotificationService extends BaseNotificationService { private sendAdvocateAssignedNotification( theCase: Case, + advocateType: AdvocateType, defenderNationalId?: string, defenderName?: string, defenderEmail?: string, @@ -1573,6 +1575,7 @@ export class InternalNotificationService extends BaseNotificationService { const { subject, body } = formatDefenderAssignedEmailNotification( this.formatMessage, theCase, + advocateType, defenderNationalId && formatDefenderRoute(this.config.clientUrl, theCase.type, theCase.id), ) @@ -1610,6 +1613,7 @@ export class InternalNotificationService extends BaseNotificationService { promises.push( this.sendAdvocateAssignedNotification( theCase, + AdvocateType.DEFENDER, defenderNationalId, defenderName, defenderEmail, @@ -1635,6 +1639,9 @@ export class InternalNotificationService extends BaseNotificationService { if (shouldSend === true) { this.sendAdvocateAssignedNotification( theCase, + spokespersonIsLawyer + ? AdvocateType.LAWYER + : AdvocateType.LEGAL_RIGHTS_PROTECTOR, spokespersonNationalId, spokespersonName, spokespersonEmail, diff --git a/apps/judicial-system/web/src/components/Inputs/InputAdvocate.tsx b/apps/judicial-system/web/src/components/Inputs/InputAdvocate.tsx index e5bfaec3c2fe..75206b7d7e37 100644 --- a/apps/judicial-system/web/src/components/Inputs/InputAdvocate.tsx +++ b/apps/judicial-system/web/src/components/Inputs/InputAdvocate.tsx @@ -12,7 +12,7 @@ import { useIntl } from 'react-intl' import { SingleValue } from 'react-select' import { Box, Input, Select } from '@island.is/island-ui/core' -import { type Lawyer } from '@island.is/judicial-system/types' +import { AdvocateType, type Lawyer } from '@island.is/judicial-system/types' import { FormContext } from '@island.is/judicial-system-web/src/components' import { ReactSelectOption, @@ -39,7 +39,7 @@ interface Props { onAdvocateNotFound?: (advocateNotFound: boolean) => void disabled?: boolean | null clientId?: string | null - advocateType?: 'defender' | 'spokesperson' | 'legal_rights_protector' + advocateType?: AdvocateType isCivilClaim?: boolean } @@ -319,7 +319,7 @@ const InputAdvocate: FC = ({ icon="search" options={options} label={ - advocateType === 'legal_rights_protector' + advocateType === AdvocateType.LEGAL_RIGHTS_PROTECTOR ? formatMessage(strings.spokespersonNameLabel) : formatMessage(strings.nameLabel, { sessionArrangements: workingCase.sessionArrangements, @@ -367,7 +367,7 @@ const InputAdvocate: FC = ({ name="defenderEmail" autoComplete="off" label={ - advocateType === 'legal_rights_protector' + advocateType === AdvocateType.LEGAL_RIGHTS_PROTECTOR ? formatMessage(strings.spokespersonEmailLabel) : formatMessage(strings.emailLabel, { sessionArrangements: workingCase.sessionArrangements, @@ -481,7 +481,7 @@ const InputAdvocate: FC = ({ name="defenderPhoneNumber" autoComplete="off" label={ - advocateType === 'legal_rights_protector' + advocateType === AdvocateType.LEGAL_RIGHTS_PROTECTOR ? formatMessage(strings.spokespersonPhoneNumberLabel) : formatMessage(strings.phoneNumberLabel, { sessionArrangements: workingCase.sessionArrangements, diff --git a/libs/judicial-system/types/src/index.ts b/libs/judicial-system/types/src/index.ts index 9694c67c1755..e5857086b71a 100644 --- a/libs/judicial-system/types/src/index.ts +++ b/libs/judicial-system/types/src/index.ts @@ -96,7 +96,7 @@ export { offenseSubstances, } from './lib/indictmentCount' -export { type Lawyer, mapToLawyer } from './lib/defender' +export { type Lawyer, mapToLawyer, AdvocateType } from './lib/advocate' export type { SubstanceMap } from './lib/indictmentCount' diff --git a/libs/judicial-system/types/src/lib/defender.ts b/libs/judicial-system/types/src/lib/advocate.ts similarity index 89% rename from libs/judicial-system/types/src/lib/defender.ts rename to libs/judicial-system/types/src/lib/advocate.ts index d4ae0aee081b..3b298721edbb 100644 --- a/libs/judicial-system/types/src/lib/defender.ts +++ b/libs/judicial-system/types/src/lib/advocate.ts @@ -42,6 +42,12 @@ type LawyerFull = { InternationConnection: string } +export enum AdvocateType { + DEFENDER = 'DEFENDER', + LAWYER = 'LAWYER', + LEGAL_RIGHTS_PROTECTOR = 'LEGAL_RIGHTS_PROTECTOR', +} + export const mapToLawyer = (lawyer: LawyerFull): Lawyer => { return { name: lawyer.Name, From d264166a4a87e91d6995780008d09710b5674cc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8Dvar=20Oddsson?= Date: Fri, 4 Oct 2024 10:52:10 +0000 Subject: [PATCH 08/23] Update string --- apps/judicial-system/backend/src/app/messages/notifications.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/judicial-system/backend/src/app/messages/notifications.ts b/apps/judicial-system/backend/src/app/messages/notifications.ts index a0db778a136f..0c83827cd58f 100644 --- a/apps/judicial-system/backend/src/app/messages/notifications.ts +++ b/apps/judicial-system/backend/src/app/messages/notifications.ts @@ -617,7 +617,7 @@ export const notifications = { body: { id: 'judicial.system.backend:notifications.defender_assigned_email.body_v4', defaultMessage: - '{court} hefur skráð þig {advocateType, select, LAWYER {lögmann} LEGAL_RIGHTS_PROTECTOR {réttargæslumann einkaréttarkröfuhafa} other {verjanda}} í máli {courtCaseNumber}.

{defenderHasAccessToRVG, select, true {Gögn málsins eru aðgengileg á {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}}.', + '{court} hefur skráð þig {advocateType, select, LAWYER {lögmann einkaréttarkröfuhafa} LEGAL_RIGHTS_PROTECTOR {réttargæslumann einkaréttarkröfuhafa} other {verjanda}} í máli {courtCaseNumber}.

{defenderHasAccessToRVG, select, true {Gögn málsins eru aðgengileg á {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: 'Texti í pósti til verjanda þegar hann er skráður á mál.', }, }), From 8263ce15b755e13361ed98cd768e9346dac5c103 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8Dvar=20Oddsson?= Date: Fri, 4 Oct 2024 11:33:02 +0000 Subject: [PATCH 09/23] Add tests --- .../internalNotification.service.ts | 10 +- ...sendAdvocateAssignedNotifications.spec.ts} | 128 +++++++++++++++++- 2 files changed, 133 insertions(+), 5 deletions(-) rename apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/{sendDefenderAssignedNotifications.spec.ts => sendAdvocateAssignedNotifications.spec.ts} (77%) diff --git a/apps/judicial-system/backend/src/app/modules/notification/internalNotification.service.ts b/apps/judicial-system/backend/src/app/modules/notification/internalNotification.service.ts index 43dc8c0da3fb..d4cc2936f172 100644 --- a/apps/judicial-system/backend/src/app/modules/notification/internalNotification.service.ts +++ b/apps/judicial-system/backend/src/app/modules/notification/internalNotification.service.ts @@ -1629,12 +1629,14 @@ export class InternalNotificationService extends BaseNotificationService { spokespersonIsLawyer, spokespersonName, spokespersonNationalId, + hasSpokesperson, } = civilClaimant - const shouldSend = this.shouldSendAdvocateAssignedNotification( - theCase, - spokespersonEmail, - ) + const shouldSend = + this.shouldSendAdvocateAssignedNotification( + theCase, + spokespersonEmail, + ) && hasSpokesperson if (shouldSend === true) { this.sendAdvocateAssignedNotification( diff --git a/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendDefenderAssignedNotifications.spec.ts b/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendAdvocateAssignedNotifications.spec.ts similarity index 77% rename from apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendDefenderAssignedNotifications.spec.ts rename to apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendAdvocateAssignedNotifications.spec.ts index 7d0ba3cc42d1..1934cf4769cb 100644 --- a/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendDefenderAssignedNotifications.spec.ts +++ b/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendAdvocateAssignedNotifications.spec.ts @@ -125,6 +125,132 @@ describe('InternalNotificationController - Send defender assigned notifications' }) }) + describe('when the case has civil claims and the advocate is a lawyer', () => { + const notificationDto: CaseNotificationDto = { + user: { id: userId } as User, + type: NotificationType.ADVOCATE_ASSIGNED, + } + const caseId = uuid() + const civilClaimant = { + hasSpokesperson: true, + spokespersonNationalId: '1234567890', + spokespersonEmail: 'recipient@gmail.com', + spokespersonName: 'John Doe', + spokespersonIsLawyer: true, + } + const theCase = { + id: caseId, + type: CaseType.INDICTMENT, + court, + courtCaseNumber: 'S-123/2022', + civilClaimants: [civilClaimant], + } as Case + + beforeEach(async () => { + await givenWhenThen(caseId, theCase, notificationDto) + }) + + it('should send correct email', () => { + expect(mockEmailService.sendEmail).toHaveBeenCalledTimes(1) + expect(mockEmailService.sendEmail).toHaveBeenCalledWith({ + from: { + name: mockConfig.email.fromName, + address: mockConfig.email.fromEmail, + }, + to: [ + { + name: civilClaimant.spokespersonName, + address: civilClaimant.spokespersonEmail, + }, + ], + replyTo: { + name: mockConfig.email.replyToName, + address: mockConfig.email.replyToEmail, + }, + attachments: undefined, + subject: 'Héraðsdómur Reykjavíkur - aðgangur að málsgögnum', + text: expect.anything(), // same as hmtl but stripped hmtl tags + html: `Héraðsdómur Reykjavíkur hefur skráð þig lögmann einkaréttarkröfuhafa í máli ${theCase.courtCaseNumber}.

Gögn málsins eru aðgengileg á yfirlitssíðu málsins í Réttarvörslugátt.`, + }) + }) + }) + + describe('when the case has civil claims and the advocate is a legal rights protector', () => { + const notificationDto: CaseNotificationDto = { + user: { id: userId } as User, + type: NotificationType.ADVOCATE_ASSIGNED, + } + const caseId = uuid() + const civilClaimant = { + hasSpokesperson: true, + spokespersonNationalId: '1234567890', + spokespersonEmail: 'recipient@gmail.com', + spokespersonName: 'John Doe', + spokespersonIsLawyer: false, + } + const theCase = { + id: caseId, + type: CaseType.INDICTMENT, + court, + courtCaseNumber: 'S-123/2022', + civilClaimants: [civilClaimant], + } as Case + + beforeEach(async () => { + await givenWhenThen(caseId, theCase, notificationDto) + }) + + it('should send correct email', () => { + expect(mockEmailService.sendEmail).toHaveBeenCalledTimes(1) + expect(mockEmailService.sendEmail).toHaveBeenCalledWith({ + from: { + name: mockConfig.email.fromName, + address: mockConfig.email.fromEmail, + }, + to: [ + { + name: civilClaimant.spokespersonName, + address: civilClaimant.spokespersonEmail, + }, + ], + replyTo: { + name: mockConfig.email.replyToName, + address: mockConfig.email.replyToEmail, + }, + attachments: undefined, + subject: 'Héraðsdómur Reykjavíkur - aðgangur að málsgögnum', + text: expect.anything(), // same as hmtl but stripped hmtl tags + html: `Héraðsdómur Reykjavíkur hefur skráð þig réttargæslumann einkaréttarkröfuhafa í máli ${theCase.courtCaseNumber}.

Gögn málsins eru aðgengileg á yfirlitssíðu málsins í Réttarvörslugátt.`, + }) + }) + }) + + describe('when the case has civil claims and civil claimant does not have representation', () => { + const notificationDto: CaseNotificationDto = { + user: { id: userId } as User, + type: NotificationType.ADVOCATE_ASSIGNED, + } + const caseId = uuid() + const civilClaimant = { + hasSpokesperson: false, + } + const theCase = { + id: caseId, + type: CaseType.INDICTMENT, + court, + courtCaseNumber: 'S-123/2022', + civilClaimants: [civilClaimant], + } as Case + + beforeEach(async () => { + await givenWhenThen(caseId, theCase, notificationDto) + }) + + it('should send correct email', () => { + expect(mockEmailService.sendEmail).not.toHaveBeenCalled() + }) + }) + describe('when sending defender data is missing', () => { const notificationDto: CaseNotificationDto = { user: { id: userId } as User, @@ -172,7 +298,7 @@ describe('InternalNotificationController - Send defender assigned notifications' await givenWhenThen(caseId, theCase, notificationDto) }) - it('should record notfication', () => { + it('should record notification', () => { expect(mockNotificationModel.create).toHaveBeenCalledTimes(1) expect(mockNotificationModel.create).toHaveBeenCalledWith({ caseId, From b41d4c66e1c01ec90b1226ec05a321da355aed71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8Dvar=20Oddsson?= Date: Mon, 7 Oct 2024 20:23:31 +0000 Subject: [PATCH 10/23] Rename defender -- advocate --- apps/judicial-system/backend/src/app/formatters/formatters.ts | 2 +- apps/judicial-system/backend/src/app/formatters/index.ts | 2 +- .../app/modules/notification/internalNotification.service.ts | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/judicial-system/backend/src/app/formatters/formatters.ts b/apps/judicial-system/backend/src/app/formatters/formatters.ts index 1ed0ef319ba5..7ed85dbcc8d7 100644 --- a/apps/judicial-system/backend/src/app/formatters/formatters.ts +++ b/apps/judicial-system/backend/src/app/formatters/formatters.ts @@ -668,7 +668,7 @@ export const formatCustodyRestrictions = ( }) } -export const formatDefenderAssignedEmailNotification = ( +export const formatAdvocateAssignedEmailNotification = ( formatMessage: FormatMessage, theCase: Case, advocateType: AdvocateType, diff --git a/apps/judicial-system/backend/src/app/formatters/index.ts b/apps/judicial-system/backend/src/app/formatters/index.ts index 385f09d8df03..ea9b36ec95ba 100644 --- a/apps/judicial-system/backend/src/app/formatters/index.ts +++ b/apps/judicial-system/backend/src/app/formatters/index.ts @@ -21,7 +21,7 @@ export { formatProsecutorReceivedByCourtSmsNotification, formatDefenderCourtDateLinkEmailNotification, formatDefenderResubmittedToCourtEmailNotification, - formatDefenderAssignedEmailNotification, + formatAdvocateAssignedEmailNotification, formatCourtIndictmentReadyForCourtEmailNotification, formatDefenderRoute, formatDefenderReadyForCourtEmailNotification, diff --git a/apps/judicial-system/backend/src/app/modules/notification/internalNotification.service.ts b/apps/judicial-system/backend/src/app/modules/notification/internalNotification.service.ts index d4cc2936f172..00df4cb93702 100644 --- a/apps/judicial-system/backend/src/app/modules/notification/internalNotification.service.ts +++ b/apps/judicial-system/backend/src/app/modules/notification/internalNotification.service.ts @@ -57,7 +57,7 @@ import { formatCourtReadyForCourtSmsNotification, formatCourtResubmittedToCourtSmsNotification, formatCourtRevokedSmsNotification, - formatDefenderAssignedEmailNotification, + formatAdvocateAssignedEmailNotification, formatDefenderCourtDateEmailNotification, formatDefenderCourtDateLinkEmailNotification, formatDefenderReadyForCourtEmailNotification, @@ -1572,7 +1572,7 @@ export class InternalNotificationService extends BaseNotificationService { defenderName?: string, defenderEmail?: string, ): Promise { - const { subject, body } = formatDefenderAssignedEmailNotification( + const { subject, body } = formatAdvocateAssignedEmailNotification( this.formatMessage, theCase, advocateType, From 18355bb7440510d50987252f319440971e6d3464 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8Dvar=20Oddsson?= Date: Mon, 7 Oct 2024 20:25:49 +0000 Subject: [PATCH 11/23] Rename defender -- advocate --- ...ations.spec.ts => sendAdvocateAssignedNotifications.spec.ts} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename apps/judicial-system/backend/src/app/modules/notification/test/notificationController/{sendDefenderAssignedNotifications.spec.ts => sendAdvocateAssignedNotifications.spec.ts} (96%) diff --git a/apps/judicial-system/backend/src/app/modules/notification/test/notificationController/sendDefenderAssignedNotifications.spec.ts b/apps/judicial-system/backend/src/app/modules/notification/test/notificationController/sendAdvocateAssignedNotifications.spec.ts similarity index 96% rename from apps/judicial-system/backend/src/app/modules/notification/test/notificationController/sendDefenderAssignedNotifications.spec.ts rename to apps/judicial-system/backend/src/app/modules/notification/test/notificationController/sendAdvocateAssignedNotifications.spec.ts index 5771be382e93..acc19f13a96f 100644 --- a/apps/judicial-system/backend/src/app/modules/notification/test/notificationController/sendDefenderAssignedNotifications.spec.ts +++ b/apps/judicial-system/backend/src/app/modules/notification/test/notificationController/sendAdvocateAssignedNotifications.spec.ts @@ -17,7 +17,7 @@ interface Then { type GivenWhenThen = (caseId: string) => Promise -describe('NotificationController - Send defender assigned notification', () => { +describe('NotificationController - Send advocate assigned notification', () => { const userId = uuid() const user = { id: userId } as User From 2b8d4e572ad5dd0eee8b1a12ec64017b805daf28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8Dvar=20Oddsson?= Date: Mon, 7 Oct 2024 20:27:56 +0000 Subject: [PATCH 12/23] Fix typo: hmtl -- html --- .../sendAdvocateAssignedNotifications.spec.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendAdvocateAssignedNotifications.spec.ts b/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendAdvocateAssignedNotifications.spec.ts index 1934cf4769cb..4454b13cad87 100644 --- a/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendAdvocateAssignedNotifications.spec.ts +++ b/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendAdvocateAssignedNotifications.spec.ts @@ -119,7 +119,7 @@ describe('InternalNotificationController - Send defender assigned notifications' }, attachments: undefined, subject: 'Héraðsdómur Reykjavíkur - aðgangur að málsgögnum', - text: expect.anything(), // same as hmtl but stripped hmtl tags + text: expect.anything(), // same as html but stripped html tags html: `Héraðsdómur Reykjavíkur hefur skráð þig verjanda í máli ${theCase.courtCaseNumber}.

Gögn málsins eru aðgengileg á yfirlitssíðu málsins í Réttarvörslugátt.`, }) }) @@ -169,7 +169,7 @@ describe('InternalNotificationController - Send defender assigned notifications' }, attachments: undefined, subject: 'Héraðsdómur Reykjavíkur - aðgangur að málsgögnum', - text: expect.anything(), // same as hmtl but stripped hmtl tags + text: expect.anything(), // same as html but stripped html tags html: `Héraðsdómur Reykjavíkur hefur skráð þig lögmann einkaréttarkröfuhafa í máli ${theCase.courtCaseNumber}.

Gögn málsins eru aðgengileg á yfirlitssíðu málsins í Réttarvörslugátt.`, }) }) @@ -219,7 +219,7 @@ describe('InternalNotificationController - Send defender assigned notifications' }, attachments: undefined, subject: 'Héraðsdómur Reykjavíkur - aðgangur að málsgögnum', - text: expect.anything(), // same as hmtl but stripped hmtl tags + text: expect.anything(), // same as html but stripped html tags html: `Héraðsdómur Reykjavíkur hefur skráð þig réttargæslumann einkaréttarkröfuhafa í máli ${theCase.courtCaseNumber}.

Gögn málsins eru aðgengileg á yfirlitssíðu málsins í Réttarvörslugátt.`, }) }) @@ -464,7 +464,7 @@ describe('InternalNotificationController - Send defender assigned notifications' }, attachments: undefined, subject: 'Héraðsdómur Reykjavíkur - aðgangur að málsgögnum', - text: expect.anything(), // same as hmtl but stripped hmtl tags + text: expect.anything(), // same as html but stripped html tags html: `Héraðsdómur Reykjavíkur hefur skráð þig verjanda í máli ${theCase.courtCaseNumber}.

Gögn málsins eru aðgengileg á yfirlitssíðu málsins í Réttarvörslugátt.`, }) expect(then.result).toEqual(expect.objectContaining({ delivered: true })) From 1c2fdd769817519f06af55720e52f12a36ddd0a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8Dvar=20Oddsson?= Date: Mon, 7 Oct 2024 20:37:11 +0000 Subject: [PATCH 13/23] Refactor tests --- .../sendAdvocateAssignedNotifications.spec.ts | 106 ++++-------------- 1 file changed, 23 insertions(+), 83 deletions(-) diff --git a/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendAdvocateAssignedNotifications.spec.ts b/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendAdvocateAssignedNotifications.spec.ts index 4454b13cad87..b6e5a6dc46c6 100644 --- a/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendAdvocateAssignedNotifications.spec.ts +++ b/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendAdvocateAssignedNotifications.spec.ts @@ -43,6 +43,8 @@ describe('InternalNotificationController - Send defender assigned notifications' let mockConfig: ConfigType let mockNotificationModel: typeof Notification let givenWhenThen: GivenWhenThen + let notificationDTO: CaseNotificationDto + let caseId: string beforeEach(async () => { const { @@ -52,6 +54,12 @@ describe('InternalNotificationController - Send defender assigned notifications' internalNotificationController, } = await createTestingNotificationModule() + notificationDTO = { + user: { id: userId } as User, + type: NotificationType.ADVOCATE_ASSIGNED, + } + + caseId = uuid() mockEmailService = emailService mockConfig = notificationConfig mockNotificationModel = notificationModel @@ -78,11 +86,6 @@ describe('InternalNotificationController - Send defender assigned notifications' }) describe('when sending defender assigned notifications', () => { - const notificationDto: CaseNotificationDto = { - user: { id: userId } as User, - type: NotificationType.ADVOCATE_ASSIGNED, - } - const caseId = uuid() const defendant = { defenderNationalId: '1234567890', defenderEmail: 'recipient@gmail.com', @@ -97,7 +100,7 @@ describe('InternalNotificationController - Send defender assigned notifications' } as Case beforeEach(async () => { - await givenWhenThen(caseId, theCase, notificationDto) + await givenWhenThen(caseId, theCase, notificationDTO) }) it('should send correct email', () => { @@ -126,11 +129,6 @@ describe('InternalNotificationController - Send defender assigned notifications' }) describe('when the case has civil claims and the advocate is a lawyer', () => { - const notificationDto: CaseNotificationDto = { - user: { id: userId } as User, - type: NotificationType.ADVOCATE_ASSIGNED, - } - const caseId = uuid() const civilClaimant = { hasSpokesperson: true, spokespersonNationalId: '1234567890', @@ -147,7 +145,7 @@ describe('InternalNotificationController - Send defender assigned notifications' } as Case beforeEach(async () => { - await givenWhenThen(caseId, theCase, notificationDto) + await givenWhenThen(caseId, theCase, notificationDTO) }) it('should send correct email', () => { @@ -176,11 +174,6 @@ describe('InternalNotificationController - Send defender assigned notifications' }) describe('when the case has civil claims and the advocate is a legal rights protector', () => { - const notificationDto: CaseNotificationDto = { - user: { id: userId } as User, - type: NotificationType.ADVOCATE_ASSIGNED, - } - const caseId = uuid() const civilClaimant = { hasSpokesperson: true, spokespersonNationalId: '1234567890', @@ -197,7 +190,7 @@ describe('InternalNotificationController - Send defender assigned notifications' } as Case beforeEach(async () => { - await givenWhenThen(caseId, theCase, notificationDto) + await givenWhenThen(caseId, theCase, notificationDTO) }) it('should send correct email', () => { @@ -226,11 +219,6 @@ describe('InternalNotificationController - Send defender assigned notifications' }) describe('when the case has civil claims and civil claimant does not have representation', () => { - const notificationDto: CaseNotificationDto = { - user: { id: userId } as User, - type: NotificationType.ADVOCATE_ASSIGNED, - } - const caseId = uuid() const civilClaimant = { hasSpokesperson: false, } @@ -243,7 +231,7 @@ describe('InternalNotificationController - Send defender assigned notifications' } as Case beforeEach(async () => { - await givenWhenThen(caseId, theCase, notificationDto) + await givenWhenThen(caseId, theCase, notificationDTO) }) it('should send correct email', () => { @@ -252,11 +240,6 @@ describe('InternalNotificationController - Send defender assigned notifications' }) describe('when sending defender data is missing', () => { - const notificationDto: CaseNotificationDto = { - user: { id: userId } as User, - type: NotificationType.ADVOCATE_ASSIGNED, - } - const caseId = uuid() const theCase = { type: CaseType.INDICTMENT, } as Case @@ -265,7 +248,7 @@ describe('InternalNotificationController - Send defender assigned notifications' beforeEach(async () => { const mockCreate = mockNotificationModel.create as jest.Mock mockCreate.mockResolvedValueOnce({} as Notification) - then = await givenWhenThen(caseId, theCase, notificationDto) + then = await givenWhenThen(caseId, theCase, notificationDTO) }) it('should not send notification', () => { @@ -276,11 +259,6 @@ describe('InternalNotificationController - Send defender assigned notifications' }) describe('record notification', () => { - const notificationDto: CaseNotificationDto = { - user: { id: userId } as User, - type: NotificationType.ADVOCATE_ASSIGNED, - } - const caseId = uuid() const defendant = { defenderEmail: 'recipient@gmail.com', defenderNationalId: '1234567890', @@ -295,14 +273,14 @@ describe('InternalNotificationController - Send defender assigned notifications' beforeEach(async () => { const mockCreate = mockNotificationModel.create as jest.Mock mockCreate.mockResolvedValueOnce({} as Notification) - await givenWhenThen(caseId, theCase, notificationDto) + await givenWhenThen(caseId, theCase, notificationDTO) }) it('should record notification', () => { expect(mockNotificationModel.create).toHaveBeenCalledTimes(1) expect(mockNotificationModel.create).toHaveBeenCalledWith({ caseId, - type: notificationDto.type, + type: notificationDTO.type, recipients: [ { address: defendant.defenderEmail, @@ -314,11 +292,6 @@ describe('InternalNotificationController - Send defender assigned notifications' }) describe('returns that the notification was sent', () => { - const notificationDto: CaseNotificationDto = { - user: { id: userId } as User, - type: NotificationType.ADVOCATE_ASSIGNED, - } - const caseId = uuid() const theCase = { id: caseId, type: CaseType.INDICTMENT, @@ -335,7 +308,7 @@ describe('InternalNotificationController - Send defender assigned notifications' beforeEach(async () => { const mockCreate = mockNotificationModel.create as jest.Mock mockCreate.mockResolvedValueOnce({} as Notification) - then = await givenWhenThen(caseId, theCase, notificationDto) + then = await givenWhenThen(caseId, theCase, notificationDTO) }) it('should return notification was sent', () => { @@ -344,11 +317,6 @@ describe('InternalNotificationController - Send defender assigned notifications' }) describe('only send notification once to defender', () => { - const notificationDto: CaseNotificationDto = { - user: { id: userId } as User, - type: NotificationType.ADVOCATE_ASSIGNED, - } - const caseId = uuid() const defendant = { defenderEmail: 'recipient@gmail.com', defenderNationalId: '1234567890', @@ -372,12 +340,12 @@ describe('InternalNotificationController - Send defender assigned notifications' notifications: [ { caseId, - type: notificationDto.type, + type: notificationDTO.type, recipients: [{ address: defendant.defenderEmail, success: true }], }, ], } as Case, - notificationDto, + notificationDTO, ) }) @@ -389,11 +357,6 @@ describe('InternalNotificationController - Send defender assigned notifications' }) describe('should send email to every defender', () => { - const notificationDto: CaseNotificationDto = { - user: { id: userId } as User, - type: NotificationType.ADVOCATE_ASSIGNED, - } - const caseId = uuid() const defender1 = { defenderEmail: 'some-email@island.is' } const defender2 = { defenderEmail: 'other-email@island.is' } const defendants = [defender1, defender2] @@ -407,7 +370,7 @@ describe('InternalNotificationController - Send defender assigned notifications' beforeEach(async () => { const mockCreate = mockNotificationModel.create as jest.Mock mockCreate.mockResolvedValueOnce({} as Notification) - then = await givenWhenThen(caseId, theCase, notificationDto) + then = await givenWhenThen(caseId, theCase, notificationDTO) }) it('should return notification was sent', () => { @@ -418,11 +381,6 @@ describe('InternalNotificationController - Send defender assigned notifications' }) describe('should only send one email to each defender', () => { - const notificationDto: CaseNotificationDto = { - user: { id: userId } as User, - type: NotificationType.ADVOCATE_ASSIGNED, - } - const caseId = uuid() const defender1 = { defenderNationalId: '1234567890', defenderEmail: 'some-email@island.is', @@ -441,7 +399,7 @@ describe('InternalNotificationController - Send defender assigned notifications' beforeEach(async () => { const mockCreate = mockNotificationModel.create as jest.Mock mockCreate.mockResolvedValueOnce({} as Notification) - then = await givenWhenThen(caseId, theCase, notificationDto) + then = await givenWhenThen(caseId, theCase, notificationDTO) }) it('should return notification was sent', () => { @@ -472,12 +430,6 @@ describe('InternalNotificationController - Send defender assigned notifications' }) describe('when sending assigned defender notifications in a restriction case', () => { - const notificationDto: CaseNotificationDto = { - user: { id: userId } as User, - type: NotificationType.ADVOCATE_ASSIGNED, - } - const caseId = uuid() - const theCase = { id: caseId, type: CaseType.ADMISSION_TO_FACILITY, @@ -490,7 +442,7 @@ describe('InternalNotificationController - Send defender assigned notifications' } as Case beforeEach(async () => { - await givenWhenThen(caseId, theCase, notificationDto) + await givenWhenThen(caseId, theCase, notificationDTO) }) it('should send email with link', () => { @@ -519,12 +471,6 @@ describe('InternalNotificationController - Send defender assigned notifications' }) describe('when sending assigned defender without national id notifications in a restriction case', () => { - const notificationDto: CaseNotificationDto = { - user: { id: userId } as User, - type: NotificationType.ADVOCATE_ASSIGNED, - } - const caseId = uuid() - const theCase = { id: caseId, type: CaseType.ADMISSION_TO_FACILITY, @@ -536,7 +482,7 @@ describe('InternalNotificationController - Send defender assigned notifications' } as Case beforeEach(async () => { - await givenWhenThen(caseId, theCase, notificationDto) + await givenWhenThen(caseId, theCase, notificationDTO) }) it('should send an email without a link', () => { @@ -565,12 +511,6 @@ describe('InternalNotificationController - Send defender assigned notifications' }) describe('when sending notifications in an investigation case', () => { - const notificationDto: CaseNotificationDto = { - user: { id: userId } as User, - type: NotificationType.ADVOCATE_ASSIGNED, - } - const caseId = uuid() - const theCase = { id: caseId, type: CaseType.PHONE_TAPPING, @@ -582,7 +522,7 @@ describe('InternalNotificationController - Send defender assigned notifications' } as Case beforeEach(async () => { - await givenWhenThen(caseId, theCase, notificationDto) + await givenWhenThen(caseId, theCase, notificationDTO) }) it('should not send email', () => { From 0ec93dd302a798f8337c14302a239fbbbab875ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8Dvar=20Oddsson?= Date: Mon, 7 Oct 2024 20:39:48 +0000 Subject: [PATCH 14/23] Add promise handling to email sending --- .../internalNotification.service.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/apps/judicial-system/backend/src/app/modules/notification/internalNotification.service.ts b/apps/judicial-system/backend/src/app/modules/notification/internalNotification.service.ts index 00df4cb93702..9b038dac2a9c 100644 --- a/apps/judicial-system/backend/src/app/modules/notification/internalNotification.service.ts +++ b/apps/judicial-system/backend/src/app/modules/notification/internalNotification.service.ts @@ -1639,14 +1639,16 @@ export class InternalNotificationService extends BaseNotificationService { ) && hasSpokesperson if (shouldSend === true) { - this.sendAdvocateAssignedNotification( - theCase, - spokespersonIsLawyer - ? AdvocateType.LAWYER - : AdvocateType.LEGAL_RIGHTS_PROTECTOR, - spokespersonNationalId, - spokespersonName, - spokespersonEmail, + promises.push( + this.sendAdvocateAssignedNotification( + theCase, + spokespersonIsLawyer + ? AdvocateType.LAWYER + : AdvocateType.LEGAL_RIGHTS_PROTECTOR, + spokespersonNationalId, + spokespersonName, + spokespersonEmail, + ), ) } } From 276040d1ecc6ddc062f484f5f02e25f14a019f0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8Dvar=20Oddsson?= Date: Mon, 7 Oct 2024 20:41:47 +0000 Subject: [PATCH 15/23] Rename parameters --- .../notification/internalNotification.service.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/judicial-system/backend/src/app/modules/notification/internalNotification.service.ts b/apps/judicial-system/backend/src/app/modules/notification/internalNotification.service.ts index 9b038dac2a9c..c8d9a1c40fe4 100644 --- a/apps/judicial-system/backend/src/app/modules/notification/internalNotification.service.ts +++ b/apps/judicial-system/backend/src/app/modules/notification/internalNotification.service.ts @@ -1568,25 +1568,25 @@ export class InternalNotificationService extends BaseNotificationService { private sendAdvocateAssignedNotification( theCase: Case, advocateType: AdvocateType, - defenderNationalId?: string, - defenderName?: string, - defenderEmail?: string, + advocateNationalId?: string, + advocateName?: string, + advocateEmail?: string, ): Promise { const { subject, body } = formatAdvocateAssignedEmailNotification( this.formatMessage, theCase, advocateType, - defenderNationalId && + advocateNationalId && formatDefenderRoute(this.config.clientUrl, theCase.type, theCase.id), ) return this.sendEmail( subject, body, - defenderName, - defenderEmail, + advocateName, + advocateEmail, undefined, - Boolean(defenderNationalId) === false, + Boolean(advocateNationalId) === false, ) } From 5c5410525d6e49aac97fcbe343e75bd691a252f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8Dvar=20Oddsson?= Date: Tue, 8 Oct 2024 09:53:30 +0000 Subject: [PATCH 16/23] Fix tests --- .../sendAdvocateAssignedNotifications.spec.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendAdvocateAssignedNotifications.spec.ts b/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendAdvocateAssignedNotifications.spec.ts index b6e5a6dc46c6..3b8c2118c9a2 100644 --- a/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendAdvocateAssignedNotifications.spec.ts +++ b/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendAdvocateAssignedNotifications.spec.ts @@ -44,7 +44,6 @@ describe('InternalNotificationController - Send defender assigned notifications' let mockNotificationModel: typeof Notification let givenWhenThen: GivenWhenThen let notificationDTO: CaseNotificationDto - let caseId: string beforeEach(async () => { const { @@ -59,7 +58,6 @@ describe('InternalNotificationController - Send defender assigned notifications' type: NotificationType.ADVOCATE_ASSIGNED, } - caseId = uuid() mockEmailService = emailService mockConfig = notificationConfig mockNotificationModel = notificationModel @@ -86,6 +84,8 @@ describe('InternalNotificationController - Send defender assigned notifications' }) describe('when sending defender assigned notifications', () => { + const caseId = uuid() + const defendant = { defenderNationalId: '1234567890', defenderEmail: 'recipient@gmail.com', @@ -129,6 +129,7 @@ describe('InternalNotificationController - Send defender assigned notifications' }) describe('when the case has civil claims and the advocate is a lawyer', () => { + const caseId = uuid() const civilClaimant = { hasSpokesperson: true, spokespersonNationalId: '1234567890', @@ -174,6 +175,7 @@ describe('InternalNotificationController - Send defender assigned notifications' }) describe('when the case has civil claims and the advocate is a legal rights protector', () => { + const caseId = uuid() const civilClaimant = { hasSpokesperson: true, spokespersonNationalId: '1234567890', @@ -219,6 +221,7 @@ describe('InternalNotificationController - Send defender assigned notifications' }) describe('when the case has civil claims and civil claimant does not have representation', () => { + const caseId = uuid() const civilClaimant = { hasSpokesperson: false, } @@ -240,6 +243,7 @@ describe('InternalNotificationController - Send defender assigned notifications' }) describe('when sending defender data is missing', () => { + const caseId = uuid() const theCase = { type: CaseType.INDICTMENT, } as Case @@ -259,6 +263,7 @@ describe('InternalNotificationController - Send defender assigned notifications' }) describe('record notification', () => { + const caseId = uuid() const defendant = { defenderEmail: 'recipient@gmail.com', defenderNationalId: '1234567890', @@ -292,6 +297,7 @@ describe('InternalNotificationController - Send defender assigned notifications' }) describe('returns that the notification was sent', () => { + const caseId = uuid() const theCase = { id: caseId, type: CaseType.INDICTMENT, @@ -317,6 +323,7 @@ describe('InternalNotificationController - Send defender assigned notifications' }) describe('only send notification once to defender', () => { + const caseId = uuid() const defendant = { defenderEmail: 'recipient@gmail.com', defenderNationalId: '1234567890', @@ -357,6 +364,7 @@ describe('InternalNotificationController - Send defender assigned notifications' }) describe('should send email to every defender', () => { + const caseId = uuid() const defender1 = { defenderEmail: 'some-email@island.is' } const defender2 = { defenderEmail: 'other-email@island.is' } const defendants = [defender1, defender2] @@ -381,6 +389,7 @@ describe('InternalNotificationController - Send defender assigned notifications' }) describe('should only send one email to each defender', () => { + const caseId = uuid() const defender1 = { defenderNationalId: '1234567890', defenderEmail: 'some-email@island.is', @@ -430,6 +439,7 @@ describe('InternalNotificationController - Send defender assigned notifications' }) describe('when sending assigned defender notifications in a restriction case', () => { + const caseId = uuid() const theCase = { id: caseId, type: CaseType.ADMISSION_TO_FACILITY, @@ -471,6 +481,7 @@ describe('InternalNotificationController - Send defender assigned notifications' }) describe('when sending assigned defender without national id notifications in a restriction case', () => { + const caseId = uuid() const theCase = { id: caseId, type: CaseType.ADMISSION_TO_FACILITY, @@ -511,6 +522,7 @@ describe('InternalNotificationController - Send defender assigned notifications' }) describe('when sending notifications in an investigation case', () => { + const caseId = uuid() const theCase = { id: caseId, type: CaseType.PHONE_TAPPING, From b41853ee4ed45458429e5b37f3ae3ff3dbb03671 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8Dvar=20Oddsson?= Date: Wed, 9 Oct 2024 13:00:11 +0000 Subject: [PATCH 17/23] Reorder imports --- .../app/modules/notification/internalNotification.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/judicial-system/backend/src/app/modules/notification/internalNotification.service.ts b/apps/judicial-system/backend/src/app/modules/notification/internalNotification.service.ts index c8d9a1c40fe4..7be128ecb9b4 100644 --- a/apps/judicial-system/backend/src/app/modules/notification/internalNotification.service.ts +++ b/apps/judicial-system/backend/src/app/modules/notification/internalNotification.service.ts @@ -51,13 +51,13 @@ import { } from '@island.is/judicial-system/types' import { + formatAdvocateAssignedEmailNotification, formatCourtHeadsUpSmsNotification, formatCourtIndictmentReadyForCourtEmailNotification, formatCourtOfAppealJudgeAssignedEmailNotification, formatCourtReadyForCourtSmsNotification, formatCourtResubmittedToCourtSmsNotification, formatCourtRevokedSmsNotification, - formatAdvocateAssignedEmailNotification, formatDefenderCourtDateEmailNotification, formatDefenderCourtDateLinkEmailNotification, formatDefenderReadyForCourtEmailNotification, From c1133f84940bf1312aff2199e1dc6dafce817787 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8Dvar=20Oddsson?= Date: Wed, 9 Oct 2024 15:16:37 +0000 Subject: [PATCH 18/23] Fix texts --- .../backend/src/app/formatters/formatters.ts | 47 +++++++++++++------ .../backend/src/app/messages/notifications.ts | 22 +++++++-- 2 files changed, 50 insertions(+), 19 deletions(-) diff --git a/apps/judicial-system/backend/src/app/formatters/formatters.ts b/apps/judicial-system/backend/src/app/formatters/formatters.ts index 7ed85dbcc8d7..84add6be6b4a 100644 --- a/apps/judicial-system/backend/src/app/formatters/formatters.ts +++ b/apps/judicial-system/backend/src/app/formatters/formatters.ts @@ -14,7 +14,7 @@ import { laws, readableIndictmentSubtypes, } from '@island.is/judicial-system/formatters' -import type { +import { AdvocateType, Gender, UserRole, @@ -674,19 +674,38 @@ export const formatAdvocateAssignedEmailNotification = ( advocateType: AdvocateType, overviewUrl?: string, ): SubjectAndBody => { - const subject = formatMessage(notifications.defenderAssignedEmail.subject, { - court: capitalize(theCase.court?.name ?? ''), - }) - - const body = formatMessage(notifications.defenderAssignedEmail.body, { - defenderHasAccessToRVG: Boolean(overviewUrl), - advocateType, - courtCaseNumber: capitalize(theCase.courtCaseNumber ?? ''), - court: theCase.court?.name ?? '', - courtName: theCase.court?.name.replace('dómur', 'dómi') ?? '', - linkStart: ``, - linkEnd: '', - }) + const subject = + advocateType === AdvocateType.DEFENDER + ? formatMessage( + notifications.defenderAssignedEmail.subjectAccessToCaseFiles, + { + court: capitalize(theCase.court?.name ?? ''), + }, + ) + : formatMessage(notifications.defenderAssignedEmail.subjectAccess, { + courtCaseNumber: theCase.courtCaseNumber, + }) + + const body = + advocateType === AdvocateType.DEFENDER + ? formatMessage( + notifications.defenderAssignedEmail.bodyAccessToCaseFiles, + { + defenderHasAccessToRVG: Boolean(overviewUrl), + courtCaseNumber: capitalize(theCase.courtCaseNumber ?? ''), + court: theCase.court?.name ?? '', + courtName: theCase.court?.name.replace('dómur', 'dómi') ?? '', + linkStart: ``, + linkEnd: '', + }, + ) + : formatMessage(notifications.defenderAssignedEmail.bodyAccess, { + court: theCase.court?.name, + advocateType, + courtCaseNumber: capitalize(theCase.courtCaseNumber ?? ''), + linkStart: ``, + linkEnd: '', + }) return { body, subject } } diff --git a/apps/judicial-system/backend/src/app/messages/notifications.ts b/apps/judicial-system/backend/src/app/messages/notifications.ts index 0c83827cd58f..c1719a542750 100644 --- a/apps/judicial-system/backend/src/app/messages/notifications.ts +++ b/apps/judicial-system/backend/src/app/messages/notifications.ts @@ -608,16 +608,28 @@ export const notifications = { }, }), defenderAssignedEmail: defineMessages({ - subject: { - id: 'judicial.system.backend:notifications.defender_assigned_email.subject', + subjectAccessToCaseFiles: { + id: 'judicial.system.backend:notifications.defender_assigned_email.subject_access_to_case_files', defaultMessage: '{court} - aðgangur að málsgögnum', description: 'Fyrirsögn í pósti til verjanda þegar hann er skráður á mál.', }, - body: { - id: 'judicial.system.backend:notifications.defender_assigned_email.body_v4', + subjectAccess: { + id: 'judicial.system.backend:notifications.defender_assigned_email.subject_access', + defaultMessage: 'Skráning í máli {courtCaseNumber}', + description: + 'Fyrirsögn í pósti til verjanda þegar hann er skráður á mál.', + }, + bodyAccessToCaseFiles: { + id: 'judicial.system.backend:notifications.defender_assigned_email.body_access_to_case_files', + defaultMessage: + '{court} hefur skráð þig verjanda í máli {courtCaseNumber}.

{defenderHasAccessToRVG, select, true {Gögn málsins eru aðgengileg á {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: 'Texti í pósti til verjanda þegar hann er skráður á mál.', + }, + bodyAccess: { + id: 'judicial.system.backend:notifications.defender_assigned_email.body_access', defaultMessage: - '{court} hefur skráð þig {advocateType, select, LAWYER {lögmann einkaréttarkröfuhafa} LEGAL_RIGHTS_PROTECTOR {réttargæslumann einkaréttarkröfuhafa} other {verjanda}} í máli {courtCaseNumber}.

{defenderHasAccessToRVG, select, true {Gögn málsins eru aðgengileg á {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}}.', + '{court} hefur skráð þig {advocateType, select, LAWYER {lögmann einkaréttarkröfuhafa} LEGAL_RIGHTS_PROTECTOR {réttargæslumann einkaréttarkröfuhafa} other {verjanda}} í máli {courtCaseNumber}.

{defenderHasAccessToRVG, select, true {Sjá nánar á {linkStart}yfirlitssíðu málsins í Réttarvörslugátt{linkEnd}} other {Þú getur nálgast málið hjá {courtName}.}}.', description: 'Texti í pósti til verjanda þegar hann er skráður á mál.', }, }), From 08b70a2da76e1cf8e5474270c23826debec8a585 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8Dvar=20Oddsson?= Date: Wed, 9 Oct 2024 15:16:55 +0000 Subject: [PATCH 19/23] Fix texts --- .../backend/src/app/formatters/formatters.ts | 8 ++++---- .../backend/src/app/messages/notifications.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/judicial-system/backend/src/app/formatters/formatters.ts b/apps/judicial-system/backend/src/app/formatters/formatters.ts index 84add6be6b4a..62ed174bfee4 100644 --- a/apps/judicial-system/backend/src/app/formatters/formatters.ts +++ b/apps/judicial-system/backend/src/app/formatters/formatters.ts @@ -677,19 +677,19 @@ export const formatAdvocateAssignedEmailNotification = ( const subject = advocateType === AdvocateType.DEFENDER ? formatMessage( - notifications.defenderAssignedEmail.subjectAccessToCaseFiles, + notifications.advocateAssignedEmail.subjectAccessToCaseFiles, { court: capitalize(theCase.court?.name ?? ''), }, ) - : formatMessage(notifications.defenderAssignedEmail.subjectAccess, { + : formatMessage(notifications.advocateAssignedEmail.subjectAccess, { courtCaseNumber: theCase.courtCaseNumber, }) const body = advocateType === AdvocateType.DEFENDER ? formatMessage( - notifications.defenderAssignedEmail.bodyAccessToCaseFiles, + notifications.advocateAssignedEmail.bodyAccessToCaseFiles, { defenderHasAccessToRVG: Boolean(overviewUrl), courtCaseNumber: capitalize(theCase.courtCaseNumber ?? ''), @@ -699,7 +699,7 @@ export const formatAdvocateAssignedEmailNotification = ( linkEnd: '', }, ) - : formatMessage(notifications.defenderAssignedEmail.bodyAccess, { + : formatMessage(notifications.advocateAssignedEmail.bodyAccess, { court: theCase.court?.name, advocateType, courtCaseNumber: capitalize(theCase.courtCaseNumber ?? ''), diff --git a/apps/judicial-system/backend/src/app/messages/notifications.ts b/apps/judicial-system/backend/src/app/messages/notifications.ts index c1719a542750..9777fdd1be49 100644 --- a/apps/judicial-system/backend/src/app/messages/notifications.ts +++ b/apps/judicial-system/backend/src/app/messages/notifications.ts @@ -607,7 +607,7 @@ export const notifications = { 'Notaður sem texti í tölvupósti til verjanda vegna breytingar á lengd gæslu/einangrunar/vistunar þar sem úrskurðað var í einangrun.', }, }), - defenderAssignedEmail: defineMessages({ + advocateAssignedEmail: defineMessages({ subjectAccessToCaseFiles: { id: 'judicial.system.backend:notifications.defender_assigned_email.subject_access_to_case_files', defaultMessage: '{court} - aðgangur að málsgögnum', From 5fa9870dab4daa08ac3256c8a49ade531d3daffd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8Dvar=20Oddsson?= Date: Thu, 10 Oct 2024 12:57:16 +0000 Subject: [PATCH 20/23] Fix texts --- apps/judicial-system/backend/src/app/formatters/formatters.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/judicial-system/backend/src/app/formatters/formatters.ts b/apps/judicial-system/backend/src/app/formatters/formatters.ts index 62ed174bfee4..d48904e27885 100644 --- a/apps/judicial-system/backend/src/app/formatters/formatters.ts +++ b/apps/judicial-system/backend/src/app/formatters/formatters.ts @@ -700,6 +700,7 @@ export const formatAdvocateAssignedEmailNotification = ( }, ) : formatMessage(notifications.advocateAssignedEmail.bodyAccess, { + defenderHasAccessToRVG: Boolean(overviewUrl), court: theCase.court?.name, advocateType, courtCaseNumber: capitalize(theCase.courtCaseNumber ?? ''), From 9f2f435b55d508420247969b9314a5ee53e6a3f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8Dvar=20Oddsson?= Date: Fri, 11 Oct 2024 09:03:29 +0000 Subject: [PATCH 21/23] Fix tests --- .../sendAdvocateAssignedNotifications.spec.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendAdvocateAssignedNotifications.spec.ts b/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendAdvocateAssignedNotifications.spec.ts index 3b8c2118c9a2..097e90d35fa6 100644 --- a/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendAdvocateAssignedNotifications.spec.ts +++ b/apps/judicial-system/backend/src/app/modules/notification/test/internalNotificationController/sendAdvocateAssignedNotifications.spec.ts @@ -167,9 +167,9 @@ describe('InternalNotificationController - Send defender assigned notifications' address: mockConfig.email.replyToEmail, }, attachments: undefined, - subject: 'Héraðsdómur Reykjavíkur - aðgangur að málsgögnum', + subject: `Skráning í máli ${theCase.courtCaseNumber}`, text: expect.anything(), // same as html but stripped html tags - html: `Héraðsdómur Reykjavíkur hefur skráð þig lögmann einkaréttarkröfuhafa í máli ${theCase.courtCaseNumber}.

Gögn málsins eru aðgengileg á yfirlitssíðu málsins í Réttarvörslugátt.`, + html: `Héraðsdómur Reykjavíkur hefur skráð þig lögmann einkaréttarkröfuhafa í máli ${theCase.courtCaseNumber}.

Sjá nánar á yfirlitssíðu málsins í Réttarvörslugátt.`, }) }) }) @@ -213,9 +213,9 @@ describe('InternalNotificationController - Send defender assigned notifications' address: mockConfig.email.replyToEmail, }, attachments: undefined, - subject: 'Héraðsdómur Reykjavíkur - aðgangur að málsgögnum', + subject: `Skráning í máli ${theCase.courtCaseNumber}`, text: expect.anything(), // same as html but stripped html tags - html: `Héraðsdómur Reykjavíkur hefur skráð þig réttargæslumann einkaréttarkröfuhafa í máli ${theCase.courtCaseNumber}.

Gögn málsins eru aðgengileg á yfirlitssíðu málsins í Réttarvörslugátt.`, + html: `Héraðsdómur Reykjavíkur hefur skráð þig réttargæslumann einkaréttarkröfuhafa í máli ${theCase.courtCaseNumber}.

Sjá nánar á yfirlitssíðu málsins í Réttarvörslugátt.`, }) }) }) From aa96f5578384e74ff6001b7fd74dcf0be7f6cf3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8Dvar=20Oddsson?= Date: Fri, 11 Oct 2024 10:10:15 +0000 Subject: [PATCH 22/23] Use correct types --- .../Indictments/Advocates/SelectCivilClaimantAdvocate.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/judicial-system/web/src/routes/Court/Indictments/Advocates/SelectCivilClaimantAdvocate.tsx b/apps/judicial-system/web/src/routes/Court/Indictments/Advocates/SelectCivilClaimantAdvocate.tsx index c79fb2078f01..7047b7724dfd 100644 --- a/apps/judicial-system/web/src/routes/Court/Indictments/Advocates/SelectCivilClaimantAdvocate.tsx +++ b/apps/judicial-system/web/src/routes/Court/Indictments/Advocates/SelectCivilClaimantAdvocate.tsx @@ -9,6 +9,7 @@ import { RadioButton, Text, } from '@island.is/island-ui/core' +import { AdvocateType } from '@island.is/judicial-system/types' import { BlueBox, FormContext, @@ -87,8 +88,8 @@ const SelectCivilClaimantAdvocate: FC = ({ civilClaimant }) => { clientId={civilClaimant.id} advocateType={ civilClaimant.spokespersonIsLawyer - ? 'defender' - : 'legal_rights_protector' + ? AdvocateType.LAWYER + : AdvocateType.LEGAL_RIGHTS_PROTECTOR } disabled={ civilClaimant.spokespersonIsLawyer === null || From a3439ff942618df1d3f83dcc04a8c40db710fd82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8Dvar=20Oddsson?= Date: Fri, 11 Oct 2024 10:37:20 +0000 Subject: [PATCH 23/23] Use correct types --- .../Prosecutor/Indictments/Processing/Processing.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/apps/judicial-system/web/src/routes/Prosecutor/Indictments/Processing/Processing.tsx b/apps/judicial-system/web/src/routes/Prosecutor/Indictments/Processing/Processing.tsx index c76de5e43862..3a1800e8c7a2 100644 --- a/apps/judicial-system/web/src/routes/Prosecutor/Indictments/Processing/Processing.tsx +++ b/apps/judicial-system/web/src/routes/Prosecutor/Indictments/Processing/Processing.tsx @@ -10,7 +10,10 @@ import { Text, } from '@island.is/island-ui/core' import * as constants from '@island.is/judicial-system/consts' -import { isTrafficViolationCase } from '@island.is/judicial-system/types' +import { + AdvocateType, + isTrafficViolationCase, +} from '@island.is/judicial-system/types' import { core, titles } from '@island.is/judicial-system-web/messages' import { BlueBox, @@ -596,8 +599,8 @@ const Processing: FC = () => { clientId={civilClaimant.id} advocateType={ civilClaimant.spokespersonIsLawyer - ? 'defender' - : 'legal_rights_protector' + ? AdvocateType.LAWYER + : AdvocateType.LEGAL_RIGHTS_PROTECTOR } disabled={ civilClaimant.spokespersonIsLawyer === null ||