Skip to content

Commit

Permalink
O3-2442: Patient Actions Slot and Patient Search Actions Slot should …
Browse files Browse the repository at this point in the history
…be hidden if no available actions
  • Loading branch information
mogoodrich committed Sep 25, 2023
1 parent a3e59ea commit 0c7ba83
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { MouseEvent } from 'react';
import React, { MouseEvent, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { Button, ButtonSkeleton, SkeletonIcon, SkeletonText } from '@carbon/react';
import { ChevronDown, ChevronUp, OverflowMenuVertical } from '@carbon/react/icons';
Expand All @@ -11,6 +11,7 @@ import {
interpolateString,
useConfig,
ConfigurableLink,
useConnectedExtensions,
} from '@openmrs/esm-framework';
import { SearchedPatient } from '../../../types';
import ContactDetails from '../contact-details/contact-details.component';
Expand Down Expand Up @@ -39,6 +40,7 @@ const PatientBanner: React.FC<PatientBannerProps> = ({
const { currentVisit } = useVisit(patientUuid);
const [showDropdown, setShowDropdown] = React.useState(false);
const config = useConfig();
const searchActionsItems = useConnectedExtensions('patient-search-actions-slot');

const patientActionsSlotState = React.useMemo(
() => ({ patientUuid, selectPatientAction, onTransition, launchPatientChart: true }),
Expand All @@ -65,6 +67,11 @@ const PatientBanner: React.FC<PatientBannerProps> = ({
setShowDropdown((value) => !value);
}, []);

const showActionsMenu = useMemo(
() => !hideActionsOverflow && searchActionsItems.length > 0,
[searchActionsItems.length, hideActionsOverflow],
);

const getGender = (gender) => {
switch (gender) {
case 'M':
Expand Down Expand Up @@ -121,7 +128,7 @@ const PatientBanner: React.FC<PatientBannerProps> = ({
</div>
</ConfigurableLink>
<div className={styles.buttonCol}>
{!hideActionsOverflow && (
{showActionsMenu && (
<div className={styles.overflowMenuContainer} ref={overflowMenuRef}>
<CustomOverflowMenuComponent
isDeceased={isDeceased}
Expand Down

0 comments on commit 0c7ba83

Please sign in to comment.