Skip to content

Commit

Permalink
Wait for up-to date request data before loading view
Browse files Browse the repository at this point in the history
  • Loading branch information
peterMuriuki committed Sep 8, 2023
1 parent 70f8ab7 commit a4ff855
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export const AddEditOrganization = (props: AddEditOrganizationProps) => {
{
select: (res) => getResourcesFromBundle(res) as IPractitionerRole[],
onError: () => sendErrorNotification(t('There was a problem fetching practitioners')),
staleTime: 0,
}
);

Expand All @@ -70,13 +71,17 @@ export const AddEditOrganization = (props: AddEditOrganizationProps) => {
return getResourcesFromBundle(res) as IPractitionerRole[];
},
enabled: !!orgId,
staleTime: 0,
}
);

if (
(!organization.isIdle && organization.isLoading) ||
(!practitioners.isIdle && practitioners.isLoading) ||
(!allPractitionerRoles.isIdle && allPractitionerRoles.isLoading)
organization.isLoading ||
organization.isFetching ||
practitioners.isLoading ||
practitioners.isFetching ||
allPractitionerRoles.isLoading ||
allPractitionerRoles.isFetching
) {
return <Spin size="large" className="custom-spinner"></Spin>;
}
Expand Down

0 comments on commit a4ff855

Please sign in to comment.