@@ -28,6 +28,7 @@ import { AddPatientModal } from '../AddPatientModal'
2828import { PatientDischargeModal } from '../PatientDischargeModal'
2929import { useRouter } from 'next/router'
3030import { useWardQuery } from '../../mutations/ward_mutations'
31+ import { ConfirmDialog } from '@helpwave/common/components/modals/ConfirmDialog'
3132
3233type PatientListTranslation = {
3334 patients : string ,
@@ -123,6 +124,7 @@ export const PatientList = ({
123124 const deletePatientMutation = useDeletePatientMutation ( )
124125 const readmitPatientMutation = useReadmitPatientMutation ( )
125126 const [ dischargingPatient , setDischargingPatient ] = useState < PatientMinimalDTO > ( )
127+ const [ deletePatient , setDeletePatient ] = useState < PatientMinimalDTO > ( )
126128
127129 const activeLabelText = ( patient : PatientWithBedAndRoomDTO ) => `${ patient . room . name } - ${ patient . bed . name } `
128130
@@ -132,6 +134,24 @@ export const PatientList = ({
132134
133135 return (
134136 < div className = { tw ( 'relative flex flex-col py-4 px-6' ) } >
137+ < ConfirmDialog
138+ id = "patientList-DeleteDialog"
139+ isOpen = { ! ! deletePatient }
140+ titleText = { translation . deleteConfirmText }
141+ descriptionText = { translation . deleteDescriptionText }
142+ onConfirm = { ( ) => {
143+ if ( deletePatient ) {
144+ deletePatientMutation . mutate ( deletePatient . id )
145+ }
146+ setDeletePatient ( undefined )
147+ } }
148+ confirmType = "negative"
149+ onBackgroundClick = { ( ) => { setDeletePatient ( undefined ) } }
150+ onCancel = { ( ) => setDeletePatient ( undefined ) }
151+ onCloseClick = { ( ) => setDeletePatient ( undefined ) }
152+ >
153+
154+ </ ConfirmDialog >
135155 < PatientDischargeModal
136156 id = "patientList-DischargeDialog"
137157 isOpen = { ! ! dischargingPatient }
@@ -285,7 +305,7 @@ export const PatientList = ({
285305 </ Button >
286306 < Button color = "negative" variant = "textButton" onClick = { event => {
287307 event . stopPropagation ( )
288- deletePatientMutation . mutate ( patient . id )
308+ setDeletePatient ( patient )
289309 } } >
290310 { translation . delete }
291311 </ Button >
0 commit comments