Skip to content

Commit

Permalink
(feat) Preload form schemas on hover (#221)
Browse files Browse the repository at this point in the history
  • Loading branch information
denniskigen authored Feb 8, 2024
1 parent e34f321 commit 638c38f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/components/dashboard/dashboard.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ import {
useLayoutType,
usePagination,
useDebounce,
openmrsFetch,
} from '@openmrs/esm-framework';
import type { KeyedMutator } from 'swr';
import { type KeyedMutator, preload } from 'swr';

import type { Form as TypedForm } from '../../types';
import { deleteForm } from '../../forms.resource';
Expand Down Expand Up @@ -306,6 +307,7 @@ function FormsList({ forms, isValidating, mutate, t }: FormsListProps) {
},
];

const editSchemaUrl = '${openmrsSpaBase}/form-builder/edit/${formUuid}';
const { paginated, goTo, results, currentPage } = usePagination(filteredForms, pageSize);

const tableRows = results?.map((form: TypedForm) => ({
Expand All @@ -314,7 +316,9 @@ function FormsList({ forms, isValidating, mutate, t }: FormsListProps) {
name: (
<ConfigurableLink
className={styles.link}
to={`${window.getOpenmrsSpaBase() + `form-builder/edit/` + form?.uuid}`}
to={editSchemaUrl}
templateParams={{ formUuid: form?.uuid }}
onMouseEnter={() => void preload(`/ws/rest/v1/form/${form?.uuid}?v=full`, openmrsFetch)}
>
{form.name}
</ConfigurableLink>
Expand Down

0 comments on commit 638c38f

Please sign in to comment.