diff --git a/tasks/components/AddPatientModal.tsx b/tasks/components/AddPatientModal.tsx index d0e2030c..d394b15a 100644 --- a/tasks/components/AddPatientModal.tsx +++ b/tasks/components/AddPatientModal.tsx @@ -4,7 +4,7 @@ import type { PropsWithLanguage } from '@helpwave/common/hooks/useTranslation' import { useTranslation } from '@helpwave/common/hooks/useTranslation' import type { ConfirmDialogProps } from '@helpwave/common/components/modals/ConfirmDialog' import { ConfirmDialog } from '@helpwave/common/components/modals/ConfirmDialog' -import type { RoomBedDropDownIDs } from './RoomBedDropDown' +import type { RoomBedDropDownIds } from './RoomBedDropDown' import { RoomBedDropDown } from './RoomBedDropDown' import React, { useState } from 'react' import { Span } from '@helpwave/common/components/Span' @@ -35,7 +35,7 @@ const defaultAddPatientModalTranslation: Record) => { const translation = useTranslation(language, defaultAddPatientModalTranslation) - const [dropdownID, setDropdownID] = useState({}) + const [dropdownId, setDropdownId] = useState({}) const [patientName, setPatientName] = useState('') const [touched, setTouched] = useState(false) const assignBedMutation = useAssignBedMutation() const createPatientMutation = usePatientCreateMutation(patient => { - if (dropdownID.bedID) { - assignBedMutation.mutate({ id: dropdownID.bedID, patientID: patient.id }) + if (dropdownId.bedId) { + assignBedMutation.mutate({ id: dropdownId.bedId, patientId: patient.id }) } }) const minimumNameLength = 4 const trimmedPatientName = patientName.trim() const validPatientName = trimmedPatientName.length >= minimumNameLength - const validRoomAndBed = dropdownID.roomID && dropdownID.bedID + const validRoomAndBed = dropdownId.roomId && dropdownId.bedId const isShowingError = touched && !validPatientName return ( @@ -88,9 +88,9 @@ export const AddPatientModal = ({ {isShowingError && {translation.minimumLength(minimumNameLength)}} setDropdownID(roomBedDropDownIDs)} + initialRoomAndBed={dropdownId} + wardId={wardId} + onChange={roomBedDropDownIds => setDropdownId(roomBedDropDownIds)} isClearable={true} /> {translation.noBedSelected} diff --git a/tasks/components/RoomBedDropDown.tsx b/tasks/components/RoomBedDropDown.tsx index d28a7dd4..326f4ca1 100644 --- a/tasks/components/RoomBedDropDown.tsx +++ b/tasks/components/RoomBedDropDown.tsx @@ -56,7 +56,7 @@ export type RoomBedDropDownIds = { export type RoomBedDropDownProps = { initialRoomAndBed: RoomBedDropDownIds, - wardID: string, + wardId: string, /** * Only triggers on valid input */ @@ -115,7 +115,7 @@ export const RoomBedDropDown = ({ onChange={value => { const newSelection = { ...currentSelection, - bedID: value + bedId: value } setCurrentSelection(newSelection) setTouched(true) diff --git a/tasks/components/layout/PatientList.tsx b/tasks/components/layout/PatientList.tsx index 4a548d69..ff00898a 100644 --- a/tasks/components/layout/PatientList.tsx +++ b/tasks/components/layout/PatientList.tsx @@ -17,7 +17,7 @@ import { LoadingAndErrorComponent } from '@helpwave/common/components/LoadingAnd import { HideableContentSection } from '@helpwave/common/components/HideableContentSection' import { Draggable } from '../dnd-kit/Draggable' import { Droppable } from '../dnd-kit/Droppable' -import { WardOverviewContext } from '../../pages/ward/[uuid]' +import { WardOverviewContext } from '../../pages/ward/[id]' import { AddPatientModal } from '../AddPatientModal' type PatientListTranslation = { @@ -112,7 +112,7 @@ export const PatientList = ({ onConfirm={() => setIsShowingAddPatientModal(0)} onCancel={() => setIsShowingAddPatientModal(0)} onBackgroundClick={() => setIsShowingAddPatientModal(0)} - wardID={context.wardID} + wardId={context.wardId} />
{translation.patients} @@ -145,7 +145,7 @@ export const PatientList = ({ {() => (
updateContext({ ...context, patientID: patient.id, roomID: patient.room.id, bedID: patient.bed.id })} + onClick={() => updateContext({ ...context, patientId: patient.id, roomId: patient.room.id, bedId: patient.bed.id })} > {patient.name}
@@ -180,7 +180,7 @@ export const PatientList = ({
updateContext({ wardID: context.wardID, patientID: patient.id })} + onClick={() => updateContext({ wardId: context.wardId, patientId: patient.id })} > {patient.name}
@@ -217,7 +217,7 @@ export const PatientList = ({
updateContext({ wardID: context.wardID, patientID: patient.id })} + onClick={() => updateContext({ wardId: context.wardId, patientId: patient.id })} > {patient.name} { /* TODO implement when backend endpoint exists diff --git a/tasks/pages/ward/[id].tsx b/tasks/pages/ward/[id].tsx index f73bc652..f48f1e5b 100644 --- a/tasks/pages/ward/[id].tsx +++ b/tasks/pages/ward/[id].tsx @@ -66,7 +66,7 @@ const defaultWardOverviewTranslation = { export type WardOverviewContextState = { /** patient set means creating patient - patientID is the current patient + patientId is the current patient */ patient?: PatientDTO, patientId?: string, @@ -99,37 +99,30 @@ const WardOverview: NextPage = ({ language }: PropsWithLanguage({ wardId }) - const [draggingRoomID, setDraggingRoomID] = useState() + const [draggingRoomId, setDraggingRoomId] = useState() const assignBedMutation = useAssignBedMutation(bed => { - if (draggingRoomID) { + if (draggingRoomId) { setContextState({ ...contextState, - bedID: bed.id, - patientID: bed.patientID, - roomID: draggingRoomID, + bedId: bed.id, + patientId: bed.patientId, + roomId: draggingRoomId, patient: undefined }) } else { setContextState({ ...contextState, - bedID: bed.id, - patientID: bed.patientID, + bedId: bed.id, + patientId: bed.patientId, patient: undefined }) } - setDraggingRoomID(undefined) + setDraggingRoomId(undefined) }) const unassignMutation = useUnassignMutation() const dischargeMutation = usePatientDischargeMutation() - const createMutation = usePatientCreateMutation(patient => { - if (contextState.bedID) { - assignBedMutation.mutate({ id: contextState.bedID, patientID: patient.id }) - } - setContextState({ ...contextState, patient: undefined }) - }) - const sensorOptions = { activationConstraint: { distance: 8 } } const sensors = useSensors( useSensor(MouseSensor, sensorOptions), @@ -151,19 +144,19 @@ const WardOverview: NextPage = ({ language }: PropsWithLanguage { const { active, over } = event const overData = over?.data.current - const patientID = draggedPatient?.patient?.id ?? draggedPatient?.bed?.patient?.id ?? '' + const patientId = draggedPatient?.patient?.id ?? draggedPatient?.bed?.patient?.id ?? '' if (overData && active.data.current) { if (overData.patientListSection) { // Moving in patientlist if (overData.patientListSection === 'unassigned') { - unassignMutation.mutate(patientID) // TODO this doesn't work for unassigned patients + unassignMutation.mutate(patientId) // TODO this doesn't work for unassigned patients } else if (overData.patientListSection === 'discharged') { - dischargeMutation.mutate(patientID) + dischargeMutation.mutate(patientId) } } else { // Moving on bed cards - setDraggingRoomID(overData.room.id) - assignBedMutation.mutate({ id: overData.bed.id, patientID }) + setDraggingRoomId(overData.room.id) + assignBedMutation.mutate({ id: overData.bed.id, patientId }) } } @@ -175,7 +168,7 @@ const WardOverview: NextPage = ({ language }: PropsWithLanguage { @@ -210,14 +203,14 @@ const WardOverview: NextPage = ({ language }: PropsWithLanguage { - setContextState({ ...emptyWardOverviewContextState, wardID: contextState.wardID, patient: undefined }) + setContextState({ ...emptyWardOverviewContextState, wardId: contextState.wardId, patient: undefined }) }} onBackgroundClick={() => { - setContextState({ ...emptyWardOverviewContextState, wardID: contextState.wardID, patient: undefined }) + setContextState({ ...emptyWardOverviewContextState, wardId: contextState.wardId, patient: undefined }) }} /> @@ -231,12 +224,12 @@ const WardOverview: NextPage = ({ language }: PropsWithLanguage ()} + left={() => ()} right={width => isShowingPatientList ? ( ) : - contextState.patientID && ( + contextState.patientId && (