Skip to content
This repository was archived by the owner on Dec 6, 2025. It is now read-only.

Commit 85d96ae

Browse files
Merge pull request #812 from helpwave/issue/810-conformation-delting-patient
feat: confirm dialog on deleting a patient
2 parents f9435f9 + 66dff79 commit 85d96ae

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

tasks/components/layout/PatientList.tsx

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { AddPatientModal } from '../AddPatientModal'
2828
import { PatientDischargeModal } from '../PatientDischargeModal'
2929
import { useRouter } from 'next/router'
3030
import { useWardQuery } from '../../mutations/ward_mutations'
31+
import { ConfirmDialog } from '@helpwave/common/components/modals/ConfirmDialog'
3132

3233
type 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

Comments
 (0)