( subscriptionData: Partial<SubscriptionData> | null | undefined )
| 42 | } |
| 43 | |
| 44 | export function getSubscriptionAccessState( |
| 45 | subscriptionData: Partial<SubscriptionData> | null | undefined |
| 46 | ) { |
| 47 | const status = getSubscriptionStatus(subscriptionData) |
| 48 | const billingBlocked = Boolean(subscriptionData?.billingBlocked) |
| 49 | const hasUsablePaidAccess = hasUsableSubscriptionAccess(status.status, billingBlocked) |
| 50 | // Team-management features (invitations, seats, roles) are available on |
| 51 | // any paid subscription attached to an organization — including `pro_*` |
| 52 | // plans that have been transferred to an org. Plan-name gating would |
| 53 | // miss those. |
| 54 | const hasUsableTeamAccess = |
| 55 | hasUsablePaidAccess && (status.isOrgScoped || status.isTeam || status.isEnterprise) |
| 56 | const hasUsableEnterpriseAccess = hasUsablePaidAccess && status.isEnterprise |
| 57 | const hasUsableMaxAccess = |
| 58 | hasUsablePaidAccess && (getPlanTierCredits(status.plan) >= 25000 || isEnterprise(status.plan)) |
| 59 | |
| 60 | return { |
| 61 | ...status, |
| 62 | billingBlocked, |
| 63 | hasUsablePaidAccess, |
| 64 | hasUsableTeamAccess, |
| 65 | hasUsableEnterpriseAccess, |
| 66 | hasUsableMaxAccess, |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Get usage data from subscription data |
no test coverage detected