Skip to content

Commit

Permalink
feat add onWorkspaceClose to the notes form extension
Browse files Browse the repository at this point in the history
  • Loading branch information
usamaidrsk committed Jul 18, 2024
1 parent d9525e4 commit 372e66e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import styles from './ward-patient-card.scss';
import { getPatientName, launchWorkspace } from '@openmrs/esm-framework';
import { type ActiveBedSelection, getWardStore, type WardStoreState } from '../store';
import classNames from 'classnames';
import { closeWorkspace } from '../../../../../openmrs-esm-core/packages/framework/esm-styleguide';

const WardPatientCard: React.FC<WardPatientCardProps> = (props) => {
const wardStore = getWardStore();
Expand Down Expand Up @@ -33,6 +34,7 @@ const WardPatientCard: React.FC<WardPatientCardProps> = (props) => {
activeBedSelection?.bed.uuid === props.bed.uuid && activeBedSelection?.patient.uuid === props.patient.uuid,
})}
onClick={() => {
closeWorkspace('ward-patient-workspace');
wardStore.setState({ activeBedSelection: { ...props } });
launchWorkspace('ward-patient-workspace');
}}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ const WardPatientNotesWorkspace = ({
const wardStore = getWardStore();
const { patient, visit, bed } = wardStore.getState().activeBedSelection;

setOnCloseCallback(() => {
const handleResetActiveBedSelection = () => {
wardStore.setState({ activeBedSelection: null });
});
};
setOnCloseCallback(handleResetActiveBedSelection);

const notesFormExtensionState = useMemo(
() => ({
Expand All @@ -24,6 +25,7 @@ const WardPatientNotesWorkspace = ({
promptBeforeClosing,
closeWorkspace,
closeWorkspaceWithSavedChanges,
onWorkspaceClose: handleResetActiveBedSelection,
}),
[patient, closeWorkspace, closeWorkspaceWithSavedChanges, promptBeforeClosing],
);
Expand Down

0 comments on commit 372e66e

Please sign in to comment.