@@ -2,13 +2,13 @@ import { __internal_useOrganizationBase, useClerk } from '@clerk/shared/react';
22import type {
33 __internal_CheckoutProps ,
44 __internal_SubscriptionDetailsProps ,
5- BillingPlanResource ,
65 BillingSubscriptionItemResource ,
76} from '@clerk/shared/types' ;
87import * as React from 'react' ;
98import { useCallback , useContext , useState } from 'react' ;
109
1110import { Users } from '@/icons' ;
11+ import { common } from '@/styledSystem' ;
1212import { useProtect } from '@/ui/common/Gate' ;
1313import {
1414 SubscriptionDetailsContext ,
@@ -19,6 +19,7 @@ import { CardAlert } from '@/ui/elements/Card/CardAlert';
1919import { useCardState , withCardStateProvider } from '@/ui/elements/contexts' ;
2020import { Drawer , useDrawerContext } from '@/ui/elements/Drawer' ;
2121import { LineItems } from '@/ui/elements/LineItems' ;
22+ import { isManageableSubscriptionItem } from '@/ui/utils/billingSubscription' ;
2223import { handleError } from '@/ui/utils/errorHandler' ;
2324import { formatDate } from '@/ui/utils/formatDate' ;
2425
@@ -44,9 +45,6 @@ import {
4445 useLocalizations ,
4546} from '../../customizables' ;
4647import { SubscriptionBadge } from '../Subscriptions/badge' ;
47- import { common } from '@/styledSystem' ;
48-
49- const isFreePlan = ( plan : BillingPlanResource ) => ! plan . hasBaseFee ;
5048
5149// We cannot derive the state of confirmation modal from the existence subscription, as it will make the animation laggy when the confirmation closes.
5250const SubscriptionForCancellationContext = React . createContext < {
@@ -376,14 +374,14 @@ const SubscriptionCardActions = ({ subscription }: { subscription: BillingSubscr
376374 const canOrgManageBilling = useProtect ( has => has ( { permission : 'org:sys_billing:manage' } ) ) ;
377375 const canManageBilling = subscriberType === 'user' || canOrgManageBilling ;
378376
377+ const isManageable = isManageableSubscriptionItem ( subscription ) ;
379378 const isSwitchable =
380379 ( ( subscription . planPeriod === 'month' && Boolean ( subscription . plan . annualMonthlyFee ) ) ||
381380 ( subscription . planPeriod === 'annual' && Boolean ( subscription . plan . fee ) ) ) &&
382381 subscription . status !== 'past_due' &&
383- ! subscription . plan . isDefault ;
384- const isFree = isFreePlan ( subscription . plan ) ;
385- const isCancellable = subscription . canceledAt === null && ! isFree ;
386- const isReSubscribable = subscription . canceledAt !== null && ! isFree ;
382+ isManageable ;
383+ const isCancellable = subscription . canceledAt === null && isManageable ;
384+ const isReSubscribable = subscription . canceledAt !== null && isManageable ;
387385
388386 const openCheckout = useCallback (
389387 ( params ?: __internal_CheckoutProps ) => {
0 commit comments