Line data Source code
1 : import type { SubscriptionState } from '@comfyorg/ingest-types'
2 :
3 : import type { SubscriptionDialogOptions } from '@/platform/billing/composables/types'
4 : import { pendingServerFact } from '@/platform/serverFacts/pendingServerFact'
5 :
6 : /** Subscribe to Run paywall options; flags locked credits for a funded account with no plan. */
7 0 : export function subscribeToRunDialogOptions(facts: {
8 : subscriptionState: SubscriptionState | null
9 : hasFunds: boolean | undefined
10 : }): SubscriptionDialogOptions {
11 : const creditsLocked = pendingServerFact(
12 : 'BE-24447',
13 : facts.hasFunds === true &&
14 : (facts.subscriptionState === 'never_subscribed' ||
15 : facts.subscriptionState === 'ended')
16 : )
17 0 : return {
18 : reason: 'subscribe_to_run',
19 : ...(creditsLocked && { creditsLocked: true })
20 : }
21 : }
|