diff --git a/packages/esm-patient-orders-app/src/components/order-stock-details.component.tsx b/packages/esm-patient-orders-app/src/components/order-stock-details.component.tsx index 911049b53..2a59426de 100644 --- a/packages/esm-patient-orders-app/src/components/order-stock-details.component.tsx +++ b/packages/esm-patient-orders-app/src/components/order-stock-details.component.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useMemo } from 'react'; import { useOrderStockInfo } from '../hooks/useOrderStockInfo'; import { CheckmarkFilled, CloseFilled } from '@carbon/react/icons'; import styles from './order-stock-details.scss'; @@ -13,12 +13,18 @@ const OrderStockDetailsComponent: React.FC = ({ const { t } = useTranslation(); const { data: stockData, isLoading } = useOrderStockInfo(orderItemUuid); + const isInStock = useMemo(() => { + if (!stockData || stockData.entry.length === 0) { + return false; + } + const resource = stockData.entry[0]?.resource; + return resource.status === 'active' && resource.netContent?.value > 0; + }, [stockData]); + if (isLoading || !stockData) { return ; } - const isInStock = stockData.entry[0]?.resource.status === 'active'; - return (
{isInStock ? (