Commit Graph

680 Commits

Author SHA1 Message Date
c0mrade
79afe3a733 feat: render original RemnaWave blocks on connection page
- Add RemnaWave types (RemnawaveAppClient, RemnawaveBlockClient, etc.)
- Dual rendering: RemnaWave blocks with SVG icons or legacy steps
- Platform dropdown, DOMPurify for SVG sanitization
- Button types: subscriptionLink, copyButton, external
2026-02-05 08:29:54 +03:00
c0mrade
445dd0601a feat: convert ConnectionModal to /connection page with crypto deep links
- Add @kastov/cryptohapp + jsencrypt for encrypted Happ deep links
- Add templateEngine utility to resolve {{SUBSCRIPTION_LINK}},
  {{HAPP_CRYPT3_LINK}}, {{HAPP_CRYPT4_LINK}}, {{USERNAME}} templates
- Convert ConnectionModal component into a standalone Connection page
- Add /connection route with ProtectedRoute and lazy loading
- Replace modal invocation in Dashboard and Subscription with
  navigate('/connection')
- Add type and svgIconKey optional fields to RemnawaveButton
- Show button type badge and SVG icon in AdminApps BlockCard
- Refactor ThemeTab to use local draft state with Save/Cancel flow
2026-02-05 07:33:45 +03:00
Fringg
998f9dbaf0 feat(subscription): auto-skip server selection step when only one available
- Add getAvailableServers helper to filter available servers
- Skip servers step in purchase wizard when only 1 server available
- Auto-select the single server on options load and period change
- Works for both new purchases and renewals in classic mode
2026-02-05 07:32:28 +03:00
Fringg
46b93ef098 fix(subscription): display promo group discounts in device/traffic purchase and tariff switch
- Add discount fields to TrafficPackage and TariffSwitchPreview types
- Show strikethrough original price and discount badge for device purchase
- Show discount badge and original price for traffic packages
- Show discount info and free label for tariff switch with 100% discount
2026-02-05 06:26:27 +03:00
c0mrade
8068f84724 fix: inline Stars confirmation and unified payment type display
- Replace confirm dialog with inline UI panel to avoid browser popup
  blockers — pay button click is a direct user gesture
- Pre-open browser window synchronously on pay click for fallback
- Unify payment type display: show same styled panel whether one or
  both methods are enabled (single method = full-width button)
- Remove getCostSubtitle text, add payStars translation key (ru, en,
  zh, fa)
2026-02-04 16:53:58 +03:00
c0mrade
e6f8ae6ab0 feat: add Stars payment confirmation and admin validation
- Show confirmation dialog before redirecting to Telegram for Stars
  payment (native popup in Mini App, confirm in browser)
- Warn admin when saving wheel config with Stars enabled but
  Telegram Stars payment method is disabled globally
- Add translation keys: confirmStarsTitle, confirmStarsPayment,
  starsNotEnabledGlobally (ru, en, zh, fa)
2026-02-04 16:41:25 +03:00
c0mrade
02640d1c38 fix: unify wheel Stars payment across desktop and mobile
- Use Telegram Stars invoice on all platforms instead of balance
  payment on desktop
- Show star cost in toggle and subtitle everywhere
- Show popup/toast when Stars are not enabled and user tries to spin
- Remove platform-specific payment type auto-select logic
- Add starsNotAvailable translation key (ru, en, zh, fa)
2026-02-04 16:26:07 +03:00
c0mrade
4499c9ad57 fix: prevent payment type reset after wheel spin
The auto-select useEffect for payment type (days/stars) was running
on every config refetch, resetting the user's manual selection back
to stars. Now it only runs once on initial load using a ref flag.
2026-02-04 16:09:10 +03:00
c0mrade
59a251cb8c fix: update Aurora colors reactively without recreating WebGL context
Split the monolithic useEffect into two: one for WebGL init (depends
only on isEnabled) and one for updating color uniforms (depends on
theme colors). Previously the entire WebGL context was torn down and
rebuilt on every color change, causing updates to not apply until
page refresh or navigation.
2026-02-04 16:00:05 +03:00
c0mrade
3a042473f0 refactor: unify ColorPicker — remove native input, fix scroll closing
- Remove native <input type="color">, eyedropper button, colorInputRef,
  isTelegram check and isInTelegramWebApp import from ColorPicker
