fix: add referral support + get referrerId from Telegram start_param in plans
This commit is contained in:
@@ -93,6 +93,19 @@ export default function PlansNew() {
|
||||
const [availableLocations, setAvailableLocations] = useState<Location[]>([]);
|
||||
const [isLoadingLocations, setIsLoadingLocations] = useState(false);
|
||||
const [isCreatingUser, setIsCreatingUser] = useState(false);
|
||||
const [referrerId, setReferrerId] = useState<string | null>(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);
|
||||
|
||||
Reference in New Issue
Block a user