Skip to content

Commit

Permalink
(fix) Restore patient banner (#365)
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelmale authored Aug 10, 2024
1 parent 6f04f6c commit a809dbf
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/form-engine.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type { FormField, SessionMode, FormSchema } from './types';
import { useSession, type Visit } from '@openmrs/esm-framework';
import { useFormJson } from '.';
import FormProcessorFactory from './components/processor-factory/form-processor-factory.component';
import { Form } from '@carbon/react';
import Loader from './components/loaders/loader.component';
import { usePatientData } from './hooks/usePatientData';
import { useWorkspaceLayout } from './hooks/useWorkspaceLayout';
Expand Down Expand Up @@ -66,13 +65,16 @@ const FormEngine = ({
// TODO: Updating this prop triggers a rerender of the entire form. This means whenever we scroll into a new page, the form is rerendered.
// Figure out a way to avoid this. Maybe use a ref with an observer instead of a state?
const [currentPage, setCurrentPage] = useState('');
const [showPatientBanner, setShowPatientBanner] = useState(false);
const {
formJson: refinedFormJson,
isLoading: isLoadingFormJson,
formError,
} = useFormJson(formUUID, formJson, encounterUUID, formSessionIntent);

const showPatientBanner = useMemo(() => {
return patient && workspaceLayout !== 'minimized' && mode !== 'embedded-view';
}, [patient, mode, workspaceLayout]);

const showButtonSet = useMemo(() => {
// if (mode === 'embedded-view') {
// return false;
Expand Down Expand Up @@ -102,7 +104,7 @@ const FormEngine = ({
}, []);

return (
<Form noValidate ref={ref} className={classNames('cds--form', styles.form)} onSubmit={handleSubmit}>
<form ref={ref} noValidate className={classNames('cds--form', styles.form)} onSubmit={handleSubmit}>
{isLoadingPatient || isLoadingFormJson ? (
<Loader />
) : (
Expand Down Expand Up @@ -171,7 +173,7 @@ const FormEngine = ({
</div>
</FormFactoryProvider>
)}
</Form>
</form>
);
};

Expand Down

0 comments on commit a809dbf

Please sign in to comment.