From 44a8080f5899aafcdd6f5c7b9b17af1ee1949b1a Mon Sep 17 00:00:00 2001 From: Flaminia Date: Thu, 14 Nov 2024 15:37:02 +0100 Subject: [PATCH] fix: stop row loaders if there is an error (#440) --- .../organisationUnits/list/OrganisationUnitList.tsx | 11 ++++++----- .../organisationUnits/list/OrganisationUnitRow.tsx | 5 ++++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/pages/organisationUnits/list/OrganisationUnitList.tsx b/src/pages/organisationUnits/list/OrganisationUnitList.tsx index 5828bf23..58954413 100644 --- a/src/pages/organisationUnits/list/OrganisationUnitList.tsx +++ b/src/pages/organisationUnits/list/OrganisationUnitList.tsx @@ -105,7 +105,12 @@ export const OrganisationUnitList = () => { (column) => column.meta.fieldFilter ) + const { queries, fetchNextPage } = usePaginatedChildrenOrgUnitsController({ + parentIds: parentIdsToLoad, + fieldFilters, + }) const isFiltering = !!identifiableFilter + const hasErrored = queries.some((query) => query.isError) const orgUnitFiltered = useFilteredOrgUnits({ searchQuery: identifiableFilter, @@ -113,11 +118,6 @@ export const OrganisationUnitList = () => { enabled: isFiltering, }) - const { queries, fetchNextPage } = usePaginatedChildrenOrgUnitsController({ - parentIds: parentIdsToLoad, - fieldFilters, - }) - // expand ancestors of the filtered org units useEffect(() => { // reset state when not filtering @@ -265,6 +265,7 @@ export const OrganisationUnitList = () => { } onShowDetailsClick={handleDetailsClick} isFiltering={isFiltering} + hasErrored={hasErrored} fetchNextPage={fetchNextPage} /> ))} diff --git a/src/pages/organisationUnits/list/OrganisationUnitRow.tsx b/src/pages/organisationUnits/list/OrganisationUnitRow.tsx index 46b4b6e1..49b740bc 100644 --- a/src/pages/organisationUnits/list/OrganisationUnitRow.tsx +++ b/src/pages/organisationUnits/list/OrganisationUnitRow.tsx @@ -23,6 +23,7 @@ export const OrganisationUnitRow = ({ isFiltering, fetchNextPage, onShowDetailsClick, + hasErrored, }: { row: Row toggleShowAll: (id: string) => void @@ -30,6 +31,7 @@ export const OrganisationUnitRow = ({ isFiltering: boolean fetchNextPage: (id: string) => void onShowDetailsClick: (model: BaseListModel) => void + hasErrored: boolean }) => { const parentRow = row.getParentRow() @@ -72,7 +74,8 @@ export const OrganisationUnitRow = ({ dataTest="row-expand-icon" loading={ row.getIsExpanded() && - row.subRows.length < 1 + row.subRows.length < 1 && + !hasErrored } icon={ row.getIsExpanded() ? (