diff --git a/src/components/view-editor/view-editor.component.tsx b/src/components/view-editor/view-editor.component.tsx index e52a80e..8bea748 100644 --- a/src/components/view-editor/view-editor.component.tsx +++ b/src/components/view-editor/view-editor.component.tsx @@ -11,6 +11,7 @@ import InteractiveBuilder from '../interactive-builder/interactive-builder.compo import { type Schema } from '../../types'; import styles from './view-editor.scss'; +import { updateSchemaInConfig } from '../../helpers'; interface TranslationFnProps { t: TFunction; @@ -59,7 +60,7 @@ const ContentPackagesEditorContent: React.FC = ({ t }) => { const renderSchemaChanges = useCallback(() => { if (!stringifiedSchema) { showSnackbar({ - title: t('errorRendering', 'Error rendering'), + title: t('renderingError', 'Rendering error'), kind: 'error', subtitle: t('renderingErrorMessage', 'There was an error rendering the clinical view'), }); @@ -162,8 +163,7 @@ const ContentPackagesEditorContent: React.FC = ({ t }) => { if (schema && schemaId) { const existingSchema = localStorage.getItem(schemaId); if (existingSchema) { - // If it exists, update the schema - localStorage.setItem(schemaId, JSON.stringify(schema)); + updateSchemaInConfig(schemaId, schema); showSnackbar({ title: t('clinicalViewUpdated', 'Clinical view updated'), kind: 'success', @@ -171,7 +171,7 @@ const ContentPackagesEditorContent: React.FC = ({ t }) => { }); setIsSaving(false); } else { - localStorage.setItem(schemaId, JSON.stringify(schema)); + updateSchemaInConfig(schemaId, schema); showSnackbar({ title: t('clinicalViewCreated', 'Clinical view saved'), kind: 'success', @@ -189,7 +189,7 @@ const ContentPackagesEditorContent: React.FC = ({ t }) => { } }; - const handlePreviewPackage = () => { + const handlePreviewClinicalView = () => { window.open(window.getOpenmrsSpaBase() + `patient/${patientUuid}/chart/Patient%20Summary`); }; @@ -280,7 +280,7 @@ const ContentPackagesEditorContent: React.FC = ({ t }) => { ? t('updateSchema', 'Update Schema') : t('saveClinicalView', 'Save clinical view')} - diff --git a/src/config-schema.ts b/src/config-schema.ts index 501090c..05d73e1 100644 --- a/src/config-schema.ts +++ b/src/config-schema.ts @@ -3,7 +3,7 @@ import { Type } from '@openmrs/esm-framework'; export const configSchema = { patientUuid: { _type: Type.String, - _description: 'UUID for the stock item category', + _description: 'UUID for the patient', _default: '6cea3475-67d0-4ce9-b947-7cfd407c9168', }, }; diff --git a/src/helpers.ts b/src/helpers.ts index 996fd23..33eef29 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -23,3 +23,7 @@ export const toCamelCase = (str: string) => { export const isValidSlotName = (slotName: string) => { return /^[a-zA-Z0-9-]+$/.test(slotName); }; + +export const updateSchemaInConfig = (schemaId, schema) => { + localStorage.setItem(schemaId, JSON.stringify(schema)); +};