- Remove scroll event listener so picker only closes on click/tap outside
- Replace native color input in AdminWheel InlinePrizeForm with ColorPicker
2026-02-04 15:40:30 +03:00
c0mrade
bb32cd8757 fix: dim accent color for background blobs
CSS wave-blobs now use accent-800 instead of accent-500 for a subdued
background glow. Aurora WebGL shader receives a darkened accent (45%
brightness) so bright accent colors like #e85002 no longer produce
overly intense background blobs while button colors stay unchanged.
2026-02-04 14:51:12 +03:00
c0mrade
576893f5c6 feat: replace payment modals with page-based navigation
- Add /balance/top-up route for payment method selection
- Add /balance/top-up/:methodId route for amount entry and payment
- Remove TopUpModal component (619 lines)
- Simplify InsufficientBalancePrompt to use navigate instead of modals
- Support ?amount and ?returnTo query params for cross-page data flow
- Fix nav isActive to highlight Balance on sub-routes
- Remove unused MainButton platform abstraction
- Increase toast accent opacity for better visibility
2026-02-04 14:36:16 +03:00
c0mrade
ecd912b16a fix: use dynamic champagne variables for light theme palette swap
Replace hardcoded RGB values with var(--color-champagne-*) references
so the light theme respects admin-configured colors (background, surface,
text). Add !important to override inline styles from applyThemeColors.
Update card/glass/input/button overrides to use champagne-50 (dynamic
surface color) instead of hardcoded white.
2026-02-04 13:10:27 +03:00
c0mrade
9ac00c94a6 fix: replace individual light theme overrides with CSS variable swap
Instead of manually overriding each bg-dark-*/border-dark-* opacity
variant with !important rules, swap the entire dark palette CSS
variables to champagne equivalents in .light scope. This automatically
handles all opacity variants, hover states, borders across all pages
without needing individual class overrides for each combination.
2026-02-04 12:58:52 +03:00
c0mrade
a91e055597 fix: use theme surface and background colors for Aurora animation
Instead of generating color stops from accent at fixed intensities,
use the actual background, surface and accent colors from theme settings.
This ensures Aurora properly adapts to both dark and light themes.
2026-02-04 12:39:44 +03:00
c0mrade
bf00d37b4a fix: add theme toggle to desktop header and sync theme across components
Add sun/moon toggle button to the desktop navigation bar so theme
switching is available in web version. Sync theme state across multiple
useTheme() instances via custom DOM event to avoid requiring page reload.
2026-02-04 12:31:32 +03:00
c0mrade
c1dc019c8b fix: Aurora animation ignoring light theme background color
Aurora WebGL всегда использовала darkBackground для color stops,
при переключении на светлую тему фон анимации оставался тёмным.

Добавлен useTheme() для реактивного определения текущей темы,
background выбирается между darkBackground и lightBackground.
2026-02-04 12:14:44 +03:00
c0mrade
bcbda17220 fix: add HMR guard to prevent ConcurrentCallError on SDK double-init
При HMR Vite перевыполняет main.tsx, вызывая повторный init() и mount*()
компонентов SDK. mountThemeParams() и другие бросают ConcurrentCallError
асинхронно, что не ловится синхронным try/catch.

Решение: флаг на window.__tg_sdk_initialized предотвращает повторную
инициализацию при горячей перезагрузке модуля.
2026-02-04 11:25:10 +03:00
c0mrade
61e3910981 fix: resolve SDK v3 mount errors, back button and fullscreen not working
- Обернуть каждый mount-вызов в safeMountSync() для защиты от
  ConcurrentCallError при HMR/повторной инициализации
- Перенести requestFullscreen() внутрь mountViewport().then() — fullscreen
  требует смонтированный viewport, ранее вызывался через dynamic import
  с setTimeout до завершения mount
- Стабилизировать обработчик BackButton через useRef + useCallback —
  navigate меняется каждый рендер, что вызывало постоянную
  пере-подписку и потерю обработчика
2026-02-04 11:18:49 +03:00
c0mrade
023c3ef6b3 refactor: migrate to @telegram-apps/sdk-react v3, remove all window.Telegram.WebApp usage
Полный переход с нативного window.Telegram.WebApp API на @telegram-apps/sdk-react v3.
Bridge SDK оборачивал receiveEvent, из-за чего popup_closed не доходил до нативного
обработчика — это было основной причиной бага с двойным открытием попапа.

Изменения:

- Удалён @telegram-apps/react-router-integration (привязан к SDK v1)
- Инициализация SDK v3 в main.tsx: init(), restoreInitData(), mount всех компонентов
- AppWithNavigator: убран TelegramRouter (initNavigator + useIntegration), все платформы
  на BrowserRouter, добавлен TelegramBackButton через SDK v3
