From 07485564fb73abd0c13b10dfad1ff9262be1b00b Mon Sep 17 00:00:00 2001 From: Jovan Ssebaggala Date: Wed, 12 Jun 2024 14:57:38 +0300 Subject: [PATCH] auto refresh encounter list after form saving/editing (#1864) --- package.json | 16 ++++++++-------- .../src/components/encounter-list/helpers.ts | 3 +-- .../src/hooks/useEncounterRows.ts | 9 +++++---- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index f375ef569..3eb5caa26 100644 --- a/package.json +++ b/package.json @@ -13,15 +13,15 @@ "access": "public" }, "scripts": { - "start": "openmrs develop --backend https://ohri-dev.globalhealthapp.net/ --sources 'packages/esm-*-app/'", - "start:core": "openmrs develop --backend https://ohri-dev.globalhealthapp.net --sources packages/esm-ohri-core-app", - "start:covid": "openmrs develop --backend https://ohri-dev.globalhealthapp.net --sources packages/esm-covid-app", - "start:hiv": "openmrs develop --backend https://ohri-dev.globalhealthapp.net --sources packages/esm-hiv-app", - "start:cervical-cancer": "openmrs develop --backend https://ohri-dev.globalhealthapp.net --sources packages/esm-cervical-cancer-app", + "start": "openmrs develop --backend https://openmrs-dev.globalhealthapp.net/ --sources 'packages/esm-*-app/'", + "start:core": "openmrs develop --backend https://openmrs-dev.globalhealthapp.net --sources packages/esm-ohri-core-app", + "start:covid": "openmrs develop --backend https://openmrs-dev.globalhealthapp.net --sources packages/esm-covid-app", + "start:hiv": "openmrs develop --backend https://openmrs-dev.globalhealthapp.net --sources packages/esm-hiv-app", + "start:cervical-cancer": "openmrs develop --backend https://openmrs-dev.globalhealthapp.net --sources packages/esm-cervical-cancer-app", "start:pmtct": "openmrs develop --backend https://ohri-namibia-dev.globalhealthapp.net --sources 'packages/esm-ohri-pmtct-app/'", - "start:form-render": "openmrs develop --backend https://ohri-dev.globalhealthapp.net --sources packages/esm-form-render-app", - "start:tb": "openmrs develop --backend https://ohri-dev.globalhealthapp.net --sources packages/esm-tb-app", - "start:opd": "openmrs develop --backend https://ohri-dev.globalhealthapp.net --sources packages/esm-opd-app", + "start:form-render": "openmrs develop --backend https://openmrs-dev.globalhealthapp.net --sources packages/esm-form-render-app", + "start:tb": "openmrs develop --backend https://openmrs-dev.globalhealthapp.net --sources packages/esm-tb-app", + "start:opd": "openmrs develop --backend https://openmrs-dev.globalhealthapp.net --sources packages/esm-opd-app", "prettier": "prettier --fix --config prettier.config.js --write \"packages/**/*.{ts,tsx}\"", "prepare": "husky install", "test": "jest --config jest.config.js --verbose false --passWithNoTests", diff --git a/packages/esm-commons-lib/src/components/encounter-list/helpers.ts b/packages/esm-commons-lib/src/components/encounter-list/helpers.ts index 9fa7aafc1..747329e3b 100644 --- a/packages/esm-commons-lib/src/components/encounter-list/helpers.ts +++ b/packages/esm-commons-lib/src/components/encounter-list/helpers.ts @@ -14,11 +14,10 @@ export function launchEncounterForm( intent: string = '*', workspaceWindowSize?: 'minimized' | 'maximized', patientUuid?: string, - mutateform?: () => void, ) { launchPatientWorkspace('patient-form-entry-workspace', { workspaceTitle: form.name, - mutateform: mutateform, + mutateForm: onFormSave, formInfo: { encounterUuid, formUuid: form.name, diff --git a/packages/esm-commons-lib/src/hooks/useEncounterRows.ts b/packages/esm-commons-lib/src/hooks/useEncounterRows.ts index 508a13e80..d2a6dd05b 100644 --- a/packages/esm-commons-lib/src/hooks/useEncounterRows.ts +++ b/packages/esm-commons-lib/src/hooks/useEncounterRows.ts @@ -1,4 +1,4 @@ -import useSWRImmutable, { mutate } from 'swr'; +import useSWR from 'swr'; import { OpenmrsEncounter } from '../api/types'; import { useCallback, useEffect, useMemo, useState } from 'react'; import { openmrsFetch } from '@openmrs/esm-framework'; @@ -12,7 +12,8 @@ export function useEncounterRows(patientUuid: string, encounterType: string, enc data: response, error, isLoading, - } = useSWRImmutable<{ data: { results: OpenmrsEncounter[] } }, Error>(url, openmrsFetch); + mutate, + } = useSWR<{ data: { results: OpenmrsEncounter[] } }, Error>(url, openmrsFetch); useEffect(() => { if (response) { @@ -30,8 +31,8 @@ export function useEncounterRows(patientUuid: string, encounterType: string, enc }, [encounterFilter, response]); const onFormSave = useCallback(() => { - mutate(url); - }, [url]); + mutate(); + }, [mutate]); return { encounters,