Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(fix) O3-2426: Closing drug search panel should send user back to order basket if they previously had it open #1452

Closed
wants to merge 7 commits into from
Next Next commit
(fix)03-2426: Closing drug search panel should send user back to orde…
…r basket if they previously had it open
  • Loading branch information
jwamalwa committed Nov 7, 2023
commit c8314343ffe88d8ca8efd48ec0acbdc85e0f0979
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const WorkspaceWindow: React.FC<ContextWorkspaceParams> = () => {
}, [workspaces, patientUuid]);

const workspaceTitle = workspaces[0]?.additionalProps?.['workspaceTitle'] ?? workspaces[0]?.title ?? '';
const onCloseWorkspace = workspaces[0]?.additionalProps?.['onCloseWorkspace'] ?? null;
const {
canHide = false,
canMaximize = false,
Expand All @@ -59,7 +60,7 @@ const WorkspaceWindow: React.FC<ContextWorkspaceParams> = () => {
className={`${styles.header} ${maximized ? `${styles.fullWidth}` : `${styles.dynamicWidth}`}`}
>
{layout === 'tablet' && !canHide && (
<HeaderMenuButton renderMenuIcon={<ArrowLeft />} onClick={closeWorkspace} />
<HeaderMenuButton renderMenuIcon={<ArrowLeft />} onClick={onCloseWorkspace ?? closeWorkspace} />
)}
<HeaderName prefix="">{workspaceTitle}</HeaderName>
<HeaderGlobalBar className={styles.headerGlobalBar}>
Expand Down Expand Up @@ -89,7 +90,7 @@ const WorkspaceWindow: React.FC<ContextWorkspaceParams> = () => {
<HeaderGlobalAction
align="bottom-right"
label={t('close', 'Close')}
onClick={() => closeWorkspace?.()}
onClick={() => onCloseWorkspace?.() ?? closeWorkspace?.()}
size="lg"
>
<Close />
Expand All @@ -98,7 +99,11 @@ const WorkspaceWindow: React.FC<ContextWorkspaceParams> = () => {
</>
)}
{layout === 'tablet' && canHide && (
<HeaderGlobalAction align="bottom-right" label={t('close', 'Close')} onClick={() => closeWorkspace?.()}>
<HeaderGlobalAction
align="bottom-right"
label={t('close', 'Close')}
onClick={() => onCloseWorkspace?.() ?? closeWorkspace?.()}
>
<DownToBottom />
</HeaderGlobalAction>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useTranslation } from 'react-i18next';
import { Button, Tile } from '@carbon/react';
import { Add, ChevronDown, ChevronUp } from '@carbon/react/icons';
import { useLayoutType } from '@openmrs/esm-framework';
import { launchPatientWorkspace, useOrderBasket } from '@openmrs/esm-patient-common-lib';
import { closeWorkspace, launchPatientWorkspace, useOrderBasket } from '@openmrs/esm-patient-common-lib';
ibacher marked this conversation as resolved.
Show resolved Hide resolved
import { prepMedicationOrderPostData } from '../api/api';
import type { DrugOrderBasketItem } from '../types';
import OrderBasketItemTile from './order-basket-item-tile.component';
Expand All @@ -23,8 +23,15 @@ export default function DrugOrderBasketPanelExtension() {
const revisedOrderBasketItems = orders.filter((x) => x.action === 'REVISE');
const discontinuedOrderBasketItems = orders.filter((x) => x.action === 'DISCONTINUE');

const onClose = useCallback(() => {
closeWorkspace('add-drug-order', true);
launchPatientWorkspace('order-basket');
}, []);

const openDrugSearch = () => {
launchPatientWorkspace('add-drug-order');
launchPatientWorkspace('add-drug-order', {
onCloseWorkspace: onClose,
});
};

const openDrugForm = (order: DrugOrderBasketItem) => {
Expand Down
Loading