From 9cb36221acd93128935cfd03ed15802e63b2f988 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8Dvar=20Oddsson?= Date: Thu, 5 Dec 2024 13:47:02 +0000 Subject: [PATCH 1/9] Refactoring --- .../IndictmentCaseFilesList.tsx | 120 ++++++++++-------- 1 file changed, 64 insertions(+), 56 deletions(-) diff --git a/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.tsx b/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.tsx index 9dd7bb9cb3bd..fdd98adb5c89 100644 --- a/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.tsx +++ b/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.tsx @@ -63,6 +63,30 @@ export const RenderFiles: FC = ({ ) } +interface FileSection { + title: string + onOpenFile: (fileId: string) => void + files?: CaseFile[] + shouldRender?: boolean +} + +const FileSection: FC = (props: FileSection) => { + const { title, files, onOpenFile, shouldRender = true } = props + + if (!files?.length || !shouldRender) { + return null + } + + return ( + + + {title} + + + + ) +} + const IndictmentCaseFilesList: FC = ({ workingCase, displayGeneratedPDFs = true, @@ -120,14 +144,11 @@ const IndictmentCaseFilesList: FC = ({ {displayHeading && ( )} - {indictments && indictments.length > 0 && ( - - - {formatMessage(caseFiles.indictmentSection)} - - - - )} + {showTrafficViolationCaseFiles && displayGeneratedPDFs && ( @@ -144,42 +165,31 @@ const IndictmentCaseFilesList: FC = ({ )} - {criminalRecords && criminalRecords.length > 0 && ( - - - {formatMessage(caseFiles.criminalRecordSection)} - - - - )} - {criminalRecordUpdate && - criminalRecordUpdate.length > 0 && - (isDistrictCourtUser(user) || + + - - {formatMessage(caseFiles.criminalRecordUpdateSection)} - - - - )} - {costBreakdowns && costBreakdowns.length > 0 && ( - - - {formatMessage(caseFiles.costBreakdownSection)} - - - - )} - {others && others.length > 0 && ( - - - {formatMessage(caseFiles.otherDocumentsSection)} - - - - )} + isPublicProsecutorUser(user) + } + /> + + {displayGeneratedPDFs && ( @@ -216,19 +226,17 @@ const IndictmentCaseFilesList: FC = ({ )} ) : null} - {workingCase.hasCivilClaims && - civilClaims && - civilClaims.length > 0 && - (isDistrictCourtUser(user) || - isProsecutionUser(user) || - isDefenceUser(user)) && ( - - - {formatMessage(strings.civilClaimsTitle)} - - - - )} + {showSubpoenaPdf && ( From fcff8ab38ad694a9d72a56bc154a880dfd2519e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8Dvar=20Oddsson?= Date: Thu, 5 Dec 2024 14:04:08 +0000 Subject: [PATCH 2/9] Refactor --- .../IndictmentCaseFilesList.tsx | 170 ++++++++++-------- 1 file changed, 99 insertions(+), 71 deletions(-) diff --git a/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.tsx b/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.tsx index fdd98adb5c89..c24e1c59e7ab 100644 --- a/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.tsx +++ b/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.tsx @@ -1,4 +1,4 @@ -import { FC, useContext } from 'react' +import { FC, useContext, useMemo } from 'react' import { useIntl } from 'react-intl' import { AnimatePresence } from 'framer-motion' @@ -23,6 +23,7 @@ import { import { CaseFile, CaseFileCategory, + User, } from '@island.is/judicial-system-web/src/graphql/schema' import { TempCase as Case } from '@island.is/judicial-system-web/src/types' import { useFileList } from '@island.is/judicial-system-web/src/utils/hooks' @@ -43,6 +44,13 @@ interface RenderFilesProps { onOpenFile: (fileId: string) => void } +interface FileSection { + title: string + onOpenFile: (fileId: string) => void + files?: CaseFile[] + shouldRender?: boolean +} + export const RenderFiles: FC = ({ caseFiles, onOpenFile, @@ -63,13 +71,6 @@ export const RenderFiles: FC = ({ ) } -interface FileSection { - title: string - onOpenFile: (fileId: string) => void - files?: CaseFile[] - shouldRender?: boolean -} - const FileSection: FC = (props: FileSection) => { const { title, files, onOpenFile, shouldRender = true } = props @@ -87,6 +88,60 @@ const FileSection: FC = (props: FileSection) => { ) } +const useFilteredCaseFiles = (caseFiles?: CaseFile[] | null) => { + return useMemo( + () => ({ + indictments: caseFiles?.filter( + (file) => file.category === CaseFileCategory.INDICTMENT, + ), + criminalRecords: caseFiles?.filter( + (file) => file.category === CaseFileCategory.CRIMINAL_RECORD, + ), + costBreakdowns: caseFiles?.filter( + (file) => file.category === CaseFileCategory.COST_BREAKDOWN, + ), + others: caseFiles?.filter( + (file) => file.category === CaseFileCategory.CASE_FILE, + ), + rulings: caseFiles?.filter( + (file) => file.category === CaseFileCategory.RULING, + ), + courtRecords: caseFiles?.filter( + (file) => file.category === CaseFileCategory.COURT_RECORD, + ), + criminalRecordUpdate: caseFiles?.filter( + (file) => file.category === CaseFileCategory.CRIMINAL_RECORD_UPDATE, + ), + uploadedCaseFiles: caseFiles?.filter( + (file) => + file.category === CaseFileCategory.PROSECUTOR_CASE_FILE || + file.category === CaseFileCategory.DEFENDANT_CASE_FILE, + ), + civilClaims: caseFiles?.filter( + (file) => file.category === CaseFileCategory.CIVIL_CLAIM, + ), + }), + [caseFiles], + ) +} + +const useFilePermissions = (workingCase: Case, user?: User) => { + return useMemo( + () => ({ + canViewCriminalRecordUpdate: + isDistrictCourtUser(user) || + isPublicProsecutor(user) || + isPublicProsecutorUser(user), + canViewCivilClaims: + Boolean(workingCase.hasCivilClaims) && + (isDistrictCourtUser(user) || + isProsecutionUser(user) || + isDefenceUser(user)), + }), + [user], + ) +} + const IndictmentCaseFilesList: FC = ({ workingCase, displayGeneratedPDFs = true, @@ -107,37 +162,8 @@ const IndictmentCaseFilesList: FC = ({ (defendant) => defendant.subpoenas && defendant.subpoenas.length > 0, ) - const cf = workingCase.caseFiles - - const indictments = cf?.filter( - (file) => file.category === CaseFileCategory.INDICTMENT, - ) - const criminalRecords = cf?.filter( - (file) => file.category === CaseFileCategory.CRIMINAL_RECORD, - ) - const costBreakdowns = cf?.filter( - (file) => file.category === CaseFileCategory.COST_BREAKDOWN, - ) - const others = cf?.filter( - (file) => file.category === CaseFileCategory.CASE_FILE, - ) - const rulings = cf?.filter( - (file) => file.category === CaseFileCategory.RULING, - ) - const courtRecords = cf?.filter( - (file) => file.category === CaseFileCategory.COURT_RECORD, - ) - const criminalRecordUpdate = cf?.filter( - (file) => file.category === CaseFileCategory.CRIMINAL_RECORD_UPDATE, - ) - const uploadedCaseFiles = cf?.filter( - (file) => - file.category === CaseFileCategory.PROSECUTOR_CASE_FILE || - file.category === CaseFileCategory.DEFENDANT_CASE_FILE, - ) - const civilClaims = cf?.filter( - (file) => file.category === CaseFileCategory.CIVIL_CLAIM, - ) + const filteredFiles = useFilteredCaseFiles(workingCase.caseFiles) + const permissions = useFilePermissions(workingCase, user) return ( <> @@ -146,7 +172,7 @@ const IndictmentCaseFilesList: FC = ({ )} {showTrafficViolationCaseFiles && displayGeneratedPDFs && ( @@ -167,27 +193,23 @@ const IndictmentCaseFilesList: FC = ({ )} {displayGeneratedPDFs && ( @@ -211,31 +233,33 @@ const IndictmentCaseFilesList: FC = ({ ))} )} - {courtRecords?.length || rulings?.length ? ( + {filteredFiles.courtRecords?.length || filteredFiles.rulings?.length ? ( {formatMessage(strings.rulingAndCourtRecordsTitle)} - {courtRecords && courtRecords.length > 0 && ( - - )} + {filteredFiles.courtRecords && + filteredFiles.courtRecords.length > 0 && ( + + )} {(isDistrictCourtUser(user) || isCompletedCase(workingCase.state)) && - rulings && - rulings.length > 0 && ( - + filteredFiles.rulings && + filteredFiles.rulings.length > 0 && ( + )} ) : null} {showSubpoenaPdf && ( @@ -275,14 +299,18 @@ const IndictmentCaseFilesList: FC = ({ )} )} - {uploadedCaseFiles && uploadedCaseFiles.length > 0 && ( - - - {formatMessage(strings.uploadedCaseFiles)} - - - - )} + {filteredFiles.uploadedCaseFiles && + filteredFiles.uploadedCaseFiles.length > 0 && ( + + + {formatMessage(strings.uploadedCaseFiles)} + + + + )} {fileNotFound && } From 80178d3e9a343155cc155fccfae0a6e977d6930e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8Dvar=20Oddsson?= Date: Thu, 5 Dec 2024 14:29:06 +0000 Subject: [PATCH 3/9] Refactor --- .../IndictmentCaseFilesList.tsx | 59 ++++++++++--------- 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.tsx b/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.tsx index c24e1c59e7ab..20e40f99ba58 100644 --- a/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.tsx +++ b/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.tsx @@ -89,36 +89,36 @@ const FileSection: FC = (props: FileSection) => { } const useFilteredCaseFiles = (caseFiles?: CaseFile[] | null) => { + const filterByCategories = ( + categories: CaseFileCategory | CaseFileCategory[], + ) => { + const categoryArray = Array.isArray(categories) ? categories : [categories] + + return ( + caseFiles?.filter( + (file) => file.category && categoryArray.includes(file.category), + ) ?? [] + ) + } + return useMemo( () => ({ - indictments: caseFiles?.filter( - (file) => file.category === CaseFileCategory.INDICTMENT, - ), - criminalRecords: caseFiles?.filter( - (file) => file.category === CaseFileCategory.CRIMINAL_RECORD, - ), - costBreakdowns: caseFiles?.filter( - (file) => file.category === CaseFileCategory.COST_BREAKDOWN, - ), - others: caseFiles?.filter( - (file) => file.category === CaseFileCategory.CASE_FILE, - ), - rulings: caseFiles?.filter( - (file) => file.category === CaseFileCategory.RULING, + indictments: filterByCategories(CaseFileCategory.INDICTMENT), + criminalRecords: filterByCategories(CaseFileCategory.CRIMINAL_RECORD), + costBreakdowns: filterByCategories(CaseFileCategory.COST_BREAKDOWN), + others: filterByCategories(CaseFileCategory.CASE_FILE), + rulings: filterByCategories(CaseFileCategory.RULING), + courtRecords: filterByCategories(CaseFileCategory.COURT_RECORD), + criminalRecordUpdate: filterByCategories( + CaseFileCategory.CRIMINAL_RECORD_UPDATE, ), - courtRecords: caseFiles?.filter( - (file) => file.category === CaseFileCategory.COURT_RECORD, - ), - criminalRecordUpdate: caseFiles?.filter( - (file) => file.category === CaseFileCategory.CRIMINAL_RECORD_UPDATE, - ), - uploadedCaseFiles: caseFiles?.filter( - (file) => - file.category === CaseFileCategory.PROSECUTOR_CASE_FILE || - file.category === CaseFileCategory.DEFENDANT_CASE_FILE, - ), - civilClaims: caseFiles?.filter( - (file) => file.category === CaseFileCategory.CIVIL_CLAIM, + uploadedCaseFiles: filterByCategories([ + CaseFileCategory.PROSECUTOR_CASE_FILE, + CaseFileCategory.DEFENDANT_CASE_FILE, + ]), + civilClaims: filterByCategories(CaseFileCategory.CIVIL_CLAIM), + sentToPrisonAdminFiles: filterByCategories( + CaseFileCategory.SENT_TO_PRISON_ADMIN_FILE, ), }), [caseFiles], @@ -311,6 +311,11 @@ const IndictmentCaseFilesList: FC = ({ /> )} + {fileNotFound && } From 77af558b2048cb0ae85deea1489a23c1df5fe3bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8Dvar=20Oddsson?= Date: Thu, 5 Dec 2024 14:40:52 +0000 Subject: [PATCH 4/9] Refactor --- .../IndictmentCaseFilesList.tsx | 4 ++++ libs/judicial-system/types/src/lib/user.ts | 16 ++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.tsx b/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.tsx index 20e40f99ba58..fdb7eabe2c41 100644 --- a/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.tsx +++ b/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.tsx @@ -8,6 +8,7 @@ import { isCompletedCase, isDefenceUser, isDistrictCourtUser, + isPrisonAdminUser, isProsecutionUser, isPublicProsecutor, isPublicProsecutorUser, @@ -137,6 +138,8 @@ const useFilePermissions = (workingCase: Case, user?: User) => { (isDistrictCourtUser(user) || isProsecutionUser(user) || isDefenceUser(user)), + canViewSentToPrisonAdminFiles: + isPrisonAdminUser(user) || isPublicProsecutorUser(user), }), [user], ) @@ -315,6 +318,7 @@ const IndictmentCaseFilesList: FC = ({ title={formatMessage(strings.civilClaimsTitle)} files={filteredFiles.sentToPrisonAdminFiles} onOpenFile={onOpen} + shouldRender={permissions.canViewSentToPrisonAdminFiles} /> {fileNotFound && } diff --git a/libs/judicial-system/types/src/lib/user.ts b/libs/judicial-system/types/src/lib/user.ts index 8c0dcb478e20..408c3136cebd 100644 --- a/libs/judicial-system/types/src/lib/user.ts +++ b/libs/judicial-system/types/src/lib/user.ts @@ -70,8 +70,8 @@ export const isPublicProsecutorUser = (user?: InstitutionUser): boolean => { return Boolean( user?.role && publicProsecutorRoles.includes(user.role) && - user?.institution?.type === InstitutionType.PROSECUTORS_OFFICE && - user?.institution?.id === '8f9e2f6d-6a00-4a5e-b39b-95fd110d762e', // TODO: Create a new institution type to avoid hardcoding + user.institution?.type === InstitutionType.PROSECUTORS_OFFICE && + user.institution?.id === '8f9e2f6d-6a00-4a5e-b39b-95fd110d762e', // TODO: Create a new institution type to avoid hardcoding ) } @@ -85,7 +85,7 @@ export const isDistrictCourtUser = (user?: InstitutionUser): boolean => { return Boolean( user?.role && districtCourtRoles.includes(user.role) && - user?.institution?.type === InstitutionType.DISTRICT_COURT, + user.institution?.type === InstitutionType.DISTRICT_COURT, ) } @@ -99,7 +99,7 @@ export const isCourtOfAppealsUser = (user?: InstitutionUser): boolean => { return Boolean( user?.role && courtOfAppealsRoles.includes(user.role) && - user?.institution?.type === InstitutionType.COURT_OF_APPEALS, + user.institution?.type === InstitutionType.COURT_OF_APPEALS, ) } @@ -109,14 +109,14 @@ export const isPrisonSystemUser = (user?: InstitutionUser): boolean => { return Boolean( user?.role && prisonSystemRoles.includes(user.role) && - (user?.institution?.type === InstitutionType.PRISON || - user?.institution?.type === InstitutionType.PRISON_ADMIN), + (user.institution?.type === InstitutionType.PRISON || + user.institution?.type === InstitutionType.PRISON_ADMIN), ) } -export const isPrisonAdminUser = (user: InstitutionUser): boolean => +export const isPrisonAdminUser = (user?: InstitutionUser): boolean => Boolean( - user.role && + user?.role && prisonSystemRoles.includes(user.role) && user.institution?.type === InstitutionType.PRISON_ADMIN, ) From d9cdddd6865425031e793cc360b02401b7e8a4bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8Dvar=20Oddsson?= Date: Thu, 5 Dec 2024 14:48:30 +0000 Subject: [PATCH 5/9] Refactor --- .../IndictmentCaseFilesList.strings.ts | 6 ++++++ .../IndictmentCaseFilesList/IndictmentCaseFilesList.tsx | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.strings.ts b/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.strings.ts index ab0f020ba135..68bcdbd647f3 100644 --- a/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.strings.ts +++ b/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.strings.ts @@ -51,4 +51,10 @@ export const strings = defineMessages({ description: 'Notaður sem texti á PDF takka til að sækja birtingarvottorð í ákærum.', }, + sentToPrionsAdmin: { + id: 'judicial.system.core:indictment_case_files_list.sent_to_prions_admin', + defaultMessage: 'Fullnusta', + description: + 'Notaður sem titill á fullnusta hluta á dómskjalaskjá í ákærum.', + }, }) diff --git a/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.tsx b/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.tsx index fdb7eabe2c41..cc9364c25d42 100644 --- a/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.tsx +++ b/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.tsx @@ -315,7 +315,7 @@ const IndictmentCaseFilesList: FC = ({ )} Date: Thu, 5 Dec 2024 14:55:57 +0000 Subject: [PATCH 6/9] Refactor --- .../IndictmentCaseFilesList.tsx | 33 ++++++++++--------- .../ServiceAnnouncement.tsx | 2 +- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.tsx b/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.tsx index cc9364c25d42..1d4b85ad60aa 100644 --- a/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.tsx +++ b/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.tsx @@ -90,20 +90,22 @@ const FileSection: FC = (props: FileSection) => { } const useFilteredCaseFiles = (caseFiles?: CaseFile[] | null) => { - const filterByCategories = ( - categories: CaseFileCategory | CaseFileCategory[], - ) => { - const categoryArray = Array.isArray(categories) ? categories : [categories] + return useMemo(() => { + const filterByCategories = ( + categories: CaseFileCategory | CaseFileCategory[], + ) => { + const categoryArray = Array.isArray(categories) + ? categories + : [categories] - return ( - caseFiles?.filter( - (file) => file.category && categoryArray.includes(file.category), - ) ?? [] - ) - } + return ( + caseFiles?.filter( + (file) => file.category && categoryArray.includes(file.category), + ) ?? [] + ) + } - return useMemo( - () => ({ + return { indictments: filterByCategories(CaseFileCategory.INDICTMENT), criminalRecords: filterByCategories(CaseFileCategory.CRIMINAL_RECORD), costBreakdowns: filterByCategories(CaseFileCategory.COST_BREAKDOWN), @@ -121,9 +123,8 @@ const useFilteredCaseFiles = (caseFiles?: CaseFile[] | null) => { sentToPrisonAdminFiles: filterByCategories( CaseFileCategory.SENT_TO_PRISON_ADMIN_FILE, ), - }), - [caseFiles], - ) + } + }, [caseFiles]) } const useFilePermissions = (workingCase: Case, user?: User) => { @@ -141,7 +142,7 @@ const useFilePermissions = (workingCase: Case, user?: User) => { canViewSentToPrisonAdminFiles: isPrisonAdminUser(user) || isPublicProsecutorUser(user), }), - [user], + [user, workingCase.hasCivilClaims], ) } diff --git a/apps/judicial-system/web/src/components/ServiceAnnouncement/ServiceAnnouncement.tsx b/apps/judicial-system/web/src/components/ServiceAnnouncement/ServiceAnnouncement.tsx index 8dac19a8c448..f70fe17e3e35 100644 --- a/apps/judicial-system/web/src/components/ServiceAnnouncement/ServiceAnnouncement.tsx +++ b/apps/judicial-system/web/src/components/ServiceAnnouncement/ServiceAnnouncement.tsx @@ -1,4 +1,4 @@ -import { FC, useEffect, useState } from 'react' +import { FC } from 'react' import { IntlShape, MessageDescriptor, useIntl } from 'react-intl' import { AlertMessage, Box, LoadingDots, Text } from '@island.is/island-ui/core' From 4ba0fb243e3de55a86719a32763e8847b6e6d61f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8Dvar=20Oddsson?= Date: Sat, 7 Dec 2024 20:06:12 +0000 Subject: [PATCH 7/9] Fix typo --- .../IndictmentCaseFilesList.strings.ts | 4 ++-- .../IndictmentCaseFilesList/IndictmentCaseFilesList.tsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.strings.ts b/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.strings.ts index 68bcdbd647f3..5a4b7ecb6bb6 100644 --- a/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.strings.ts +++ b/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.strings.ts @@ -51,8 +51,8 @@ export const strings = defineMessages({ description: 'Notaður sem texti á PDF takka til að sækja birtingarvottorð í ákærum.', }, - sentToPrionsAdmin: { - id: 'judicial.system.core:indictment_case_files_list.sent_to_prions_admin', + sentToPrisonAdmin: { + id: 'judicial.system.core:indictment_case_files_list.sent_to_prison_admin', defaultMessage: 'Fullnusta', description: 'Notaður sem titill á fullnusta hluta á dómskjalaskjá í ákærum.', diff --git a/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.tsx b/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.tsx index 1d4b85ad60aa..05c46df7d49c 100644 --- a/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.tsx +++ b/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.tsx @@ -316,7 +316,7 @@ const IndictmentCaseFilesList: FC = ({ )} Date: Thu, 12 Dec 2024 21:52:11 +0000 Subject: [PATCH 8/9] Add rulings under permissions --- .../IndictmentCaseFilesList/IndictmentCaseFilesList.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.tsx b/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.tsx index 2a5be5e45c73..1d3da30fb917 100644 --- a/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.tsx +++ b/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.tsx @@ -143,6 +143,8 @@ const useFilePermissions = (workingCase: Case, user?: User) => { isDefenceUser(user)), canViewSentToPrisonAdminFiles: isPrisonAdminUser(user) || isPublicProsecutorUser(user), + canViewRulings: + isDistrictCourtUser(user) || isCompletedCase(workingCase.state), }), [user, workingCase.hasCivilClaims], ) @@ -255,7 +257,7 @@ const IndictmentCaseFilesList: FC = ({ onOpenFile={onOpen} /> )} - {(isDistrictCourtUser(user) || isCompletedCase(workingCase.state)) && + {permissions.canViewRulings && filteredFiles.rulings && filteredFiles.rulings.length > 0 && ( Date: Fri, 13 Dec 2024 21:49:51 +0000 Subject: [PATCH 9/9] Fix lint --- .../IndictmentCaseFilesList/IndictmentCaseFilesList.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.tsx b/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.tsx index 1d3da30fb917..752011aac971 100644 --- a/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.tsx +++ b/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.tsx @@ -146,7 +146,7 @@ const useFilePermissions = (workingCase: Case, user?: User) => { canViewRulings: isDistrictCourtUser(user) || isCompletedCase(workingCase.state), }), - [user, workingCase.hasCivilClaims], + [user, workingCase.hasCivilClaims, workingCase.state], ) }