Skip to content

Commit

Permalink
feat(j-s): Court Session type (#15338)
Browse files Browse the repository at this point in the history
* Adds court session type to scheduled indictments

* Removes unused Contentful string

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
gudjong and kodiakhq[bot] authored Jun 25, 2024
1 parent b04fa29 commit b7942bd
Show file tree
Hide file tree
Showing 30 changed files with 303 additions and 121 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
CaseIndictmentRulingDecision,
CaseState,
CaseType,
CourtSessionType,
IndictmentCaseReviewDecision,
IndictmentDecision,
} from '@island.is/judicial-system/types'
Expand Down Expand Up @@ -128,4 +129,7 @@ export class CaseListEntry {

@Field(() => CaseIndictmentRulingDecision, { nullable: true })
readonly indictmentRulingDecision?: CaseIndictmentRulingDecision

@Field(() => CourtSessionType, { nullable: true })
readonly courtSessionType?: CourtSessionType
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
CaseIndictmentRulingDecision,
CaseLegalProvisions,
CaseType,
CourtSessionType,
IndictmentCaseReviewDecision,
IndictmentDecision,
RequestSharedWithDefender,
Expand Down Expand Up @@ -495,4 +496,9 @@ export class UpdateCaseInput {
@IsOptional()
@Field(() => IndictmentDecision, { nullable: true })
readonly indictmentDecision?: IndictmentDecision

@Allow()
@IsOptional()
@Field(() => CourtSessionType, { nullable: true })
readonly courtSessionType?: CourtSessionType
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
CaseState,
CaseType,
CourtDocument,
CourtSessionType,
IndictmentCaseReviewDecision,
IndictmentDecision,
RequestSharedWithDefender,
Expand Down Expand Up @@ -53,6 +54,7 @@ registerEnumType(IndictmentCaseReviewDecision, {
name: 'IndictmentCaseReviewDecision',
})
registerEnumType(IndictmentDecision, { name: 'IndictmentDecision' })
registerEnumType(CourtSessionType, { name: 'CourtSessionType' })

@ObjectType()
class DateLog {
Expand Down Expand Up @@ -439,4 +441,7 @@ export class Case {

@Field(() => IndictmentDecision, { nullable: true })
readonly indictmentDecision?: IndictmentDecision

@Field(() => CourtSessionType, { nullable: true })
readonly courtSessionType?: CourtSessionType
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use strict'

module.exports = {
async up(queryInterface, Sequelize) {
return queryInterface.sequelize.transaction((transaction) =>
queryInterface.addColumn(
'case',
'court_session_type',
{
type: Sequelize.STRING,
allowNull: true,
},
{ transaction },
),
)
},

async down(queryInterface) {
return queryInterface.sequelize.transaction((transaction) =>
queryInterface.removeColumn('case', 'court_session_type', {
transaction,
}),
)
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,21 +156,24 @@ export interface UpdateCase
| 'appealIsolationToDate'
| 'indictmentRulingDecision'
| 'indictmentReviewerId'
| 'indictmentReviewDecision'
| 'indictmentDecision'
| 'rulingSignatureDate'
| 'judgeId'
| 'courtSessionType'
> {
type?: CaseType
state?: CaseState
policeCaseNumbers?: string[]
defendantWaivesRightToCounsel?: boolean
rulingDate?: Date | null
rulingSignatureDate?: Date | null
courtCaseNumber?: string | null
courtRecordSignatoryId?: string | null
courtRecordSignatureDate?: Date | null
parentCaseId?: string | null
arraignmentDate?: UpdateDateLog | null
courtDate?: UpdateDateLog | null
postponedIndefinitelyExplanation?: string | null
judgeId?: string | null
indictmentReturnedExplanation?: string | null
indictmentDeniedExplanation?: string | null
indictmentHash?: string | null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
CaseLegalProvisions,
CaseType,
CourtDocument,
CourtSessionType,
IndictmentCaseReviewDecision,
IndictmentDecision,
RequestSharedWithDefender,
Expand Down Expand Up @@ -502,4 +503,9 @@ export class UpdateCaseDto {
@IsEnum(IndictmentDecision)
@ApiPropertyOptional({ enum: IndictmentDecision })
readonly indictmentDecision?: IndictmentDecision

@IsOptional()
@IsEnum(CourtSessionType)
@ApiPropertyOptional({ enum: CourtSessionType })
readonly courtSessionType?: CourtSessionType
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ const districtCourtFields: (keyof UpdateCaseDto)[] = [
'postponedIndefinitelyExplanation',
'indictmentRulingDecision',
'indictmentDecision',
'courtSessionType',
]

const courtOfAppealsFields: (keyof UpdateCaseDto)[] = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export class CaseListInterceptor implements NestInterceptor {
indictmentReviewDecision: theCase.indictmentReviewDecision,
indictmentDecision: theCase.indictmentDecision,
indictmentRulingDecision: theCase.indictmentRulingDecision,
courtSessionType: theCase.courtSessionType,
}
}),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export const attributes: (keyof Case)[] = [
'indictmentDecision',
'indictmentRulingDecision',
'indictmentHash',
'courtSessionType',
]

export interface LimitedAccessUpdateCase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
CaseState,
CaseType,
CourtDocument,
CourtSessionType,
IndictmentCaseReviewDecision,
IndictmentDecision,
RequestSharedWithDefender,
Expand Down Expand Up @@ -1033,4 +1034,15 @@ export class Case extends Model {
@Column({ type: DataType.STRING, allowNull: true })
@ApiPropertyOptional({ type: String })
indictmentHash?: string

/**********
* The court session type in indictment cases - example: MAIN_HEARING
**********/
@Column({
type: DataType.ENUM,
allowNull: true,
values: Object.values(CourtSessionType),
})
@ApiPropertyOptional({ enum: CourtSessionType })
courtSessionType?: CourtSessionType
}
Original file line number Diff line number Diff line change
Expand Up @@ -266,5 +266,6 @@ query Case($input: CaseQueryInput!) {
indictmentVerdictAppealDeadline
indictmentDecision
indictmentReviewDecision
courtSessionType
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -146,5 +146,6 @@ query LimitedAccessCase($input: CaseQueryInput!) {
postponedIndefinitelyExplanation
indictmentDecision
indictmentRulingDecision
courtSessionType
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface Props {
court: Institution
courtDate: string
courtRoom?: string | null
title?: string
title?: string | null
}

const InfoCardCaseScheduled: React.FC<Props> = (props) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ export const strings = defineMessages({
description:
'Notaður sem titill á Frestað um ótilgreindan tíma upplýsingakorti.',
},
schedulingTitle: {
id: 'judicial.system.core:info_card_case_scheduled_indictment.scheduling_title',
defaultMessage: 'Aðalmeðferð',
description: 'Notaður sem titill á Aðalmeðferð upplýsingakorti.',
},
schedulingUntilVerdictTitle: {
id: 'judicial.system.core:info_card_case_scheduled_indictment.scheduling_until_verdict_title',
defaultMessage: 'Á dagskrá',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@ import React from 'react'
import { useIntl } from 'react-intl'

import { Text } from '@island.is/island-ui/core'
import { courtSessionTypeNames } from '@island.is/judicial-system/types'
import {
CourtSessionType,
IndictmentDecision,
Institution,
} from '@island.is/judicial-system-web/src/graphql/schema'

import { IndictmentDecision, Institution } from '../../graphql/schema'
import InfoCard from './InfoCard'
import InfoCardCaseScheduled from './InfoCardCaseScheduled'
import { strings } from './InfoCardCaseScheduledIndictment.strings'
Expand All @@ -14,6 +19,7 @@ interface Props {
courtDate: string
courtRoom?: string | null
postponedIndefinitelyExplanation?: string | null
courtSessionType?: CourtSessionType | null
}

const InfoCardCaseScheduledIndictment: React.FC<Props> = (props) => {
Expand All @@ -23,6 +29,7 @@ const InfoCardCaseScheduledIndictment: React.FC<Props> = (props) => {
courtDate,
courtRoom,
postponedIndefinitelyExplanation,
courtSessionType,
} = props
const { formatMessage } = useIntl()

Expand Down Expand Up @@ -59,7 +66,7 @@ const InfoCardCaseScheduledIndictment: React.FC<Props> = (props) => {
court={court}
courtDate={courtDate}
courtRoom={courtRoom}
title={formatMessage(strings.schedulingTitle)}
title={courtSessionType && courtSessionTypeNames[courtSessionType]}
/>
)
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,88 @@ import parseISO from 'date-fns/parseISO'

import { Box, Text } from '@island.is/island-ui/core'
import { capitalize } from '@island.is/judicial-system/formatters'
import { courtSessionTypeNames } from '@island.is/judicial-system/types'
import { tables } from '@island.is/judicial-system-web/messages'
import { CourtSessionType } from '@island.is/judicial-system-web/src/graphql/schema'

interface Props {
courtDate?: string | null
postponedIndefinitelyExplanation?: string | null
courtSessionType?: CourtSessionType | null
}

const CourtDate: FC<Props> = (props) => {
const { courtDate, postponedIndefinitelyExplanation } = props
const PostponedCourtDate = () => {
const { formatMessage } = useIntl()

if (!courtDate && !postponedIndefinitelyExplanation) {
return <Text>{formatMessage(tables.postponed)}</Text>
}

const CourtDateWithCourtSessionType: FC<{
courtDate: string
courtSessionType: CourtSessionType
}> = ({ courtDate, courtSessionType }) => {
return (
<>
<Text>{courtSessionTypeNames[courtSessionType]}</Text>
<Text as="span" variant="small">
{capitalize(
format(parseISO(courtDate), 'EEEE', {
locale: localeIS,
}),
).substring(0, 3)}
{'. '}
{capitalize(
format(parseISO(courtDate), 'dd.MM.y', {
locale: localeIS,
}),
).replace('dagur', 'd.')}{' '}
kl. {format(parseISO(courtDate), 'kk:mm')}
</Text>
</>
)
}

const SimpleCourtDate: FC<{ courtDate: string }> = ({ courtDate }) => {
return (
<>
<Text>
<Box component="span">
{capitalize(
format(parseISO(courtDate), 'EEEE d. LLLL y', {
locale: localeIS,
}),
).replace('dagur', 'd.')}
</Box>
</Text>
<Text as="span" variant="small">
kl. {format(parseISO(courtDate), 'kk:mm')}
</Text>
</>
)
}

const CourtDate: FC<Props> = ({
courtDate,
postponedIndefinitelyExplanation,
courtSessionType,
}) => {
if (postponedIndefinitelyExplanation) {
return <PostponedCourtDate />
}

if (!courtDate) {
return null
}

return postponedIndefinitelyExplanation ? (
<Text>{formatMessage(tables.postponed)}</Text>
) : (
courtDate && (
<>
<Text>
<Box component="span">
{capitalize(
format(parseISO(courtDate), 'EEEE d. LLLL y', {
locale: localeIS,
}),
).replace('dagur', 'd.')}
</Box>
</Text>
<Text as="span" variant="small">
kl. {format(parseISO(courtDate), 'kk:mm')}
</Text>
</>
if (courtSessionType) {
return (
<CourtDateWithCourtSessionType
courtDate={courtDate}
courtSessionType={courtSessionType}
/>
)
)
}

return <SimpleCourtDate courtDate={courtDate} />
}
export default CourtDate
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,16 @@ export const strings = defineMessages({
defaultMessage: 'Staðfesta',
description: 'Notaður sem texti á halda áfram takka.',
},
courtSessionLabel: {
id: 'judicial.system.core:court.indictments.conclusion.court_session_label',
defaultMessage: 'Tegund þinghalds',
description:
'Notaður sem titill á tegund þinghalds valkosti á Niðurstaða skrefi.',
},
courtSessionPlaceholder: {
id: 'judicial.system.core:court.indictments.conclusion.court_session_placeholder',
defaultMessage: 'Veldu tegund þinghalds',
description:
'Notaður sem skýritexti í tegund þinghalds valkosti á Niðurstaða skrefi.',
},
})
Loading

0 comments on commit b7942bd

Please sign in to comment.