diff --git a/app/exchange.tsx b/app/exchange.tsx index 803426e..a216ba3 100644 --- a/app/exchange.tsx +++ b/app/exchange.tsx @@ -1,3 +1,5 @@ +import { useBalance } from '@/hooks/use-balance'; +import { usePricing } from '@/hooks/use-pricing'; import Ionicons from '@expo/vector-icons/Ionicons'; import { useRouter } from 'expo-router'; import React, { useCallback, useMemo, useState } from 'react'; @@ -12,8 +14,6 @@ import { View } from 'react-native'; import { useSafeAreaInsets } from 'react-native-safe-area-context'; -import { useBalance } from '@/hooks/use-balance'; -import { usePricing } from '@/hooks/use-pricing'; type PurchaseTab = 'subscription' | 'pack'; @@ -44,19 +44,14 @@ const TABS: { key: PurchaseTab; label: string }[] = [ { key: 'pack', label: 'points pack' }, ]; -const POINT_BUNDLES: PointsBundle[] = [ - { id: 'bundle-500', points: 500, price: 35 }, - { id: 'bundle-2000', points: 2000, price: 140 }, - { id: 'bundle-5000', points: 5000, price: 350 }, - { id: 'bundle-10000', points: 10000, price: 700 }, -]; +const POINT_BUNDLES: PointsBundle[] = []; export default function PointsExchangeScreen() { const router = useRouter(); const insets = useSafeAreaInsets(); const [activeTab, setActiveTab] = useState('subscription'); const [selectedBundleId, setSelectedBundleId] = useState(null); - const [selectedSubscriptionIndex, setSelectedSubscriptionIndex] = useState(null); + const [selectedSubscriptionIndex, setSelectedSubscriptionIndex] = useState(0); const [customAmount, setCustomAmount] = useState('500'); const { balance, isLoading: isBalanceLoading, refresh } = useBalance(); @@ -139,26 +134,14 @@ export default function PointsExchangeScreen() { ] ); } else { + console.log(`自定义数量`, customAmount) // 自定义数量 const amount = parseInt(customAmount, 10); - if (isNaN(amount) || amount < 500) { + if (isNaN(amount) || amount < 0) { Alert.alert('Invalid Amount', 'Please enter a valid amount (minimum 500 points).'); return; } - - Alert.alert( - 'Confirm purchase', - `You are purchasing ${amount} points.`, - [ - { text: 'Cancel', style: 'cancel' }, - { - text: 'Confirm', - onPress: () => { - rechargeToken(amount); - }, - }, - ] - ); + rechargeToken(amount); } } }, [ @@ -369,7 +352,6 @@ export default function PointsExchangeScreen() { {/* 自定义金额输入 */} - Or enter custom amount: