diff --git a/src/lib/form/useOnSubmit.ts b/src/lib/form/useOnSubmit.ts index 84e861dc..2067c6b9 100644 --- a/src/lib/form/useOnSubmit.ts +++ b/src/lib/form/useOnSubmit.ts @@ -11,6 +11,7 @@ import { } from './createJsonPatchOperations' import { useCreateModel } from './useCreateModel' import { usePatchModel } from './usePatchModel' +import { useQueryClient } from 'react-query' type OnSubmit = FormProps['onSubmit'] @@ -24,6 +25,7 @@ export const useOnSubmitEdit = ({ section, }: UseOnSubmitEditOptions) => { const patchDirtyFields = usePatchModel(modelId, section.namePlural) + const queryClient = useQueryClient() const saveAlert = useAlert( ({ message }) => message, (options) => options @@ -53,6 +55,9 @@ export const useOnSubmitEdit = ({ message: i18n.t('Saved successfully'), success: true, }) + queryClient.invalidateQueries({ + queryKey: [{ resource: getSectionPath(section) }], + }) navigate(`/${getSectionPath(section)}`) }, [patchDirtyFields, saveAlert, navigate, section] @@ -81,6 +86,7 @@ export const useOnSubmitNew = ({ section: ModelSection }) => { const createModel = useCreateModel(section.namePlural) + const queryClient = useQueryClient() const saveAlert = useAlert( ({ message }) => message, (options) => options @@ -107,6 +113,9 @@ export const useOnSubmitNew = ({ message: i18n.t('Created successfully'), success: true, }) + queryClient.invalidateQueries({ + queryKey: [{ resource: getSectionPath(section) }], + }) navigate(`/${getSectionPath(section)}`) }, [createModel, saveAlert, navigate, section] diff --git a/src/pages/defaultFormTests.tsx b/src/pages/defaultFormTests.tsx index 0f40106a..6649d796 100644 --- a/src/pages/defaultFormTests.tsx +++ b/src/pages/defaultFormTests.tsx @@ -5,7 +5,7 @@ export const generateDefaultAddFormTests = ({ }) => { xdescribe(`${componentName} default add form tests`, () => { it('should should return to the list view when cancelling', () => {}) - it('should show a loader while the form is being submitted ', () => {}) + it('should show a loader while the form is being submitted', () => {}) }) } diff --git a/src/pages/organisationUnits/list/OrganisationUnitRow.tsx b/src/pages/organisationUnits/list/OrganisationUnitRow.tsx index 49b740bc..c68ad9dc 100644 --- a/src/pages/organisationUnits/list/OrganisationUnitRow.tsx +++ b/src/pages/organisationUnits/list/OrganisationUnitRow.tsx @@ -87,7 +87,9 @@ export const OrganisationUnitRow = ({ onClick={row.getToggleExpandedHandler()} > - ) : null} + ) : ( + + )}