Line data Source code
1 : import type {
2 : BillingCycle,
3 : SubscriptionCheckoutTier
4 : } from '@comfyorg/account-core/billing'
5 :
6 : import { toTierKey } from '@/platform/billing/subscription/constants/tierPricing'
7 : import type {
8 : SubscriptionDuration,
9 : SubscriptionTier
10 : } from '@comfyorg/billing-core'
11 :
12 : /** The plan a customer is on, in the telemetry vocabulary; absent when it names none. */
13 0 : export function toCurrentTier(
14 : tier: SubscriptionTier | null | undefined
15 : ): SubscriptionCheckoutTier | undefined {
16 0 : if (tier === 'TEAM') return 'team'
17 0 : return (tier && toTierKey(tier)) || undefined
18 : }
19 :
20 0 : export function toBillingCycle(
21 : duration: SubscriptionDuration | null | undefined
22 : ): BillingCycle | undefined {
23 0 : if (!duration) return undefined
24 0 : return duration === 'ANNUAL' ? 'yearly' : 'monthly'
25 : }
|