Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: stop row loaders if there is an error #440

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/pages/organisationUnits/list/OrganisationUnitList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,19 @@ 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,
fieldFilters,
enabled: isFiltering,
})

const { queries, fetchNextPage } = usePaginatedChildrenOrgUnitsController({
parentIds: parentIdsToLoad,
fieldFilters,
})

// expand ancestors of the filtered org units
useEffect(() => {
// reset state when not filtering
Expand Down Expand Up @@ -265,6 +265,7 @@ export const OrganisationUnitList = () => {
}
onShowDetailsClick={handleDetailsClick}
isFiltering={isFiltering}
hasErrored={hasErrored}
fetchNextPage={fetchNextPage}
/>
))}
Expand Down
5 changes: 4 additions & 1 deletion src/pages/organisationUnits/list/OrganisationUnitRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ export const OrganisationUnitRow = ({
isFiltering,
fetchNextPage,
onShowDetailsClick,
hasErrored,
}: {
row: Row<OrganisationUnitListItem>
toggleShowAll: (id: string) => void
showAllActive: boolean
isFiltering: boolean
fetchNextPage: (id: string) => void
onShowDetailsClick: (model: BaseListModel) => void
hasErrored: boolean
}) => {
const parentRow = row.getParentRow()

Expand Down Expand Up @@ -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() ? (
Expand Down
Loading