diff --git a/src/Components/Medicine/MedicineAdministrationSheet/index.tsx b/src/Components/Medicine/MedicineAdministrationSheet/index.tsx index 187d5447314..9b37c53f599 100644 --- a/src/Components/Medicine/MedicineAdministrationSheet/index.tsx +++ b/src/Components/Medicine/MedicineAdministrationSheet/index.tsx @@ -39,7 +39,11 @@ const MedicineAdministrationSheet = ({ readonly, is_prn }: Props) => { const discontinuedPrescriptions = useQuery(MedicineRoutes.listPrescriptions, { pathParams: { consultation }, - query: { ...filters, discontinued: true }, + query: { + ...filters, + limit: showDiscontinued ? 100 : 1, + discontinued: true, + }, prefetch: !showDiscontinued, }); @@ -97,47 +101,60 @@ const MedicineAdministrationSheet = ({ readonly, is_prn }: Props) => { ) } /> - - - Scroll to view more prescriptions - - - } - disableOverlay={loading || !prescriptions?.length} - > - {loading && } - {prescriptions?.length === 0 && } - - {!!prescriptions?.length && ( - { - refetch(); - discontinuedPrescriptions.refetch(); - }} - /> - )} - - {!showDiscontinued && !!discontinuedCount && ( +
+ + Scroll to view more prescriptions + +
+ } + disableOverlay={ + loading || !prescriptions?.length || !(prescriptions?.length > 1) + } + > + {loading ? ( + + ) : ( + <> + {prescriptions?.length === 0 && } + {!!prescriptions?.length && ( + { + refetch(); + discontinuedPrescriptions.refetch(); + }} + /> + )} + + )} +
+ {!!discontinuedCount && ( setShowDiscontinued(true)} + disabled={loading || discontinuedPrescriptions.loading} + onClick={() => setShowDiscontinued(!showDiscontinued)} > - + - Show {discontinuedCount} discontinued + {showDiscontinued ? "Hide" : "Show"}{" "} + {discontinuedCount} discontinued prescription(s) )} - + ); };