Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(j-s): Add modal when revoking send to prison admin #17110

Merged
merged 5 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:public_prosecutor.indictments.overview.revoke_send_to_prison_admin_modal_title',
oddsson marked this conversation as resolved.
Show resolved Hide resolved
defaultMessage: 'Afturkalla úr fullnustu',
description: 'Notaður sem titill í "Afturkalla úr fullnustu" modal glugga.',
},
revokeSendToPrisonAdminModalText: {
id: 'judicial.system.core:public_prosecutor.indictments.overview.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:public_prosecutor.indictments.overview.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 @@ -29,12 +29,15 @@ import { getAppealExpirationInfo } from '../InfoCard/DefendantInfo/DefendantInfo
import SectionHeading from '../SectionHeading/SectionHeading'
import { strings } from './BlueBoxWithDate.strings'
import * as styles from './BlueBoxWithIcon.css'
import Modal from '../Modal/Modal'

interface Props {
defendant: Defendant
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',
oddsson marked this conversation as resolved.
Show resolved Hide resolved
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
Loading