diff --git a/src/Components/Medicine/PrescriptionBuilder.tsx b/src/Components/Medicine/PrescriptionBuilder.tsx index 6bb4b02d0ca..aa8bd5ae310 100644 --- a/src/Components/Medicine/PrescriptionBuilder.tsx +++ b/src/Components/Medicine/PrescriptionBuilder.tsx @@ -69,7 +69,7 @@ export default function PrescriptionBuilder({ setShowDiscontinueFor(obj)} onAdministerClick={() => setShowAdministerFor(obj)} readonly={disabled} diff --git a/src/Components/Medicine/PrescriptionDetailCard.tsx b/src/Components/Medicine/PrescriptionDetailCard.tsx index 731e779a4d1..d2a86ee2775 100644 --- a/src/Components/Medicine/PrescriptionDetailCard.tsx +++ b/src/Components/Medicine/PrescriptionDetailCard.tsx @@ -7,25 +7,26 @@ import { useTranslation } from "react-i18next"; import RecordMeta from "../../CAREUI/display/RecordMeta"; import { useState } from "react"; -export default function PrescriptionDetailCard({ - prescription, - ...props -}: { +interface Props { prescription: Prescription; readonly?: boolean; children?: React.ReactNode; onDiscontinueClick?: () => void; onAdministerClick?: () => void; selected?: boolean; - showPrescription?: boolean; -}) { + collapsible?: boolean; +} + +export default function PrescriptionDetailCard({ + prescription, + collapsible = false, + ...props +}: Props) { const { t } = useTranslation(); - const [showPrescription, setShowPrescription] = useState( - props.showPrescription, + const [isCollapsed, setIsCollapsed] = useState( + collapsible && prescription.discontinued, ); - const handleShow = () => { - setShowPrescription(!showPrescription); - }; + return (
-
+
{ + if (collapsible) { + setIsCollapsed(!isCollapsed); + } + }} + >
@@ -67,7 +76,10 @@ export default function PrescriptionDetailCard({
{ + e.stopPropagation(); + props.onAdministerClick?.(); + }} type="button" size="small" variant="secondary" @@ -84,7 +96,10 @@ export default function PrescriptionDetailCard({ variant="danger" ghost border - onClick={props.onDiscontinueClick} + onClick={(e) => { + e.stopPropagation(); + props.onDiscontinueClick?.(); + }} > {t("discontinue")} @@ -93,7 +108,7 @@ export default function PrescriptionDetailCard({ )}
- {showPrescription && ( + {!isCollapsed && (