Skip to content

Commit

Permalink
fix tile styles and last encounter fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
kajambiya committed Sep 6, 2024
1 parent 8037c58 commit 64b77fd
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@ export interface EncounterValuesTileProps {

export const EncounterTile: React.FC<EncounterTileProps> = ({ patientUuid, columns, headerTitle }) => {
return (
// <>
<Tile className={styles.tile}>
<div className={styles.cardTitle}>
<h4 className={styles.title}> {headerTitle} </h4>
</div>
<Column className={styles.columnContainer}>
{columns.map((column, ind) => (
<EncounterValuesTile key={ind} patientUuid={patientUuid} column={column} />
))}
</Column>
</Tile>
// </>
<div className={styles.tilesContainer}>
<Tile className={styles.tile}>
<div className={styles.cardTitle}>
<h4 className={styles.title}> {headerTitle} </h4>
</div>
<Column className={styles.columnContainer}>
{columns.map((column, ind) => (
<EncounterValuesTile key={column.key} patientUuid={patientUuid} column={column} />
))}
</Column>
</Tile>
</div>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -36,6 +35,10 @@
display: block;
}

.tilesContainer {
height: fit-content;
}

.columnContainer {
margin: 0px 0px layout.$spacing-06 layout.$spacing-06;
font-size: 14px;
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -11,15 +11,15 @@ 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<OpenmrsEncounter> } }, Error>(
endpointUrl,
openmrsFetch,
);

return {
lastEncounter: data ? data?.data?.results.shift() : null,
lastEncounter: data ? data?.data?.results[0] : null,
error,
isLoading: !data && !error,
isValidating,
Expand Down

0 comments on commit 64b77fd

Please sign in to comment.