Skip to content

Commit d933fba

Browse files
authored
fix: show free trial messaging correctly for SSP plans (#1731)
* fix: show free trial messaging correctly for SSP plans * fix: update tests
1 parent 87215b8 commit d933fba

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

src/components/subscriptions/SubscriptionCard.jsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const SubscriptionCard = ({
4040
const subscriptionStatus = getSubscriptionStatus(subscription);
4141

4242
let subscriptionUpcomingPrice;
43-
if (!loadingStripeSummary) {
43+
if (!loadingStripeSummary && invoiceAmount) {
4444
const locale = getLocale();
4545
subscriptionUpcomingPrice = `${invoiceAmount.toLocaleString(locale, { style: 'currency', currency, maximumFractionDigits: 0 })} ${currency.toUpperCase()}`;
4646
}
@@ -109,7 +109,11 @@ const SubscriptionCard = ({
109109
className="ml-2"
110110
target="_blank"
111111
rel="noopener noreferrer"
112-
onClick={() => (openStripeBillingPortal(enterpriseUuid))}
112+
destination="#"
113+
onClick={e => {
114+
e.preventDefault();
115+
openStripeBillingPortal(enterpriseUuid);
116+
}}
113117
>
114118
Manage subscription
115119
</Hyperlink>),

src/components/subscriptions/data/constants.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ export const SUBSCRIPTION_STATUS_BADGE_MAP = {
5959
};
6060

6161
// Self-service plan types
62-
export const SELF_SERVICE_TRIAL = 'Self-service Trial';
63-
export const SELF_SERVICE_PAID = 'Self-service Paid';
62+
export const SELF_SERVICE_TRIAL = 'self-service-trial';
63+
export const SELF_SERVICE_PAID = 'self-service-paid';
6464

6565
export const FREE_TRIAL_BADGE = 'Free Trial';
6666

src/components/subscriptions/data/hooks.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ export const useUpcomingInvoiceAmount = ({ subPlanUuid, planType, setErrors }) =
252252
try {
253253
const response = await EnterpriseAccessApiService.fetchStripeEvent(subPlanUuid);
254254
const results = camelCaseObject(response.data);
255-
setInvoiceAmount(results.upcomingInvoiceAmountDue);
255+
setInvoiceAmount(results.upcomingInvoiceAmountDue / 100);
256256
setCurrency(results.currency);
257257
} catch (error) {
258258
logError(error);

src/components/subscriptions/tests/data/hooks.test.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ describe('useUpcomingInvoiceAmount', () => {
136136

137137
await waitFor(() => {
138138
expect(EnterpriseAccessApiService.fetchStripeEvent).toHaveBeenCalledTimes(1);
139-
expect(result.current.invoiceAmount).toBe(15000);
139+
expect(result.current.invoiceAmount).toBe(150);
140140
expect(result.current.currency).toBe('usd');
141141
expect(result.current.loadingStripeSummary).toBe(false);
142142
expect(setErrors).not.toHaveBeenCalled();

0 commit comments

Comments
 (0)