@@ -15,7 +15,7 @@ import {
15
15
import { PUBLIC_PROSECUTOR_STAFF_INDICTMENT_SEND_TO_PRISON_ADMIN_ROUTE } from '@island.is/judicial-system/consts'
16
16
import { formatDate } from '@island.is/judicial-system/formatters'
17
17
import { VERDICT_APPEAL_WINDOW_DAYS } from '@island.is/judicial-system/types'
18
- import { errors } from '@island.is/judicial-system-web/messages'
18
+ import { core , errors } from '@island.is/judicial-system-web/messages'
19
19
20
20
import {
21
21
CaseIndictmentRulingDecision ,
@@ -29,12 +29,15 @@ import { getAppealExpirationInfo } from '../InfoCard/DefendantInfo/DefendantInfo
29
29
import SectionHeading from '../SectionHeading/SectionHeading'
30
30
import { strings } from './BlueBoxWithDate.strings'
31
31
import * as styles from './BlueBoxWithIcon.css'
32
+ import Modal from '../Modal/Modal'
32
33
33
34
interface Props {
34
35
defendant : Defendant
35
36
icon ?: IconMapIcon
36
37
}
37
38
39
+ type VisibleModal = 'REVOKE_SEND_TO_PRISON_ADMIN'
40
+
38
41
const BlueBoxWithDate : FC < Props > = ( props ) => {
39
42
const { defendant, icon } = props
40
43
const { formatMessage } = useIntl ( )
@@ -47,7 +50,8 @@ const BlueBoxWithDate: FC<Props> = (props) => {
47
50
} )
48
51
const [ triggerAnimation , setTriggerAnimation ] = useState < boolean > ( false )
49
52
const [ triggerAnimation2 , setTriggerAnimation2 ] = useState < boolean > ( false )
50
- const { setAndSendDefendantToServer } = useDefendants ( )
53
+ const [ modalVisible , setModalVisible ] = useState < VisibleModal > ( )
54
+ const { setAndSendDefendantToServer, isUpdatingDefendant } = useDefendants ( )
51
55
const { workingCase, setWorkingCase } = useContext ( FormContext )
52
56
const router = useRouter ( )
53
57
@@ -111,6 +115,8 @@ const BlueBoxWithDate: FC<Props> = (props) => {
111
115
} ,
112
116
setWorkingCase ,
113
117
)
118
+
119
+ setModalVisible ( undefined )
114
120
}
115
121
116
122
const appealExpirationInfo = useMemo ( ( ) => {
@@ -335,7 +341,7 @@ const BlueBoxWithDate: FC<Props> = (props) => {
335
341
{ defendant . isSentToPrisonAdmin ? (
336
342
< Button
337
343
variant = "text"
338
- onClick = { handleRevokeSendToPrisonAdmin }
344
+ onClick = { ( ) => setModalVisible ( 'REVOKE_SEND_TO_PRISON_ADMIN' ) }
339
345
size = "small"
340
346
colorScheme = "destructive"
341
347
>
@@ -355,6 +361,20 @@ const BlueBoxWithDate: FC<Props> = (props) => {
355
361
</ Button >
356
362
) }
357
363
</ Box >
364
+ { modalVisible === 'REVOKE_SEND_TO_PRISON_ADMIN' && (
365
+ < Modal
366
+ title = { formatMessage ( strings . revokeSendToPrisonAdminModalTitle ) }
367
+ text = { formatMessage ( strings . revokeSendToPrisonAdminModalText , {
368
+ courtCaseNumber : workingCase . courtCaseNumber ,
369
+ defendant : defendant . name ,
370
+ } ) }
371
+ onPrimaryButtonClick = { handleRevokeSendToPrisonAdmin }
372
+ primaryButtonText = { formatMessage ( strings . revoke ) }
373
+ isPrimaryButtonLoading = { isUpdatingDefendant }
374
+ secondaryButtonText = { formatMessage ( core . cancel ) }
375
+ onSecondaryButtonClick = { ( ) => setModalVisible ( undefined ) }
376
+ />
377
+ ) }
358
378
</ >
359
379
)
360
380
}
0 commit comments