From 8753000a034d22f2997b9b9f9573f583928097c5 Mon Sep 17 00:00:00 2001 From: PEDZEO Date: Tue, 20 Jan 2026 00:13:11 +0300 Subject: [PATCH] Add Telegram WebApp support: initialize app, enhance layout with fullscreen toggle, and improve polling mechanism in Wheel component --- src/components/layout/Layout.tsx | 28 ++++++++ src/hooks/useTelegramWebApp.ts | 113 +++++++++++++++++++++++++++++++ src/main.tsx | 4 ++ src/pages/Wheel.tsx | 62 ++++++++++++----- src/styles/globals.css | 5 ++ src/vite-env.d.ts | 23 +++++++ 6 files changed, 219 insertions(+), 16 deletions(-) create mode 100644 src/hooks/useTelegramWebApp.ts diff --git a/src/components/layout/Layout.tsx b/src/components/layout/Layout.tsx index 3c242ed..e7af97f 100644 --- a/src/components/layout/Layout.tsx +++ b/src/components/layout/Layout.tsx @@ -14,6 +14,7 @@ import { wheelApi } from '../../api/wheel' import { themeColorsApi } from '../../api/themeColors' import { promoApi } from '../../api/promo' import { useTheme } from '../../hooks/useTheme' +import { useTelegramWebApp } from '../../hooks/useTelegramWebApp' // Fallback branding from environment variables const FALLBACK_NAME = import.meta.env.VITE_APP_NAME || 'Cabinet' @@ -122,6 +123,18 @@ const WheelIcon = () => ( ) +const FullscreenIcon = () => ( + + + +) + +const ExitFullscreenIcon = () => ( + + + +) + export default function Layout({ children }: LayoutProps) { const { t } = useTranslation() const location = useLocation() @@ -129,6 +142,7 @@ export default function Layout({ children }: LayoutProps) { const [mobileMenuOpen, setMobileMenuOpen] = useState(false) const { toggleTheme, isDark } = useTheme() const [userPhotoUrl, setUserPhotoUrl] = useState(null) + const { isTelegramWebApp, isFullscreen, isFullscreenSupported, toggleFullscreen } = useTelegramWebApp() // Fetch enabled themes from API - same source of truth as AdminSettings const { data: enabledThemes } = useQuery({ @@ -352,6 +366,20 @@ export default function Layout({ children }: LayoutProps) { {/* Right side */}
+ {/* Fullscreen toggle - only show in Telegram WebApp */} + {isTelegramWebApp && isFullscreenSupported && ( + + )} + {/* Theme toggle button - only show if both themes are enabled */} {canToggle && (