fix: bug
This commit is contained in:
@@ -2,18 +2,23 @@ import { useState, useEffect, useMemo } from 'react'
|
||||
import { Linking, Alert } from 'react-native'
|
||||
|
||||
import { subscription, useSession } from '@/lib/auth'
|
||||
import type { SubscriptionListItem } from '@/lib/auth'
|
||||
import type { StripePricingTableResponse, SubscriptionListItem } from '@/lib/auth'
|
||||
|
||||
interface CreditPlan {
|
||||
amountInCents: number
|
||||
credits: number
|
||||
popular?: boolean
|
||||
name: string
|
||||
currency: string
|
||||
featureList: string[]
|
||||
}
|
||||
|
||||
|
||||
|
||||
export function useMembership() {
|
||||
const { data: session } = useSession()
|
||||
const [selectedPlanIndex, setSelectedPlanIndex] = useState(0)
|
||||
const [stripePricingData, setStripePricingData] = useState<any>(null)
|
||||
const [stripePricingData, setStripePricingData] = useState<StripePricingTableResponse>(null)
|
||||
const [authSubscriptions, setAuthSubscriptions] = useState<any>(null)
|
||||
const [isStripePricingLoading, setIsStripePricingLoading] = useState(false)
|
||||
const [isLoadingSubscriptions, setIsLoadingSubscriptions] = useState(false)
|
||||
@@ -66,11 +71,14 @@ export function useMembership() {
|
||||
const creditPlans = useMemo((): CreditPlan[] => {
|
||||
if (!stripePricingData?.pricing_table_items) return []
|
||||
return stripePricingData.pricing_table_items
|
||||
.filter((item: any) => item.recurring?.interval === 'month')
|
||||
.map((item: any) => ({
|
||||
.filter((item) => item.recurring?.interval === 'month')
|
||||
.map((item) => ({
|
||||
amountInCents: parseInt(item.amount),
|
||||
credits: parseInt(item.metadata?.grant_token || item.amount),
|
||||
credits: parseInt(item.amount),
|
||||
popular: item.is_highlight || item.highlight_text === 'most_popular',
|
||||
name: item.name || '',
|
||||
currency: item.currency || 'usd',
|
||||
featureList: item.feature_list || [],
|
||||
}))
|
||||
}, [stripePricingData?.pricing_table_items])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user