Update Wheel.tsx

This commit is contained in:
Egor
2026-01-15 19:36:46 +03:00
committed by GitHub
parent 32d240a202
commit 92f29db60f

View File

@@ -72,6 +72,30 @@ export default function Wheel() {
enabled: showHistory, enabled: showHistory,
}) })
// Auto-select payment type based on availability
useEffect(() => {
if (!config) return
const starsEnabled = config.spin_cost_stars_enabled && config.spin_cost_stars
const daysEnabled = config.spin_cost_days_enabled && config.spin_cost_days
const canPayBalance = starsEnabled && config.can_pay_stars
const canPayDays = daysEnabled && config.can_pay_days
if (isTelegramMiniApp) {
// In Mini App: prefer days if available, Stars payment is separate button
if (canPayDays) {
setPaymentType('subscription_days')
}
} else {
// In Web: prefer balance (Stars converted to rubles), fallback to days
if (canPayBalance) {
setPaymentType('telegram_stars')
} else if (canPayDays) {
setPaymentType('subscription_days')
}
}
}, [config, isTelegramMiniApp])
// Function to poll for new spin result after Stars payment // Function to poll for new spin result after Stars payment
const pollForSpinResult = useCallback(async (maxAttempts = 15, delayMs = 800) => { const pollForSpinResult = useCallback(async (maxAttempts = 15, delayMs = 800) => {
// Wait a bit before first poll to give the bot time to process the payment // Wait a bit before first poll to give the bot time to process the payment
@@ -368,23 +392,6 @@ export default function Wheel() {
const canPayBalance = starsEnabled && config.can_pay_stars // For web: pay with internal balance const canPayBalance = starsEnabled && config.can_pay_stars // For web: pay with internal balance
const canPayDays = daysEnabled && config.can_pay_days const canPayDays = daysEnabled && config.can_pay_days
// Auto-select payment type based on availability
useEffect(() => {
if (isTelegramMiniApp) {
// In Mini App: prefer days if available, Stars payment is separate button
if (canPayDays) {
setPaymentType('subscription_days')
}
} else {
// In Web: prefer balance (Stars converted to rubles), fallback to days
if (canPayBalance) {
setPaymentType('telegram_stars')
} else if (canPayDays) {
setPaymentType('subscription_days')
}
}
}, [canPayBalance, canPayDays, isTelegramMiniApp])
return ( return (
<div className="animate-fade-in pb-8"> <div className="animate-fade-in pb-8">
{/* Hero Header */} {/* Hero Header */}