diff --git a/src/locales/en.json b/src/locales/en.json index c2cebf0..fc1268a 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -713,6 +713,7 @@ "starsPaymentSuccessCheckHistory": "Payment successful! Check history or Telegram for the result.", "starsPaymentFailed": "Payment failed. Please try again.", "starsPaymentRedirected": "Telegram will open for payment. Refresh the page after payment.", + "starsNotAvailable": "Star payments are currently unavailable. Contact support.", "youWon": "You won", "noPrize": "No luck this time...", "noHistory": "No spin history yet", diff --git a/src/locales/fa.json b/src/locales/fa.json index 83a82c4..5a92e26 100644 --- a/src/locales/fa.json +++ b/src/locales/fa.json @@ -599,6 +599,7 @@ "starsPaymentSuccess": "پرداخت موفق! نتیجه به تلگرام ارسال شد.", "starsPaymentFailed": "پرداخت ناموفق. دوباره تلاش کنید.", "starsPaymentRedirected": "تلگرام برای پرداخت باز می‌شود. پس از پرداخت صفحه را بازخوانی کنید.", + "starsNotAvailable": "پرداخت با ستاره در حال حاضر در دسترس نیست. با پشتیبانی تماس بگیرید.", "noHistory": "هنوز تاریخچه‌ای نیست", "banner": { "title": "شانس خود را امتحان کنید!", diff --git a/src/locales/ru.json b/src/locales/ru.json index 0e7fa9a..7c83bda 100644 --- a/src/locales/ru.json +++ b/src/locales/ru.json @@ -741,6 +741,7 @@ "starsPaymentSuccessCheckHistory": "Оплата прошла! Проверьте историю или Telegram для результата.", "starsPaymentFailed": "Ошибка оплаты. Попробуйте еще раз.", "starsPaymentRedirected": "Откроется Telegram для оплаты. После оплаты обновите страницу.", + "starsNotAvailable": "Оплата звёздами сейчас недоступна. Обратитесь в поддержку.", "youWon": "Вы выиграли", "noPrize": "В этот раз не повезло...", "noHistory": "История вращений пуста", diff --git a/src/locales/zh.json b/src/locales/zh.json index bc5c0a2..97cd77a 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -603,6 +603,7 @@ "starsPaymentSuccess": "支付成功!抽奖结果已发送到Telegram。", "starsPaymentFailed": "支付失败。请重试。", "starsPaymentRedirected": "将打开Telegram进行支付。支付后请刷新页面。", + "starsNotAvailable": "星星支付暂不可用。请联系客服。", "noHistory": "暂无抽奖记录", "banner": { "title": "试试运气!", diff --git a/src/pages/Wheel.tsx b/src/pages/Wheel.tsx index 5a70cc6..1d96092 100644 --- a/src/pages/Wheel.tsx +++ b/src/pages/Wheel.tsx @@ -5,8 +5,8 @@ import { wheelApi, type SpinResult, type SpinHistoryItem } from '../api/wheel'; import FortuneWheel from '../components/wheel/FortuneWheel'; import WheelLegend from '../components/wheel/WheelLegend'; import InsufficientBalancePrompt from '../components/InsufficientBalancePrompt'; -import { useCurrency } from '../hooks/useCurrency'; import { usePlatform, useHaptic } from '@/platform'; +import { useNotify } from '@/platform/hooks/useNotify'; import { Card } from '@/components/data-display/Card/Card'; import { Button } from '@/components/primitives/Button/Button'; import { motion, AnimatePresence } from 'framer-motion'; @@ -60,9 +60,9 @@ const ChevronIcon = ({ expanded }: { expanded: boolean }) => ( export default function Wheel() { const { t } = useTranslation(); const queryClient = useQueryClient(); - const { formatAmount, currencySymbol } = useCurrency(); - const { platform, openInvoice, capabilities } = usePlatform(); + const { openInvoice, capabilities } = usePlatform(); const haptic = useHaptic(); + const notify = useNotify(); const [isSpinning, setIsSpinning] = useState(false); const [targetRotation, setTargetRotation] = useState(null); @@ -74,9 +74,6 @@ export default function Wheel() { const [historyExpanded, setHistoryExpanded] = useState(false); const paymentTypeInitialized = useRef(false); - // Check if we're in Telegram Mini App environment - const isTelegramMiniApp = platform === 'telegram'; - const { data: config, isLoading, @@ -98,25 +95,13 @@ export default function Wheel() { 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 stars if available - if (starsEnabled) { - setPaymentType('telegram_stars'); - } else 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'); - } + if (starsEnabled) { + setPaymentType('telegram_stars'); + } else if (daysEnabled) { + setPaymentType('subscription_days'); } - }, [config, isTelegramMiniApp]); + }, [config]); // Function to poll for new spin result after Stars payment const pollForSpinResult = useCallback( @@ -362,7 +347,11 @@ export default function Wheel() { }; const handleUnifiedSpin = () => { - if (isTelegramMiniApp && paymentType === 'telegram_stars') { + if (paymentType === 'telegram_stars') { + if (!config?.spin_cost_stars_enabled || !config?.spin_cost_stars) { + notify.warning(t('wheel.starsNotAvailable')); + return; + } handleDirectStarsPay(); } else { handleSpin(); @@ -456,11 +445,7 @@ export default function Wheel() { 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; // For web: pay with internal balance - const canPayDays = daysEnabled && config.can_pay_days; - const bothMethodsAvailable = isTelegramMiniApp - ? starsEnabled && daysEnabled && canPayDays - : starsEnabled && daysEnabled && canPayBalance && canPayDays; + const bothMethodsAvailable = !!(starsEnabled && daysEnabled); const spinDisabled = !config.can_spin || @@ -472,10 +457,7 @@ export default function Wheel() { const getCostSubtitle = () => { if (bothMethodsAvailable) return null; // toggle handles it if (paymentType === 'telegram_stars' && starsEnabled) { - if (isTelegramMiniApp) { - return `${config.spin_cost_stars} ⭐`; - } - return `${formatAmount(config.required_balance_kopeks / 100)} ${currencySymbol} (${config.spin_cost_stars} ⭐)`; + return `${config.spin_cost_stars} ⭐`; } if (paymentType === 'subscription_days' && daysEnabled) { return t('wheel.days', { count: config.spin_cost_days ?? 0 }); @@ -529,9 +511,7 @@ export default function Wheel() { }`} > - {isTelegramMiniApp - ? `${config.spin_cost_stars} ⭐` - : `${formatAmount(config.required_balance_kopeks / 100)} ${currencySymbol}`} + {`${config.spin_cost_stars} ⭐`}