Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
oddsson committed Dec 5, 2024
1 parent 80178d3 commit 77af558
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
isCompletedCase,
isDefenceUser,
isDistrictCourtUser,
isPrisonAdminUser,
isProsecutionUser,
isPublicProsecutor,
isPublicProsecutorUser,
Expand Down Expand Up @@ -137,6 +138,8 @@ const useFilePermissions = (workingCase: Case, user?: User) => {
(isDistrictCourtUser(user) ||
isProsecutionUser(user) ||
isDefenceUser(user)),
canViewSentToPrisonAdminFiles:
isPrisonAdminUser(user) || isPublicProsecutorUser(user),
}),
[user],
)
Expand Down Expand Up @@ -315,6 +318,7 @@ const IndictmentCaseFilesList: FC<Props> = ({
title={formatMessage(strings.civilClaimsTitle)}
files={filteredFiles.sentToPrisonAdminFiles}
onOpenFile={onOpen}
shouldRender={permissions.canViewSentToPrisonAdminFiles}
/>
<AnimatePresence>
{fileNotFound && <FileNotFoundModal dismiss={dismissFileNotFound} />}
Expand Down
16 changes: 8 additions & 8 deletions libs/judicial-system/types/src/lib/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
}

Expand All @@ -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,
)
}

Expand All @@ -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,
)
}

Expand All @@ -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,
)
Expand Down

0 comments on commit 77af558

Please sign in to comment.