diff --git a/app/plans/page.tsx b/app/plans/page.tsx index c7c384e..24566f1 100644 --- a/app/plans/page.tsx +++ b/app/plans/page.tsx @@ -93,6 +93,19 @@ export default function PlansNew() { const [availableLocations, setAvailableLocations] = useState([]); const [isLoadingLocations, setIsLoadingLocations] = useState(false); const [isCreatingUser, setIsCreatingUser] = useState(false); + const [referrerId, setReferrerId] = useState(null); + + // Получаем referrerId из Telegram start_param при монтировании + useEffect(() => { + const telegramWebApp = (window as any).Telegram?.WebApp; + const startParam = telegramWebApp?.initDataUnsafe?.start_param; + + if (startParam && startParam.startsWith('ref_')) { + const refId = startParam.replace('ref_', ''); + setReferrerId(refId); + console.log('🎁 Referral detected:', refId); + } + }, []); // Загрузить локации при переходе к шагу выбора useEffect(() => { @@ -183,6 +196,7 @@ export default function PlansNew() { telegramUsername: user?.username || null, firstName: user?.first_name || null, lastName: user?.last_name || null, + referrerId: referrerId || null, // Добавляем referrerId }; console.log('📤 REQUEST BODY:', requestBody);