- useTelegramSDK: детекция через retrieveLaunchParams(), реактивные значения через
  useSignal() (fullscreen, viewport, safe area insets), initData через retrieveRawInitData()
- TelegramAdapter: полная перезапись — попапы через showPopup() (Promise-based, без
  ручного onEvent/offEvent/timeout), кнопки через setMainButtonParams/showBackButton,
  haptic через hapticFeedbackImpactOccurred, тема через themeParamsState с конвертацией
  camelCase→snake_case, cloud storage через getCloudStorageItem/setCloudStorageItem
- api/client.ts: initData через retrieveRawInitData() вместо window.Telegram.WebApp.initData
- AppHeader: фото пользователя через initDataUser() сигнал
- ConnectionModal: openLink через SDK вместо window.Telegram.WebApp.openLink
- ColorPicker: детекция Telegram через isInTelegramWebApp()
- Удалён интерфейс TelegramWebApp (368 строк) и Window augmentation из vite-env.d.ts
- Убрано поле telegram из PlatformContext в types.ts
- Обновлён manualChunks в vite.config.ts
2026-02-04 11:06:59 +03:00
c0mrade
2d00a5c21f fix: prevent popup cascade when Telegram callback doesn't fire
- Add persistent popupClosed listener that resets state even after
  per-call listener is removed by timeout
- Increase safety timeout from 5s to 30s to give user time to interact
- On WebAppPopupOpened error, keep popupOpen=true to block retries
  instead of resetting and allowing infinite error loop
- Remove callback param from showPopup to avoid dual-listener conflicts
- Remove debug console logs
2026-02-04 10:10:07 +03:00
c0mrade
9284eca810 debug: add console logging to Telegram popup flow
Trace showPopup lifecycle (open, callback, popupClosed event,
timeout) to diagnose why popup action doesn't execute and
subsequent calls fail. Reduce safety timeout to 5s for faster
debugging.
2026-02-04 09:56:46 +03:00
c0mrade
7ac7db4ddb fix: add fallback recovery for Telegram popup callback not firing
Listen for popupClosed event as backup and add safety timeout
to handle Telegram Desktop bug where popup_closed payload is
undefined, preventing the callback from being invoked and
leaving popup state permanently locked.
2026-02-04 09:45:57 +03:00
c0mrade
792fb1ed8a fix: get fresh Telegram WebApp reference on each popup call
Telegram may reinitialize window.Telegram.WebApp after app startup,
making cached references stale. Get a fresh reference inside
showPopupSafe to ensure the callback is registered on the current
WebApp instance.
2026-02-04 09:27:04 +03:00
c0mrade
ef77276246 fix: use direct dialog.popup call instead of useDestructiveConfirm
Avoid async/await hook chain that could lose the popup callback.
Call dialog.popup().then() directly from usePlatform for reliability.
2026-02-04 09:20:49 +03:00
c0mrade
71647ebc87 fix: prevent duplicate Telegram popup opening
Add popup guard in TelegramAdapter DialogController to prevent
"Popup is already opened" error. Migrate PromoOffersSection from
direct showPopup call to useDestructiveConfirm hook.
2026-02-04 08:54:23 +03:00
c0mrade
ecfb86ce16 Merge main branch updates 2026-02-04 07:18:53 +03:00
c0mrade
483f3f4d0f Migrate to Telegram Navigator integration
Replace manual BackButton management with official @telegram-apps/react-router-integration
to fix navigation issues (back button cycling and double-click).

Changes:
- Migrate from @tma.js/sdk-react to @telegram-apps/sdk-react
- Downgrade react-router-dom to v6 for package compatibility
- Add AppWithNavigator component with Telegram navigator integration
- Use browser history mode (hashMode: null) to prevent hash URLs
- Add multi-level platform detection (user data, platform, version)
- Add try-catch error handling for navigator attach/detach
- Simplify useBackButton hook to no-op (navigator handles automatically)
- Update vite config with new Telegram packages

The navigator automatically manages BackButton based on router history,
falling back to BrowserRouter in regular browser environment.
2026-02-04 07:18:43 +03:00
c0mrade
482bdd0b0d Remove replace flag from back button navigation to fix double-click issue
Fixed issue where users had to click the Telegram Mini App back button twice
in many admin pages. The replace flag was causing conflicts between Telegram's
BackButton internal history and React Router's history management.

