@@ -13,6 +13,7 @@ import {
1313 SheetHeader ,
1414 SheetTitle ,
1515} from "@/components/ui/sheet" ;
16+ import { ToolTipLabel } from "@/components/ui/tooltip" ;
1617import { CancelPlanButton } from "components/settings/Account/Billing/CancelPlanModal/CancelPlanModal" ;
1718import { BillingPricing } from "components/settings/Account/Billing/Pricing" ;
1819import { differenceInDays , isAfter } from "date-fns" ;
@@ -30,6 +31,7 @@ export function PlanInfoCardUI(props: {
3031 getTeam : ( ) => Promise < Team > ;
3132 openPlanSheetButtonByDefault : boolean ;
3233 highlightPlan : Team [ "billingPlan" ] | undefined ;
34+ isOwnerAccount : boolean ;
3335} ) {
3436 const { subscriptions, team, openPlanSheetButtonByDefault } = props ;
3537 const validPlan = getValidTeamPlan ( team ) ;
@@ -66,12 +68,7 @@ export function PlanInfoCardUI(props: {
6668 < div className = "flex flex-col items-start gap-0.5" >
6769 < div className = "flex items-center gap-2" >
6870 < h3 className = "font-semibold text-2xl capitalize tracking-tight" >
69- { validPlan === "growth_legacy"
70- ? "Growth"
71- : validPlan === "starter_legacy"
72- ? "Starter"
73- : validPlan } { " " }
74- Plan
71+ { validPlan === "growth_legacy" ? "Growth" : validPlan } Plan
7572 </ h3 >
7673 { validPlan . includes ( "legacy" ) && (
7774 < Badge variant = "warning" > Legacy</ Badge >
@@ -112,32 +109,57 @@ export function PlanInfoCardUI(props: {
112109
113110 { props . team . billingPlan !== "free" && (
114111 < div className = "flex items-center gap-3" >
115- < Button
116- variant = "outline"
117- size = "sm"
118- className = "gap-2 bg-background"
119- onClick = { ( ) => {
120- setIsPlanSheetOpen ( true ) ;
121- } }
112+ < ToolTipLabel
113+ label = {
114+ props . isOwnerAccount
115+ ? null
116+ : "Only team owners can change plans."
117+ }
122118 >
123- < SquarePenIcon className = "size-4 text-muted-foreground" />
124- Change Plan
125- </ Button >
119+ < div >
120+ < Button
121+ variant = "outline"
122+ size = "sm"
123+ className = "gap-2 bg-background"
124+ onClick = { ( ) => {
125+ setIsPlanSheetOpen ( true ) ;
126+ } }
127+ disabled = { ! props . isOwnerAccount }
128+ >
129+ < SquarePenIcon className = "size-4 text-muted-foreground" />
130+ Change Plan
131+ </ Button >
132+ </ div >
133+ </ ToolTipLabel >
126134
127- { props . team . planCancellationDate ? (
128- < RenewSubscriptionButton
129- teamId = { props . team . id }
130- getTeam = { props . getTeam }
131- />
132- ) : (
133- < CancelPlanButton
134- teamId = { props . team . id }
135- teamSlug = { props . team . slug }
136- billingStatus = { props . team . billingStatus }
137- currentPlan = { props . team . billingPlan }
138- getTeam = { props . getTeam }
139- />
140- ) }
135+ < ToolTipLabel
136+ label = {
137+ props . isOwnerAccount
138+ ? null
139+ : props . team . planCancellationDate
140+ ? "Only team owners can renew plans."
141+ : "Only team owners can cancel plans."
142+ }
143+ >
144+ < div >
145+ { props . team . planCancellationDate ? (
146+ < RenewSubscriptionButton
147+ teamId = { props . team . id }
148+ getTeam = { props . getTeam }
149+ disabled = { ! props . isOwnerAccount }
150+ />
151+ ) : (
152+ < CancelPlanButton
153+ teamId = { props . team . id }
154+ teamSlug = { props . team . slug }
155+ billingStatus = { props . team . billingStatus }
156+ currentPlan = { props . team . billingPlan }
157+ getTeam = { props . getTeam }
158+ disabled = { ! props . isOwnerAccount }
159+ />
160+ ) }
161+ </ div >
162+ </ ToolTipLabel >
141163 </ div >
142164 ) }
143165 </ div >
@@ -153,16 +175,28 @@ export function PlanInfoCardUI(props: {
153175 To unlock additional usage, upgrade your plan to Starter or
154176 Growth.
155177 </ p >
178+
156179 < div className = "mt-4" >
157- < Button
158- variant = "default"
159- size = "sm"
160- onClick = { ( ) => {
161- setIsPlanSheetOpen ( true ) ;
162- } }
180+ < ToolTipLabel
181+ label = {
182+ props . isOwnerAccount
183+ ? null
184+ : "Only team owners can change plans."
185+ }
163186 >
164- Select a plan
165- </ Button >
187+ < div >
188+ < Button
189+ disabled = { ! props . isOwnerAccount }
190+ variant = "default"
191+ size = "sm"
192+ onClick = { ( ) => {
193+ setIsPlanSheetOpen ( true ) ;
194+ } }
195+ >
196+ Select a plan
197+ </ Button >
198+ </ div >
199+ </ ToolTipLabel >
166200 </ div >
167201 </ div >
168202 ) : (
@@ -203,17 +237,28 @@ export function PlanInfoCardUI(props: {
203237 </ Button >
204238
205239 { /* manage team billing */ }
206- < BillingPortalButton
207- teamSlug = { team . slug }
208- buttonProps = { {
209- variant : "outline" ,
210- size : "sm" ,
211- className : "bg-background gap-2" ,
212- } }
240+ < ToolTipLabel
241+ label = {
242+ props . isOwnerAccount
243+ ? null
244+ : "Only team owners can manage billing."
245+ }
213246 >
214- < CreditCardIcon className = "size-4 text-muted-foreground" />
215- Manage Billing
216- </ BillingPortalButton >
247+ < div >
248+ < BillingPortalButton
249+ teamSlug = { team . slug }
250+ buttonProps = { {
251+ variant : "outline" ,
252+ size : "sm" ,
253+ className : "bg-background gap-2" ,
254+ disabled : ! props . isOwnerAccount ,
255+ } }
256+ >
257+ < CreditCardIcon className = "size-4 text-muted-foreground" />
258+ Manage Billing
259+ </ BillingPortalButton >
260+ </ div >
261+ </ ToolTipLabel >
217262 </ div >
218263 </ div >
219264 ) }
0 commit comments