Skip to content

Commit

Permalink
feat(j-s): Add modal when revoking send to prison admin (#17110)
Browse files Browse the repository at this point in the history
* Add modal when revoking send to prison admin

* Update CF ids

* Fix lint
  • Loading branch information
oddsson authored Dec 9, 2024
1 parent 5f9b084 commit 02d4080
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 5 deletions.
5 changes: 5 additions & 0 deletions apps/judicial-system/web/messages/Core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,11 @@ export const core = defineMessages({
defaultMessage: 'Halda áfram',
description: 'Notað fyrir "Halda áfram" takka í öllum flæðum.',
},
cancel: {
id: 'judicial.system.core:cancel',
defaultMessage: 'Hætta við',
description: 'Notað fyrir "Hætta við" takka í öllum flæðum.',
},
createCase: {
id: 'judicial.system.core:create_case',
defaultMessage: 'Stofna mál',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,20 @@ export const strings = defineMessages({
description:
'Notaður sem titill í svæði þar sem kærufrestur viðurlagaákvörðunar er tekinn fram',
},
revokeSendToPrisonAdminModalTitle: {
id: 'judicial.system.core:blue_box_with_date.revoke_send_to_prison_admin_modal_title',
defaultMessage: 'Afturkalla úr fullnustu',
description: 'Notaður sem titill í "Afturkalla úr fullnustu" modal glugga.',
},
revokeSendToPrisonAdminModalText: {
id: 'judicial.system.core:blue_box_with_date.revoke_send_to_prison_admin_modal_text',
defaultMessage:
'Mál {courtCaseNumber} verður afturkallað.\nÁkærði: {defendant}.',
description: 'Notaður sem texti í "Afturkalla úr fullnustu" modal glugga.',
},
revoke: {
id: 'judicial.system.core:blue_box_with_date.revoke',
defaultMessage: 'Afturkalla',
description: 'Notaður sem texti fyrir aðgerðina að afturkalla mál',
},
})
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
import { PUBLIC_PROSECUTOR_STAFF_INDICTMENT_SEND_TO_PRISON_ADMIN_ROUTE } from '@island.is/judicial-system/consts'
import { formatDate } from '@island.is/judicial-system/formatters'
import { VERDICT_APPEAL_WINDOW_DAYS } from '@island.is/judicial-system/types'
import { errors } from '@island.is/judicial-system-web/messages'
import { core, errors } from '@island.is/judicial-system-web/messages'

import {
CaseIndictmentRulingDecision,
Expand All @@ -26,6 +26,7 @@ import { formatDateForServer, useDefendants } from '../../utils/hooks'
import DateTime from '../DateTime/DateTime'
import { FormContext } from '../FormProvider/FormProvider'
import { getAppealExpirationInfo } from '../InfoCard/DefendantInfo/DefendantInfo'
import Modal from '../Modal/Modal'
import SectionHeading from '../SectionHeading/SectionHeading'
import { strings } from './BlueBoxWithDate.strings'
import * as styles from './BlueBoxWithIcon.css'
Expand All @@ -35,6 +36,8 @@ interface Props {
icon?: IconMapIcon
}

type VisibleModal = 'REVOKE_SEND_TO_PRISON_ADMIN'

const BlueBoxWithDate: FC<Props> = (props) => {
const { defendant, icon } = props
const { formatMessage } = useIntl()
Expand All @@ -47,7 +50,8 @@ const BlueBoxWithDate: FC<Props> = (props) => {
})
const [triggerAnimation, setTriggerAnimation] = useState<boolean>(false)
const [triggerAnimation2, setTriggerAnimation2] = useState<boolean>(false)
const { setAndSendDefendantToServer } = useDefendants()
const [modalVisible, setModalVisible] = useState<VisibleModal>()
const { setAndSendDefendantToServer, isUpdatingDefendant } = useDefendants()
const { workingCase, setWorkingCase } = useContext(FormContext)
const router = useRouter()

Expand Down Expand Up @@ -111,6 +115,8 @@ const BlueBoxWithDate: FC<Props> = (props) => {
},
setWorkingCase,
)

setModalVisible(undefined)
}

const appealExpirationInfo = useMemo(() => {
Expand Down Expand Up @@ -335,7 +341,7 @@ const BlueBoxWithDate: FC<Props> = (props) => {
{defendant.isSentToPrisonAdmin ? (
<Button
variant="text"
onClick={handleRevokeSendToPrisonAdmin}
onClick={() => setModalVisible('REVOKE_SEND_TO_PRISON_ADMIN')}
size="small"
colorScheme="destructive"
>
Expand All @@ -355,6 +361,20 @@ const BlueBoxWithDate: FC<Props> = (props) => {
</Button>
)}
</Box>
{modalVisible === 'REVOKE_SEND_TO_PRISON_ADMIN' && (
<Modal
title={formatMessage(strings.revokeSendToPrisonAdminModalTitle)}
text={formatMessage(strings.revokeSendToPrisonAdminModalText, {
courtCaseNumber: workingCase.courtCaseNumber,
defendant: defendant.name,
})}
onPrimaryButtonClick={handleRevokeSendToPrisonAdmin}
primaryButtonText={formatMessage(strings.revoke)}
isPrimaryButtonLoading={isUpdatingDefendant}
secondaryButtonText={formatMessage(core.cancel)}
onSecondaryButtonClick={() => setModalVisible(undefined)}
/>
)}
</>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const strings = defineMessages({
'Notaður sem titill á tilkynningarglugga um að senda til fullnustu.',
},
modalText: {
id: 'judicial.system.core:send_to_prison_admin.modal_text',
id: 'judicial.system.core:send_to_prison_admin.modal_text_v1',
defaultMessage:
'Mál {courtCaseNumber} verður sent til Fangelsismálastofnunar til fullnustu.\nÁkærði: {defendant}.',
description:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ const useCaseList = () => {
router.push(`${routeTo}/${caseToOpen.id}`)
}
},
[router, user],
[router, user, features],
)

const handleOpenCase = useCallback(
Expand Down

0 comments on commit 02d4080

Please sign in to comment.