From 16781debc7c33cba38bd373589192c0711b6cdbb Mon Sep 17 00:00:00 2001 From: unakb Date: Mon, 23 Dec 2024 14:30:52 +0000 Subject: [PATCH 1/7] feat(j-s): Display "Not yet serviced" Tag on case list table --- .../src/app/modules/case/case.service.ts | 7 +++ .../TagCaseState/TagCaseState.strings.ts | 5 ++ .../components/TagCaseState/TagCaseState.tsx | 55 +++++++++++++++---- .../CasesInProgressTable.tsx | 5 +- .../web/src/routes/Shared/Cases/cases.graphql | 5 ++ 5 files changed, 65 insertions(+), 12 deletions(-) diff --git a/apps/judicial-system/backend/src/app/modules/case/case.service.ts b/apps/judicial-system/backend/src/app/modules/case/case.service.ts index ff03a3b13def..2ac9e2e32ef5 100644 --- a/apps/judicial-system/backend/src/app/modules/case/case.service.ts +++ b/apps/judicial-system/backend/src/app/modules/case/case.service.ts @@ -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, }, diff --git a/apps/judicial-system/web/src/components/TagCaseState/TagCaseState.strings.ts b/apps/judicial-system/web/src/components/TagCaseState/TagCaseState.strings.ts index 89ece434dfc5..7745ebcf1884 100644 --- a/apps/judicial-system/web/src/components/TagCaseState/TagCaseState.strings.ts +++ b/apps/judicial-system/web/src/components/TagCaseState/TagCaseState.strings.ts @@ -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', + }, }) diff --git a/apps/judicial-system/web/src/components/TagCaseState/TagCaseState.tsx b/apps/judicial-system/web/src/components/TagCaseState/TagCaseState.tsx index 3e5445189f72..f5ab384f535b 100644 --- a/apps/judicial-system/web/src/components/TagCaseState/TagCaseState.tsx +++ b/apps/judicial-system/web/src/components/TagCaseState/TagCaseState.tsx @@ -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' @@ -30,6 +32,25 @@ 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 haveAllDefendantsBeenServiced = ( + defendants?: Defendant[] | null, +): boolean => { + if (!defendants) { + return false + } + + return defendants.every((defendant) => { + if (!defendant.subpoenas || defendant.subpoenas.length === 0) { + return true + } + + return defendant.subpoenas.some((subpoena) => + isSuccessfulServiceStatus(subpoena.serviceStatus), + ) + }) } export const mapIndictmentCaseStateToTagVariant = ( @@ -59,6 +80,7 @@ export const mapCaseStateToTagVariant = ( isCourtRole?: boolean, indictmentRulingDecision?: CaseIndictmentRulingDecision | null, indictmentDecision?: IndictmentDecision | null, + defendants?: Defendant[] | null, ): { color: TagVariant; text: string } => { switch (state) { case CaseState.NEW: @@ -70,24 +92,33 @@ export const mapCaseStateToTagVariant = ( color: 'purple', text: formatMessage(isCourtRole ? strings.new : strings.sent), } - case CaseState.RECEIVED: - switch (indictmentDecision) { - case IndictmentDecision.POSTPONING: - case IndictmentDecision.SCHEDULING: - case IndictmentDecision.COMPLETING: - return { color: 'mint', text: formatMessage(strings.scheduled) } - case IndictmentDecision.POSTPONING_UNTIL_VERDICT: + case CaseState.RECEIVED: { + if (isIndictmentCase(caseType)) { + if (!haveAllDefendantsBeenServiced(defendants)) { return { - color: 'mint', - text: formatMessage(strings.postponedUntilVerdict), + color: 'red', + text: formatMessage(strings.notYetServiced), } - case IndictmentDecision.REDISTRIBUTING: - return { color: 'blue', text: formatMessage(strings.reassignment) } + } + switch (indictmentDecision) { + case IndictmentDecision.POSTPONING: + case IndictmentDecision.SCHEDULING: + case IndictmentDecision.COMPLETING: + return { color: 'mint', text: formatMessage(strings.scheduled) } + case IndictmentDecision.POSTPONING_UNTIL_VERDICT: + return { + color: 'mint', + text: formatMessage(strings.postponedUntilVerdict), + } + case IndictmentDecision.REDISTRIBUTING: + return { color: 'blue', text: formatMessage(strings.reassignment) } + } } return scheduledDate ? { color: 'mint', text: formatMessage(strings.scheduled) } : { color: 'blueberry', text: formatMessage(strings.received) } + } case CaseState.ACCEPTED: return isIndictmentCase(caseType) || isValidToDateInThePast @@ -129,6 +160,7 @@ const TagCaseState: FC = (props) => { indictmentRulingDecision, customMapCaseStateToTag, indictmentDecision, + defendants, } = props const tagVariant = customMapCaseStateToTag @@ -142,6 +174,7 @@ const TagCaseState: FC = (props) => { isCourtRole, indictmentRulingDecision, indictmentDecision, + defendants, ) if (!tagVariant) return null diff --git a/apps/judicial-system/web/src/routes/Court/components/CasesInProgressTable/CasesInProgressTable.tsx b/apps/judicial-system/web/src/routes/Court/components/CasesInProgressTable/CasesInProgressTable.tsx index 80ed5591e736..bd9fd07173f4 100644 --- a/apps/judicial-system/web/src/routes/Court/components/CasesInProgressTable/CasesInProgressTable.tsx +++ b/apps/judicial-system/web/src/routes/Court/components/CasesInProgressTable/CasesInProgressTable.tsx @@ -9,8 +9,9 @@ import { import { useIntl } from 'react-intl' import { AnimatePresence } from 'framer-motion' -import { Box, toast } from '@island.is/island-ui/core' +import { Box, Tag, toast } from '@island.is/island-ui/core' import { capitalize } from '@island.is/judicial-system/formatters' +import { isSuccessfulServiceStatus } from '@island.is/judicial-system/types' import { core, errors, tables } from '@island.is/judicial-system-web/messages' import { FormContext, @@ -35,6 +36,7 @@ import { CaseListEntry, CaseState, CaseTransition, + Defendant, } from '@island.is/judicial-system-web/src/graphql/schema' import { TempCase as Case } from '@island.is/judicial-system-web/src/types' import { useCase } from '@island.is/judicial-system-web/src/utils/hooks' @@ -158,6 +160,7 @@ const CasesInProgressTable: FC = (props) => { isCourtRole={true} courtDate={row.courtDate} indictmentDecision={row.indictmentDecision} + defendants={row.defendants as Defendant[]} /> ), }, diff --git a/apps/judicial-system/web/src/routes/Shared/Cases/cases.graphql b/apps/judicial-system/web/src/routes/Shared/Cases/cases.graphql index b188cbfac1aa..b18a3131f9b5 100644 --- a/apps/judicial-system/web/src/routes/Shared/Cases/cases.graphql +++ b/apps/judicial-system/web/src/routes/Shared/Cases/cases.graphql @@ -30,6 +30,11 @@ query Cases { isSentToPrisonAdmin punishmentType openedByPrisonAdminDate + subpoenas { + id + serviceStatus + subpoenaId + } } defendantsPunishmentType courtDate From c32044910c545caaa502402684d3a6bc4cbd12c6 Mon Sep 17 00:00:00 2001 From: unakb Date: Mon, 23 Dec 2024 14:45:29 +0000 Subject: [PATCH 2/7] fix(j-s): display tag for defenders --- .../components/TagCaseState/TagCaseState.tsx | 26 +++++++++---------- .../CasesInProgressTable.tsx | 1 + .../Cases/components/DefenderCasesTable.tsx | 6 ++++- .../Defender/Cases/defenderCases.graphql | 5 ++++ .../src/routes/Shared/Cases/ActiveCases.tsx | 6 ++++- 5 files changed, 29 insertions(+), 15 deletions(-) diff --git a/apps/judicial-system/web/src/components/TagCaseState/TagCaseState.tsx b/apps/judicial-system/web/src/components/TagCaseState/TagCaseState.tsx index f5ab384f535b..c93d8ec2dfa1 100644 --- a/apps/judicial-system/web/src/components/TagCaseState/TagCaseState.tsx +++ b/apps/judicial-system/web/src/components/TagCaseState/TagCaseState.tsx @@ -100,19 +100,19 @@ export const mapCaseStateToTagVariant = ( text: formatMessage(strings.notYetServiced), } } - switch (indictmentDecision) { - case IndictmentDecision.POSTPONING: - case IndictmentDecision.SCHEDULING: - case IndictmentDecision.COMPLETING: - return { color: 'mint', text: formatMessage(strings.scheduled) } - case IndictmentDecision.POSTPONING_UNTIL_VERDICT: - return { - color: 'mint', - text: formatMessage(strings.postponedUntilVerdict), - } - case IndictmentDecision.REDISTRIBUTING: - return { color: 'blue', text: formatMessage(strings.reassignment) } - } + } + switch (indictmentDecision) { + case IndictmentDecision.POSTPONING: + case IndictmentDecision.SCHEDULING: + case IndictmentDecision.COMPLETING: + return { color: 'mint', text: formatMessage(strings.scheduled) } + case IndictmentDecision.POSTPONING_UNTIL_VERDICT: + return { + color: 'mint', + text: formatMessage(strings.postponedUntilVerdict), + } + case IndictmentDecision.REDISTRIBUTING: + return { color: 'blue', text: formatMessage(strings.reassignment) } } return scheduledDate diff --git a/apps/judicial-system/web/src/routes/Court/components/CasesInProgressTable/CasesInProgressTable.tsx b/apps/judicial-system/web/src/routes/Court/components/CasesInProgressTable/CasesInProgressTable.tsx index bd9fd07173f4..7d28c11240bb 100644 --- a/apps/judicial-system/web/src/routes/Court/components/CasesInProgressTable/CasesInProgressTable.tsx +++ b/apps/judicial-system/web/src/routes/Court/components/CasesInProgressTable/CasesInProgressTable.tsx @@ -157,6 +157,7 @@ const CasesInProgressTable: FC = (props) => { cell: (row) => ( = ({ courtDate={column.courtDate} indictmentDecision={column.indictmentDecision} indictmentRulingDecision={column.indictmentRulingDecision} + defendants={column.defendants as Defendant[]} /> {column.appealState && ( diff --git a/apps/judicial-system/web/src/routes/Defender/Cases/defenderCases.graphql b/apps/judicial-system/web/src/routes/Defender/Cases/defenderCases.graphql index 9c2057fd61a2..5c07fc3c2f22 100644 --- a/apps/judicial-system/web/src/routes/Defender/Cases/defenderCases.graphql +++ b/apps/judicial-system/web/src/routes/Defender/Cases/defenderCases.graphql @@ -23,6 +23,11 @@ query DefenderCases($input: CaseListQueryInput) { name noNationalId defenderChoice + subpoenas { + id + serviceStatus + subpoenaId + } } initialRulingDate rulingDate diff --git a/apps/judicial-system/web/src/routes/Shared/Cases/ActiveCases.tsx b/apps/judicial-system/web/src/routes/Shared/Cases/ActiveCases.tsx index 7e444f9327d4..ade8559a401c 100644 --- a/apps/judicial-system/web/src/routes/Shared/Cases/ActiveCases.tsx +++ b/apps/judicial-system/web/src/routes/Shared/Cases/ActiveCases.tsx @@ -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[] @@ -105,6 +108,7 @@ const ActiveCases: FC = (props) => { courtDate={row.courtDate} indictmentDecision={row.indictmentDecision} indictmentRulingDecision={row.indictmentRulingDecision} + defendants={row.defendants as Defendant[]} /> ), }, From d8cc07841dcff2794fdef5e05e9c20db75446659 Mon Sep 17 00:00:00 2001 From: unakb Date: Mon, 23 Dec 2024 14:54:55 +0000 Subject: [PATCH 3/7] fix(j-s): Cleanup --- .../web/src/components/TagCaseState/TagCaseState.tsx | 11 ++++------- .../CasesInProgressTable/CasesInProgressTable.tsx | 2 +- .../Defender/Cases/components/DefenderCasesTable.tsx | 2 +- .../web/src/routes/Shared/Cases/ActiveCases.tsx | 2 +- .../web/src/routes/Shared/Cases/MobileCase.tsx | 1 + 5 files changed, 8 insertions(+), 10 deletions(-) diff --git a/apps/judicial-system/web/src/components/TagCaseState/TagCaseState.tsx b/apps/judicial-system/web/src/components/TagCaseState/TagCaseState.tsx index c93d8ec2dfa1..80349d023573 100644 --- a/apps/judicial-system/web/src/components/TagCaseState/TagCaseState.tsx +++ b/apps/judicial-system/web/src/components/TagCaseState/TagCaseState.tsx @@ -35,7 +35,7 @@ interface Props { defendants?: Defendant[] | null } -const haveAllDefendantsBeenServiced = ( +const haveAllSubpoenasBeenServiced = ( defendants?: Defendant[] | null, ): boolean => { if (!defendants) { @@ -43,11 +43,8 @@ const haveAllDefendantsBeenServiced = ( } return defendants.every((defendant) => { - if (!defendant.subpoenas || defendant.subpoenas.length === 0) { - return true - } - - return defendant.subpoenas.some((subpoena) => + // if at least one subpoena for each defendant was serviced, we return true + return defendant.subpoenas?.some((subpoena) => isSuccessfulServiceStatus(subpoena.serviceStatus), ) }) @@ -94,7 +91,7 @@ export const mapCaseStateToTagVariant = ( } case CaseState.RECEIVED: { if (isIndictmentCase(caseType)) { - if (!haveAllDefendantsBeenServiced(defendants)) { + if (scheduledDate && !haveAllSubpoenasBeenServiced(defendants)) { return { color: 'red', text: formatMessage(strings.notYetServiced), diff --git a/apps/judicial-system/web/src/routes/Court/components/CasesInProgressTable/CasesInProgressTable.tsx b/apps/judicial-system/web/src/routes/Court/components/CasesInProgressTable/CasesInProgressTable.tsx index 7d28c11240bb..b9ea5281b211 100644 --- a/apps/judicial-system/web/src/routes/Court/components/CasesInProgressTable/CasesInProgressTable.tsx +++ b/apps/judicial-system/web/src/routes/Court/components/CasesInProgressTable/CasesInProgressTable.tsx @@ -161,7 +161,7 @@ const CasesInProgressTable: FC = (props) => { isCourtRole={true} courtDate={row.courtDate} indictmentDecision={row.indictmentDecision} - defendants={row.defendants as Defendant[]} + defendants={row.defendants} /> ), }, diff --git a/apps/judicial-system/web/src/routes/Defender/Cases/components/DefenderCasesTable.tsx b/apps/judicial-system/web/src/routes/Defender/Cases/components/DefenderCasesTable.tsx index ed6a394d20ba..be8edb2ecdd4 100644 --- a/apps/judicial-system/web/src/routes/Defender/Cases/components/DefenderCasesTable.tsx +++ b/apps/judicial-system/web/src/routes/Defender/Cases/components/DefenderCasesTable.tsx @@ -186,7 +186,7 @@ export const DefenderCasesTable: FC = ({ courtDate={column.courtDate} indictmentDecision={column.indictmentDecision} indictmentRulingDecision={column.indictmentRulingDecision} - defendants={column.defendants as Defendant[]} + defendants={column.defendants} /> {column.appealState && ( diff --git a/apps/judicial-system/web/src/routes/Shared/Cases/ActiveCases.tsx b/apps/judicial-system/web/src/routes/Shared/Cases/ActiveCases.tsx index ade8559a401c..29cdaa3286de 100644 --- a/apps/judicial-system/web/src/routes/Shared/Cases/ActiveCases.tsx +++ b/apps/judicial-system/web/src/routes/Shared/Cases/ActiveCases.tsx @@ -108,7 +108,7 @@ const ActiveCases: FC = (props) => { courtDate={row.courtDate} indictmentDecision={row.indictmentDecision} indictmentRulingDecision={row.indictmentRulingDecision} - defendants={row.defendants as Defendant[]} + defendants={row.defendants} /> ), }, diff --git a/apps/judicial-system/web/src/routes/Shared/Cases/MobileCase.tsx b/apps/judicial-system/web/src/routes/Shared/Cases/MobileCase.tsx index a14415196497..6e27a56edc29 100644 --- a/apps/judicial-system/web/src/routes/Shared/Cases/MobileCase.tsx +++ b/apps/judicial-system/web/src/routes/Shared/Cases/MobileCase.tsx @@ -86,6 +86,7 @@ const MobileCase: FC> = ({ courtDate={theCase.courtDate} indictmentRulingDecision={theCase.indictmentRulingDecision} indictmentDecision={theCase.indictmentDecision} + defendants={theCase.defendants} />, ]} isLoading={isLoading} From 31e7f0b3a9cd909c10d2199bff873e70678ed840 Mon Sep 17 00:00:00 2001 From: unakb Date: Mon, 23 Dec 2024 16:02:30 +0000 Subject: [PATCH 4/7] fix(j-s): Removed unused imports --- .../components/CasesInProgressTable/CasesInProgressTable.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/judicial-system/web/src/routes/Court/components/CasesInProgressTable/CasesInProgressTable.tsx b/apps/judicial-system/web/src/routes/Court/components/CasesInProgressTable/CasesInProgressTable.tsx index b9ea5281b211..6f1fe58ad32a 100644 --- a/apps/judicial-system/web/src/routes/Court/components/CasesInProgressTable/CasesInProgressTable.tsx +++ b/apps/judicial-system/web/src/routes/Court/components/CasesInProgressTable/CasesInProgressTable.tsx @@ -9,9 +9,8 @@ import { import { useIntl } from 'react-intl' import { AnimatePresence } from 'framer-motion' -import { Box, Tag, toast } from '@island.is/island-ui/core' +import { Box, toast } from '@island.is/island-ui/core' import { capitalize } from '@island.is/judicial-system/formatters' -import { isSuccessfulServiceStatus } from '@island.is/judicial-system/types' import { core, errors, tables } from '@island.is/judicial-system-web/messages' import { FormContext, From e455066f18b69a081527a59d57c882a1f1a9b111 Mon Sep 17 00:00:00 2001 From: unakb Date: Mon, 23 Dec 2024 16:08:27 +0000 Subject: [PATCH 5/7] Update CasesInProgressTable.tsx --- .../components/CasesInProgressTable/CasesInProgressTable.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/judicial-system/web/src/routes/Court/components/CasesInProgressTable/CasesInProgressTable.tsx b/apps/judicial-system/web/src/routes/Court/components/CasesInProgressTable/CasesInProgressTable.tsx index 6f1fe58ad32a..cf1e1c68910d 100644 --- a/apps/judicial-system/web/src/routes/Court/components/CasesInProgressTable/CasesInProgressTable.tsx +++ b/apps/judicial-system/web/src/routes/Court/components/CasesInProgressTable/CasesInProgressTable.tsx @@ -35,7 +35,6 @@ import { CaseListEntry, CaseState, CaseTransition, - Defendant, } from '@island.is/judicial-system-web/src/graphql/schema' import { TempCase as Case } from '@island.is/judicial-system-web/src/types' import { useCase } from '@island.is/judicial-system-web/src/utils/hooks' From d06f32654d981113a5ec9d61450edb79973cd517 Mon Sep 17 00:00:00 2001 From: unakb Date: Mon, 23 Dec 2024 16:12:23 +0000 Subject: [PATCH 6/7] Update TagCaseState.tsx --- .../web/src/components/TagCaseState/TagCaseState.tsx | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/apps/judicial-system/web/src/components/TagCaseState/TagCaseState.tsx b/apps/judicial-system/web/src/components/TagCaseState/TagCaseState.tsx index 80349d023573..f813f756cd85 100644 --- a/apps/judicial-system/web/src/components/TagCaseState/TagCaseState.tsx +++ b/apps/judicial-system/web/src/components/TagCaseState/TagCaseState.tsx @@ -35,13 +35,7 @@ interface Props { defendants?: Defendant[] | null } -const haveAllSubpoenasBeenServiced = ( - defendants?: Defendant[] | null, -): boolean => { - if (!defendants) { - return false - } - +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) => @@ -90,7 +84,7 @@ export const mapCaseStateToTagVariant = ( text: formatMessage(isCourtRole ? strings.new : strings.sent), } case CaseState.RECEIVED: { - if (isIndictmentCase(caseType)) { + if (isIndictmentCase(caseType) && defendants) { if (scheduledDate && !haveAllSubpoenasBeenServiced(defendants)) { return { color: 'red', From a52e8cb43c28bc8df8afb43bcf69089d7bf249e1 Mon Sep 17 00:00:00 2001 From: unakb Date: Mon, 6 Jan 2025 12:49:32 +0000 Subject: [PATCH 7/7] Update TagCaseState.tsx --- .../src/components/TagCaseState/TagCaseState.tsx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/apps/judicial-system/web/src/components/TagCaseState/TagCaseState.tsx b/apps/judicial-system/web/src/components/TagCaseState/TagCaseState.tsx index f813f756cd85..743f91920971 100644 --- a/apps/judicial-system/web/src/components/TagCaseState/TagCaseState.tsx +++ b/apps/judicial-system/web/src/components/TagCaseState/TagCaseState.tsx @@ -84,12 +84,15 @@ export const mapCaseStateToTagVariant = ( text: formatMessage(isCourtRole ? strings.new : strings.sent), } case CaseState.RECEIVED: { - if (isIndictmentCase(caseType) && defendants) { - if (scheduledDate && !haveAllSubpoenasBeenServiced(defendants)) { - return { - color: 'red', - text: formatMessage(strings.notYetServiced), - } + if ( + isIndictmentCase(caseType) && + defendants && + scheduledDate && + !haveAllSubpoenasBeenServiced(defendants) + ) { + return { + color: 'red', + text: formatMessage(strings.notYetServiced), } } switch (indictmentDecision) {