Merge pull request #69 from BEDOLAGA-DEV/dev

Dev
This commit is contained in:
Egor
2026-01-21 05:36:25 +03:00
committed by GitHub
6 changed files with 55 additions and 7 deletions

View File

@@ -13,6 +13,7 @@ import { brandingApi, getCachedBranding, setCachedBranding, preloadLogo } from '
import { wheelApi } from '../../api/wheel'
import { themeColorsApi } from '../../api/themeColors'
import { promoApi } from '../../api/promo'
import { referralApi } from '../../api/referral'
import { useTheme } from '../../hooks/useTheme'
import { useTelegramWebApp } from '../../hooks/useTelegramWebApp'
import { usePullToRefresh } from '../../hooks/usePullToRefresh'
@@ -295,6 +296,15 @@ export default function Layout({ children }: LayoutProps) {
retry: false,
})
// Fetch referral terms to check if enabled
const { data: referralTerms } = useQuery({
queryKey: ['referral-terms'],
queryFn: referralApi.getReferralTerms,
enabled: isAuthenticated,
staleTime: 60000, // 1 minute
retry: false,
})
// Fetch active discount to determine mobile layout
const { data: activeDiscount } = useQuery({
queryKey: ['active-discount'],
@@ -311,10 +321,15 @@ export default function Layout({ children }: LayoutProps) {
{ path: '/', label: t('nav.dashboard'), icon: HomeIcon },
{ path: '/subscription', label: t('nav.subscription'), icon: SubscriptionIcon },
{ path: '/balance', label: t('nav.balance'), icon: WalletIcon },
{ path: '/referral', label: t('nav.referral'), icon: UsersIcon },
{ path: '/support', label: t('nav.support'), icon: ChatIcon },
]
// Only show referral if program is enabled
if (referralTerms?.is_enabled) {
items.push({ path: '/referral', label: t('nav.referral'), icon: UsersIcon })
}
items.push({ path: '/support', label: t('nav.support'), icon: ChatIcon })
// Only show contests if there are available contests
if (contestsCount && contestsCount.count > 0) {
items.push({ path: '/contests', label: t('nav.contests'), icon: GamepadIcon })
@@ -328,7 +343,7 @@ export default function Layout({ children }: LayoutProps) {
items.push({ path: '/info', label: t('nav.info'), icon: InfoIcon })
return items
}, [t, contestsCount, pollsCount])
}, [t, contestsCount, pollsCount, referralTerms])
// Separate navItems for desktop that includes wheel (if enabled)
const desktopNavItems = useMemo(() => {

View File

@@ -384,7 +384,8 @@
"referral_first_payment": "Referral First Payment",
"referral_subscription_renewal": "Referral Subscription Renewal",
"referral_bonus": "Referral Bonus"
}
},
"disabled": "Referral program is currently disabled"
},
"support": {
"title": "Support",

View File

@@ -272,7 +272,8 @@
"referral_first_payment": "اولین پرداخت کاربر معرفی‌شده",
"referral_subscription_renewal": "تمدید اشتراک کاربر معرفی‌شده",
"referral_bonus": "پاداش کاربر معرفی‌شده"
}
},
"disabled": "برنامه معرفی موقتاً غیرفعال است"
},
"support": {
"title": "پشتیبانی",

View File

@@ -384,7 +384,8 @@
"referral_first_payment": "Первая оплата реферала",
"referral_subscription_renewal": "Продление подписки реферала",
"referral_bonus": "Бонус за реферала"
}
},
"disabled": "Реферальная программа временно отключена"
},
"support": {
"title": "Поддержка",

View File

@@ -273,7 +273,8 @@
"referral_first_payment": "推荐用户首次付款",
"referral_subscription_renewal": "推荐用户续订",
"referral_bonus": "推荐奖金"
}
},
"disabled": "推荐计划暂时停用"
},
"support": {
"title": "支持",

View File

@@ -137,6 +137,35 @@ export default function Referral() {
)
}
// Show disabled state if referral program is disabled
if (terms && !terms.is_enabled) {
return (
<div className='flex flex-col items-center justify-center min-h-[60vh] gap-6'>
<div className='w-24 h-24 rounded-full bg-dark-800 flex items-center justify-center'>
<svg
className='w-12 h-12 text-dark-500'
fill='none'
viewBox='0 0 24 24'
stroke='currentColor'
strokeWidth={1.5}
>
<path
strokeLinecap='round'
strokeLinejoin='round'
d='M15 19.128a9.38 9.38 0 002.625.372 9.337 9.337 0 004.121-.952 4.125 4.125 0 00-7.533-2.493M15 19.128v-.003c0-1.113-.285-2.16-.786-3.07M15 19.128v.106A12.318 12.318 0 018.624 21c-2.331 0-4.512-.645-6.374-1.766l-.001-.109a6.375 6.375 0 0111.964-3.07M12 6.375a3.375 3.375 0 11-6.75 0 3.375 3.375 0 016.75 0zm8.25 2.25a2.625 2.625 0 11-5.25 0 2.625 2.625 0 015.25 0z'
/>
</svg>
</div>
<div className='text-center'>
<h1 className='text-2xl font-bold text-dark-100 mb-2'>
{t('referral.title')}
</h1>
<p className='text-dark-400'>{t('referral.disabled')}</p>
</div>
</div>
)
}
return (
<div className='space-y-6'>
<h1 className='text-2xl sm:text-3xl font-bold text-dark-50'>