From 2817c98bea07de2b7806be7325f690becee1d89b Mon Sep 17 00:00:00 2001 From: Ashraf Mohammed <98876115+AshrafMd-1@users.noreply.github.com> Date: Tue, 14 Nov 2023 13:05:55 +0000 Subject: [PATCH 1/4] fix scroll overlay --- .../MedicineAdministrationSheet/index.tsx | 35 ++++++++++--------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/src/Components/Medicine/MedicineAdministrationSheet/index.tsx b/src/Components/Medicine/MedicineAdministrationSheet/index.tsx index 187d5447314..e83caf09044 100644 --- a/src/Components/Medicine/MedicineAdministrationSheet/index.tsx +++ b/src/Components/Medicine/MedicineAdministrationSheet/index.tsx @@ -106,7 +106,9 @@ const MedicineAdministrationSheet = ({ readonly, is_prn }: Props) => { } - disableOverlay={loading || !prescriptions?.length} + disableOverlay={ + loading || !prescriptions?.length || !(prescriptions?.length > 1) + } > {loading && } {prescriptions?.length === 0 && } @@ -121,23 +123,22 @@ const MedicineAdministrationSheet = ({ readonly, is_prn }: Props) => { }} /> )} - - {!showDiscontinued && !!discontinuedCount && ( - setShowDiscontinued(true)} - > - - - - Show {discontinuedCount} discontinued - prescription(s) - - - - )} + {!showDiscontinued && !!discontinuedCount && ( + setShowDiscontinued(true)} + > + + + + Show {discontinuedCount} discontinued + prescription(s) + + + + )} ); }; From bcb2a1f4cd538b5c9e335ccc2c187556a466ffff Mon Sep 17 00:00:00 2001 From: Ashraf Mohammed Date: Wed, 15 Nov 2023 13:26:30 +0530 Subject: [PATCH 2/4] add style --- .../MedicineAdministrationSheet/index.tsx | 83 ++++++++++--------- 1 file changed, 43 insertions(+), 40 deletions(-) diff --git a/src/Components/Medicine/MedicineAdministrationSheet/index.tsx b/src/Components/Medicine/MedicineAdministrationSheet/index.tsx index e83caf09044..6a187f1f998 100644 --- a/src/Components/Medicine/MedicineAdministrationSheet/index.tsx +++ b/src/Components/Medicine/MedicineAdministrationSheet/index.tsx @@ -97,48 +97,51 @@ const MedicineAdministrationSheet = ({ readonly, is_prn }: Props) => { ) } /> - - - Scroll to view more prescriptions - - - } - disableOverlay={ - loading || !prescriptions?.length || !(prescriptions?.length > 1) - } - > - {loading && } - {prescriptions?.length === 0 && } - - {!!prescriptions?.length && ( - { - refetch(); - discontinuedPrescriptions.refetch(); - }} - /> - )} - - {!showDiscontinued && !!discontinuedCount && ( - setShowDiscontinued(true)} +
+ + Scroll to view more prescriptions + +
+ } + disableOverlay={ + loading || !prescriptions?.length || !(prescriptions?.length > 1) + } > - - - - Show {discontinuedCount} discontinued - prescription(s) + {loading && } + {prescriptions?.length === 0 && } + + {!!prescriptions?.length && ( + { + refetch(); + discontinuedPrescriptions.refetch(); + }} + /> + )} + + {!showDiscontinued && !!discontinuedCount && ( + setShowDiscontinued(true)} + > + + + + Show {discontinuedCount} discontinued + prescription(s) + - -
- )} + + )} + ); }; From c1cdaf438f923c90f13f7e03acd5b8c3b2a80582 Mon Sep 17 00:00:00 2001 From: Ashraf Mohammed Date: Wed, 15 Nov 2023 14:04:14 +0530 Subject: [PATCH 3/4] add hide button --- .../MedicineAdministrationSheet/index.tsx | 61 ++++++++++++------- 1 file changed, 40 insertions(+), 21 deletions(-) diff --git a/src/Components/Medicine/MedicineAdministrationSheet/index.tsx b/src/Components/Medicine/MedicineAdministrationSheet/index.tsx index 6a187f1f998..f30cb6e704a 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, }); @@ -112,33 +116,48 @@ const MedicineAdministrationSheet = ({ readonly, is_prn }: Props) => { loading || !prescriptions?.length || !(prescriptions?.length > 1) } > - {loading && } - {prescriptions?.length === 0 && } - - {!!prescriptions?.length && ( - { - refetch(); - discontinuedPrescriptions.refetch(); - }} - /> + {loading ? ( + + ) : ( + <> + {prescriptions?.length === 0 && } + {!!prescriptions?.length && ( + { + refetch(); + discontinuedPrescriptions.refetch(); + }} + /> + )} + )} - {!showDiscontinued && !!discontinuedCount && ( + {!!discontinuedCount && ( setShowDiscontinued(true)} + onClick={() => !loading && setShowDiscontinued(!showDiscontinued)} > - - - - Show {discontinuedCount} discontinued - prescription(s) + {loading ? ( + + + Loading... + + ) : ( + + + + {showDiscontinued ? "Hide" : "Show"}{" "} + {discontinuedCount} discontinued + prescription(s) + - + )} )} From 6bdde35d4d2351a21c321e8ede15fe31efbb1cbb Mon Sep 17 00:00:00 2001 From: Ashraf Mohammed Date: Wed, 15 Nov 2023 14:58:53 +0530 Subject: [PATCH 4/4] add loading logic --- .../MedicineAdministrationSheet/index.tsx | 30 ++++++++----------- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/src/Components/Medicine/MedicineAdministrationSheet/index.tsx b/src/Components/Medicine/MedicineAdministrationSheet/index.tsx index f30cb6e704a..9b37c53f599 100644 --- a/src/Components/Medicine/MedicineAdministrationSheet/index.tsx +++ b/src/Components/Medicine/MedicineAdministrationSheet/index.tsx @@ -138,26 +138,20 @@ const MedicineAdministrationSheet = ({ readonly, is_prn }: Props) => { !loading && setShowDiscontinued(!showDiscontinued)} + disabled={loading || discontinuedPrescriptions.loading} + onClick={() => setShowDiscontinued(!showDiscontinued)} > - {loading ? ( - - - Loading... - - ) : ( - - - - {showDiscontinued ? "Hide" : "Show"}{" "} - {discontinuedCount} discontinued - prescription(s) - + + + + {showDiscontinued ? "Hide" : "Show"}{" "} + {discontinuedCount} discontinued + prescription(s) - )} + )}