File tree Expand file tree Collapse file tree 3 files changed +13
-3
lines changed
Expand file tree Collapse file tree 3 files changed +13
-3
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @clerk/clerk-js ' : patch
3+ ---
4+
5+ Fix PricingTable logic for plan button text.
Original file line number Diff line number Diff line change @@ -121,12 +121,13 @@ function Card(props: CardProps) {
121121 const hasFeatures = plan . features . length > 0 ;
122122 const isPlanActive = subscription ?. status === 'active' ;
123123 const showStatusRow = ! ! subscription ;
124+ const isEligibleForSwitchToAnnual = plan . annualMonthlyAmount > 0 && planPeriod === 'annual' ;
124125
125126 const shouldShowFooter =
126127 ! subscription ||
127128 subscription ?. status === 'upcoming' ||
128129 subscription ?. canceledAt ||
129- ( planPeriod !== subscription ?. planPeriod && ! plan . isDefault ) ;
130+ ( planPeriod !== subscription ?. planPeriod && ! plan . isDefault && isEligibleForSwitchToAnnual ) ;
130131 const shouldShowFooterNotice =
131132 subscription ?. status === 'upcoming' && ( planPeriod === subscription . planPeriod || plan . isDefault ) ;
132133
Original file line number Diff line number Diff line change @@ -215,17 +215,21 @@ export const usePlansContext = () => {
215215 _selectedPlanPeriod = 'month' ;
216216 }
217217
218+ const isEligibleForSwitchToAnnual = ( plan ?. annualMonthlyAmount ?? 0 ) > 0 ;
219+
218220 return {
219221 localizationKey : subscription
220222 ? subscription . canceledAt
221223 ? localizationKeys ( 'commerce.reSubscribe' )
222224 : selectedPlanPeriod !== subscription . planPeriod
223225 ? selectedPlanPeriod === 'month'
224226 ? localizationKeys ( 'commerce.switchToMonthly' )
225- : localizationKeys ( 'commerce.switchToAnnual' )
227+ : isEligibleForSwitchToAnnual
228+ ? localizationKeys ( 'commerce.switchToAnnual' )
229+ : localizationKeys ( 'commerce.manageSubscription' )
226230 : localizationKeys ( 'commerce.manageSubscription' )
227231 : // If there are no active or grace period subscriptions, show the get started button
228- ctx . subscriptions . length > 0
232+ ctx . subscriptions . filter ( subscription => ! subscription . plan . isDefault ) . length > 0
229233 ? localizationKeys ( 'commerce.switchPlan' )
230234 : localizationKeys ( 'commerce.subscribe' ) ,
231235 variant : isCompact ? 'bordered' : 'solid' ,
You can’t perform that action at this time.
0 commit comments