From 64b77fdbc90c1be1b8d395cfeab380ca2926f2bf Mon Sep 17 00:00:00 2001 From: Jovan Ssebaggala Date: Fri, 6 Sep 2024 09:15:58 +0300 Subject: [PATCH] fix tile styles and last encounter fetch --- .../components/encounter-tile.component.tsx | 24 +++++++++---------- .../src/encounter-tile/components/tile.scss | 5 +++- .../encounter-tile/hooks/useLastEncounter.ts | 6 ++--- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/packages/esm-patient-chart-app/src/encounter-tile/components/encounter-tile.component.tsx b/packages/esm-patient-chart-app/src/encounter-tile/components/encounter-tile.component.tsx index fb318625bc..6db06f5548 100644 --- a/packages/esm-patient-chart-app/src/encounter-tile/components/encounter-tile.component.tsx +++ b/packages/esm-patient-chart-app/src/encounter-tile/components/encounter-tile.component.tsx @@ -26,18 +26,18 @@ export interface EncounterValuesTileProps { export const EncounterTile: React.FC = ({ patientUuid, columns, headerTitle }) => { return ( - // <> - -
-

{headerTitle}

-
- - {columns.map((column, ind) => ( - - ))} - -
- // +
+ +
+

{headerTitle}

+
+ + {columns.map((column, ind) => ( + + ))} + +
+
); }; diff --git a/packages/esm-patient-chart-app/src/encounter-tile/components/tile.scss b/packages/esm-patient-chart-app/src/encounter-tile/components/tile.scss index 36a1ab3c1f..2a58460f3a 100644 --- a/packages/esm-patient-chart-app/src/encounter-tile/components/tile.scss +++ b/packages/esm-patient-chart-app/src/encounter-tile/components/tile.scss @@ -21,7 +21,6 @@ } .tile { - height: 35%; padding: layout.$spacing-01 0 layout.$spacing-05 layout.$spacing-05; margin: layout.$spacing-03; border: solid 1px #e0e0e0; @@ -36,6 +35,10 @@ display: block; } +.tilesContainer { + height: fit-content; +} + .columnContainer { margin: 0px 0px layout.$spacing-06 layout.$spacing-06; font-size: 14px; diff --git a/packages/esm-patient-chart-app/src/encounter-tile/hooks/useLastEncounter.ts b/packages/esm-patient-chart-app/src/encounter-tile/hooks/useLastEncounter.ts index 71aab27749..f46b7d45f9 100644 --- a/packages/esm-patient-chart-app/src/encounter-tile/hooks/useLastEncounter.ts +++ b/packages/esm-patient-chart-app/src/encounter-tile/hooks/useLastEncounter.ts @@ -1,4 +1,4 @@ -import { openmrsFetch } from '@openmrs/esm-framework'; +import { openmrsFetch, restBaseUrl } from '@openmrs/esm-framework'; import { type OpenmrsEncounter } from '@openmrs/esm-patient-common-lib'; import useSWR from 'swr'; @@ -11,7 +11,7 @@ export const encounterRepresentation = export function useLastEncounter(patientUuid: string, encounterType: string) { const query = `encounterType=${encounterType}&patient=${patientUuid}&limit=1&order=desc&startIndex=0`; - const endpointUrl = `/ws/rest/v1/encounter?${query}&v=${encounterRepresentation}`; + const endpointUrl = `${restBaseUrl}/encounter?${query}&v=${encounterRepresentation}`; const { data, error, isValidating } = useSWR<{ data: { results: Array } }, Error>( endpointUrl, @@ -19,7 +19,7 @@ export function useLastEncounter(patientUuid: string, encounterType: string) { ); return { - lastEncounter: data ? data?.data?.results.shift() : null, + lastEncounter: data ? data?.data?.results[0] : null, error, isLoading: !data && !error, isValidating,