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): Unserviced tag for indictment cases #17352

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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 @@ -426,6 +426,13 @@ export const caseListInclude: Includeable[] = [
order: [['created', 'DESC']],
separate: true,
},
{
model: Subpoena,
as: 'subpoenas',
required: false,
order: [['created', 'DESC']],
separate: true,
},
],
separate: true,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,9 @@ export const strings = defineMessages({
defaultMessage: 'Afturkallað',
description: 'Notað sem merki þegar mál í stöðu "Afturkallað" í málalista',
},
notYetServiced: {
id: 'judicial.system.core:tag_case_state.not_yet_serviced',
defaultMessage: 'Óbirt',
description: 'Notað sem merki þegar mál í stöðu "Óbirt" í málalista',
},
})
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import { Tag, TagVariant } from '@island.is/island-ui/core'
import {
isIndictmentCase,
isInvestigationCase,
isSuccessfulServiceStatus,
} from '@island.is/judicial-system/types'
import {
CaseIndictmentRulingDecision,
CaseState,
CaseType,
Defendant,
IndictmentDecision,
User,
} from '@island.is/judicial-system-web/src/graphql/schema'
Expand All @@ -30,6 +32,16 @@ interface Props {
indictmentReviewer?: User | null, // TODO: Refactor so we have a more generalized interface for the info passed in to the component
) => { color: TagVariant; text: string }
indictmentDecision?: IndictmentDecision | null
defendants?: Defendant[] | null
}

const haveAllSubpoenasBeenServiced = (defendants: Defendant[]): boolean => {
return defendants.every((defendant) => {
// if at least one subpoena for each defendant was serviced, we return true
return defendant.subpoenas?.some((subpoena) =>
isSuccessfulServiceStatus(subpoena.serviceStatus),
)
})
}

export const mapIndictmentCaseStateToTagVariant = (
Expand Down Expand Up @@ -59,6 +71,7 @@ export const mapCaseStateToTagVariant = (
isCourtRole?: boolean,
indictmentRulingDecision?: CaseIndictmentRulingDecision | null,
indictmentDecision?: IndictmentDecision | null,
defendants?: Defendant[] | null,
): { color: TagVariant; text: string } => {
switch (state) {
case CaseState.NEW:
Expand All @@ -70,7 +83,15 @@ export const mapCaseStateToTagVariant = (
color: 'purple',
text: formatMessage(isCourtRole ? strings.new : strings.sent),
}
case CaseState.RECEIVED:
case CaseState.RECEIVED: {
if (isIndictmentCase(caseType) && defendants) {
if (scheduledDate && !haveAllSubpoenasBeenServiced(defendants)) {
return {
color: 'red',
text: formatMessage(strings.notYetServiced),
}
}
}
switch (indictmentDecision) {
case IndictmentDecision.POSTPONING:
case IndictmentDecision.SCHEDULING:
Expand All @@ -88,6 +109,7 @@ export const mapCaseStateToTagVariant = (
return scheduledDate
? { color: 'mint', text: formatMessage(strings.scheduled) }
: { color: 'blueberry', text: formatMessage(strings.received) }
}

case CaseState.ACCEPTED:
return isIndictmentCase(caseType) || isValidToDateInThePast
Expand Down Expand Up @@ -129,6 +151,7 @@ const TagCaseState: FC<Props> = (props) => {
indictmentRulingDecision,
customMapCaseStateToTag,
indictmentDecision,
defendants,
} = props

const tagVariant = customMapCaseStateToTag
Expand All @@ -142,6 +165,7 @@ const TagCaseState: FC<Props> = (props) => {
isCourtRole,
indictmentRulingDecision,
indictmentDecision,
defendants,
)

if (!tagVariant) return null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,11 @@ const CasesInProgressTable: FC<CasesInProgressTableProps> = (props) => {
cell: (row) => (
<TagCaseState
caseState={row.state}
caseType={row.type}
isCourtRole={true}
courtDate={row.courtDate}
indictmentDecision={row.indictmentDecision}
defendants={row.defendants}
/>
),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ import {
SortButton,
TableSkeleton,
} from '@island.is/judicial-system-web/src/components/Table'
import { CaseListEntry } from '@island.is/judicial-system-web/src/graphql/schema'
import {
CaseListEntry,
Defendant,
} from '@island.is/judicial-system-web/src/graphql/schema'
import {
useCaseList,
useSort,
Expand Down Expand Up @@ -183,6 +186,7 @@ export const DefenderCasesTable: FC<Props> = ({
courtDate={column.courtDate}
indictmentDecision={column.indictmentDecision}
indictmentRulingDecision={column.indictmentRulingDecision}
defendants={column.defendants}
/>
</Box>
{column.appealState && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ query DefenderCases($input: CaseListQueryInput) {
name
noNationalId
defenderChoice
subpoenas {
id
serviceStatus
subpoenaId
}
}
initialRulingDate
rulingDate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ import {
DefendantInfo,
} from '@island.is/judicial-system-web/src/components/Table'
import Table from '@island.is/judicial-system-web/src/components/Table/Table'
import { CaseListEntry } from '@island.is/judicial-system-web/src/graphql/schema'
import {
CaseListEntry,
Defendant,
} from '@island.is/judicial-system-web/src/graphql/schema'

interface Props {
cases: CaseListEntry[]
Expand Down Expand Up @@ -105,6 +108,7 @@ const ActiveCases: FC<Props> = (props) => {
courtDate={row.courtDate}
indictmentDecision={row.indictmentDecision}
indictmentRulingDecision={row.indictmentRulingDecision}
defendants={row.defendants}
/>
),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ const MobileCase: FC<PropsWithChildren<Props>> = ({
courtDate={theCase.courtDate}
indictmentRulingDecision={theCase.indictmentRulingDecision}
indictmentDecision={theCase.indictmentDecision}
defendants={theCase.defendants}
/>,
]}
isLoading={isLoading}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ query Cases {
isSentToPrisonAdmin
punishmentType
openedByPrisonAdminDate
subpoenas {
id
serviceStatus
subpoenaId
}
}
defendantsPunishmentType
courtDate
Expand Down
Loading