Skip to content

Commit

Permalink
feat(j-s): Unserviced tag for indictment cases (#17352)
Browse files Browse the repository at this point in the history
* feat(j-s): Display "Not yet serviced" Tag on case list table

* fix(j-s): display tag for defenders

* fix(j-s): Cleanup

* fix(j-s): Removed unused imports

* Update CasesInProgressTable.tsx

* Update TagCaseState.tsx

* Update TagCaseState.tsx

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
unakb and kodiakhq[bot] authored Jan 6, 2025
1 parent 76e1ebf commit 6698aad
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 3 deletions.
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,18 @@ export const mapCaseStateToTagVariant = (
color: 'purple',
text: formatMessage(isCourtRole ? strings.new : strings.sent),
}
case CaseState.RECEIVED:
case CaseState.RECEIVED: {
if (
isIndictmentCase(caseType) &&
defendants &&
scheduledDate &&
!haveAllSubpoenasBeenServiced(defendants)
) {
return {
color: 'red',
text: formatMessage(strings.notYetServiced),
}
}
switch (indictmentDecision) {
case IndictmentDecision.POSTPONING:
case IndictmentDecision.SCHEDULING:
Expand All @@ -88,6 +112,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 +154,7 @@ const TagCaseState: FC<Props> = (props) => {
indictmentRulingDecision,
customMapCaseStateToTag,
indictmentDecision,
defendants,
} = props

const tagVariant = customMapCaseStateToTag
Expand All @@ -142,6 +168,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

0 comments on commit 6698aad

Please sign in to comment.