-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(j-s): Reviewer completes indictment review (#14762)
* feat(j-s): Complete indictment review * feat(j-s): continued complete indictment review work * Update updateCase.input.ts * fix(j-s): cleanup * feat(j-s): Set decision * fix(j-s): cleanup * fix(j-s): cleanup * feat(j-s): Hide case from prosecutor reviewer list when review is finished * fix filter
- Loading branch information
Showing
18 changed files
with
311 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
apps/judicial-system/backend/migrations/20240508231112-update-case.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use strict' | ||
|
||
module.exports = { | ||
up: (queryInterface, Sequelize) => { | ||
return queryInterface.sequelize.transaction((t) => | ||
queryInterface.addColumn( | ||
'case', | ||
'indictment_review_decision', | ||
{ | ||
type: Sequelize.STRING, | ||
allowNull: true, | ||
}, | ||
{ transaction: t }, | ||
), | ||
) | ||
}, | ||
|
||
down: (queryInterface) => { | ||
return queryInterface.sequelize.transaction((t) => | ||
queryInterface.removeColumn('case', 'indictment_review_decision', { | ||
transaction: t, | ||
}), | ||
) | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...l-system/web/src/routes/PublicProsecutor/Indictments/ReviewDecision/ReviewDecision.css.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { style } from '@vanilla-extract/css' | ||
|
||
import { theme } from '@island.is/island-ui/theme' | ||
|
||
export const gridRow = style({ | ||
display: 'grid', | ||
gridTemplateColumns: '1.6fr 1fr', | ||
gridGap: theme.spacing[1], | ||
marginBottom: theme.spacing[1], | ||
}) |
51 changes: 51 additions & 0 deletions
51
...stem/web/src/routes/PublicProsecutor/Indictments/ReviewDecision/ReviewDecision.strings.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { defineMessages } from 'react-intl' | ||
|
||
export const strings = defineMessages({ | ||
title: { | ||
id: 'judicial.system.core:public_prosecutor.indictments.review_decision.title', | ||
defaultMessage: 'Ákvörðun um áfrýjun', | ||
description: 'Notaður sem titill á ákvörðum um áfrýjun boxi fyrir ákæru.', | ||
}, | ||
subtitle: { | ||
id: 'judicial.system.core:public_prosecutor.indictments.review_decision.subtitle', | ||
defaultMessage: | ||
'Frestur til að áfrýja dómi rennur út {indictmentAppealDeadline}', | ||
description: | ||
'Notaður sem undirtitill á ákvörðum um áfrýjun boxi fyrir ákæru.', | ||
}, | ||
appealToCourtOfAppeals: { | ||
id: 'judicial.system.core:public_prosecutor.indictments.review_decision.appeal_to_court_of_appeals', | ||
defaultMessage: 'Áfrýja héraðsdómi til Landsréttar', | ||
description: | ||
'Notaður sem texti fyrir "Áfrýja héraðsdómi til Landsréttar" radio takka.', | ||
}, | ||
acceptDecision: { | ||
id: 'judicial.system.core:public_prosecutor.indictments.review_decision.accept_decision', | ||
defaultMessage: 'Una héraðsdómi', | ||
description: 'Notaður sem texti fyrir "Una héraðsdómi" radio takka.', | ||
}, | ||
reviewModalTitle: { | ||
id: 'judicial.system.core:indictments_review.title', | ||
defaultMessage: 'Staðfesta ákvörðun', | ||
description: 'Notaður sem titill á yfirliti ákæru.', | ||
}, | ||
reviewModalText: { | ||
id: 'judicial.system.core:indictments_review.modal_text', | ||
|
||
defaultMessage: | ||
'Ertu viss um að þú viljir {reviewerDecision, select, ACCEPT {una héraðsdómi} APPEAL {áfrýja héraðsdómi til Landsréttar} other {halda áfram}}?', | ||
description: 'Notaður sem texti í yfirlitsglugga um yfirlit ákæru.', | ||
}, | ||
reviewModalPrimaryButtonText: { | ||
id: 'judicial.system.core:indictments_review.modal_primary_button_text', | ||
defaultMessage: 'Staðfesta', | ||
description: | ||
'Notaður sem texti á aðal takka í yfirlitsglugga um yfirlit ákæru.', | ||
}, | ||
reviewModalSecondaryButtonText: { | ||
id: 'judicial.system.core:indictments_review.modal_secondary_button_text', | ||
defaultMessage: 'Hætta við', | ||
description: | ||
'Notaður sem texti á aukatakka í yfirlitsglugga um yfirlit ákæru.', | ||
}, | ||
}) |
126 changes: 126 additions & 0 deletions
126
...cial-system/web/src/routes/PublicProsecutor/Indictments/ReviewDecision/ReviewDecision.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
import { useContext, useState } from 'react' | ||
import { useIntl } from 'react-intl' | ||
import { useRouter } from 'next/router' | ||
|
||
import { Box, RadioButton, Text } from '@island.is/island-ui/core' | ||
import * as constants from '@island.is/judicial-system/consts' | ||
import { formatDate } from '@island.is/judicial-system/formatters' | ||
import { | ||
IndictmentCaseReviewDecision, | ||
isPublicProsecutor, | ||
} from '@island.is/judicial-system/types' | ||
import { | ||
BlueBox, | ||
Modal, | ||
SectionHeading, | ||
UserContext, | ||
} from '@island.is/judicial-system-web/src/components' | ||
import { useCase } from '@island.is/judicial-system-web/src/utils/hooks' | ||
|
||
import { strings } from './ReviewDecision.strings' | ||
import * as styles from './ReviewDecision.css' | ||
|
||
interface Props { | ||
caseId: string | ||
indictmentAppealDeadline?: string | ||
modalVisible?: boolean | ||
setModalVisible: React.Dispatch<React.SetStateAction<boolean>> | ||
onSelect?: () => void | ||
} | ||
|
||
export const ReviewDecision: React.FC<Props> = (props) => { | ||
const { user } = useContext(UserContext) | ||
const router = useRouter() | ||
const { formatMessage: fm } = useIntl() | ||
const { updateCase } = useCase() | ||
|
||
const { | ||
caseId, | ||
indictmentAppealDeadline, | ||
modalVisible, | ||
setModalVisible, | ||
onSelect, | ||
} = props | ||
|
||
const [indictmentReviewDecision, setIndictmentReviewDecision] = useState< | ||
IndictmentCaseReviewDecision | undefined | ||
>(undefined) | ||
|
||
const handleReviewDecision = async () => { | ||
if (!indictmentReviewDecision) { | ||
return | ||
} | ||
const updateSuccess = await updateCase(caseId, { | ||
indictmentReviewDecision: indictmentReviewDecision, | ||
}) | ||
if (updateSuccess) { | ||
router.push(constants.CASES_ROUTE) | ||
} | ||
} | ||
|
||
const options = [ | ||
{ | ||
label: fm(strings.appealToCourtOfAppeals), | ||
value: IndictmentCaseReviewDecision.APPEAL, | ||
}, | ||
{ | ||
label: fm(strings.acceptDecision), | ||
value: IndictmentCaseReviewDecision.ACCEPT, | ||
}, | ||
] | ||
|
||
if (!isPublicProsecutor(user)) { | ||
return null | ||
} | ||
|
||
return ( | ||
<Box marginBottom={5}> | ||
<SectionHeading | ||
title={fm(strings.title)} | ||
description={ | ||
<Text variant="eyebrow"> | ||
{fm(strings.subtitle, { | ||
indictmentAppealDeadline: formatDate( | ||
indictmentAppealDeadline, | ||
'P', | ||
), | ||
})} | ||
</Text> | ||
} | ||
/> | ||
<BlueBox> | ||
<div className={styles.gridRow}> | ||
{options.map((item, index) => { | ||
return ( | ||
<RadioButton | ||
name={`reviewOption-${index}`} | ||
label={item.label} | ||
value={item.value} | ||
checked={indictmentReviewDecision === item.value} | ||
onChange={() => { | ||
onSelect && onSelect() | ||
setIndictmentReviewDecision(item.value) | ||
}} | ||
backgroundColor="white" | ||
large | ||
/> | ||
) | ||
})} | ||
</div> | ||
</BlueBox> | ||
{modalVisible && ( | ||
<Modal | ||
title={fm(strings.reviewModalTitle)} | ||
text={fm(strings.reviewModalText, { | ||
reviewerDecision: indictmentReviewDecision, | ||
})} | ||
primaryButtonText={fm(strings.reviewModalPrimaryButtonText)} | ||
secondaryButtonText={fm(strings.reviewModalSecondaryButtonText)} | ||
onClose={() => setModalVisible(false)} | ||
onPrimaryButtonClick={handleReviewDecision} | ||
onSecondaryButtonClick={() => setModalVisible(false)} | ||
/> | ||
)} | ||
</Box> | ||
) | ||
} |
Oops, something went wrong.