-
Notifications
You must be signed in to change notification settings - Fork 39
fix: adding trial plan subscription card changes #1716
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
base: master
Are you sure you want to change the base?
Conversation
…dmin-portal into kiram15/ENT-10992
| actions={( | ||
| <div> | ||
| {renderActions() || renderDaysUntilPlanStartText('mt-4')} | ||
| {renderActions()} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why the renderDaysUntilPlanStartText might have been rendered twice in the first place? And it was breaking the tests so I took it out, but would love some context
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1716 +/- ##
==========================================
- Coverage 87.06% 87.03% -0.04%
==========================================
Files 780 780
Lines 17766 17829 +63
Branches 3630 3733 +103
==========================================
+ Hits 15468 15517 +49
- Misses 2234 2237 +3
- Partials 64 75 +11 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…dmin-portal into kiram15/ENT-10992
iloveagent57
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! One suggestion on that function signature
| * @param {string} planType - The type of plan | ||
| * @param {func} setErrors - setErrors function from SubscriptionContext | ||
| */ | ||
| export const useStripeBillingPortalSession = ({ enterpriseUuid, planType, setErrors }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❌ Hm, so this whole pattern of a home-grown API hook with built-in state management is an anti-pattern that we've replaced with react useQuery. If Hamzah were still here reviewing frontend PRs I'm not sure we'd allow new code to use this pattern. One motivation to use react query in this instance is that the generated URL does eventually expire, but as written this hook won't refresh the URL after the first successful fetch. Using react query would allow us to leverage a built-in cache timeout setting which we can simply configure to a shorter duration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh wait, forgot this isn't the frontend-app-enterprise-checkout repo. Scratch what I said...
I'll re-state my concern: I think this hook does not gracefully handle when the generated URL expires.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expiration: 5 minutes after generation, or 1 hour if clicked.
https://docs.stripe.com/customer-management
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is why I was originally surprised we didn't architect this endpoint to just be a link that itself performs a 302 redirect, so our frontend code didn't need to be bothered with implementing response parsing. Nevertheless, this is how the endpoint got implemented, so I'd just recommend we architect the button to directly perform an API call on click instead of using a hook to pre-cache the URL on render and retrieve it via hook state.
| key={stripeUrl} | ||
| as={Link} | ||
| to={stripeUrl} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My suggestion is to make this button dynamic; here's an example in broad strokes:
<Button
id="Manage subscription button"
onClick={handleManageSubscriptionClick}
disabled={isGeneratingUrl}
...
>Then do dynamic stuff on click:
const handleManageSubscriptionClick = async (e) => {
const response = await EnterpriseAccessApiService.fetchStripeBillingPortalSession(
enterpriseUuid
);
const results = camelCaseObject(response.data);
if (results.url) {
window.open(results.url, '_blank', 'noopener,noreferrer');
}
};
For all changes
Only if submitting a visual change