Skip to content

Commit

Permalink
fix(j-s): Civil claimant view for courts (#16171)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
unakb authored Oct 4, 2024
1 parent 1482e07 commit fa8f276
Show file tree
Hide file tree
Showing 7 changed files with 283 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -36,7 +42,13 @@ export class CivilClaimantController {
) {}

@UseGuards(CaseExistsGuard, CaseWriteGuard)
@RolesRules(prosecutorRule, prosecutorRepresentativeRule)
@RolesRules(
prosecutorRule,
prosecutorRepresentativeRule,
districtCourtJudgeRule,
districtCourtRegistrarRule,
districtCourtAssistantRule,
)
@Post()
@ApiCreatedResponse({
type: CivilClaimant,
Expand All @@ -52,7 +64,13 @@ export class CivilClaimantController {
}

@UseGuards(CaseExistsGuard, CaseWriteGuard)
@RolesRules(prosecutorRule, prosecutorRepresentativeRule)
@RolesRules(
prosecutorRule,
prosecutorRepresentativeRule,
districtCourtJudgeRule,
districtCourtRegistrarRule,
districtCourtAssistantRule,
)
@Patch(':civilClaimantId')
@ApiOkResponse({
type: CivilClaimant,
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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.',
},
})
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -39,6 +40,7 @@ const HearingArrangements = () => {
)

const stepIsValid = !isSendingNotification && isDefenderStepValid(workingCase)
const hasCivilClaimants = (workingCase.civilClaimants?.length ?? 0) > 0

return (
<PageLayout
Expand All @@ -50,23 +52,33 @@ const HearingArrangements = () => {
>
<PageHeader title={formatMessage(titles.court.indictments.defender)} />
<FormContentContainer>
<PageTitle>{formatMessage(m.title)}</PageTitle>
<PageTitle>{formatMessage(strings.title)}</PageTitle>
<CourtCaseInfo workingCase={workingCase} />
<Box component="section" marginBottom={5}>
<AlertMessage
message={formatMessage(m.alertBannerText)}
message={formatMessage(strings.alertBannerText)}
type="info"
/>
</Box>
<Box component="section" marginBottom={10}>
<Box component="section" marginBottom={hasCivilClaimants ? 5 : 10}>
<SectionHeading
title={formatMessage(m.selectDefenderHeading)}
title={formatMessage(strings.selectDefenderHeading)}
required
/>
{workingCase.defendants?.map((defendant, index) => (
<SelectDefender defendant={defendant} key={index} />
))}
</Box>
{hasCivilClaimants && (
<Box component="section" marginBottom={10}>
<SectionHeading title={formatMessage(strings.civilClaimants)} />
{workingCase.civilClaimants?.map((civilClaimant) => (
<Box component="section" marginBottom={5} key={civilClaimant.id}>
<SelectCivilClaimantAdvocate civilClaimant={civilClaimant} />
</Box>
))}
</Box>
)}
</FormContentContainer>
<FormContentContainer isFooter>
<FormFooter
Expand All @@ -85,4 +97,4 @@ const HearingArrangements = () => {
)
}

export default HearingArrangements
export default Advocates
Original file line number Diff line number Diff line change
@@ -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<Props> = ({ 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 (
<BlueBox>
<Box marginBottom={2}>
<Text variant="h4">{civilClaimant.name}</Text>
</Box>
{civilClaimant.hasSpokesperson ? (
<>
<Box display="flex" marginY={2}>
<Box width="half" marginRight={1}>
<RadioButton
name="civilClaimantAdvocateType"
id={`civil_claimant_lawyer-${civilClaimant.id}`}
label={formatMessage(strings.lawyer)}
large
backgroundColor="white"
checked={civilClaimant.spokespersonIsLawyer === true}
onChange={() =>
updateCivilClaimant({
spokespersonIsLawyer: true,
} as UpdateCivilClaimantInput)
}
/>
</Box>
<Box width="half" marginLeft={1}>
<RadioButton
name="civilClaimantAdvocateType"
id={`civil_claimant_legal_rights_protector-${civilClaimant.id}`}
label={formatMessage(strings.legalRightsProtector)}
large
backgroundColor="white"
checked={civilClaimant.spokespersonIsLawyer === false}
onChange={() =>
updateCivilClaimant({
spokespersonIsLawyer: false,
} as UpdateCivilClaimantInput)
}
/>
</Box>
</Box>
<Box marginBottom={2}>
<InputAdvocate
clientId={civilClaimant.id}
advocateType={
civilClaimant.spokespersonIsLawyer
? 'defender'
: 'legal_rights_protector'
}
disabled={
civilClaimant.spokespersonIsLawyer === null ||
civilClaimant.spokespersonIsLawyer === undefined
}
isCivilClaim={true}
/>
</Box>
<Checkbox
name={`shareFilesWithCivilClaimantAdvocate-${civilClaimant.id}`}
label={formatMessage(strings.shareFilesWithCivilClaimantAdvocate, {
defenderIsLawyer: civilClaimant.spokespersonIsLawyer,
})}
checked={Boolean(civilClaimant.caseFilesSharedWithSpokesperson)}
disabled={
civilClaimant.spokespersonIsLawyer === null ||
civilClaimant.spokespersonIsLawyer === undefined
}
onChange={() => {
updateCivilClaimant({
caseFilesSharedWithSpokesperson:
!civilClaimant.caseFilesSharedWithSpokesperson,
} as UpdateCivilClaimantInput)
}}
tooltip={formatMessage(
strings.shareFilesWithCivilClaimantAdvocateTooltip,
{
defenderIsLawyer: civilClaimant.spokespersonIsLawyer,
},
)}
backgroundColor="white"
large
filled
/>
</>
) : (
<AlertMessage
message={formatMessage(strings.noCivilClaimantAdvocate)}
type="info"
/>
)}
<Box display="flex" justifyContent="flexEnd" marginTop={2}>
<Button
variant="text"
colorScheme={
civilClaimant.hasSpokesperson ? 'destructive' : 'default'
}
onClick={() => {
updateCivilClaimant({
hasSpokesperson: !civilClaimant.hasSpokesperson,
spokespersonEmail: null,
spokespersonPhoneNumber: null,
spokespersonName: null,
spokespersonIsLawyer: null,
spokespersonNationalId: null,
caseFilesSharedWithSpokesperson: null,
} as UpdateCivilClaimantInput)
}}
>
{civilClaimant.hasSpokesperson
? formatMessage(strings.removeCivilClaimantAdvocate, {
defenderIsLawyer: civilClaimant.spokespersonIsLawyer,
})
: formatMessage(strings.addCivilClaimantAdvocate)}
</Button>
</Box>
</BlueBox>
)
}

export default SelectCivilClaimantAdvocate
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -80,7 +80,7 @@ const SelectDefender: FC<Props> = ({ defendant }) => {
dataTestId={`defendantWaivesRightToCounsel-${defendant.id}`}
name={`defendantWaivesRightToCounsel-${defendant.id}`}
label={capitalize(
formatMessage(m.defendantWaivesRightToCounsel, {
formatMessage(strings.defendantWaivesRightToCounsel, {
accused: formatMessage(core.indictmentDefendant, { gender }),
}),
)}
Expand Down
Loading

0 comments on commit fa8f276

Please sign in to comment.