diff --git a/apps/judicial-system/backend/src/app/modules/defendant/defendant.controller.ts b/apps/judicial-system/backend/src/app/modules/defendant/defendant.controller.ts index 71922368ffe9..c7f86416e0f0 100644 --- a/apps/judicial-system/backend/src/app/modules/defendant/defendant.controller.ts +++ b/apps/judicial-system/backend/src/app/modules/defendant/defendant.controller.ts @@ -27,6 +27,7 @@ import { districtCourtRegistrarRule, prosecutorRepresentativeRule, prosecutorRule, + publicProsecutorStaffRule, } from '../../guards' import { Case, CaseExistsGuard, CaseWriteGuard, CurrentCase } from '../case' import { CreateDefendantDto } from './dto/createDefendant.dto' @@ -71,6 +72,7 @@ export class DefendantController { districtCourtJudgeRule, districtCourtRegistrarRule, districtCourtAssistantRule, + publicProsecutorStaffRule, ) @Patch(':defendantId') @ApiOkResponse({ diff --git a/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.css.ts b/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.css.ts index b6f2ad3ddc6d..1e529137bfe4 100644 --- a/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.css.ts +++ b/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.css.ts @@ -1,14 +1,18 @@ -import { style } from '@vanilla-extract/css' +import { style, styleVariants } from '@vanilla-extract/css' import { theme } from '@island.is/island-ui/theme' -export const gridRow = style({ +const baseGridRow = style({ display: 'grid', - gridTemplateColumns: '5fr 1fr', gridGap: theme.spacing[1], marginBottom: theme.spacing[1], }) +export const gridRow = styleVariants({ + withButton: [baseGridRow, { gridTemplateColumns: '5fr 1fr' }], + withoutButton: [baseGridRow, { gridTemplateColumns: '1fr' }], +}) + export const infoCardDefendant = style({ display: 'flex', flexDirection: 'column', diff --git a/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx b/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx index dfcbbeb911c7..37946284b531 100644 --- a/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx +++ b/apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx @@ -17,6 +17,7 @@ export type DefendantActionButton = { text: string onClick: (defendant: Defendant) => void icon?: IconMapIcon + isDisabled: (defendant: Defendant) => boolean } interface DefendantInfoProps { @@ -29,7 +30,14 @@ export const DefendantInfo: FC = (props) => { const { defendant, displayDefenderInfo, defendantActionButton } = props return ( -
+
@@ -78,6 +86,7 @@ export const DefendantInfo: FC = (props) => { onClick={() => defendantActionButton.onClick(defendant)} icon={defendantActionButton.icon} iconType="outline" + disabled={defendantActionButton.isDisabled(defendant)} > {defendantActionButton.text} diff --git a/apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.tsx b/apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.tsx index 5e758d541cfd..eab3ef01ee06 100644 --- a/apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.tsx +++ b/apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.tsx @@ -69,7 +69,7 @@ export const Overview = () => { setModalVisible('REVIEWER_ASSIGNED') } - const handleDefendantViewVerdict = () => { + const handleDefendantViewsVerdict = () => { if (!selectedDefendant) { return } @@ -113,10 +113,6 @@ export const Overview = () => { ) }, [data?.users, user]) - const handleViewVerdict = () => { - setModalVisible(undefined) - } - return ( { setModalVisible('DEFENDANT_VIEWS_VERDICT') }, icon: 'mailOpen', + isDisabled: (defendant) => + defendant.hasViewedVerdict || false, } : undefined } @@ -224,7 +222,7 @@ export const Overview = () => { primaryButtonText={fm( strings.defendantViewsVerdictModalPrimaryButtonText, )} - onPrimaryButtonClick={() => handleDefendantViewVerdict()} + onPrimaryButtonClick={() => handleDefendantViewsVerdict()} secondaryButtonText={fm(core.back)} onSecondaryButtonClick={() => setModalVisible(undefined)} />