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): Display connected indictment case files #15526

Merged
merged 10 commits into from
Jul 18, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,25 @@ export const include: Includeable[] = [
},
{ model: Notification, as: 'notifications' },
{ model: Case, as: 'mergeCase' },
{ model: Case, as: 'mergedCases', separate: true },
{
model: Case,
as: 'mergedCases',
where: { state: CaseState.COMPLETED },
include: [
{
model: CaseFile,
as: 'caseFiles',
required: false,
where: { state: { [Op.not]: CaseFileState.DELETED } },
separate: true,
},
{ model: Institution, as: 'court' },
{ model: User, as: 'judge' },
{ model: User, as: 'prosecutor' },
{ model: Institution, as: 'prosecutorsOffice' },
],
separate: true,
},
]

export const order: OrderItem[] = [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { defineMessages } from 'react-intl'

export const strings = defineMessages({
heading: {
id: 'judicial.system.core:connected_case_files_accordion.heading',
defaultMessage: 'Gögn úr máli {caseNumber}',
description:
'Notaður sem titill fyrir gögn úr sameinuðu ákærumáli á dómara skjá',
},
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React, { FC } from 'react'
import { useIntl } from 'react-intl'

import { AccordionItem } from '@island.is/island-ui/core'

import { Case } from '@island.is/judicial-system-web/src/graphql/schema'
import { strings } from './ConnectedCaseFilesAccordionItem.strings'

import { IndictmentCaseFilesList } from '@island.is/judicial-system-web/src/components'

interface Props {
connectedCase: Case
}

const ConnectedCaseFilesAccordionItem: FC<Props> = ({ connectedCase }) => {
const { formatMessage } = useIntl()
const { caseFiles, courtCaseNumber } = connectedCase

if (!courtCaseNumber || !caseFiles || caseFiles.length < 1) {
return null
}

return (
<AccordionItem
id="connectedCaseFiles"
labelVariant="h3"
label={formatMessage(strings.heading, {
caseNumber: connectedCase.courtCaseNumber,
})}
>
<IndictmentCaseFilesList
workingCase={connectedCase}
displayHeading={false}
/>
</AccordionItem>
)
}

export default ConnectedCaseFilesAccordionItem
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,37 @@ query Case($input: CaseQueryInput!) {
mergedCases {
id
courtCaseNumber
type
court {
id
name
}
judge {
id
name
title
email
}
prosecutor {
id
name
email
}
prosecutorsOffice {
id
name
}
caseFiles {
id
created
name
state
key
size
category
}
policeCaseNumbers
indictmentSubtypes
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { strings } from './IndictmentCaseFilesList.strings'

interface Props {
workingCase: Case
displayHeading?: boolean
}

interface RenderFilesProps {
Expand Down Expand Up @@ -57,7 +58,10 @@ export const RenderFiles: FC<Props & RenderFilesProps> = ({
)
}

const IndictmentCaseFilesList: FC<Props> = ({ workingCase }) => {
const IndictmentCaseFilesList: FC<Props> = ({
workingCase,
displayHeading = true,
}) => {
const { formatMessage } = useIntl()
const { user } = useContext(UserContext)
const { onOpen, fileNotFound, dismissFileNotFound } = useFileList({
Expand Down Expand Up @@ -93,7 +97,9 @@ const IndictmentCaseFilesList: FC<Props> = ({ workingCase }) => {

return (
<>
<SectionHeading title={formatMessage(strings.title)} />
{displayHeading && (
<SectionHeading title={formatMessage(strings.title)} />
)}
{indictments && indictments.length > 0 && (
<Box marginBottom={5}>
<Text variant="h4" as="h4" marginBottom={1}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,51 @@ const InfoCardActiveIndictment = () => {
),
},
]}
additionalDataSections={[
...(workingCase.mergedCases
? workingCase.mergedCases.map((mergedCase) => ({
data: [
{
title: formatMessage(core.policeCaseNumber),
value: mergedCase.policeCaseNumbers?.map((n) => (
<Text key={n}>{n}</Text>
)),
},
{
title: formatMessage(strings.mergedFromTitle),
value: <Text>{mergedCase.courtCaseNumber}</Text>,
},
{
title: formatMessage(core.prosecutor),
value: mergedCase.prosecutorsOffice?.name,
},
{
title: formatMessage(core.judge),
value: mergedCase.judge?.name,
},
{
title: formatMessage(core.court),
value: mergedCase.court?.name,
},
{
title: formatMessage(strings.offence),
value: (
<>
{readableIndictmentSubtypes(
mergedCase.policeCaseNumbers,
mergedCase.indictmentSubtypes,
).map((subtype, index) => (
<Text key={`${subtype}-${index}`}>
{capitalize(subtype)}
</Text>
))}
</>
),
},
],
}))
: []),
]}
defendants={
workingCase.defendants
? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,9 @@ export const strings = defineMessages({
defaultMessage: 'Sameinað máli',
description: 'Notaður sem titill á "Sameinað" hluta af yfirliti ákæru.',
},
mergedFromTitle: {
id: 'judicial.system.core:info_card_indictment.merged_from_title',
defaultMessage: 'Sameinað úr',
description: 'Notaður sem titill á "Sameinað úr" hluta af yfirliti ákæru.',
},
})
1 change: 1 addition & 0 deletions apps/judicial-system/web/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export {
default as CheckboxList,
type CheckboxInfo,
} from './CheckboxList/CheckboxList'
export { default as ConnectedCaseFilesAccordionItem } from './AccordionItems/ConnectedCaseFilesAccordionItem/ConnectedCaseFilesAccordionItem'
export { default as CommentsAccordionItem } from './AccordionItems/CommentsAccordionItem/CommentsAccordionItem'
export { default as ConclusionDraft } from './ConclusionDraft/ConclusionDraft'
export { default as ContextMenu } from './ContextMenu/ContextMenu'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
PageLayout,
PageTitle,
useIndictmentsLawsBroken,
ConnectedCaseFilesAccordionItem,
} from '@island.is/judicial-system-web/src/components'
import {
CaseState,
Expand Down Expand Up @@ -103,6 +104,13 @@ const IndictmentOverview = () => {
<IndictmentsLawsBrokenAccordionItem workingCase={workingCase} />
</Box>
)}
{workingCase.mergedCases &&
workingCase.mergedCases.length > 0 &&
workingCase.mergedCases.map((mergedCase) => (
<Box marginBottom={5}>
<ConnectedCaseFilesAccordionItem connectedCase={mergedCase} />
</Box>
))}
unakb marked this conversation as resolved.
Show resolved Hide resolved
{workingCase.caseFiles && (
<Box component="section" marginBottom={10}>
<IndictmentCaseFilesList workingCase={workingCase} />
Expand Down
Loading