Skip to content

Commit

Permalink
Merge branch 'main' into j-s/fix-empty-national-id
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Dec 5, 2024
2 parents 15d5e0e + 090c75d commit 12f9d3c
Show file tree
Hide file tree
Showing 54 changed files with 1,185 additions and 478 deletions.
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' },
{ model: Institution, as: 'prosecutorsOffice' },
{
model: Defendant,
Expand Down Expand Up @@ -775,12 +776,16 @@ export class CaseService {
CaseFileCategory.CRIMINAL_RECORD,
CaseFileCategory.COST_BREAKDOWN,
CaseFileCategory.CASE_FILE,
CaseFileCategory.PROSECUTOR_CASE_FILE,
CaseFileCategory.DEFENDANT_CASE_FILE,
]
: [
CaseFileCategory.INDICTMENT,
CaseFileCategory.CRIMINAL_RECORD,
CaseFileCategory.COST_BREAKDOWN,
CaseFileCategory.CASE_FILE,
CaseFileCategory.PROSECUTOR_CASE_FILE,
CaseFileCategory.DEFENDANT_CASE_FILE,
]

const deliverCaseFileToCourtMessages =
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
23 changes: 21 additions & 2 deletions apps/judicial-system/backend/src/app/modules/file/file.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,12 @@ export class FileService {
courtDocumentFolder = CourtDocumentFolder.INDICTMENT_DOCUMENTS
break
case CaseFileCategory.COURT_RECORD:
courtDocumentFolder = CourtDocumentFolder.COURT_DOCUMENTS
break
case CaseFileCategory.RULING:
courtDocumentFolder = CourtDocumentFolder.COURT_DOCUMENTS
break
case CaseFileCategory.CASE_FILE:
case CaseFileCategory.PROSECUTOR_CASE_FILE:
case CaseFileCategory.DEFENDANT_CASE_FILE:
case undefined:
case null:
courtDocumentFolder = CourtDocumentFolder.CASE_DOCUMENTS
Expand Down Expand Up @@ -388,6 +388,25 @@ export class FileService {
},
])
}

if (
isIndictmentCase(theCase.type) &&
file.category &&
[
CaseFileCategory.PROSECUTOR_CASE_FILE,
CaseFileCategory.DEFENDANT_CASE_FILE,
].includes(file.category)
) {
await this.messageService.sendMessagesToQueue([
{
type: MessageType.DELIVERY_TO_COURT_CASE_FILE,
user,
caseId: theCase.id,
elementId: file.id,
},
])
}

return file
}

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
Loading

0 comments on commit 12f9d3c

Please sign in to comment.