Skip to content

Commit f4395f4

Browse files
aelioxpanteliselef
authored andcommitted
fix(clerk-js,types,localizations): Adjust invalid plan change alert wording (#6248)
Co-authored-by: panteliselef <panteliselef@outlook.com>
1 parent e57aa2c commit f4395f4

File tree

9 files changed

+26
-3
lines changed

9 files changed

+26
-3
lines changed

.changeset/orange-doors-notice.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@clerk/localizations': minor
3+
'@clerk/clerk-js': patch
4+
'@clerk/types': minor
5+
---
6+
7+
Improve invalid plan change callout for monthly-only plans

integration/tests/pricing-table.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ testAgainstRunningApps({ withEnv: [appConfigs.envs.withBilling] })('pricing tabl
351351
page
352352
.locator('.cl-checkout-root')
353353
.getByText(
354-
'You cannot subscribe to this plan by paying monthly. To subscribe to this plan, you need to choose to pay annually',
354+
'You cannot subscribe to this plan by paying monthly. To subscribe to this plan, you need to choose to pay annually.',
355355
),
356356
).toBeVisible();
357357

packages/clerk-js/bundlewatch.config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
{ "path": "./dist/waitlist*.js", "maxSize": "1.5KB" },
2424
{ "path": "./dist/keylessPrompt*.js", "maxSize": "6.5KB" },
2525
{ "path": "./dist/pricingTable*.js", "maxSize": "4.02KB" },
26-
{ "path": "./dist/checkout*.js", "maxSize": "8.4KB" },
26+
{ "path": "./dist/checkout*.js", "maxSize": "8.45KB" },
2727
{ "path": "./dist/up-billing-page*.js", "maxSize": "3.0KB" },
2828
{ "path": "./dist/op-billing-page*.js", "maxSize": "3.0KB" },
2929
{ "path": "./dist/up-plans-page*.js", "maxSize": "1.0KB" },

packages/clerk-js/src/ui/components/Checkout/parts.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ export const InvalidPlanScreen = () => {
4848
return _error?.meta?.plan;
4949
}, [error]);
5050

51+
const isPlanUpgradePossible = useMemo(() => {
52+
const _error = error?.errors.find(e => e.code === 'invalid_plan_change');
53+
return _error?.meta?.isPlanUpgradePossible || false;
54+
}, [error]);
55+
5156
if (!planFromError) {
5257
return null;
5358
}
@@ -85,7 +90,11 @@ export const InvalidPlanScreen = () => {
8590
<Alert
8691
variant='info'
8792
colorScheme='info'
88-
title={localizationKeys('commerce.cannotSubscribeMonthly')}
93+
title={
94+
isPlanUpgradePossible
95+
? localizationKeys('commerce.cannotSubscribeMonthly')
96+
: localizationKeys('commerce.cannotSubscribeUnrecoverable')
97+
}
8998
/>
9099
</Box>
91100
</Flex>

packages/localizations/src/en-US.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ export const enUS: LocalizationResource = {
6969
cancelSubscriptionTitle: 'Cancel {{plan}} Subscription?',
7070
cannotSubscribeMonthly:
7171
'You cannot subscribe to this plan by paying monthly. To subscribe to this plan, you need to choose to pay annually.',
72+
cannotSubscribeUnrecoverable:
73+
'You cannot subscribe to this plan. Your existing subscription is more expensive than this plan.',
7274
checkout: {
7375
description__paymentSuccessful: 'Your payment was successful.',
7476
description__subscriptionSuccessful: 'Your new subscription is all set.',

packages/shared/src/error.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ export function parseError(error: ClerkAPIErrorJSON): ClerkAPIError {
167167
identifiers: error?.meta?.identifiers,
168168
zxcvbn: error?.meta?.zxcvbn,
169169
plan: error?.meta?.plan,
170+
isPlanUpgradePossible: error?.meta?.is_plan_upgrade_possible,
170171
},
171172
};
172173
}
@@ -188,6 +189,7 @@ export function errorToJSON(error: ClerkAPIError | null): ClerkAPIErrorJSON {
188189
identifiers: error?.meta?.identifiers,
189190
zxcvbn: error?.meta?.zxcvbn,
190191
plan: error?.meta?.plan,
192+
is_plan_upgrade_possible: error?.meta?.isPlanUpgradePossible,
191193
},
192194
};
193195
}

packages/types/src/api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export interface ClerkAPIError {
3636
id: string;
3737
name: string;
3838
};
39+
isPlanUpgradePossible?: boolean;
3940
};
4041
}
4142

packages/types/src/json.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ export interface ClerkAPIErrorJSON {
358358
id: string;
359359
name: string;
360360
};
361+
is_plan_upgrade_possible?: boolean;
361362
};
362363
}
363364

packages/types/src/localization.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ export type __internal_LocalizationResource = {
214214
monthly: LocalizationValue;
215215
annually: LocalizationValue;
216216
cannotSubscribeMonthly: LocalizationValue;
217+
cannotSubscribeUnrecoverable: LocalizationValue;
217218
pricingTable: {
218219
billingCycle: LocalizationValue;
219220
included: LocalizationValue;

0 commit comments

Comments
 (0)