Skip to content

Commit de90ede

Browse files
authored
fix(clerk-js): Allow cancelation of past due subscription items (#6783)
1 parent 8bb283b commit de90ede

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+69
-11
lines changed

.changeset/public-animals-march.md

Lines changed: 7 additions & 0 deletions

packages/clerk-js/src/ui/components/SubscriptionDetails/__tests__/SubscriptionDetails.test.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -999,7 +999,7 @@ describe('SubscriptionDetails', () => {
999999
],
10001000
});
10011001

1002-
const { getByRole, getByText, queryByText, queryByRole } = render(
1002+
const { getByRole, getByText, queryByText } = render(
10031003
<Drawer.Root
10041004
open
10051005
onOpenChange={() => {}}
@@ -1018,9 +1018,6 @@ describe('SubscriptionDetails', () => {
10181018
expect(queryByText('Subscribed on')).toBeNull();
10191019
expect(getByText('Past due on')).toBeVisible();
10201020
expect(getByText('January 15, 2021')).toBeVisible();
1021-
1022-
// Menu button should be present but disabled
1023-
expect(queryByRole('button', { name: /Open menu/i })).toBeNull();
10241021
});
10251022
});
10261023

packages/clerk-js/src/ui/components/SubscriptionDetails/index.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -295,11 +295,13 @@ const SubscriptionDetailsFooter = withCardStateProvider(() => {
295295
})
296296
: selectedSubscription.status === 'upcoming'
297297
? localizationKeys('commerce.cancelSubscriptionNoCharge')
298-
: localizationKeys('commerce.cancelSubscriptionAccessUntil', {
299-
plan: selectedSubscription.plan.name,
300-
// this will always be defined in this state
301-
date: selectedSubscription.periodEnd as Date,
302-
})
298+
: selectedSubscription.status === 'past_due'
299+
? localizationKeys('commerce.cancelSubscriptionPastDue')
300+
: localizationKeys('commerce.cancelSubscriptionAccessUntil', {
301+
plan: selectedSubscription.plan.name,
302+
// this will always be defined in this state
303+
date: selectedSubscription.periodEnd as Date,
304+
})
303305
}
304306
/>
305307
<CardAlert>{error}</CardAlert>
@@ -376,7 +378,7 @@ const SubscriptionCardActions = ({ subscription }: { subscription: CommerceSubsc
376378
subscription.planPeriod === 'annual') &&
377379
subscription.status !== 'past_due';
378380
const isFree = isFreePlan(subscription.plan);
379-
const isCancellable = subscription.canceledAt === null && !isFree && subscription.status !== 'past_due';
381+
const isCancellable = subscription.canceledAt === null && !isFree;
380382
const isReSubscribable = subscription.canceledAt !== null && !isFree;
381383

382384
const openCheckout = useCallback(

packages/localizations/src/ar-SA.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ export const arSA: LocalizationResource = {
8181
cancelSubscription: undefined,
8282
cancelSubscriptionAccessUntil: undefined,
8383
cancelSubscriptionNoCharge: undefined,
84+
cancelSubscriptionPastDue: undefined,
8485
cancelSubscriptionTitle: undefined,
8586
cannotSubscribeMonthly: undefined,
8687
cannotSubscribeUnrecoverable: undefined,

packages/localizations/src/be-BY.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ export const beBY: LocalizationResource = {
8181
cancelSubscription: undefined,
8282
cancelSubscriptionAccessUntil: undefined,
8383
cancelSubscriptionNoCharge: undefined,
84+
cancelSubscriptionPastDue: undefined,
8485
cancelSubscriptionTitle: undefined,
8586
cannotSubscribeMonthly: undefined,
8687
cannotSubscribeUnrecoverable: undefined,

packages/localizations/src/bg-BG.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ export const bgBG: LocalizationResource = {
8282
cancelSubscription: undefined,
8383
cancelSubscriptionAccessUntil: undefined,
8484
cancelSubscriptionNoCharge: undefined,
85+
cancelSubscriptionPastDue: undefined,
8586
cancelSubscriptionTitle: undefined,
8687
cannotSubscribeMonthly: undefined,
8788
cannotSubscribeUnrecoverable: undefined,

packages/localizations/src/bn-IN.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ export const bnIN: LocalizationResource = {
8181
cancelSubscription: undefined,
8282
cancelSubscriptionAccessUntil: undefined,
8383
cancelSubscriptionNoCharge: undefined,
84+
cancelSubscriptionPastDue: undefined,
8485
cancelSubscriptionTitle: undefined,
8586
cannotSubscribeMonthly: undefined,
8687
cannotSubscribeUnrecoverable: undefined,

packages/localizations/src/ca-ES.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ export const caES: LocalizationResource = {
8282
cancelSubscription: undefined,
8383
cancelSubscriptionAccessUntil: undefined,
8484
cancelSubscriptionNoCharge: undefined,
85+
cancelSubscriptionPastDue: undefined,
8586
cancelSubscriptionTitle: undefined,
8687
cannotSubscribeMonthly: undefined,
8788
cannotSubscribeUnrecoverable: undefined,

packages/localizations/src/cs-CZ.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export const csCZ: LocalizationResource = {
8383
cancelSubscriptionAccessUntil:
8484
"Funkce '{{plan}}' můžete používat do {{ date | longDate('cs-CZ') }}, poté k nim ztratíte přístup.",
8585
cancelSubscriptionNoCharge: 'Za toto předplatné vám nebudou účtovány žádné poplatky.',
86+
cancelSubscriptionPastDue: undefined,
8687
cancelSubscriptionTitle: 'Zrušit předplatné {{plan}}?',
8788
cannotSubscribeMonthly:
8889
'Nelze se přihlásit k tomuto plánu s měsíční platbou. Abyste se k němu přihlásili, musíte zvolit roční platbu.',
@@ -858,9 +859,10 @@ export const csCZ: LocalizationResource = {
858859
form_param_max_length_exceeded__last_name: 'Příjmení nesmí přesáhnout 256 znaků.',
859860
form_param_max_length_exceeded__name: 'Jméno nesmí přesáhnout 256 znaků.',
860861
form_param_nil: 'Tento parametr je povinný.',
861-
form_param_value_invalid: 'Tento parametr má neplatnou hodnotu.',
862+
form_param_type_invalid: undefined,
862863
form_param_type_invalid__email_address: undefined,
863864
form_param_type_invalid__phone_number: undefined,
865+
form_param_value_invalid: 'Tento parametr má neplatnou hodnotu.',
864866
form_password_incorrect: 'Heslo je nesprávné.',
865867
form_password_length_too_short: 'Heslo je příliš krátké.',
866868
form_password_not_strong_enough: 'Vaše heslo není dostatečně silné.',

packages/localizations/src/da-DK.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ export const daDK: LocalizationResource = {
8181
cancelSubscription: undefined,
8282
cancelSubscriptionAccessUntil: undefined,
8383
cancelSubscriptionNoCharge: undefined,
84+
cancelSubscriptionPastDue: undefined,
8485
cancelSubscriptionTitle: undefined,
8586
cannotSubscribeMonthly: undefined,
8687
cannotSubscribeUnrecoverable: undefined,

0 commit comments

Comments
 (0)