Skip to content

Commit

Permalink
fix(billing): adjust usage page loading spinner logic TASK-1321 (#5323)
Browse files Browse the repository at this point in the history
### 📣 Summary
Fix error that was causing infinite loading spinner on usage page for
non-Stripe instances.

### 📖 Description
The usage page was expecting addons context to complete loading before
switching from loading spinner to displaying page contents. However, the
usage page needs to be usable on non-Stripe instances addons context
never loads on such instances. I have adjusted the logic for checking
whether or not the page is ready to display accordingly. At the same
time, I also removed the memoization for this logic, as it was
unnecessary and only used in one place.

### 👀 Preview steps

1. Access the usage page with Stripe disabled
2. On main, you will get an infinite loading spinner
3. On this branch, you will see the usage page as expected

Co-authored-by: Anji Tong <ollejna@gmail.com>
  • Loading branch information
jamesrkiger and duvld authored Dec 13, 2024
1 parent f57d31b commit 3927d40
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions jsapp/js/account/usage/usage.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,6 @@ export default function Usage() {

const location = useLocation();

const isFullyLoaded = useMemo(
() =>
!usageStatus.pending &&
!usageStatus.error &&
(products.isLoaded || !limits.stripeEnabled) &&
limits.isLoaded &&
oneTimeAddOnsContext.isLoaded,
[
usageStatus,
products.isLoaded,
limits.isLoaded,
limits.stripeEnabled,
oneTimeAddOnsContext.isLoaded,
]
);

const dateRange = useMemo(() => {
let startDate: string;
const endDate = usage.billingPeriodEnd
Expand Down Expand Up @@ -198,7 +182,12 @@ export default function Usage() {
subscriptionStore.fetchSubscriptionInfo();
}, [location]);

if (!isFullyLoaded) {
if (
usageStatus.pending ||
usageStatus.error ||
!limits.isLoaded ||
(limits.stripeEnabled && (!products.isLoaded || !oneTimeAddOnsContext.isLoaded))
) {
return <LoadingSpinner />;
}

Expand Down

0 comments on commit 3927d40

Please sign in to comment.