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

feat: add a billing loading action #21863

Merged
merged 3 commits into from
Apr 26, 2024

Conversation

zlwaterfield
Copy link
Contributor

@zlwaterfield zlwaterfield commented Apr 25, 2024

Changes

We're seeing a few UX hiccups for users when activating/deactivating subscriptions because buttons don't show loading and aren't disabled.

@xrdt already added this for deactivating here: #21765.

This Is adding it for activating products and addons.

Demo: https://assets.zlwaterfield.com/misc%2FScreen%20Cast%202024-04-25%20at%2012.56.38%20PM.gif

@zlwaterfield zlwaterfield self-assigned this Apr 25, 2024
Copy link
Contributor

github-actions bot commented Apr 25, 2024

Size Change: 0 B

Total Size: 1.04 MB

ℹ️ View Unchanged
Filename Size
frontend/dist/toolbar.js 1.04 MB

compressed-size-action

@zlwaterfield zlwaterfield requested a review from a team April 25, 2024 20:13
Comment on lines +113 to +118
billingProductLoading: [
null as string | null,
{
setBillingProductLoading: (_, { productKey }) => productKey,
},
],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this should be getting reset somewhere when it's done loading? If the page refreshes then makes sense that it doesn't get manually reset, but the page doesn't always refresh.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It probably makes more sense to move the call on the subscribe / add buttons into a loader so the loading state can be handled by kea.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be the same as the deactivate loader currently on billingLogic.tsx

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are all outgoing links, so that's why I did it this way. I only added these to buttons with to props.

I could move into kea but it would just be a window.location.href = and the loader wouldn't get reset anyways.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it makes sense to move to kea since sometimes we will need to redirect to checkout but that won't be known at time of click, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original question was:

I feel like this should be getting reset somewhere when it's done loading?

So I'm just saying that all these requests are requests to the server that will return a redirect so the loading doesn't need to be reset because there always be a page refresh.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can look into moving these into kea as a fetch that gets redirected as well, that's just a bit of a different change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like keeping the redirect logic in the billing service is fine. It keeps the logic around when to interact with stripe in one place.

Copy link
Contributor Author

@zlwaterfield zlwaterfield Apr 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just gave moving into kea a try. I did just something like:

                activateProduct: async ({ productKey, redirect }: { productKey: string, redirect?: string }) => {
                    let path = 'api/billing-v2/activation?products=' + productKey
                    if (redirect) {
                        path += '&redirect=' + redirect
                    }
                    return api.getResponse(path)
                }

but the API returns a redirect to the billing repo, and then the fetch goes there and gets a CORS issue. So it's definitely better to keep it as is.

Copy link
Contributor

@xrdt xrdt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thanks for hashing through all the questions in the comment thread.

@zlwaterfield zlwaterfield merged commit daa182d into master Apr 26, 2024
103 checks passed
@zlwaterfield zlwaterfield deleted the zach/billing-activation-deactivation-loading branch April 26, 2024 00:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants