diff --git a/src/lib/form/useOnSubmit.ts b/src/lib/form/useOnSubmit.ts index 84e861dc..7e21b022 100644 --- a/src/lib/form/useOnSubmit.ts +++ b/src/lib/form/useOnSubmit.ts @@ -2,6 +2,7 @@ import { useAlert } from '@dhis2/app-runtime' import i18n from '@dhis2/d2-i18n' import { useMemo } from 'react' import { FormProps } from 'react-final-form' +import { useQueryClient } from 'react-query' import { ModelSection } from '../../types' import { IdentifiableObject } from '../../types/generated' import { getSectionPath, useNavigateWithSearchState } from '../routeUtils' @@ -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: section.namePlural }], + }) 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: section.namePlural }], + }) 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/OrganisationUnitList.tsx b/src/pages/organisationUnits/list/OrganisationUnitList.tsx index 58954413..b35f83d0 100644 --- a/src/pages/organisationUnits/list/OrganisationUnitList.tsx +++ b/src/pages/organisationUnits/list/OrganisationUnitList.tsx @@ -250,19 +250,6 @@ export const OrganisationUnitList = () => { - setParentIdsToLoad((prev) => { - const { [id]: wasShown, ...withoutId } = - prev - if (wasShown) { - return withoutId - } - return { ...prev, [id]: true } - }) - } - showAllActive={ - parentIdsToLoad[row.original.id] === true - } onShowDetailsClick={handleDetailsClick} isFiltering={isFiltering} hasErrored={hasErrored} diff --git a/src/pages/organisationUnits/list/OrganisationUnitRow.tsx b/src/pages/organisationUnits/list/OrganisationUnitRow.tsx index 49b740bc..cb42a8c3 100644 --- a/src/pages/organisationUnits/list/OrganisationUnitRow.tsx +++ b/src/pages/organisationUnits/list/OrganisationUnitRow.tsx @@ -18,16 +18,12 @@ import { OrganisationUnitListActions } from './OrganisationUnitListActions' export const OrganisationUnitRow = ({ row, - toggleShowAll, - showAllActive, isFiltering, fetchNextPage, onShowDetailsClick, hasErrored, }: { row: Row - toggleShowAll: (id: string) => void - showAllActive: boolean isFiltering: boolean fetchNextPage: (id: string) => void onShowDetailsClick: (model: BaseListModel) => void @@ -47,26 +43,6 @@ export const OrganisationUnitRow = ({ > {row.getCanExpand() ? ( <> - {isFiltering && - (showAllActive || - row.original.childCount !== - row.subRows.length) && ( - - )} - ) : null} + ) : ( + + )}