From 755fc79be12aa63ba094d491755a01f17dcc12db Mon Sep 17 00:00:00 2001 From: unakb Date: Wed, 15 May 2024 18:31:05 +0000 Subject: [PATCH 01/13] feat(j-s): Public defender overview after review --- .../defendant/dto/updateDefendant.input.ts | 5 + .../defendant/models/defendant.model.ts | 3 + .../20240514111505-update-defendant.js | 25 ++++ .../defendant/dto/updateDefendant.dto.ts | 5 + .../defendant/models/defendant.model.ts | 7 ++ .../src/components/FormProvider/case.graphql | 1 + .../DefendantInfo/DefendantInfo.strings.ts | 0 .../InfoCard/DefendantInfo/DefendantInfo.tsx | 76 ++++++++++++ .../web/src/components/InfoCard/InfoCard.tsx | 40 +++---- .../InfoCard/InfoCardClosedIndictment.tsx | 26 ++-- .../InfoCard/InfoCardIndictment.strings.ts | 10 ++ .../Indictments/Overview/Overview.strings.ts | 6 + .../Indictments/Overview/Overview.tsx | 111 +++++++++--------- .../ReviewDecision/ReviewDecision.css.ts | 0 .../ReviewDecision/ReviewDecision.strings.ts | 0 .../ReviewDecision/ReviewDecision.tsx | 0 .../IndictmentOverview/IndictmentOverview.tsx | 2 +- 17 files changed, 222 insertions(+), 95 deletions(-) create mode 100644 apps/judicial-system/backend/migrations/20240514111505-update-defendant.js create mode 100644 apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.strings.ts create mode 100644 apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx rename apps/judicial-system/web/src/routes/PublicProsecutor/{Indictments => components}/ReviewDecision/ReviewDecision.css.ts (100%) rename apps/judicial-system/web/src/routes/PublicProsecutor/{Indictments => components}/ReviewDecision/ReviewDecision.strings.ts (100%) rename apps/judicial-system/web/src/routes/PublicProsecutor/{Indictments => components}/ReviewDecision/ReviewDecision.tsx (100%) diff --git a/apps/judicial-system/api/src/app/modules/defendant/dto/updateDefendant.input.ts b/apps/judicial-system/api/src/app/modules/defendant/dto/updateDefendant.input.ts index 376ade4c40d1..caa42f85a691 100644 --- a/apps/judicial-system/api/src/app/modules/defendant/dto/updateDefendant.input.ts +++ b/apps/judicial-system/api/src/app/modules/defendant/dto/updateDefendant.input.ts @@ -82,4 +82,9 @@ export class UpdateDefendantInput { @IsOptional() @Field(() => ServiceRequirement, { nullable: true }) readonly serviceRequirement?: ServiceRequirement + + @Allow() + @IsOptional() + @Field(() => Boolean, { nullable: true }) + readonly hasViewedVerdict?: boolean } diff --git a/apps/judicial-system/api/src/app/modules/defendant/models/defendant.model.ts b/apps/judicial-system/api/src/app/modules/defendant/models/defendant.model.ts index b2e8e5981883..881a58b38e33 100644 --- a/apps/judicial-system/api/src/app/modules/defendant/models/defendant.model.ts +++ b/apps/judicial-system/api/src/app/modules/defendant/models/defendant.model.ts @@ -62,4 +62,7 @@ export class Defendant { @Field(() => ServiceRequirement, { nullable: true }) readonly serviceRequirement?: ServiceRequirement + + @Field(() => Boolean, { nullable: true }) + readonly hasViewedVerdict?: boolean } diff --git a/apps/judicial-system/backend/migrations/20240514111505-update-defendant.js b/apps/judicial-system/backend/migrations/20240514111505-update-defendant.js new file mode 100644 index 000000000000..ce36db71963d --- /dev/null +++ b/apps/judicial-system/backend/migrations/20240514111505-update-defendant.js @@ -0,0 +1,25 @@ +'use strict' + +module.exports = { + up: (queryInterface, Sequelize) => { + return queryInterface.sequelize.transaction((t) => + queryInterface.addColumn( + 'defendant', + 'has_viewed_verdict', + { + type: Sequelize.BOOLEAN, + allowNull: true, + }, + { transaction: t }, + ), + ) + }, + + down: (queryInterface) => { + return queryInterface.sequelize.transaction((t) => + queryInterface.removeColumn('defendant', 'has_viewed_verdict', { + transaction: t, + }), + ) + }, +} diff --git a/apps/judicial-system/backend/src/app/modules/defendant/dto/updateDefendant.dto.ts b/apps/judicial-system/backend/src/app/modules/defendant/dto/updateDefendant.dto.ts index bfdbe97196e2..ee22375ef61f 100644 --- a/apps/judicial-system/backend/src/app/modules/defendant/dto/updateDefendant.dto.ts +++ b/apps/judicial-system/backend/src/app/modules/defendant/dto/updateDefendant.dto.ts @@ -73,4 +73,9 @@ export class UpdateDefendantDto { @IsEnum(ServiceRequirement) @ApiPropertyOptional({ enum: ServiceRequirement }) readonly serviceRequirement?: ServiceRequirement + + @IsOptional() + @IsBoolean() + @ApiPropertyOptional() + readonly hasViewedVerdict?: boolean } diff --git a/apps/judicial-system/backend/src/app/modules/defendant/models/defendant.model.ts b/apps/judicial-system/backend/src/app/modules/defendant/models/defendant.model.ts index 5bc890121c29..8eeddd3767a8 100644 --- a/apps/judicial-system/backend/src/app/modules/defendant/models/defendant.model.ts +++ b/apps/judicial-system/backend/src/app/modules/defendant/models/defendant.model.ts @@ -143,4 +143,11 @@ export class Defendant extends Model { }) @ApiProperty() serviceRequirement?: ServiceRequirement + + @Column({ + type: DataType.BOOLEAN, + allowNull: true, + }) + @ApiProperty() + hasViewedVerdict?: boolean } diff --git a/apps/judicial-system/web/src/components/FormProvider/case.graphql b/apps/judicial-system/web/src/components/FormProvider/case.graphql index ffd4abefce09..9cc402308975 100644 --- a/apps/judicial-system/web/src/components/FormProvider/case.graphql +++ b/apps/judicial-system/web/src/components/FormProvider/case.graphql @@ -23,6 +23,7 @@ query Case($input: CaseQueryInput!) { defendantWaivesRightToCounsel defendantPlea serviceRequirement + hasViewedVerdict } defenderName defenderNationalId diff --git a/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.strings.ts b/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.strings.ts new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx b/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx new file mode 100644 index 000000000000..9a556fe241d1 --- /dev/null +++ b/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx @@ -0,0 +1,76 @@ +import React, { FC } from 'react' + +import { IconMapIcon } from '@island.is/island-ui/core' +import { Box, Button, LinkV2, Text } from '@island.is/island-ui/core' +import { formatDOB } from '@island.is/judicial-system/formatters' +import { Defendant } from '@island.is/judicial-system-web/src/graphql/schema' + +import { link } from '../../MarkdownWrapper/MarkdownWrapper.css' +import * as styles from '../InfoCard.css' + +export type DefendantActionButton = { + text: string + onClick: () => void + icon?: IconMapIcon +} +interface DefendantInfoProps { + defendant: Defendant + displayDefenderInfo: boolean + defendantActionButton?: DefendantActionButton +} + +export const DefendantInfo: FC = ({ + defendant, + displayDefenderInfo, + defendantActionButton, +}) => { + return ( +
+ + {`${defendant.name}`} + {defendant.nationalId && ( + + {`, ${formatDOB(defendant.nationalId, defendant.noNationalId)}`} + + )} + {defendant.citizenship && {`, (${defendant.citizenship})`}} + {defendant.address && {`, ${defendant.address}`}} + + + {defendant.defenderName && displayDefenderInfo && ( + + + {defendant.defenderName} + {defendant.defenderEmail && ( + {`, `} + )} + + {defendant.defenderEmail} + + + + )} + + {defendantActionButton && ( + + )} +
+ ) +} diff --git a/apps/judicial-system/web/src/components/InfoCard/InfoCard.tsx b/apps/judicial-system/web/src/components/InfoCard/InfoCard.tsx index 60c646643ccf..9a2e405c558c 100644 --- a/apps/judicial-system/web/src/components/InfoCard/InfoCard.tsx +++ b/apps/judicial-system/web/src/components/InfoCard/InfoCard.tsx @@ -2,12 +2,15 @@ import React from 'react' import { useIntl } from 'react-intl' import { Box, Icon, IconMapIcon, LinkV2, Text } from '@island.is/island-ui/core' -import { formatDOB } from '@island.is/judicial-system/formatters' import { Defendant, SessionArrangements, } from '@island.is/judicial-system-web/src/graphql/schema' +import { + DefendantActionButton, + DefendantInfo, +} from './DefendantInfo/DefendantInfo' import { strings } from './InfoCard.strings' import { link } from '../MarkdownWrapper/MarkdownWrapper.css' import * as styles from './InfoCard.css' @@ -31,7 +34,11 @@ interface DataSection { interface Props { courtOfAppealData?: Array<{ title: string; value?: React.ReactNode }> data: Array<{ title: string; value?: React.ReactNode }> - defendants?: { title: string; items: Defendant[] } + defendants?: { + title: string + items: Defendant[] + defendantActionButton?: DefendantActionButton + } defenders?: Defender[] icon?: IconMapIcon additionalDataSections?: DataSection[] @@ -113,30 +120,13 @@ const InfoCard: React.FC = (props) => { {defendants && ( <> {defendants.title} - + {defendants.items.map((defendant) => ( - - - {`${defendant.name}, `} - - {defendant.nationalId - ? `${formatDOB( - defendant.nationalId, - defendant.noNationalId, - )}, ` - : ''} - - - {defendant.citizenship && ` (${defendant.citizenship}), `} - - {defendant.address && ( - {`${defendant.address}`} - )} - - + ))} diff --git a/apps/judicial-system/web/src/components/InfoCard/InfoCardClosedIndictment.tsx b/apps/judicial-system/web/src/components/InfoCard/InfoCardClosedIndictment.tsx index f6e2a4ceb7cc..9c8279db5687 100644 --- a/apps/judicial-system/web/src/components/InfoCard/InfoCardClosedIndictment.tsx +++ b/apps/judicial-system/web/src/components/InfoCard/InfoCardClosedIndictment.tsx @@ -9,23 +9,19 @@ import { import { core } from '@island.is/judicial-system-web/messages' import { FormContext } from '../FormProvider/FormProvider' +import { DefendantActionButton } from './DefendantInfo/DefendantInfo' import InfoCard, { NameAndEmail } from './InfoCard' import { strings } from './InfoCardIndictment.strings' -const InfoCardClosedIndictment: React.FC< - React.PropsWithChildren -> = () => { +export interface Props { + defendantActionButton?: DefendantActionButton +} + +const InfoCardClosedIndictment: React.FC = (props) => { const { workingCase } = useContext(FormContext) const { formatMessage } = useIntl() - const defenders = workingCase.defendants?.map((defendant) => { - return { - name: defendant.defenderName || '', - defenderNationalId: defendant.defenderNationalId || '', - sessionArrangement: undefined, - email: defendant.defenderEmail || '', - phoneNumber: defendant.defenderPhoneNumber || '', - } - }) + + const { defendantActionButton } = props return ( 1 - ? formatMessage(core.indictmentDefendants) - : formatMessage(core.indictmentDefendant, { + ? formatMessage(strings.indictmentDefendants) + : formatMessage(strings.indictmentDefendant, { gender: workingCase.defendants[0].gender, }), ), items: workingCase.defendants, + defendantActionButton: defendantActionButton, } : undefined } - defenders={defenders} additionalDataSections={[ ...(workingCase.indictmentReviewer?.name ? [ diff --git a/apps/judicial-system/web/src/components/InfoCard/InfoCardIndictment.strings.ts b/apps/judicial-system/web/src/components/InfoCard/InfoCardIndictment.strings.ts index 85316ab91f90..8043cf5d8f8b 100644 --- a/apps/judicial-system/web/src/components/InfoCard/InfoCardIndictment.strings.ts +++ b/apps/judicial-system/web/src/components/InfoCard/InfoCardIndictment.strings.ts @@ -22,4 +22,14 @@ export const strings = defineMessages({ defaultMessage: 'Yfirlestur', description: 'Notaður sem titill á "yfirlestur" hluta af yfirliti ákæru.', }, + indictmentDefendant: { + id: 'judicial.system.core:info_card_indictment.indictment_defendant', + defaultMessage: 'Dómfelldi', + description: 'Notaður sem titill á "dómfelldi" hluta af yfirliti ákæru.', + }, + indictmentDefendants: { + id: 'judicial.system.core:info_card_indictment.indictment_defendants', + defaultMessage: 'Dómfelldu', + description: 'Notaður sem titill á "dómfelldu" hluta af yfirliti ákæru.', + }, }) diff --git a/apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.strings.ts b/apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.strings.ts index bda2b5b7b75f..e572db189814 100644 --- a/apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.strings.ts +++ b/apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.strings.ts @@ -38,4 +38,10 @@ export const strings = defineMessages({ 'Máli {caseNumber} hefur verið úthlutað til yfirlestrar á {reviewer}.', description: 'Notaður sem texti í tilkynningaglugga um yfirlesara.', }, + + displayVerdict: { + id: 'judicial.system.core:public_prosecutor.indictments.overview.display_verdict', + defaultMessage: 'Birta dóm', + description: 'Notaður sem texti á takka til að birta dóm.', + }, }) diff --git a/apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.tsx b/apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.tsx index c8447d6ea830..881e2525513d 100644 --- a/apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.tsx +++ b/apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.tsx @@ -11,6 +11,7 @@ import { useRouter } from 'next/router' import { Box, Option, Select, Text } from '@island.is/island-ui/core' import * as constants from '@island.is/judicial-system/consts' import { formatDate } from '@island.is/judicial-system/formatters' +import { isPublicProsecutorUser } from '@island.is/judicial-system/types' import { core, titles } from '@island.is/judicial-system-web/messages' import { BlueBox, @@ -36,25 +37,17 @@ import { strings } from './Overview.strings' export const Overview = () => { const router = useRouter() - const { workingCase, isLoadingWorkingCase, caseNotFound } = - useContext(FormContext) const { formatMessage: fm } = useIntl() const { user } = useContext(UserContext) const { updateCase } = useCase() + const { workingCase, isLoadingWorkingCase, caseNotFound } = + useContext(FormContext) + const [selectedIndictmentReviewer, setSelectedIndictmentReviewer] = useState | null>() const [modalVisible, setModalVisible] = useState(false) - - useEffect(() => { - setSelectedIndictmentReviewer( - workingCase.indictmentReviewer?.id - ? { - label: workingCase.indictmentReviewer?.name ?? '', - value: workingCase.indictmentReviewer?.id, - } - : null, - ) - }, [workingCase.id, workingCase.indictmentReviewer]) + const lawsBroken = useIndictmentsLawsBroken(workingCase) + const displayReviewerChoices = workingCase.indictmentReviewer === null const assignReviewer = async () => { if (!selectedIndictmentReviewer) { @@ -70,8 +63,6 @@ export const Overview = () => { setModalVisible(true) } - const lawsBroken = useIndictmentsLawsBroken(workingCase) - const handleNavigationTo = useCallback( (destination: string) => router.push(`${destination}/${workingCase.id}`), [router, workingCase.id], @@ -117,7 +108,15 @@ export const Overview = () => { {fm(strings.title)} - + { + console.log('test') + }, + icon: 'mailOpen', + }} + /> {lawsBroken.size > 0 && ( @@ -129,47 +128,51 @@ export const Overview = () => { )} - - - {fm(strings.reviewerSubtitle, { - indictmentAppealDeadline: formatDate( - workingCase.indictmentAppealDeadline, - 'P', - ), - })} - - } - /> - - { + setSelectedIndictmentReviewer(value as Option) + }} + isDisabled={loading} + required + /> + + + )} - - - + {displayReviewerChoices && ( + + + + )} {modalVisible && ( { From 2ad19c86f1b505dab3f2b105dfc7e9e1885a68d0 Mon Sep 17 00:00:00 2001 From: unakb Date: Wed, 15 May 2024 18:32:24 +0000 Subject: [PATCH 02/13] Update DefendantInfo.tsx --- .../InfoCard/DefendantInfo/DefendantInfo.tsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx b/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx index 9a556fe241d1..95308313b95d 100644 --- a/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx +++ b/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx @@ -1,7 +1,12 @@ import React, { FC } from 'react' -import { IconMapIcon } from '@island.is/island-ui/core' -import { Box, Button, LinkV2, Text } from '@island.is/island-ui/core' +import { + Box, + Button, + IconMapIcon, + LinkV2, + Text, +} from '@island.is/island-ui/core' import { formatDOB } from '@island.is/judicial-system/formatters' import { Defendant } from '@island.is/judicial-system-web/src/graphql/schema' @@ -13,6 +18,7 @@ export type DefendantActionButton = { onClick: () => void icon?: IconMapIcon } + interface DefendantInfoProps { defendant: Defendant displayDefenderInfo: boolean @@ -27,7 +33,9 @@ export const DefendantInfo: FC = ({ return (
- {`${defendant.name}`} + + {defendant.name} + {defendant.nationalId && ( {`, ${formatDOB(defendant.nationalId, defendant.noNationalId)}`} From 2259a1c852935d553245911989dc0313b23b8c59 Mon Sep 17 00:00:00 2001 From: unakb Date: Thu, 16 May 2024 15:40:05 +0000 Subject: [PATCH 03/13] feat(j-s): Continued work on setting viewed verdict --- .../DefendantInfo/DefendantInfo.css.ts | 21 +++++ .../InfoCard/DefendantInfo/DefendantInfo.tsx | 62 +++++++------ .../src/components/InfoCard/InfoCard.css.ts | 11 --- .../Indictments/Overview/Overview.strings.ts | 19 +++- .../Indictments/Overview/Overview.tsx | 88 ++++++++++++++----- 5 files changed, 137 insertions(+), 64 deletions(-) create mode 100644 apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.css.ts diff --git a/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.css.ts b/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.css.ts new file mode 100644 index 000000000000..b6f2ad3ddc6d --- /dev/null +++ b/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.css.ts @@ -0,0 +1,21 @@ +import { style } from '@vanilla-extract/css' + +import { theme } from '@island.is/island-ui/theme' + +export const gridRow = style({ + display: 'grid', + gridTemplateColumns: '5fr 1fr', + gridGap: theme.spacing[1], + marginBottom: theme.spacing[1], +}) + +export const infoCardDefendant = style({ + display: 'flex', + flexDirection: 'column', + + '@media': { + [`screen and (min-width: ${theme.breakpoints.lg}px)`]: { + display: 'block', + }, + }, +}) diff --git a/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx b/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx index 95308313b95d..dfcbbeb911c7 100644 --- a/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx +++ b/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx @@ -11,11 +11,11 @@ import { formatDOB } from '@island.is/judicial-system/formatters' import { Defendant } from '@island.is/judicial-system-web/src/graphql/schema' import { link } from '../../MarkdownWrapper/MarkdownWrapper.css' -import * as styles from '../InfoCard.css' +import * as styles from './DefendantInfo.css' export type DefendantActionButton = { text: string - onClick: () => void + onClick: (defendant: Defendant) => void icon?: IconMapIcon } @@ -25,26 +25,27 @@ interface DefendantInfoProps { defendantActionButton?: DefendantActionButton } -export const DefendantInfo: FC = ({ - defendant, - displayDefenderInfo, - defendantActionButton, -}) => { +export const DefendantInfo: FC = (props) => { + const { defendant, displayDefenderInfo, defendantActionButton } = props + return ( -
- - - {defendant.name} - - {defendant.nationalId && ( +
+
+ - {`, ${formatDOB(defendant.nationalId, defendant.noNationalId)}`} + {defendant.name} - )} - {defendant.citizenship && {`, (${defendant.citizenship})`}} - {defendant.address && {`, ${defendant.address}`}} - - + {defendant.nationalId && ( + + {`, ${formatDOB(defendant.nationalId, defendant.noNationalId)}`} + + )} + {defendant.citizenship && ( + {`, (${defendant.citizenship})`} + )} + {defendant.address && {`, ${defendant.address}`}} + + {defendant.defenderName && displayDefenderInfo && ( = ({ )} - +
+ {defendantActionButton && ( - + + + )}
) diff --git a/apps/judicial-system/web/src/components/InfoCard/InfoCard.css.ts b/apps/judicial-system/web/src/components/InfoCard/InfoCard.css.ts index 4934805dfc9a..e06105c24bec 100644 --- a/apps/judicial-system/web/src/components/InfoCard/InfoCard.css.ts +++ b/apps/judicial-system/web/src/components/InfoCard/InfoCard.css.ts @@ -35,14 +35,3 @@ export const infoCardAdditionalSectionContainer = style({ }, }, }) - -export const infoCardDefendant = style({ - display: 'flex', - flexDirection: 'column', - - '@media': { - [`screen and (min-width: ${theme.breakpoints.lg}px)`]: { - display: 'block', - }, - }, -}) diff --git a/apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.strings.ts b/apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.strings.ts index e572db189814..bc0a5d574c5f 100644 --- a/apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.strings.ts +++ b/apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.strings.ts @@ -38,10 +38,25 @@ export const strings = defineMessages({ 'Máli {caseNumber} hefur verið úthlutað til yfirlestrar á {reviewer}.', description: 'Notaður sem texti í tilkynningaglugga um yfirlesara.', }, - displayVerdict: { id: 'judicial.system.core:public_prosecutor.indictments.overview.display_verdict', - defaultMessage: 'Birta dóm', + defaultMessage: 'Dómur birtur', + description: 'Notaður sem texti á takka til að birta dóm.', + }, + defendantViewsVerdictModalTitle: { + id: 'judicial.system.core:public_prosecutor.indictments.overview.defendant_views_verdict_modal_title', + defaultMessage: 'Hefur dómur verið birtur dómfellda?', + description: 'Notaður sem titill á tilkynningaglugga um birtan dóm.', + }, + defendantViewsVerdictModalText: { + id: 'judicial.system.core:public_prosecutor.indictments.overview.defendant_views_verdict_modal_text', + defaultMessage: + 'Dómfelldi fær fjögurra vikna frest til að áfrýja dómi eftir að birting hans hefur verið staðfest.', + description: 'Notaður sem texti í tilkynningaglugga um birtan dóm.', + }, + defendantViewsVerdictModalPrimaryButtonText: { + id: 'judicial.system.core:public_prosecutor.indictments.overview.defendant_views_verdict_modal_primary_button_text', + defaultMessage: 'Staðfesta', description: 'Notaður sem texti á takka til að birta dóm.', }, }) diff --git a/apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.tsx b/apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.tsx index 881e2525513d..5e758d541cfd 100644 --- a/apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.tsx +++ b/apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.tsx @@ -1,18 +1,16 @@ -import React, { - useCallback, - useContext, - useEffect, - useMemo, - useState, -} from 'react' +import React, { useCallback, useContext, useMemo, useState } from 'react' import { useIntl } from 'react-intl' import { useRouter } from 'next/router' import { Box, Option, Select, Text } from '@island.is/island-ui/core' import * as constants from '@island.is/judicial-system/consts' import { formatDate } from '@island.is/judicial-system/formatters' -import { isPublicProsecutorUser } from '@island.is/judicial-system/types' -import { core, titles } from '@island.is/judicial-system-web/messages' +import { isCompletedCase } from '@island.is/judicial-system/types' +import { + core, + defendant, + titles, +} from '@island.is/judicial-system-web/messages' import { BlueBox, CourtCaseInfo, @@ -31,24 +29,32 @@ import { UserContext, } from '@island.is/judicial-system-web/src/components' import { useProsecutorSelectionUsersQuery } from '@island.is/judicial-system-web/src/components/ProsecutorSelection/prosecutorSelectionUsers.generated' -import { useCase } from '@island.is/judicial-system-web/src/utils/hooks' +import { Defendant } from '@island.is/judicial-system-web/src/graphql/schema' +import { + useCase, + useDefendants, +} from '@island.is/judicial-system-web/src/utils/hooks' import { strings } from './Overview.strings' +type VisibleModal = 'REVIEWER_ASSIGNED' | 'DEFENDANT_VIEWS_VERDICT' export const Overview = () => { const router = useRouter() const { formatMessage: fm } = useIntl() const { user } = useContext(UserContext) const { updateCase } = useCase() - const { workingCase, isLoadingWorkingCase, caseNotFound } = + const { workingCase, isLoadingWorkingCase, caseNotFound, setWorkingCase } = useContext(FormContext) - const [selectedIndictmentReviewer, setSelectedIndictmentReviewer] = useState | null>() - const [modalVisible, setModalVisible] = useState(false) + const [modalVisible, setModalVisible] = useState() const lawsBroken = useIndictmentsLawsBroken(workingCase) + const displayReviewerChoices = workingCase.indictmentReviewer === null + const [selectedDefendant, setSelectedDefendant] = useState() + const { setAndSendDefendantToServer } = useDefendants() + const assignReviewer = async () => { if (!selectedIndictmentReviewer) { return @@ -60,7 +66,23 @@ export const Overview = () => { return } - setModalVisible(true) + setModalVisible('REVIEWER_ASSIGNED') + } + + const handleDefendantViewVerdict = () => { + if (!selectedDefendant) { + return + } + + const updatedDefendant = { + caseId: workingCase.id, + defendantId: selectedDefendant.id, + hasViewedVerdict: true, + } + + setAndSendDefendantToServer(updatedDefendant, setWorkingCase) + + setModalVisible(undefined) } const handleNavigationTo = useCallback( @@ -91,6 +113,10 @@ export const Overview = () => { ) }, [data?.users, user]) + const handleViewVerdict = () => { + setModalVisible(undefined) + } + return ( { { - console.log('test') - }, - icon: 'mailOpen', - }} + defendantActionButton={ + isCompletedCase(workingCase.state) + ? { + text: fm(strings.displayVerdict), + onClick: (defendant) => { + setSelectedDefendant(defendant) + setModalVisible('DEFENDANT_VIEWS_VERDICT') + }, + icon: 'mailOpen', + } + : undefined + } /> {lawsBroken.size > 0 && ( @@ -174,7 +205,7 @@ export const Overview = () => { )} - {modalVisible && ( + {modalVisible === 'REVIEWER_ASSIGNED' && ( { onSecondaryButtonClick={() => router.push(constants.CASES_ROUTE)} /> )} + + {modalVisible === 'DEFENDANT_VIEWS_VERDICT' && ( + handleDefendantViewVerdict()} + secondaryButtonText={fm(core.back)} + onSecondaryButtonClick={() => setModalVisible(undefined)} + /> + )} ) } From 5ec5ca6088775c025647746e7cf78b4cf469ba86 Mon Sep 17 00:00:00 2001 From: unakb Date: Fri, 17 May 2024 11:09:21 +0000 Subject: [PATCH 04/13] fix(j-s): Cleanup --- .../src/app/modules/defendant/defendant.controller.ts | 2 ++ .../InfoCard/DefendantInfo/DefendantInfo.css.ts | 10 +++++++--- .../InfoCard/DefendantInfo/DefendantInfo.tsx | 11 ++++++++++- .../Indictments/Overview/Overview.tsx | 10 ++++------ 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/apps/judicial-system/backend/src/app/modules/defendant/defendant.controller.ts b/apps/judicial-system/backend/src/app/modules/defendant/defendant.controller.ts index 71922368ffe9..c7f86416e0f0 100644 --- a/apps/judicial-system/backend/src/app/modules/defendant/defendant.controller.ts +++ b/apps/judicial-system/backend/src/app/modules/defendant/defendant.controller.ts @@ -27,6 +27,7 @@ import { districtCourtRegistrarRule, prosecutorRepresentativeRule, prosecutorRule, + publicProsecutorStaffRule, } from '../../guards' import { Case, CaseExistsGuard, CaseWriteGuard, CurrentCase } from '../case' import { CreateDefendantDto } from './dto/createDefendant.dto' @@ -71,6 +72,7 @@ export class DefendantController { districtCourtJudgeRule, districtCourtRegistrarRule, districtCourtAssistantRule, + publicProsecutorStaffRule, ) @Patch(':defendantId') @ApiOkResponse({ diff --git a/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.css.ts b/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.css.ts index b6f2ad3ddc6d..1e529137bfe4 100644 --- a/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.css.ts +++ b/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.css.ts @@ -1,14 +1,18 @@ -import { style } from '@vanilla-extract/css' +import { style, styleVariants } from '@vanilla-extract/css' import { theme } from '@island.is/island-ui/theme' -export const gridRow = style({ +const baseGridRow = style({ display: 'grid', - gridTemplateColumns: '5fr 1fr', gridGap: theme.spacing[1], marginBottom: theme.spacing[1], }) +export const gridRow = styleVariants({ + withButton: [baseGridRow, { gridTemplateColumns: '5fr 1fr' }], + withoutButton: [baseGridRow, { gridTemplateColumns: '1fr' }], +}) + export const infoCardDefendant = style({ display: 'flex', flexDirection: 'column', diff --git a/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx b/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx index dfcbbeb911c7..37946284b531 100644 --- a/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx +++ b/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx @@ -17,6 +17,7 @@ export type DefendantActionButton = { text: string onClick: (defendant: Defendant) => void icon?: IconMapIcon + isDisabled: (defendant: Defendant) => boolean } interface DefendantInfoProps { @@ -29,7 +30,14 @@ export const DefendantInfo: FC = (props) => { const { defendant, displayDefenderInfo, defendantActionButton } = props return ( -
+
@@ -78,6 +86,7 @@ export const DefendantInfo: FC = (props) => { onClick={() => defendantActionButton.onClick(defendant)} icon={defendantActionButton.icon} iconType="outline" + disabled={defendantActionButton.isDisabled(defendant)} > {defendantActionButton.text} diff --git a/apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.tsx b/apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.tsx index 5e758d541cfd..eab3ef01ee06 100644 --- a/apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.tsx +++ b/apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.tsx @@ -69,7 +69,7 @@ export const Overview = () => { setModalVisible('REVIEWER_ASSIGNED') } - const handleDefendantViewVerdict = () => { + const handleDefendantViewsVerdict = () => { if (!selectedDefendant) { return } @@ -113,10 +113,6 @@ export const Overview = () => { ) }, [data?.users, user]) - const handleViewVerdict = () => { - setModalVisible(undefined) - } - return ( { setModalVisible('DEFENDANT_VIEWS_VERDICT') }, icon: 'mailOpen', + isDisabled: (defendant) => + defendant.hasViewedVerdict || false, } : undefined } @@ -224,7 +222,7 @@ export const Overview = () => { primaryButtonText={fm( strings.defendantViewsVerdictModalPrimaryButtonText, )} - onPrimaryButtonClick={() => handleDefendantViewVerdict()} + onPrimaryButtonClick={() => handleDefendantViewsVerdict()} secondaryButtonText={fm(core.back)} onSecondaryButtonClick={() => setModalVisible(undefined)} /> From 1a0be09128656279fc6293b9ae703732e644d54b Mon Sep 17 00:00:00 2001 From: unakb Date: Fri, 17 May 2024 11:13:47 +0000 Subject: [PATCH 05/13] Delete DefendantInfo.strings.ts --- .../components/InfoCard/DefendantInfo/DefendantInfo.strings.ts | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.strings.ts diff --git a/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.strings.ts b/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.strings.ts deleted file mode 100644 index e69de29bb2d1..000000000000 From dcfc0db251dee32cb0c7f9d33471f84c8229169d Mon Sep 17 00:00:00 2001 From: unakb Date: Mon, 20 May 2024 09:26:52 +0000 Subject: [PATCH 06/13] feat(j-s): Changed to date --- .../defendant/dto/updateDefendant.input.ts | 4 +- .../defendant/models/defendant.model.ts | 4 +- .../20240514111505-update-defendant.js | 9 ++-- .../defendant/dto/updateDefendant.dto.ts | 4 +- .../defendant/models/defendant.model.ts | 4 +- .../src/components/FormProvider/case.graphql | 2 +- .../DefendantInfo/DefendantInfo.strings.ts | 21 ++++++++ .../InfoCard/DefendantInfo/DefendantInfo.tsx | 54 ++++++++++++++----- .../web/src/components/InfoCard/InfoCard.tsx | 8 +-- .../InfoCard/InfoCardClosedIndictment.tsx | 8 +-- .../Indictments/Overview/Overview.tsx | 7 +-- 11 files changed, 88 insertions(+), 37 deletions(-) create mode 100644 apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.strings.ts diff --git a/apps/judicial-system/api/src/app/modules/defendant/dto/updateDefendant.input.ts b/apps/judicial-system/api/src/app/modules/defendant/dto/updateDefendant.input.ts index caa42f85a691..8b179cee53a5 100644 --- a/apps/judicial-system/api/src/app/modules/defendant/dto/updateDefendant.input.ts +++ b/apps/judicial-system/api/src/app/modules/defendant/dto/updateDefendant.input.ts @@ -85,6 +85,6 @@ export class UpdateDefendantInput { @Allow() @IsOptional() - @Field(() => Boolean, { nullable: true }) - readonly hasViewedVerdict?: boolean + @Field(() => String, { nullable: true }) + readonly verdictViewDate?: string } diff --git a/apps/judicial-system/api/src/app/modules/defendant/models/defendant.model.ts b/apps/judicial-system/api/src/app/modules/defendant/models/defendant.model.ts index 881a58b38e33..be22c0f5a29c 100644 --- a/apps/judicial-system/api/src/app/modules/defendant/models/defendant.model.ts +++ b/apps/judicial-system/api/src/app/modules/defendant/models/defendant.model.ts @@ -63,6 +63,6 @@ export class Defendant { @Field(() => ServiceRequirement, { nullable: true }) readonly serviceRequirement?: ServiceRequirement - @Field(() => Boolean, { nullable: true }) - readonly hasViewedVerdict?: boolean + @Field(() => String, { nullable: true }) + readonly verdictViewDate?: string } diff --git a/apps/judicial-system/backend/migrations/20240514111505-update-defendant.js b/apps/judicial-system/backend/migrations/20240514111505-update-defendant.js index ce36db71963d..d9be034fbb91 100644 --- a/apps/judicial-system/backend/migrations/20240514111505-update-defendant.js +++ b/apps/judicial-system/backend/migrations/20240514111505-update-defendant.js @@ -5,11 +5,8 @@ module.exports = { return queryInterface.sequelize.transaction((t) => queryInterface.addColumn( 'defendant', - 'has_viewed_verdict', - { - type: Sequelize.BOOLEAN, - allowNull: true, - }, + 'verdict_view_date', + { type: Sequelize.DATE, allowNull: true }, { transaction: t }, ), ) @@ -17,7 +14,7 @@ module.exports = { down: (queryInterface) => { return queryInterface.sequelize.transaction((t) => - queryInterface.removeColumn('defendant', 'has_viewed_verdict', { + queryInterface.removeColumn('defendant', 'verdict_view_date', { transaction: t, }), ) diff --git a/apps/judicial-system/backend/src/app/modules/defendant/dto/updateDefendant.dto.ts b/apps/judicial-system/backend/src/app/modules/defendant/dto/updateDefendant.dto.ts index ee22375ef61f..7f906f57551c 100644 --- a/apps/judicial-system/backend/src/app/modules/defendant/dto/updateDefendant.dto.ts +++ b/apps/judicial-system/backend/src/app/modules/defendant/dto/updateDefendant.dto.ts @@ -75,7 +75,7 @@ export class UpdateDefendantDto { readonly serviceRequirement?: ServiceRequirement @IsOptional() - @IsBoolean() + @IsString() @ApiPropertyOptional() - readonly hasViewedVerdict?: boolean + readonly verdictViewDate?: string } diff --git a/apps/judicial-system/backend/src/app/modules/defendant/models/defendant.model.ts b/apps/judicial-system/backend/src/app/modules/defendant/models/defendant.model.ts index 8eeddd3767a8..6d78ca88ae8b 100644 --- a/apps/judicial-system/backend/src/app/modules/defendant/models/defendant.model.ts +++ b/apps/judicial-system/backend/src/app/modules/defendant/models/defendant.model.ts @@ -145,9 +145,9 @@ export class Defendant extends Model { serviceRequirement?: ServiceRequirement @Column({ - type: DataType.BOOLEAN, + type: DataType.STRING, allowNull: true, }) @ApiProperty() - hasViewedVerdict?: boolean + verdictViewDate?: string } diff --git a/apps/judicial-system/web/src/components/FormProvider/case.graphql b/apps/judicial-system/web/src/components/FormProvider/case.graphql index 9cc402308975..dd224b72299b 100644 --- a/apps/judicial-system/web/src/components/FormProvider/case.graphql +++ b/apps/judicial-system/web/src/components/FormProvider/case.graphql @@ -23,7 +23,7 @@ query Case($input: CaseQueryInput!) { defendantWaivesRightToCounsel defendantPlea serviceRequirement - hasViewedVerdict + verdictViewDate } defenderName defenderNationalId diff --git a/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.strings.ts b/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.strings.ts new file mode 100644 index 000000000000..f812704d995d --- /dev/null +++ b/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.strings.ts @@ -0,0 +1,21 @@ +import { defineMessages } from 'react-intl' + +export const strings = defineMessages({ + appealExpirationDate: { + id: 'judicial.system.core:info_card.defendant_info.appeal_expiration_date', + defaultMessage: 'Áfrýjunarfrestur dómfellda er til {appealExpirationDate}', + description: 'Notað til að birta áfrýjunarfrest dómfellda í ákæru.', + }, + appealDateExpired: { + id: 'judicial.system.core:info_card.defendant_info.appeal_date_expired', + defaultMessage: 'Áfrýjunarfrestur dómfellda var til {appealExpirationDate}', + description: + 'Notað til að láta vita að áfrýjunarfrestur í ákæru er útrunninn.', + }, + appealDateNotBegun: { + id: 'judicial.system.core:info_card.defendant_info.appeal_date_not_begun', + defaultMessage: 'Áfrýjunarfrestur dómfellda er ekki hafinn', + description: + 'Notaður til að láta vita að áfrýjunarfrestur dómfellda er ekki hafinn.', + }, +}) diff --git a/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx b/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx index 37946284b531..f906a2f22932 100644 --- a/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx +++ b/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx @@ -1,4 +1,5 @@ -import React, { FC } from 'react' +import React, { FC, PropsWithChildren } from 'react' +import { useIntl } from 'react-intl' import { Box, @@ -7,13 +8,14 @@ import { LinkV2, Text, } from '@island.is/island-ui/core' -import { formatDOB } from '@island.is/judicial-system/formatters' +import { formatDate, formatDOB } from '@island.is/judicial-system/formatters' import { Defendant } from '@island.is/judicial-system-web/src/graphql/schema' +import { strings } from './DefendantInfo.strings' import { link } from '../../MarkdownWrapper/MarkdownWrapper.css' import * as styles from './DefendantInfo.css' -export type DefendantActionButton = { +export type DefendantInfoActionButton = { text: string onClick: (defendant: Defendant) => void icon?: IconMapIcon @@ -23,17 +25,39 @@ export type DefendantActionButton = { interface DefendantInfoProps { defendant: Defendant displayDefenderInfo: boolean - defendantActionButton?: DefendantActionButton + defendantInfoActionButton?: DefendantInfoActionButton } -export const DefendantInfo: FC = (props) => { - const { defendant, displayDefenderInfo, defendantActionButton } = props +export const DefendantInfo: FC> = ( + props, +) => { + const { defendant, displayDefenderInfo, defendantInfoActionButton } = props + const { formatMessage } = useIntl() + + const getAppealExpirationInfo = (viewDate?: string) => { + if (!viewDate) { + return formatMessage(strings.appealDateNotBegun) + } + + const today = new Date() + const expiryDate = new Date(viewDate) + expiryDate.setDate(expiryDate.getDate() + 28) + + const message = + today < expiryDate + ? strings.appealExpirationDate + : strings.appealDateExpired + + return formatMessage(message, { + appealExpirationDate: formatDate(expiryDate, 'P'), + }) + } return (
= (props) => { {defendant.address && {`, ${defendant.address}`}} +
+ + {getAppealExpirationInfo(defendant.verdictViewDate ?? '')} + +
+ {defendant.defenderName && displayDefenderInfo && ( = (props) => { )}
- {defendantActionButton && ( + {defendantInfoActionButton && ( )} diff --git a/apps/judicial-system/web/src/components/InfoCard/InfoCard.tsx b/apps/judicial-system/web/src/components/InfoCard/InfoCard.tsx index 9a2e405c558c..7abdbe3bcf61 100644 --- a/apps/judicial-system/web/src/components/InfoCard/InfoCard.tsx +++ b/apps/judicial-system/web/src/components/InfoCard/InfoCard.tsx @@ -8,8 +8,8 @@ import { } from '@island.is/judicial-system-web/src/graphql/schema' import { - DefendantActionButton, DefendantInfo, + DefendantInfoActionButton, } from './DefendantInfo/DefendantInfo' import { strings } from './InfoCard.strings' import { link } from '../MarkdownWrapper/MarkdownWrapper.css' @@ -37,7 +37,7 @@ interface Props { defendants?: { title: string items: Defendant[] - defendantActionButton?: DefendantActionButton + defendantInfoActionButton?: DefendantInfoActionButton } defenders?: Defender[] icon?: IconMapIcon @@ -125,7 +125,9 @@ const InfoCard: React.FC = (props) => { ))} diff --git a/apps/judicial-system/web/src/components/InfoCard/InfoCardClosedIndictment.tsx b/apps/judicial-system/web/src/components/InfoCard/InfoCardClosedIndictment.tsx index 9c8279db5687..5ef6e72d749a 100644 --- a/apps/judicial-system/web/src/components/InfoCard/InfoCardClosedIndictment.tsx +++ b/apps/judicial-system/web/src/components/InfoCard/InfoCardClosedIndictment.tsx @@ -9,19 +9,19 @@ import { import { core } from '@island.is/judicial-system-web/messages' import { FormContext } from '../FormProvider/FormProvider' -import { DefendantActionButton } from './DefendantInfo/DefendantInfo' +import { DefendantInfoActionButton } from './DefendantInfo/DefendantInfo' import InfoCard, { NameAndEmail } from './InfoCard' import { strings } from './InfoCardIndictment.strings' export interface Props { - defendantActionButton?: DefendantActionButton + defendantInfoActionButton?: DefendantInfoActionButton } const InfoCardClosedIndictment: React.FC = (props) => { const { workingCase } = useContext(FormContext) const { formatMessage } = useIntl() - const { defendantActionButton } = props + const { defendantInfoActionButton } = props return ( = (props) => { }), ), items: workingCase.defendants, - defendantActionButton: defendantActionButton, + defendantInfoActionButton: defendantInfoActionButton, } : undefined } diff --git a/apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.tsx b/apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.tsx index eab3ef01ee06..9720d89e71b4 100644 --- a/apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.tsx +++ b/apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.tsx @@ -31,6 +31,7 @@ import { import { useProsecutorSelectionUsersQuery } from '@island.is/judicial-system-web/src/components/ProsecutorSelection/prosecutorSelectionUsers.generated' import { Defendant } from '@island.is/judicial-system-web/src/graphql/schema' import { + formatDateForServer, useCase, useDefendants, } from '@island.is/judicial-system-web/src/utils/hooks' @@ -77,7 +78,7 @@ export const Overview = () => { const updatedDefendant = { caseId: workingCase.id, defendantId: selectedDefendant.id, - hasViewedVerdict: true, + verdictViewDate: formatDateForServer(new Date()), } setAndSendDefendantToServer(updatedDefendant, setWorkingCase) @@ -131,7 +132,7 @@ export const Overview = () => { { }, icon: 'mailOpen', isDisabled: (defendant) => - defendant.hasViewedVerdict || false, + defendant.verdictViewDate !== null, } : undefined } From 8a1a8185c5edfee6758c8da9c6a438168c06e84d Mon Sep 17 00:00:00 2001 From: unakb Date: Tue, 21 May 2024 08:46:54 +0000 Subject: [PATCH 07/13] fix(j-s): Test --- .../test/defendantController/updateRolesRules.spec.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/judicial-system/backend/src/app/modules/defendant/test/defendantController/updateRolesRules.spec.ts b/apps/judicial-system/backend/src/app/modules/defendant/test/defendantController/updateRolesRules.spec.ts index 3daff84becec..4cf550c25287 100644 --- a/apps/judicial-system/backend/src/app/modules/defendant/test/defendantController/updateRolesRules.spec.ts +++ b/apps/judicial-system/backend/src/app/modules/defendant/test/defendantController/updateRolesRules.spec.ts @@ -4,6 +4,7 @@ import { districtCourtRegistrarRule, prosecutorRepresentativeRule, prosecutorRule, + publicProsecutorStaffRule, } from '../../../../guards' import { DefendantController } from '../../defendant.controller' @@ -19,11 +20,12 @@ describe('DefendantController - Update rules', () => { }) it('should give permission to roles', () => { - expect(rules).toHaveLength(5) + expect(rules).toHaveLength(6) expect(rules).toContain(prosecutorRule) expect(rules).toContain(prosecutorRepresentativeRule) expect(rules).toContain(districtCourtJudgeRule) expect(rules).toContain(districtCourtRegistrarRule) expect(rules).toContain(districtCourtAssistantRule) + expect(rules).toContain(publicProsecutorStaffRule) }) }) From f257e845e35a551314ef00a16d99fd7c870972f5 Mon Sep 17 00:00:00 2001 From: unakb Date: Tue, 21 May 2024 09:20:36 +0000 Subject: [PATCH 08/13] Update Overview.tsx --- .../PublicProsecutor/Indictments/Overview/Overview.tsx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.tsx b/apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.tsx index 9720d89e71b4..6fd8a0b0fecf 100644 --- a/apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.tsx +++ b/apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.tsx @@ -6,11 +6,7 @@ import { Box, Option, Select, Text } from '@island.is/island-ui/core' import * as constants from '@island.is/judicial-system/consts' import { formatDate } from '@island.is/judicial-system/formatters' import { isCompletedCase } from '@island.is/judicial-system/types' -import { - core, - defendant, - titles, -} from '@island.is/judicial-system-web/messages' +import { core, titles } from '@island.is/judicial-system-web/messages' import { BlueBox, CourtCaseInfo, From ca7bcea7c8d6308325c6cfa2eeda6c64f747b308 Mon Sep 17 00:00:00 2001 From: unakb Date: Tue, 21 May 2024 09:51:31 +0000 Subject: [PATCH 09/13] Update Overview.tsx --- .../routes/PublicProsecutor/Indictments/Overview/Overview.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.tsx b/apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.tsx index 6fd8a0b0fecf..eed2faf3d792 100644 --- a/apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.tsx +++ b/apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.tsx @@ -129,7 +129,8 @@ export const Overview = () => { { From 6abc5ccb9f6d47bb7fc9d55d539a01214b20715f Mon Sep 17 00:00:00 2001 From: unakb Date: Tue, 21 May 2024 10:29:51 +0000 Subject: [PATCH 10/13] Missing defender string --- .../InfoCard/DefendantInfo/DefendantInfo.strings.ts | 5 +++++ .../src/components/InfoCard/DefendantInfo/DefendantInfo.tsx | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.strings.ts b/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.strings.ts index f812704d995d..f89786a9be07 100644 --- a/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.strings.ts +++ b/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.strings.ts @@ -18,4 +18,9 @@ export const strings = defineMessages({ description: 'Notaður til að láta vita að áfrýjunarfrestur dómfellda er ekki hafinn.', }, + defender: { + id: 'judicial.system.core:info_card.defendant_info.defender', + defaultMessage: 'Verjandi', + description: 'Notað til að birta titil á verjanda í ákæru.', + }, }) diff --git a/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx b/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx index f906a2f22932..82372c5bd241 100644 --- a/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx +++ b/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx @@ -92,7 +92,9 @@ export const DefendantInfo: FC> = ( role="paragraph" marginBottom={1} > - {defendant.defenderName} + {`${formatMessage(strings.defender)}: ${ + defendant.defenderName + }`} {defendant.defenderEmail && ( {`, `} )} From 182f275ff4266a03a9ef105fc194f645ec2bd13c Mon Sep 17 00:00:00 2001 From: unakb Date: Tue, 21 May 2024 11:04:53 +0000 Subject: [PATCH 11/13] Update limitedAccessCase.graphql --- .../web/src/components/FormProvider/limitedAccessCase.graphql | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/judicial-system/web/src/components/FormProvider/limitedAccessCase.graphql b/apps/judicial-system/web/src/components/FormProvider/limitedAccessCase.graphql index df1d08288313..e54f9fba060c 100644 --- a/apps/judicial-system/web/src/components/FormProvider/limitedAccessCase.graphql +++ b/apps/judicial-system/web/src/components/FormProvider/limitedAccessCase.graphql @@ -28,6 +28,7 @@ query LimitedAccessCase($input: CaseQueryInput!) { defenderEmail defenderPhoneNumber defendantWaivesRightToCounsel + verdictViewDate } defenderName defenderNationalId From 3a1a17a2729bf889a6ed81be61b5c12977d12dca Mon Sep 17 00:00:00 2001 From: unakb Date: Tue, 21 May 2024 11:30:49 +0000 Subject: [PATCH 12/13] Minor css fixes --- .../src/components/InfoCard/DefendantInfo/DefendantInfo.css.ts | 2 +- apps/judicial-system/web/src/components/InfoCard/InfoCard.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.css.ts b/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.css.ts index 1e529137bfe4..08d63afd7637 100644 --- a/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.css.ts +++ b/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.css.ts @@ -5,7 +5,7 @@ import { theme } from '@island.is/island-ui/theme' const baseGridRow = style({ display: 'grid', gridGap: theme.spacing[1], - marginBottom: theme.spacing[1], + marginBottom: theme.spacing[2], }) export const gridRow = styleVariants({ diff --git a/apps/judicial-system/web/src/components/InfoCard/InfoCard.tsx b/apps/judicial-system/web/src/components/InfoCard/InfoCard.tsx index 7abdbe3bcf61..0dd85e15c729 100644 --- a/apps/judicial-system/web/src/components/InfoCard/InfoCard.tsx +++ b/apps/judicial-system/web/src/components/InfoCard/InfoCard.tsx @@ -115,7 +115,7 @@ const InfoCard: React.FC = (props) => { {defendants && ( <> From 9b53f42d4195f0f38c89302a8264bcd047b882d0 Mon Sep 17 00:00:00 2001 From: unakb Date: Tue, 21 May 2024 11:40:39 +0000 Subject: [PATCH 13/13] cleanup --- .../InfoCard/DefendantInfo/DefendantInfo.tsx | 57 +++++++++---------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx b/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx index 82372c5bd241..8d5b7e4ea0a2 100644 --- a/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx +++ b/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx @@ -66,16 +66,13 @@ export const DefendantInfo: FC> = ( {defendant.name} + {defendant.nationalId && + `, ${formatDOB(defendant.nationalId, defendant.noNationalId)}`} + + + {defendant.citizenship && `, (${defendant.citizenship})`} + {defendant.address && `, ${defendant.address}`} - {defendant.nationalId && ( - - {`, ${formatDOB(defendant.nationalId, defendant.noNationalId)}`} - - )} - {defendant.citizenship && ( - {`, (${defendant.citizenship})`} - )} - {defendant.address && {`, ${defendant.address}`}}
@@ -85,28 +82,28 @@ export const DefendantInfo: FC> = (
{defendant.defenderName && displayDefenderInfo && ( - - - {`${formatMessage(strings.defender)}: ${ - defendant.defenderName - }`} - {defendant.defenderEmail && ( + + {`${formatMessage(strings.defender)}: ${ + defendant.defenderName + }`} + {defendant.defenderEmail && ( + <> {`, `} - )} - - {defendant.defenderEmail} - - - + + {defendant.defenderEmail} + + + )} +
)}