diff --git a/apps/judicial-system/backend/src/app/modules/case/interceptors/caseFile.interceptor.ts b/apps/judicial-system/backend/src/app/modules/case/interceptors/caseFile.interceptor.ts index d7d74fb30a5c..7dd3dfdf9e71 100644 --- a/apps/judicial-system/backend/src/app/modules/case/interceptors/caseFile.interceptor.ts +++ b/apps/judicial-system/backend/src/app/modules/case/interceptors/caseFile.interceptor.ts @@ -12,8 +12,10 @@ import { CaseAppealState, CaseFileCategory, isDefenceUser, + isIndictmentCase, isPrisonStaffUser, isPrisonSystemUser, + isRestrictionCase, User, } from '@island.is/judicial-system/types' @@ -33,15 +35,18 @@ export class CaseFileInterceptor implements NestInterceptor { if ( isPrisonStaffUser(user) || - data.appealState !== CaseAppealState.COMPLETED + (isRestrictionCase(data.type) && + data.appealState !== CaseAppealState.COMPLETED) ) { data.caseFiles?.splice(0, data.caseFiles.length) } else if (isPrisonSystemUser(user)) { data.caseFiles?.splice( 0, data.caseFiles.length, - ...data.caseFiles.filter( - (cf) => cf.category === CaseFileCategory.APPEAL_RULING, + ...data.caseFiles.filter((cf) => + isIndictmentCase(data.type) + ? cf.category === CaseFileCategory.RULING + : cf.category === CaseFileCategory.APPEAL_RULING, ), ) } diff --git a/apps/judicial-system/backend/src/app/modules/file/guards/caseFileCategory.ts b/apps/judicial-system/backend/src/app/modules/file/guards/caseFileCategory.ts index 2d8d88353f35..60f536547067 100644 --- a/apps/judicial-system/backend/src/app/modules/file/guards/caseFileCategory.ts +++ b/apps/judicial-system/backend/src/app/modules/file/guards/caseFileCategory.ts @@ -23,4 +23,7 @@ export const defenderCaseFileCategoriesForIndictmentCases = [ CaseFileCategory.DEFENDANT_CASE_FILE, ] -export const prisonAdminCaseFileCategories = [CaseFileCategory.APPEAL_RULING] +export const prisonAdminCaseFileCategories = [ + CaseFileCategory.APPEAL_RULING, + CaseFileCategory.RULING, +] diff --git a/apps/judicial-system/backend/src/app/modules/file/guards/test/limitedAccessViewCaseFileGuard.spec.ts b/apps/judicial-system/backend/src/app/modules/file/guards/test/limitedAccessViewCaseFileGuard.spec.ts index e4e7672dc2d6..b46d12eda442 100644 --- a/apps/judicial-system/backend/src/app/modules/file/guards/test/limitedAccessViewCaseFileGuard.spec.ts +++ b/apps/judicial-system/backend/src/app/modules/file/guards/test/limitedAccessViewCaseFileGuard.spec.ts @@ -224,7 +224,10 @@ describe('Limited Access View Case File Guard', () => { describe.each(Object.keys(CaseType))('for %s cases', (type) => { describe.each(completedCaseStates)('in state %s', (state) => { - const allowedCaseFileCategories = [CaseFileCategory.APPEAL_RULING] + const allowedCaseFileCategories = [ + CaseFileCategory.APPEAL_RULING, + CaseFileCategory.RULING, + ] describe.each(allowedCaseFileCategories)( 'prison system users can view %s',