Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/platform/cloud/subscription/components/PricingTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,13 @@ import {
FirebaseAuthStoreError,
useFirebaseAuthStore
} from '@/stores/firebaseAuthStore'
import type { components } from '@/types/comfyRegistryTypes'
import type { components, operations } from '@/types/comfyRegistryTypes'

type SubscriptionTier = components['schemas']['SubscriptionTier']
type TierKey = 'standard' | 'creator' | 'pro'
type CheckoutTier = TierKey | `${TierKey}-yearly`
type CheckoutResponse =
operations['createCloudSubscriptionCheckoutTier']['responses']['201']['content']['application/json']

type BillingCycle = 'monthly' | 'yearly'

Expand Down Expand Up @@ -391,7 +393,9 @@ const getAnnualTotal = (tier: PricingTierConfig): number =>
const getCreditsDisplay = (tier: PricingTierConfig): number =>
tier.pricing.credits * (currentBillingCycle.value === 'yearly' ? 12 : 1)

const initiateCheckout = async (tierKey: TierKey) => {
const initiateCheckout = async (
tierKey: TierKey
): Promise<CheckoutResponse> => {
const authHeader = await getAuthHeader()
if (!authHeader) {
throw new FirebaseAuthStoreError(t('toastMessages.userNotAuthenticated'))
Expand Down Expand Up @@ -429,7 +433,7 @@ const initiateCheckout = async (tierKey: TierKey) => {
)
}

return await response.json()
return (await response.json()) as CheckoutResponse
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note for other reviewers: it would actually be somewhat bad to do runtime validation here if we ever believe this code is going to run on local - because it would prevent us from changing the API in a functionally backwards-compatible way (but not strictly same type) in the future.

}

const handleSubscribe = wrapWithErrorHandlingAsync(async (tierKey: TierKey) => {
Expand Down
Loading