Updated all 32 admin pages to use simple navigate() calls without replace flag.
2026-02-04 06:11:29 +03:00
c0mrade
55e2068606 Fix back button cycling in Telegram Mini App
Add replace: true to all navigate() calls in useBackButton hooks
Prevents history cycles when navigating back and forth
All 32 admin pages now use navigate(path, { replace: true })
Back button now goes directly to parent without cycling
2026-02-04 05:59:15 +03:00
c0mrade
cb8326309c Fix promo deactivation to use correct API method
Use clearActiveDiscount instead of deactivateDiscount
Correct endpoint: DELETE /cabinet/promo/active-discount
2026-02-04 05:15:23 +03:00
c0mrade
e4b35ae0ad Merge main branch changes 2026-02-04 05:03:21 +03:00
c0mrade
e948cdc8d2 Complete back button logic for all admin pages in Telegram Mini App
Main sections navigate to /admin (15 pages)
Detail/edit pages navigate to parent lists (16 pages)
All pages use useBackButton hook with proper navigation paths
Native Telegram back button in Mini App, UI button on web
Email template pages keep UI-only back buttons as required
2026-02-04 05:03:06 +03:00
Egor
f89573a1f3 Update promo.ts 2026-02-04 04:56:05 +03:00
c0mrade
98d90a99c6 Use native Telegram back button in AdminPaymentMethods
Replace desktop-style back button with native Telegram BackButton API:
- Use useBackButton hook for Telegram Mini App
- Show UI back button only on web (when !capabilities.hasBackButton)
- Improves native feel in Telegram environment
2026-02-04 04:26:15 +03:00
c0mrade
b2a6b959c1 Restore drag-and-drop and add promo deactivation with Telegram popup
Payment methods drag-and-drop fixes:
- Restore original working drag-and-drop from commit 84c6d26
- Use position: relative instead of opacity for dragged items
- Remove closestCenter collision detection
- Use PointerSensor with distance: 5 without TouchSensor
- Restore touch-none and responsive padding on drag handles
- Restore original shadow and background colors

Promo deactivation feature:
- Add deactivation button to active discount banner in PromoOffersSection
- Use Telegram native popup (showPopup) in Mini App environment
- Fallback to modal for web browsers
- Add confirmation modal with warning about permanent action
- Integrate with useTelegramSDK for proper platform detection
2026-02-04 04:08:35 +03:00
c0mrade
6d5ee3856e Fix ESLint fast-refresh warnings
Refactor to resolve react-refresh/only-export-components warnings:
- Move buttonVariants export to separate file (Button.variants.ts)
- Extract WebSocketContext to dedicated context file
- Move useWebSocketContext hook to separate file
- Update imports across affected files

All component files now export only components, improving fast refresh reliability
2026-02-04 04:08:11 +03:00
c0mrade
9042603e67 Move payment method editing to separate page and fix auth error handling
- Replace modal with dedicated AdminPaymentMethodEdit page
- Add route /admin/payment-methods/:methodId/edit
- Fix 401 error handling for auth endpoints to show error messages instead of reloading page
- Update client.ts to use window.Telegram.WebApp.initData directly
- Maintain useTelegramDnd for drag and drop functionality
2026-02-04 03:39:38 +03:00
c0mrade
c8c9920ade Merge remote-tracking branch 'origin/main' into feat/linear-ui-redesign
# Conflicts:
#	src/components/PromoDiscountBadge.tsx
2026-02-04 03:25:35 +03:00
Egor
0b127a5f85 Add files via upload 2026-02-04 02:12:18 +03:00
Egor
7f5c0c83b3 Add files via upload 2026-02-04 02:10:26 +03:00
Egor
73212e508d Update PromoDiscountBadge.tsx 2026-02-04 02:10:08 +03:00
Egor
8c9b161b58 Update promo.ts 2026-02-04 02:09:31 +03:00
Egor
6c8d2ad69e Update Subscription.tsx 2026-02-04 01:17:05 +03:00
Egor
026cb47694 Update Subscription.tsx 2026-02-04 01:08:05 +03:00
Egor
9804e3a874 Update Subscription.tsx 2026-02-04 01:00:49 +03:00
Egor
9e590247e0 Add files via upload 2026-02-04 00:51:07 +03:00
Egor
158a47e1e1 Update Subscription.tsx 2026-02-04 00:50:50 +03:00
c0mrade
84c6d265cf Fix drag-and-drop multiple reorders and wheel lights pattern
- Allow multiple prize reorders before saving by using current displayed order
- Simplify lights pattern calculation using distance-based logic
- Fixes: drag only worked once, lights appeared to go through wheel
2026-02-04 00:22:46 +03:00
c0mrade
b6561f32b3 Fix TypeScript error in WheelLegend
Remove prize.value reference - WheelPrize type doesn't contain value field
(only display_name, emoji, color, prize_type)
2026-02-03 23:47:22 +03:00