Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat(j-s): Show indictment decision type to public prosecutor users #17079

Merged
merged 9 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ export class CaseListEntry {
@Field(() => String, { nullable: true })
readonly prosecutorPostponedAppealDate?: string

@Field(() => Institution, { nullable: true })
readonly court?: Institution

@Field(() => User, { nullable: true })
readonly creatingProsecutor?: User

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ export const include: Includeable[] = [
]

export const caseListInclude: Includeable[] = [
{ model: Institution, as: 'court' },
oddsson marked this conversation as resolved.
Show resolved Hide resolved
{ model: Institution, as: 'prosecutorsOffice' },
{
model: Defendant,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export class CaseListInterceptor implements NestInterceptor {
// WARNING: Be careful when adding to this list. No sensitive information should be returned.
// If you need to add sensitive information, then you should consider adding a new endpoint
// for defenders and other user roles that are not allowed to see sensitive information.

return {
id: theCase.id,
created: theCase.created,
Expand Down Expand Up @@ -65,6 +64,7 @@ export class CaseListInterceptor implements NestInterceptor {
indictmentRulingDecision: theCase.indictmentRulingDecision,
courtSessionType: theCase.courtSessionType,
eventLogs: theCase.eventLogs,
court: theCase.court,
}
}),
),
Expand Down
11 changes: 11 additions & 0 deletions apps/judicial-system/web/messages/Core/tables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,15 @@ export const tables = defineMessages({
defaultMessage: 'Sent',
description: 'Notaður sem titill fyrir sent dálk í lista yfir mál.',
},
fineTag: {
id: 'judicial.system.core:tables.fine_tag',
defaultMessage: 'Viðurlagaákvörðun',
description:
'Notaðir sem texti í tagg þegar mál endar sem viðurlagaákvörðun',
},
rulingTag: {
id: 'judicial.system.core:tables.ruling_tag',
defaultMessage: 'Dómur',
description: 'Notaðir sem texti í tagg þegar mál endar sem dómur',
},
})
40 changes: 24 additions & 16 deletions apps/judicial-system/web/src/components/Table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import { AnimatePresence, motion } from 'framer-motion'

import { Box, Text } from '@island.is/island-ui/core'
import { theme } from '@island.is/island-ui/theme'
import { formatDate } from '@island.is/judicial-system/formatters'
import {
districtCourtAbbreviation,
formatDate,
} from '@island.is/judicial-system/formatters'
import {
CaseType,
isCompletedCase,
Expand Down Expand Up @@ -168,25 +171,30 @@ const Table: FC<TableProps> = (props) => {
return null
}

const getColumnValue = (
entry: CaseListEntry,
column: keyof CaseListEntry,
) => {
const courtAbbreviation = districtCourtAbbreviation(entry.court?.name)

switch (column) {
case 'defendants':
return entry.defendants?.[0]?.name ?? ''
case 'courtCaseNumber':
return courtAbbreviation
? `${courtAbbreviation}: ${entry.courtCaseNumber}`
: entry.courtCaseNumber ?? ''
default:
return entry[column]?.toString() ?? ''
}
}

useMemo(() => {
if (sortConfig) {
data.sort((a: CaseListEntry, b: CaseListEntry) => {
const getColumnValue = (entry: CaseListEntry) => {
if (
sortConfig.column === 'defendants' &&
entry.defendants &&
entry.defendants.length > 0 &&
entry.defendants[0].name
) {
return entry.defendants[0].name
}

return entry[sortConfig.column]?.toString()
}

const compareResult = compareLocaleIS(
getColumnValue(a),
getColumnValue(b),
getColumnValue(a, sortConfig.column),
getColumnValue(b, sortConfig.column),
)

return sortConfig.direction === 'ascending'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { FC } from 'react'
import { useIntl } from 'react-intl'
import { AnimatePresence } from 'framer-motion'

import { Text } from '@island.is/island-ui/core'
import { Tag, Text } from '@island.is/island-ui/core'
import { capitalize, formatDate } from '@island.is/judicial-system/formatters'
import { core, tables } from '@island.is/judicial-system-web/messages'
import { SectionHeading } from '@island.is/judicial-system-web/src/components'
Expand All @@ -18,7 +18,10 @@ import TableInfoContainer from '@island.is/judicial-system-web/src/components/Ta
import TagCaseState, {
mapIndictmentCaseStateToTagVariant,
} from '@island.is/judicial-system-web/src/components/TagCaseState/TagCaseState'
import { CaseListEntry } from '@island.is/judicial-system-web/src/graphql/schema'
import {
CaseIndictmentRulingDecision,
CaseListEntry,
} from '@island.is/judicial-system-web/src/graphql/schema'

import { strings } from './CasesAwaitingReview.strings'

Expand Down Expand Up @@ -48,6 +51,7 @@ const CasesForReview: FC<CasesForReviewTableProps> = ({ loading, cases }) => {
),
sortable: { isSortable: true, key: 'defendants' },
},
{ title: formatMessage(tables.type) },
{ title: formatMessage(tables.state) },
{
title: formatMessage(tables.deadline),
Expand All @@ -58,9 +62,9 @@ const CasesForReview: FC<CasesForReviewTableProps> = ({ loading, cases }) => {
},
]}
data={cases}
generateContextMenuItems={(row) => {
return [openCaseInNewTabMenuItem(row.id)]
}}
generateContextMenuItems={(row) => [
openCaseInNewTabMenuItem(row.id),
]}
columns={[
{
cell: (row) => (
Expand All @@ -74,6 +78,18 @@ const CasesForReview: FC<CasesForReviewTableProps> = ({ loading, cases }) => {
{
cell: (row) => <DefendantInfo defendants={row.defendants} />,
},
{
cell: (row) => (
<Tag variant="darkerBlue" outlined disabled>
{formatMessage(
row.indictmentRulingDecision ===
CaseIndictmentRulingDecision.FINE
? tables.fineTag
: tables.rulingTag,
)}
</Tag>
),
},
{
cell: (row) => (
<TagCaseState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ import { FC } from 'react'
import { useIntl } from 'react-intl'
import { AnimatePresence } from 'framer-motion'

import { Text } from '@island.is/island-ui/core'
import { capitalize, formatDate } from '@island.is/judicial-system/formatters'
import { Tag, Text } from '@island.is/island-ui/core'
import {
capitalize,
districtCourtAbbreviation,
formatDate,
} from '@island.is/judicial-system/formatters'
import { core, tables } from '@island.is/judicial-system-web/messages'
import { SectionHeading } from '@island.is/judicial-system-web/src/components'
import { useContextMenu } from '@island.is/judicial-system-web/src/components/ContextMenu/ContextMenu'
Expand All @@ -18,7 +22,10 @@ import TableInfoContainer from '@island.is/judicial-system-web/src/components/Ta
import TagCaseState, {
mapIndictmentCaseStateToTagVariant,
} from '@island.is/judicial-system-web/src/components/TagCaseState/TagCaseState'
import { CaseListEntry } from '@island.is/judicial-system-web/src/graphql/schema'
import {
CaseIndictmentRulingDecision,
CaseListEntry,
} from '@island.is/judicial-system-web/src/graphql/schema'

import { strings } from './CasesForReview.strings'

Expand All @@ -41,6 +48,10 @@ const CasesForReview: FC<CasesForReviewTableProps> = ({ loading, cases }) => {
thead={[
{
title: formatMessage(tables.caseNumber),
sortable: {
isSortable: true,
key: 'courtCaseNumber',
},
},
{
title: capitalize(
Expand All @@ -51,6 +62,7 @@ const CasesForReview: FC<CasesForReviewTableProps> = ({ loading, cases }) => {
key: 'defendants',
},
},
{ title: formatMessage(tables.type) },
{ title: formatMessage(tables.state) },
{ title: formatMessage(tables.prosecutorName) },
{
Expand All @@ -62,22 +74,42 @@ const CasesForReview: FC<CasesForReviewTableProps> = ({ loading, cases }) => {
},
]}
data={cases}
generateContextMenuItems={(row) => {
return [openCaseInNewTabMenuItem(row.id)]
}}
generateContextMenuItems={(row) => [
openCaseInNewTabMenuItem(row.id),
]}
columns={[
{
cell: (row) => (
<CourtCaseNumber
courtCaseNumber={row.courtCaseNumber ?? ''}
policeCaseNumbers={row.policeCaseNumbers ?? []}
appealCaseNumber={row.appealCaseNumber ?? ''}
/>
),
cell: (row) => {
const courtAbbreviation = districtCourtAbbreviation(
row.court?.name,
)

return (
<CourtCaseNumber
courtCaseNumber={`${
courtAbbreviation ? `${courtAbbreviation}: ` : ''
}${row.courtCaseNumber ?? ''}`}
policeCaseNumbers={row.policeCaseNumbers ?? []}
appealCaseNumber={row.appealCaseNumber ?? ''}
/>
)
},
},
{
cell: (row) => <DefendantInfo defendants={row.defendants} />,
},
{
cell: (row) => (
<Tag variant="darkerBlue" outlined disabled>
{formatMessage(
row.indictmentRulingDecision ===
CaseIndictmentRulingDecision.FINE
? tables.fineTag
: tables.rulingTag,
)}
</Tag>
),
},
{
cell: (row) => (
<TagCaseState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { MessageDescriptor, useIntl } from 'react-intl'
import { AnimatePresence } from 'framer-motion'

import { Tag, Text } from '@island.is/island-ui/core'
import { capitalize } from '@island.is/judicial-system/formatters'
import {
capitalize,
districtCourtAbbreviation,
} from '@island.is/judicial-system/formatters'
import { CaseIndictmentRulingDecision } from '@island.is/judicial-system/types'
import { core, tables } from '@island.is/judicial-system-web/messages'
import { SectionHeading } from '@island.is/judicial-system-web/src/components'
Expand Down Expand Up @@ -89,34 +92,59 @@ const CasesReviewed: FC<Props> = ({ loading, cases }) => {
thead={[
{
title: formatMessage(tables.caseNumber),
sortable: {
isSortable: true,
key: 'courtCaseNumber',
},
},
{
title: capitalize(
formatMessage(core.defendant, { suffix: 'i' }),
),
sortable: { isSortable: true, key: 'defendants' },
},
{ title: formatMessage(tables.type) },
{ title: formatMessage(tables.reviewDecision) },
{ title: formatMessage(tables.verdictViewState) },
{ title: formatMessage(tables.prosecutorName) },
]}
data={cases}
generateContextMenuItems={(row) => {
return [openCaseInNewTabMenuItem(row.id)]
}}
generateContextMenuItems={(row) => [
openCaseInNewTabMenuItem(row.id),
]}
columns={[
{
cell: (row) => (
<CourtCaseNumber
courtCaseNumber={row.courtCaseNumber ?? ''}
policeCaseNumbers={row.policeCaseNumbers ?? []}
appealCaseNumber={row.appealCaseNumber ?? ''}
/>
),
cell: (row) => {
const courtAbbreviation = districtCourtAbbreviation(
row.court?.name,
)

return (
<CourtCaseNumber
courtCaseNumber={`${
courtAbbreviation ? `${courtAbbreviation}: ` : ''
}${row.courtCaseNumber ?? ''}`}
policeCaseNumbers={row.policeCaseNumbers ?? []}
appealCaseNumber={row.appealCaseNumber ?? ''}
/>
)
},
},
{
cell: (row) => <DefendantInfo defendants={row.defendants} />,
},
{
cell: (row) => (
<Tag variant="darkerBlue" outlined disabled>
{formatMessage(
row.indictmentRulingDecision ===
CaseIndictmentRulingDecision.FINE
? tables.fineTag
: tables.rulingTag,
)}
</Tag>
),
},
{
cell: (row) => (
<Tag variant="darkerBlue" outlined disabled truncate>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ query Cases {
initialRulingDate
rulingDate
rulingSignatureDate
court {
id
name
}
judge {
id
created
Expand Down
23 changes: 23 additions & 0 deletions libs/judicial-system/formatters/src/lib/formatters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,29 @@ export const indictmentSubtypes: IndictmentSubtypes = {
THEFT: 'þjófnaður',
}

export const districtCourtAbbreviation = (courtName?: string | null) => {
switch (courtName) {
case 'Héraðsdómur Reykjavíkur':
return 'HDR'
case 'Héraðsdómur Reykjaness':
return 'HDRN'
case 'Héraðsdómur Vesturlands':
return 'HDV'
case 'Héraðsdómur Suðurlands':
return 'HDS'
case 'Héraðsdómur Norðurlands eystra':
return 'HDNE'
case 'Héraðsdómur Norðurlands vestra':
return 'HDNV'
case 'Héraðsdómur Austurlands':
return 'HDA'
case 'Héraðsdómur Vestfjarða':
return 'HDVF'
default:
return ''
}
}

export const getAppealResultTextByValue = (
value?: CaseAppealRulingDecision | null,
) => {
Expand Down
Loading