From fa8f276f5a795b3df1b43d45f400d3d6677b4159 Mon Sep 17 00:00:00 2001 From: unakb Date: Fri, 4 Oct 2024 17:35:05 +0000 Subject: [PATCH] fix(j-s): Civil claimant view for courts (#16171) * fix(j-s): Civil claimant view for courts * feat(j-s): Judge can add and remove advocates * Update civilClaimant.controller.ts * Fixed key on Box --- .../defendant/civilClaimant.controller.ts | 24 ++- .../pages/domur/akaera/malflytjendur/[id].ts | 4 +- .../Advocates/Advocates.strings.ts | 77 +++++++++ .../Defender.tsx => Advocates/Advocates.tsx} | 26 ++- .../Advocates/SelectCivilClaimantAdvocate.tsx | 162 ++++++++++++++++++ .../SelectDefender.tsx | 4 +- .../Indictments/Defender/Defender.strings.ts | 28 --- 7 files changed, 283 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} (74%) 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..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 @@ -19,7 +19,13 @@ import { RolesRules, } from '@island.is/judicial-system/auth' -import { prosecutorRepresentativeRule, prosecutorRule } from '../../guards' +import { + districtCourtAssistantRule, + districtCourtJudgeRule, + districtCourtRegistrarRule, + 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 +42,13 @@ export class CivilClaimantController { ) {} @UseGuards(CaseExistsGuard, CaseWriteGuard) - @RolesRules(prosecutorRule, prosecutorRepresentativeRule) + @RolesRules( + prosecutorRule, + prosecutorRepresentativeRule, + districtCourtJudgeRule, + districtCourtRegistrarRule, + districtCourtAssistantRule, + ) @Post() @ApiCreatedResponse({ type: CivilClaimant, @@ -52,7 +64,13 @@ export class CivilClaimantController { } @UseGuards(CaseExistsGuard, CaseWriteGuard) - @RolesRules(prosecutorRule, prosecutorRepresentativeRule) + @RolesRules( + prosecutorRule, + prosecutorRepresentativeRule, + districtCourtJudgeRule, + districtCourtRegistrarRule, + districtCourtAssistantRule, + ) @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..1250e9fa97b9 --- /dev/null +++ b/apps/judicial-system/web/src/routes/Court/Indictments/Advocates/Advocates.strings.ts @@ -0,0 +1,77 @@ +import { defineMessages } from 'react-intl' + +export const strings = defineMessages({ + title: { + 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.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.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.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.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.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.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.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.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/Defender/Defender.tsx b/apps/judicial-system/web/src/routes/Court/Indictments/Advocates/Advocates.tsx similarity index 74% 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..ffdba0747338 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) => ( + + + + ))} + + )} { ) } -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..c79fb2078f01 --- /dev/null +++ b/apps/judicial-system/web/src/routes/Court/Indictments/Advocates/SelectCivilClaimantAdvocate.tsx @@ -0,0 +1,162 @@ +import { FC, useContext } from 'react' +import { useIntl } from 'react-intl' + +import { + AlertMessage, + Box, + Button, + 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} + + {civilClaimant.hasSpokesperson ? ( + <> + + + + 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. ', - }, -})