Spaces:
Running
Running
axeronis commited on
Commit ·
80c9efd
1
Parent(s): bbf53ef
feat: comprehensive updates - remove 7-day trial mentions, AI trial restriction, notifications with dialog summary, Telegram welcome message, Google OAuth on register
Browse files- backend/alembic/versions/2026_01_23_welcome_msg.py +26 -0
- backend/app/api/auth.py +36 -0
- backend/app/api/playbook.py +66 -0
- backend/app/api/webhook.py +36 -0
- backend/app/models/tenant.py +3 -0
- backend/app/services/ai_core/lead_analyzer.py +13 -0
- backend/app/services/notification_service.py +16 -6
- frontend/app/instructions/page.tsx +1 -1
- frontend/app/page.tsx +3 -8
- frontend/app/register/page.tsx +72 -0
- frontend/app/settings/brain/page.tsx +25 -0
- frontend/app/terms/page.tsx +3 -3
- frontend/contexts/AuthContext.tsx +3 -3
backend/alembic/versions/2026_01_23_welcome_msg.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""add_telegram_welcome_message
|
| 2 |
+
|
| 3 |
+
Revision ID: 2026_01_23_welcome_msg
|
| 4 |
+
Revises:
|
| 5 |
+
Create Date: 2026-01-23
|
| 6 |
+
|
| 7 |
+
"""
|
| 8 |
+
from alembic import op
|
| 9 |
+
import sqlalchemy as sa
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
# revision identifiers, used by Alembic.
|
| 13 |
+
revision = '2026_01_23_welcome_msg'
|
| 14 |
+
down_revision = None # Will be set by Alembic based on current head
|
| 15 |
+
branch_labels = None
|
| 16 |
+
depends_on = None
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
def upgrade():
|
| 20 |
+
"""Add telegram_welcome_message column to tenants table."""
|
| 21 |
+
op.add_column('tenants', sa.Column('telegram_welcome_message', sa.Text(), nullable=True))
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def downgrade():
|
| 25 |
+
"""Remove telegram_welcome_message column from tenants table."""
|
| 26 |
+
op.drop_column('tenants', 'telegram_welcome_message')
|
backend/app/api/auth.py
CHANGED
|
@@ -70,6 +70,7 @@ class UserResponse(BaseModel):
|
|
| 70 |
class GoogleAuthRequest(BaseModel):
|
| 71 |
token: str # Google ID token
|
| 72 |
company_name: Optional[str] = None
|
|
|
|
| 73 |
|
| 74 |
|
| 75 |
class VerifyRequest(BaseModel):
|
|
@@ -507,11 +508,30 @@ async def google_auth(
|
|
| 507 |
# User doesn't exist - register
|
| 508 |
company_name = request.company_name or f"{full_name}'s Company"
|
| 509 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 510 |
# Create new Tenant (Company) with 7-day trial
|
| 511 |
new_tenant = Tenant(
|
| 512 |
name=company_name,
|
| 513 |
business_name=company_name,
|
| 514 |
tokens_balance=10000, # Welcome bonus
|
|
|
|
| 515 |
is_active=True,
|
| 516 |
subscription_end=datetime.utcnow() + timedelta(days=7) # Trial expires in 7 days
|
| 517 |
)
|
|
@@ -539,6 +559,22 @@ async def google_auth(
|
|
| 539 |
# 1. Paying partner activation fee ($500)
|
| 540 |
# 2. Admin activates them manually
|
| 541 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 542 |
await session.commit()
|
| 543 |
await session.refresh(new_user)
|
| 544 |
await session.refresh(new_tenant)
|
|
|
|
| 70 |
class GoogleAuthRequest(BaseModel):
|
| 71 |
token: str # Google ID token
|
| 72 |
company_name: Optional[str] = None
|
| 73 |
+
referral_code: Optional[str] = None # Partner referral code
|
| 74 |
|
| 75 |
|
| 76 |
class VerifyRequest(BaseModel):
|
|
|
|
| 508 |
# User doesn't exist - register
|
| 509 |
company_name = request.company_name or f"{full_name}'s Company"
|
| 510 |
|
| 511 |
+
# TASK: Lookup Referring Partner (if referral code provided)
|
| 512 |
+
referring_partner_id = None
|
| 513 |
+
if request.referral_code:
|
| 514 |
+
logger.info("Google auth with referral code", referral_code=request.referral_code)
|
| 515 |
+
|
| 516 |
+
result = await session.execute(
|
| 517 |
+
select(Partner).where(Partner.referral_code == request.referral_code)
|
| 518 |
+
)
|
| 519 |
+
referring_partner = result.scalar_one_or_none()
|
| 520 |
+
|
| 521 |
+
if referring_partner:
|
| 522 |
+
referring_partner_id = referring_partner.id
|
| 523 |
+
logger.info(
|
| 524 |
+
"Found referring partner for Google auth",
|
| 525 |
+
partner_company=referring_partner.company_name,
|
| 526 |
+
partner_id=str(referring_partner_id)
|
| 527 |
+
)
|
| 528 |
+
|
| 529 |
# Create new Tenant (Company) with 7-day trial
|
| 530 |
new_tenant = Tenant(
|
| 531 |
name=company_name,
|
| 532 |
business_name=company_name,
|
| 533 |
tokens_balance=10000, # Welcome bonus
|
| 534 |
+
partner_ref_id=referring_partner_id, # Link to referring partner (or None)
|
| 535 |
is_active=True,
|
| 536 |
subscription_end=datetime.utcnow() + timedelta(days=7) # Trial expires in 7 days
|
| 537 |
)
|
|
|
|
| 559 |
# 1. Paying partner activation fee ($500)
|
| 560 |
# 2. Admin activates them manually
|
| 561 |
|
| 562 |
+
# TASK: Create ReferredTenant record if referral code was used
|
| 563 |
+
if referring_partner_id:
|
| 564 |
+
referred_tenant = ReferredTenant(
|
| 565 |
+
partner_id=referring_partner_id,
|
| 566 |
+
tenant_id=new_tenant.id,
|
| 567 |
+
is_active=True,
|
| 568 |
+
total_paid=0.0,
|
| 569 |
+
total_commission=0.0
|
| 570 |
+
)
|
| 571 |
+
session.add(referred_tenant)
|
| 572 |
+
logger.info(
|
| 573 |
+
"Created ReferredTenant record for Google auth",
|
| 574 |
+
partner_id=str(referring_partner_id),
|
| 575 |
+
tenant_id=str(new_tenant.id)
|
| 576 |
+
)
|
| 577 |
+
|
| 578 |
await session.commit()
|
| 579 |
await session.refresh(new_user)
|
| 580 |
await session.refresh(new_tenant)
|
backend/app/api/playbook.py
CHANGED
|
@@ -9,11 +9,62 @@ from datetime import datetime
|
|
| 9 |
from app.core.database import get_async_session
|
| 10 |
from app.api.deps import get_current_user
|
| 11 |
from app.models import User, SalesStage, Tenant
|
|
|
|
| 12 |
|
| 13 |
|
| 14 |
router = APIRouter(prefix="/playbook", tags=["Playbook"])
|
| 15 |
|
| 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
# ============================================================================
|
| 18 |
# Schemas
|
| 19 |
# ============================================================================
|
|
@@ -138,6 +189,9 @@ async def create_stage(
|
|
| 138 |
await session.commit()
|
| 139 |
await session.refresh(new_stage)
|
| 140 |
|
|
|
|
|
|
|
|
|
|
| 141 |
return SalesStageResponse(
|
| 142 |
id=new_stage.id,
|
| 143 |
tenant_id=new_stage.tenant_id,
|
|
@@ -192,6 +246,9 @@ async def update_stage(
|
|
| 192 |
await session.commit()
|
| 193 |
await session.refresh(stage)
|
| 194 |
|
|
|
|
|
|
|
|
|
|
| 195 |
return SalesStageResponse(
|
| 196 |
id=stage.id,
|
| 197 |
tenant_id=stage.tenant_id,
|
|
@@ -273,6 +330,9 @@ async def delete_stage(
|
|
| 273 |
session.add(stage)
|
| 274 |
await session.commit()
|
| 275 |
|
|
|
|
|
|
|
|
|
|
| 276 |
return None
|
| 277 |
|
| 278 |
|
|
@@ -480,6 +540,9 @@ async def load_template(
|
|
| 480 |
for stage in created_stages:
|
| 481 |
await session.refresh(stage)
|
| 482 |
|
|
|
|
|
|
|
|
|
|
| 483 |
return {
|
| 484 |
"message": f"Template '{template_type}' loaded successfully",
|
| 485 |
"stages_created": len(created_stages),
|
|
@@ -770,6 +833,9 @@ async def generate_funnel_with_ai(
|
|
| 770 |
for stage in created_stages:
|
| 771 |
await session.refresh(stage)
|
| 772 |
|
|
|
|
|
|
|
|
|
|
| 773 |
return GenerateFunnelResponse(
|
| 774 |
success=True,
|
| 775 |
message=f"Сгенерировано {len(created_stages)} этапов воронки" + (f" и {len(generated_qualification_fields)} полей квалификации" if saved_qual_fields else "") + " на основе анализа вашего бизнеса",
|
|
|
|
| 9 |
from app.core.database import get_async_session
|
| 10 |
from app.api.deps import get_current_user
|
| 11 |
from app.models import User, SalesStage, Tenant
|
| 12 |
+
from sqlalchemy.orm.attributes import flag_modified
|
| 13 |
|
| 14 |
|
| 15 |
router = APIRouter(prefix="/playbook", tags=["Playbook"])
|
| 16 |
|
| 17 |
|
| 18 |
+
# ============================================================================
|
| 19 |
+
# Sync Helper
|
| 20 |
+
# ============================================================================
|
| 21 |
+
|
| 22 |
+
async def sync_tenant_qualification_fields(session: AsyncSession, tenant_id: UUID):
|
| 23 |
+
"""
|
| 24 |
+
Collect all unique exit_criteria from active stages and merge them into
|
| 25 |
+
tenant.ai_settings["qualification_fields"]. This ensures AI extraction
|
| 26 |
+
uses the same fields defined in the funnel.
|
| 27 |
+
"""
|
| 28 |
+
# Get all active stages
|
| 29 |
+
result = await session.execute(
|
| 30 |
+
select(SalesStage)
|
| 31 |
+
.where(SalesStage.tenant_id == tenant_id)
|
| 32 |
+
.where(SalesStage.is_active == True)
|
| 33 |
+
)
|
| 34 |
+
stages = result.scalars().all()
|
| 35 |
+
|
| 36 |
+
# Collect unique criteria from all stages
|
| 37 |
+
all_criteria = set()
|
| 38 |
+
for stage in stages:
|
| 39 |
+
for criterion in (stage.exit_criteria or []):
|
| 40 |
+
if criterion and criterion.strip():
|
| 41 |
+
all_criteria.add(criterion.strip())
|
| 42 |
+
|
| 43 |
+
# Get tenant
|
| 44 |
+
tenant = await session.get(Tenant, tenant_id)
|
| 45 |
+
if not tenant:
|
| 46 |
+
return
|
| 47 |
+
|
| 48 |
+
# Merge with existing qualification_fields (preserve user additions)
|
| 49 |
+
ai_settings = tenant.ai_settings or {}
|
| 50 |
+
existing_fields = set(ai_settings.get("qualification_fields", []))
|
| 51 |
+
|
| 52 |
+
# Combine: all stage criteria + existing fields
|
| 53 |
+
merged_fields = list(all_criteria | existing_fields)
|
| 54 |
+
|
| 55 |
+
# Update tenant
|
| 56 |
+
ai_settings["qualification_fields"] = merged_fields
|
| 57 |
+
ai_settings["custom_fields"] = merged_fields # Backward compat
|
| 58 |
+
tenant.ai_settings = ai_settings
|
| 59 |
+
tenant.custom_fields = merged_fields # Legacy field
|
| 60 |
+
flag_modified(tenant, "ai_settings")
|
| 61 |
+
|
| 62 |
+
session.add(tenant)
|
| 63 |
+
await session.commit()
|
| 64 |
+
|
| 65 |
+
print(f"✅ Synced {len(merged_fields)} qualification fields for tenant {tenant_id}")
|
| 66 |
+
|
| 67 |
+
|
| 68 |
# ============================================================================
|
| 69 |
# Schemas
|
| 70 |
# ============================================================================
|
|
|
|
| 189 |
await session.commit()
|
| 190 |
await session.refresh(new_stage)
|
| 191 |
|
| 192 |
+
# Sync exit criteria to tenant qualification fields
|
| 193 |
+
await sync_tenant_qualification_fields(session, current_user.tenant_id)
|
| 194 |
+
|
| 195 |
return SalesStageResponse(
|
| 196 |
id=new_stage.id,
|
| 197 |
tenant_id=new_stage.tenant_id,
|
|
|
|
| 246 |
await session.commit()
|
| 247 |
await session.refresh(stage)
|
| 248 |
|
| 249 |
+
# Sync exit criteria to tenant qualification fields
|
| 250 |
+
await sync_tenant_qualification_fields(session, current_user.tenant_id)
|
| 251 |
+
|
| 252 |
return SalesStageResponse(
|
| 253 |
id=stage.id,
|
| 254 |
tenant_id=stage.tenant_id,
|
|
|
|
| 330 |
session.add(stage)
|
| 331 |
await session.commit()
|
| 332 |
|
| 333 |
+
# Sync exit criteria to tenant qualification fields (recalculate)
|
| 334 |
+
await sync_tenant_qualification_fields(session, current_user.tenant_id)
|
| 335 |
+
|
| 336 |
return None
|
| 337 |
|
| 338 |
|
|
|
|
| 540 |
for stage in created_stages:
|
| 541 |
await session.refresh(stage)
|
| 542 |
|
| 543 |
+
# Sync exit criteria to tenant qualification fields
|
| 544 |
+
await sync_tenant_qualification_fields(session, current_user.tenant_id)
|
| 545 |
+
|
| 546 |
return {
|
| 547 |
"message": f"Template '{template_type}' loaded successfully",
|
| 548 |
"stages_created": len(created_stages),
|
|
|
|
| 833 |
for stage in created_stages:
|
| 834 |
await session.refresh(stage)
|
| 835 |
|
| 836 |
+
# Sync all exit criteria to tenant qualification fields
|
| 837 |
+
await sync_tenant_qualification_fields(session, current_user.tenant_id)
|
| 838 |
+
|
| 839 |
return GenerateFunnelResponse(
|
| 840 |
success=True,
|
| 841 |
message=f"Сгенерировано {len(created_stages)} этапов воронки" + (f" и {len(generated_qualification_fields)} полей квалификации" if saved_qual_fields else "") + " на основе анализа вашего бизнеса",
|
backend/app/api/webhook.py
CHANGED
|
@@ -634,6 +634,31 @@ async def telegram_webhook(
|
|
| 634 |
# Extract text (or caption from media) or transcribe voice
|
| 635 |
user_text = message.get("text") or message.get("caption") or ""
|
| 636 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 637 |
# Handle reply_to_message - include context of quoted message
|
| 638 |
reply_to = message.get("reply_to_message")
|
| 639 |
reply_context = ""
|
|
@@ -1217,6 +1242,17 @@ async def process_ai_response_background(
|
|
| 1217 |
tenant_id=str(tenant_id)
|
| 1218 |
)
|
| 1219 |
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1220 |
# Set processing status to GENERATING
|
| 1221 |
lead.processing_status = "generating"
|
| 1222 |
session.add(lead)
|
|
|
|
| 634 |
# Extract text (or caption from media) or transcribe voice
|
| 635 |
user_text = message.get("text") or message.get("caption") or ""
|
| 636 |
|
| 637 |
+
# 👋 HANDLE /start COMMAND - Send welcome message, don't trigger AI
|
| 638 |
+
if user_text.strip().lower() == '/start':
|
| 639 |
+
welcome_message = getattr(tenant, 'telegram_welcome_message', None)
|
| 640 |
+
if welcome_message:
|
| 641 |
+
from app.services.telegram_service import telegram_service
|
| 642 |
+
try:
|
| 643 |
+
await telegram_service.send_message(
|
| 644 |
+
token=tenant.telegram_bot_token,
|
| 645 |
+
chat_id=chat_id,
|
| 646 |
+
text=welcome_message
|
| 647 |
+
)
|
| 648 |
+
logger.info(
|
| 649 |
+
"👋 Welcome message sent",
|
| 650 |
+
chat_id=chat_id,
|
| 651 |
+
tenant_id=str(tenant_id)
|
| 652 |
+
)
|
| 653 |
+
except Exception as e:
|
| 654 |
+
logger.error(f"❌ Failed to send welcome message: {e}")
|
| 655 |
+
else:
|
| 656 |
+
logger.info(
|
| 657 |
+
"👋 /start received but no welcome message configured",
|
| 658 |
+
tenant_id=str(tenant_id)
|
| 659 |
+
)
|
| 660 |
+
return {"ok": True, "status": "welcome_sent"}
|
| 661 |
+
|
| 662 |
# Handle reply_to_message - include context of quoted message
|
| 663 |
reply_to = message.get("reply_to_message")
|
| 664 |
reply_context = ""
|
|
|
|
| 1242 |
tenant_id=str(tenant_id)
|
| 1243 |
)
|
| 1244 |
return
|
| 1245 |
+
|
| 1246 |
+
# 🔒 CHECK SUBSCRIPTION PLAN - AI only works for paid plans (start, growth, enterprise)
|
| 1247 |
+
# Trial accounts can save settings but AI doesn't respond
|
| 1248 |
+
subscription_plan = (tenant.subscription_plan or "trial").lower()
|
| 1249 |
+
if subscription_plan == "trial":
|
| 1250 |
+
logger.info(
|
| 1251 |
+
"🔒 AI disabled for trial accounts - upgrade to Start/Growth/Enterprise",
|
| 1252 |
+
tenant_id=str(tenant_id),
|
| 1253 |
+
plan=subscription_plan
|
| 1254 |
+
)
|
| 1255 |
+
return
|
| 1256 |
# Set processing status to GENERATING
|
| 1257 |
lead.processing_status = "generating"
|
| 1258 |
session.add(lead)
|
backend/app/models/tenant.py
CHANGED
|
@@ -118,6 +118,9 @@ class Tenant(SQLModel, table=True):
|
|
| 118 |
voice_reference_url: Optional[str] = Field(default=None) # URL to custom voice audio (for voice cloning)
|
| 119 |
voice_first_required: bool = Field(default=False) # Whether AI must send voice as first message
|
| 120 |
|
|
|
|
|
|
|
|
|
|
| 121 |
|
| 122 |
# Status
|
| 123 |
is_active: bool = Field(default=True)
|
|
|
|
| 118 |
voice_reference_url: Optional[str] = Field(default=None) # URL to custom voice audio (for voice cloning)
|
| 119 |
voice_first_required: bool = Field(default=False) # Whether AI must send voice as first message
|
| 120 |
|
| 121 |
+
# Telegram Welcome Message - sent when user clicks /start (AI doesn't respond to /start)
|
| 122 |
+
telegram_welcome_message: Optional[str] = Field(default=None)
|
| 123 |
+
|
| 124 |
|
| 125 |
# Status
|
| 126 |
is_active: bool = Field(default=True)
|
backend/app/services/ai_core/lead_analyzer.py
CHANGED
|
@@ -256,6 +256,18 @@ async def check_and_notify_qualification_complete(
|
|
| 256 |
# Smart message based on business type
|
| 257 |
heat_emoji = "🔥" if lead.heat_score >= 70 else "🟡" if lead.heat_score >= 50 else "❄️"
|
| 258 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 259 |
message = (
|
| 260 |
f"✅ **ЛИД ПОЛНОСТЬЮ КВАЛИФИЦИРОВАН** ✅\n\n"
|
| 261 |
f"👤 Клиент: {lead.name or 'Неизвестно'}\n"
|
|
@@ -263,6 +275,7 @@ async def check_and_notify_qualification_complete(
|
|
| 263 |
f"───────────────\n"
|
| 264 |
f"📋 **СОБРАННАЯ ИНФОРМАЦИЯ:**\n"
|
| 265 |
f"{qual_text}\n"
|
|
|
|
| 266 |
f"───────────────\n"
|
| 267 |
f"💡 Все поля заполнены — готов к работе с {bot_role}!"
|
| 268 |
)
|
|
|
|
| 256 |
# Smart message based on business type
|
| 257 |
heat_emoji = "🔥" if lead.heat_score >= 70 else "🟡" if lead.heat_score >= 50 else "❄️"
|
| 258 |
|
| 259 |
+
# Add brief dialog summary
|
| 260 |
+
dialog_summary = ""
|
| 261 |
+
if lead.ai_summary_json and isinstance(lead.ai_summary_json, dict):
|
| 262 |
+
intent = lead.ai_summary_json.get('intent', '')
|
| 263 |
+
summary = lead.ai_summary_json.get('summary', '')
|
| 264 |
+
if intent or summary:
|
| 265 |
+
dialog_summary = f"\n📝 **САММАРИ ДИАЛОГА:**\n"
|
| 266 |
+
if intent:
|
| 267 |
+
dialog_summary += f"• Намерение: {intent}\n"
|
| 268 |
+
if summary:
|
| 269 |
+
dialog_summary += f"• {summary[:200]}{'...' if len(summary) > 200 else ''}\n"
|
| 270 |
+
|
| 271 |
message = (
|
| 272 |
f"✅ **ЛИД ПОЛНОСТЬЮ КВАЛИФИЦИРОВАН** ✅\n\n"
|
| 273 |
f"👤 Клиент: {lead.name or 'Неизвестно'}\n"
|
|
|
|
| 275 |
f"───────────────\n"
|
| 276 |
f"📋 **СОБРАННАЯ ИНФОРМАЦИЯ:**\n"
|
| 277 |
f"{qual_text}\n"
|
| 278 |
+
f"{dialog_summary}"
|
| 279 |
f"───────────────\n"
|
| 280 |
f"💡 Все поля заполнены — готов к работе с {bot_role}!"
|
| 281 |
)
|
backend/app/services/notification_service.py
CHANGED
|
@@ -106,7 +106,7 @@ class NotificationService:
|
|
| 106 |
return notification
|
| 107 |
|
| 108 |
def _format_hot_lead_message(self, lead: Lead) -> str:
|
| 109 |
-
"""Format HOT lead message."""
|
| 110 |
parts = []
|
| 111 |
|
| 112 |
if lead.name:
|
|
@@ -118,12 +118,22 @@ class NotificationService:
|
|
| 118 |
if lead.heat_score:
|
| 119 |
parts.append(f"📊 Heat Score: {lead.heat_score}/100")
|
| 120 |
|
| 121 |
-
#
|
| 122 |
if lead.ai_summary_json and isinstance(lead.ai_summary_json, dict):
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
|
| 128 |
return "\n".join(parts) if parts else "Новый горячий лид!"
|
| 129 |
|
|
|
|
| 106 |
return notification
|
| 107 |
|
| 108 |
def _format_hot_lead_message(self, lead: Lead) -> str:
|
| 109 |
+
"""Format HOT lead message with dialog summary."""
|
| 110 |
parts = []
|
| 111 |
|
| 112 |
if lead.name:
|
|
|
|
| 118 |
if lead.heat_score:
|
| 119 |
parts.append(f"📊 Heat Score: {lead.heat_score}/100")
|
| 120 |
|
| 121 |
+
# Add dialog summary from AI summary
|
| 122 |
if lead.ai_summary_json and isinstance(lead.ai_summary_json, dict):
|
| 123 |
+
intent = lead.ai_summary_json.get('intent', '')
|
| 124 |
+
summary = lead.ai_summary_json.get('summary', '')
|
| 125 |
+
recommendation = lead.ai_summary_json.get('recommendation', '')
|
| 126 |
+
|
| 127 |
+
if intent or summary:
|
| 128 |
+
parts.append("\n📝 Краткое саммари:")
|
| 129 |
+
if intent:
|
| 130 |
+
parts.append(f"• Намерение: {intent}")
|
| 131 |
+
if summary:
|
| 132 |
+
# Truncate long summaries
|
| 133 |
+
summary_text = summary[:300] + ('...' if len(summary) > 300 else '')
|
| 134 |
+
parts.append(f"• {summary_text}")
|
| 135 |
+
if recommendation:
|
| 136 |
+
parts.append(f"💡 {recommendation[:150]}")
|
| 137 |
|
| 138 |
return "\n".join(parts) if parts else "Новый горячий лид!"
|
| 139 |
|
frontend/app/instructions/page.tsx
CHANGED
|
@@ -147,7 +147,7 @@ export default function InstructionsPage() {
|
|
| 147 |
>
|
| 148 |
Начать бесплатно <ArrowRight className="w-5 h-5" />
|
| 149 |
</Link>
|
| 150 |
-
|
| 151 |
</motion.div>
|
| 152 |
|
| 153 |
{/* Video placeholder */}
|
|
|
|
| 147 |
>
|
| 148 |
Начать бесплатно <ArrowRight className="w-5 h-5" />
|
| 149 |
</Link>
|
| 150 |
+
{/* CTA removed - no trial period mention */}
|
| 151 |
</motion.div>
|
| 152 |
|
| 153 |
{/* Video placeholder */}
|
frontend/app/page.tsx
CHANGED
|
@@ -86,7 +86,7 @@ const T = {
|
|
| 86 |
heroTitle1: 'ОН НЕ ОТВЕЧАЕТ.', heroTitle2: 'ОН', heroTitle3: 'ЗАКРЫВАЕТ.', heroTitle4: '',
|
| 87 |
heroDesc1: 'AI-усилитель продаж, который превращает переписки в деньги.',
|
| 88 |
heroDesc2: 'Пока вы спите - он квалифицирует и дожимает. В тандеме с вашими клозерами он делает отдел продаж несокрушимым.',
|
| 89 |
-
tryFree: 'Запустить за 5 минут',
|
| 90 |
// Pain Points - stronger copy
|
| 91 |
painTitle: 'Признайтесь, это про вас', painSubtitle: 'Почему вы теряете до 70% продаж',
|
| 92 |
pain1title: '2 минуты', pain1desc: 'Критический порог. Через 120 секунд ожидания клиент открывает чат конкурента. AI отвечает за 2 секунды.',
|
|
@@ -153,7 +153,7 @@ const T = {
|
|
| 153 |
faq3q: 'Как AI узнает мой продукт?', faq3a: 'Загрузите PDF или дайте ссылку на сайт. AI изучит всё за 60 секунд.',
|
| 154 |
faq4q: 'Можно платить за год?', faq4a: 'Да, и сэкономить 30%. Это 4 месяца бесплатно.',
|
| 155 |
// CTA
|
| 156 |
-
ctaTitle: 'ХВАТИТ ТЕРЯТЬ ДЕНЬГИ.', ctaButton: 'Запустить AI-продавца', ctaSubtext: '
|
| 157 |
priceObjectionTitle: 'Сомневаетесь в цене?', priceObjectionDesc: 'Послушайте, что об этом думает наш AI',
|
| 158 |
// Footer
|
| 159 |
footerDesc: 'AI-продавец для Telegram. Закрывает сделки, записывает на встречи, продаёт из каталога - 24/7.',
|
|
@@ -439,7 +439,7 @@ export default function HomePage() {
|
|
| 439 |
{/* Hero Voice Demo - Nova Introduction */}
|
| 440 |
<button
|
| 441 |
onClick={toggleHeroAudio}
|
| 442 |
-
className={`flex items-center justify-center gap-3 px-6 py-3 rounded-xl font-bold transition-all ${isHeroPlaying
|
| 443 |
? 'bg-red-500/20 text-red-400 border border-red-500/30'
|
| 444 |
: 'bg-white/10 text-white border border-white/20 hover:bg-white/15 hover:border-white/30'
|
| 445 |
}`}
|
|
@@ -452,11 +452,6 @@ export default function HomePage() {
|
|
| 452 |
<span>{isHeroPlaying ? t.stopVoice : t.playVoice}</span>
|
| 453 |
</button>
|
| 454 |
</div>
|
| 455 |
-
|
| 456 |
-
<div className="text-sm text-slate-500 flex items-center gap-2 mt-2">
|
| 457 |
-
<Shield className="w-4 h-4 text-emerald-500" />
|
| 458 |
-
<span className="font-medium">{t.freeDays}</span>
|
| 459 |
-
</div>
|
| 460 |
</div>
|
| 461 |
</motion.div>
|
| 462 |
</div>
|
|
|
|
| 86 |
heroTitle1: 'ОН НЕ ОТВЕЧАЕТ.', heroTitle2: 'ОН', heroTitle3: 'ЗАКРЫВАЕТ.', heroTitle4: '',
|
| 87 |
heroDesc1: 'AI-усилитель продаж, который превращает переписки в деньги.',
|
| 88 |
heroDesc2: 'Пока вы спите - он квалифицирует и дожимает. В тандеме с вашими клозерами он делает отдел продаж несокрушимым.',
|
| 89 |
+
tryFree: 'Запустить за 5 минут',
|
| 90 |
// Pain Points - stronger copy
|
| 91 |
painTitle: 'Признайтесь, это про вас', painSubtitle: 'Почему вы теряете до 70% продаж',
|
| 92 |
pain1title: '2 минуты', pain1desc: 'Критический порог. Через 120 секунд ожидания клиент открывает чат конкурента. AI отвечает за 2 секунды.',
|
|
|
|
| 153 |
faq3q: 'Как AI узнает мой продукт?', faq3a: 'Загрузите PDF или дайте ссылку на сайт. AI изучит всё за 60 секунд.',
|
| 154 |
faq4q: 'Можно платить за год?', faq4a: 'Да, и сэкономить 30%. Это 4 месяца бесплатно.',
|
| 155 |
// CTA
|
| 156 |
+
ctaTitle: 'ХВАТИТ ТЕРЯТЬ ДЕНЬГИ.', ctaButton: 'Запустить AI-продавца', ctaSubtext: 'Карта не нужна',
|
| 157 |
priceObjectionTitle: 'Сомневаетесь в цене?', priceObjectionDesc: 'Послушайте, что об этом думает наш AI',
|
| 158 |
// Footer
|
| 159 |
footerDesc: 'AI-продавец для Telegram. Закрывает сделки, записывает на встречи, продаёт из каталога - 24/7.',
|
|
|
|
| 439 |
{/* Hero Voice Demo - Nova Introduction */}
|
| 440 |
<button
|
| 441 |
onClick={toggleHeroAudio}
|
| 442 |
+
className={`mt-4 flex items-center justify-center gap-3 px-6 py-3 rounded-xl font-bold transition-all ${isHeroPlaying
|
| 443 |
? 'bg-red-500/20 text-red-400 border border-red-500/30'
|
| 444 |
: 'bg-white/10 text-white border border-white/20 hover:bg-white/15 hover:border-white/30'
|
| 445 |
}`}
|
|
|
|
| 452 |
<span>{isHeroPlaying ? t.stopVoice : t.playVoice}</span>
|
| 453 |
</button>
|
| 454 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 455 |
</div>
|
| 456 |
</motion.div>
|
| 457 |
</div>
|
frontend/app/register/page.tsx
CHANGED
|
@@ -228,6 +228,78 @@ export default function RegisterPage() {
|
|
| 228 |
</form>
|
| 229 |
</div>
|
| 230 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 231 |
<div className="text-center mt-6">
|
| 232 |
<p className="text-sm text-slate-500">
|
| 233 |
{t('auth.alreadyHaveAccount')}{' '}
|
|
|
|
| 228 |
</form>
|
| 229 |
</div>
|
| 230 |
|
| 231 |
+
{/* Google OAuth */}
|
| 232 |
+
<div className="mt-6">
|
| 233 |
+
<div className="relative">
|
| 234 |
+
<div className="absolute inset-0 flex items-center">
|
| 235 |
+
<div className="w-full border-t border-white/10" />
|
| 236 |
+
</div>
|
| 237 |
+
<div className="relative flex justify-center text-sm">
|
| 238 |
+
<span className="px-3 bg-[#020005] text-slate-500">{t('auth.orContinueWith') || 'или'}</span>
|
| 239 |
+
</div>
|
| 240 |
+
</div>
|
| 241 |
+
|
| 242 |
+
<button
|
| 243 |
+
type="button"
|
| 244 |
+
onClick={async () => {
|
| 245 |
+
setIsLoading(true)
|
| 246 |
+
setError('')
|
| 247 |
+
try {
|
| 248 |
+
// Initialize Google Sign-In
|
| 249 |
+
const { googleAuth } = await import('@/contexts/AuthContext').then(m => ({ googleAuth: null }))
|
| 250 |
+
|
| 251 |
+
// Use Google Identity Services
|
| 252 |
+
const google = (window as any).google
|
| 253 |
+
if (!google) {
|
| 254 |
+
// Load Google GSI script dynamically
|
| 255 |
+
const script = document.createElement('script')
|
| 256 |
+
script.src = 'https://accounts.google.com/gsi/client'
|
| 257 |
+
script.async = true
|
| 258 |
+
script.defer = true
|
| 259 |
+
document.head.appendChild(script)
|
| 260 |
+
await new Promise(resolve => { script.onload = resolve })
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
// Initialize and show Google Sign-In
|
| 264 |
+
const clientId = process.env.NEXT_PUBLIC_GOOGLE_CLIENT_ID
|
| 265 |
+
if (!clientId) {
|
| 266 |
+
throw new Error('Google Client ID not configured')
|
| 267 |
+
}
|
| 268 |
+
|
| 269 |
+
; (window as any).google.accounts.id.initialize({
|
| 270 |
+
client_id: clientId,
|
| 271 |
+
callback: async (response: any) => {
|
| 272 |
+
try {
|
| 273 |
+
// Call our googleAuth with referral code
|
| 274 |
+
const { googleAuth: auth } = useAuth()
|
| 275 |
+
await auth(response.credential, undefined, referralCode)
|
| 276 |
+
} catch (err: any) {
|
| 277 |
+
setError(err.message || 'Google authentication failed')
|
| 278 |
+
setIsLoading(false)
|
| 279 |
+
}
|
| 280 |
+
}
|
| 281 |
+
})
|
| 282 |
+
|
| 283 |
+
; (window as any).google.accounts.id.prompt()
|
| 284 |
+
} catch (err: any) {
|
| 285 |
+
setError(err.message || 'Failed to initialize Google Sign-In')
|
| 286 |
+
} finally {
|
| 287 |
+
setIsLoading(false)
|
| 288 |
+
}
|
| 289 |
+
}}
|
| 290 |
+
disabled={isLoading}
|
| 291 |
+
className="mt-4 w-full flex items-center justify-center gap-3 py-3 px-4 border border-white/20 rounded-xl bg-white/5 hover:bg-white/10 text-white font-medium transition-all disabled:opacity-50"
|
| 292 |
+
>
|
| 293 |
+
<svg className="w-5 h-5" viewBox="0 0 24 24">
|
| 294 |
+
<path fill="#4285F4" d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z" />
|
| 295 |
+
<path fill="#34A853" d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z" />
|
| 296 |
+
<path fill="#FBBC05" d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z" />
|
| 297 |
+
<path fill="#EA4335" d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z" />
|
| 298 |
+
</svg>
|
| 299 |
+
Google
|
| 300 |
+
</button>
|
| 301 |
+
</div>
|
| 302 |
+
|
| 303 |
<div className="text-center mt-6">
|
| 304 |
<p className="text-sm text-slate-500">
|
| 305 |
{t('auth.alreadyHaveAccount')}{' '}
|
frontend/app/settings/brain/page.tsx
CHANGED
|
@@ -95,6 +95,7 @@ export default function BrainSettingsPage() {
|
|
| 95 |
const [newField, setNewField] = useState('')
|
| 96 |
const [newBannedWord, setNewBannedWord] = useState('')
|
| 97 |
const [aiEnabled, setAiEnabled] = useState(true)
|
|
|
|
| 98 |
|
| 99 |
// Knowledge State
|
| 100 |
const [searchQuery, setSearchQuery] = useState('')
|
|
@@ -161,6 +162,7 @@ export default function BrainSettingsPage() {
|
|
| 161 |
bot_gender: tenantData.ai_identity?.bot_gender || 'male'
|
| 162 |
})
|
| 163 |
setAiEnabled(tenantData.ai_enabled !== false) // Default true
|
|
|
|
| 164 |
setBookingSettings(tenantData.booking_settings)
|
| 165 |
setLoading(false)
|
| 166 |
}
|
|
@@ -257,6 +259,7 @@ export default function BrainSettingsPage() {
|
|
| 257 |
bot_gender: botIdentity.bot_gender
|
| 258 |
},
|
| 259 |
ai_enabled: aiEnabled,
|
|
|
|
| 260 |
...persona
|
| 261 |
})
|
| 262 |
queryClient.invalidateQueries({ queryKey: ['ai-settings'] })
|
|
@@ -1030,6 +1033,28 @@ export default function BrainSettingsPage() {
|
|
| 1030 |
</div>
|
| 1031 |
</motion.div>
|
| 1032 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1033 |
{/* Business Model - NEW SECTION */}
|
| 1034 |
<motion.div variants={item} className="bg-surface-elevated rounded-2xl shadow-sm border border-white/10 p-8">
|
| 1035 |
<div className="flex items-center gap-3 mb-6">
|
|
|
|
| 95 |
const [newField, setNewField] = useState('')
|
| 96 |
const [newBannedWord, setNewBannedWord] = useState('')
|
| 97 |
const [aiEnabled, setAiEnabled] = useState(true)
|
| 98 |
+
const [welcomeMessage, setWelcomeMessage] = useState('') // Telegram /start welcome message
|
| 99 |
|
| 100 |
// Knowledge State
|
| 101 |
const [searchQuery, setSearchQuery] = useState('')
|
|
|
|
| 162 |
bot_gender: tenantData.ai_identity?.bot_gender || 'male'
|
| 163 |
})
|
| 164 |
setAiEnabled(tenantData.ai_enabled !== false) // Default true
|
| 165 |
+
setWelcomeMessage(tenantData.telegram_welcome_message || '') // Welcome message for /start
|
| 166 |
setBookingSettings(tenantData.booking_settings)
|
| 167 |
setLoading(false)
|
| 168 |
}
|
|
|
|
| 259 |
bot_gender: botIdentity.bot_gender
|
| 260 |
},
|
| 261 |
ai_enabled: aiEnabled,
|
| 262 |
+
telegram_welcome_message: welcomeMessage || null, // Save welcome message
|
| 263 |
...persona
|
| 264 |
})
|
| 265 |
queryClient.invalidateQueries({ queryKey: ['ai-settings'] })
|
|
|
|
| 1033 |
</div>
|
| 1034 |
</motion.div>
|
| 1035 |
|
| 1036 |
+
{/* Telegram Welcome Message */}
|
| 1037 |
+
<motion.div variants={item}>
|
| 1038 |
+
<h2 className="text-sm font-medium text-slate-400 uppercase tracking-wider mb-4">
|
| 1039 |
+
Приветственное сообщение
|
| 1040 |
+
</h2>
|
| 1041 |
+
<div className="bg-white/5 rounded-xl border border-white/10 p-4">
|
| 1042 |
+
<label className="block text-sm text-slate-300 mb-2">
|
| 1043 |
+
Сообщение при /start в Telegram
|
| 1044 |
+
</label>
|
| 1045 |
+
<textarea
|
| 1046 |
+
value={welcomeMessage}
|
| 1047 |
+
onChange={(e) => setWelcomeMessage(e.target.value)}
|
| 1048 |
+
placeholder="Привет! 👋 Я AI-ассистент. Чем могу помочь?"
|
| 1049 |
+
rows={3}
|
| 1050 |
+
className="w-full px-4 py-3 bg-white/5 border border-white/10 rounded-lg text-white placeholder:text-slate-600 focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500/20 transition-all outline-none resize-none"
|
| 1051 |
+
/>
|
| 1052 |
+
<p className="text-xs text-slate-500 mt-2">
|
| 1053 |
+
Это сообщение отправляется когда пользователь нажимает /start. AI не отвечает на /start, но знает содержимое этого сообщения.
|
| 1054 |
+
</p>
|
| 1055 |
+
</div>
|
| 1056 |
+
</motion.div>
|
| 1057 |
+
|
| 1058 |
{/* Business Model - NEW SECTION */}
|
| 1059 |
<motion.div variants={item} className="bg-surface-elevated rounded-2xl shadow-sm border border-white/10 p-8">
|
| 1060 |
<div className="flex items-center gap-3 mb-6">
|
frontend/app/terms/page.tsx
CHANGED
|
@@ -25,7 +25,7 @@ const T = {
|
|
| 25 |
|
| 26 |
sec3title: '3. Тарифные планы',
|
| 27 |
sec3text: 'Мы предлагаем следующие тарифы:',
|
| 28 |
-
sec3list: ['
|
| 29 |
sec3annual: 'Годовые подписки получают скидку 30%.',
|
| 30 |
|
| 31 |
sec4title: '4. Аккаунты пользователей',
|
|
@@ -66,7 +66,7 @@ const T = {
|
|
| 66 |
|
| 67 |
sec3title: '3. Subscription Plans',
|
| 68 |
sec3text: 'We offer the following subscription tiers:',
|
| 69 |
-
sec3list: ['
|
| 70 |
sec3annual: 'Annual subscriptions receive a 30% discount.',
|
| 71 |
|
| 72 |
sec4title: '4. User Accounts',
|
|
@@ -107,7 +107,7 @@ const T = {
|
|
| 107 |
|
| 108 |
sec3title: '3. Тарифтик пландар',
|
| 109 |
sec3text: 'Биз төмөнкү тарифтерди сунуштайбыз:',
|
| 110 |
-
sec3list: ['
|
| 111 |
sec3annual: 'Жылдык төлөм 30% арзандатуу алат.',
|
| 112 |
|
| 113 |
sec4title: '4. Колдонуучу аккаунттары',
|
|
|
|
| 25 |
|
| 26 |
sec3title: '3. Тарифные планы',
|
| 27 |
sec3text: 'Мы предлагаем следующие тарифы:',
|
| 28 |
+
sec3list: ['Start ($69/месяц): 500 диалогов', 'Growth ($139/месяц): 1,500 диалогов', 'Enterprise ($349/месяц): Безлимитные диалоги'],
|
| 29 |
sec3annual: 'Годовые подписки получают скидку 30%.',
|
| 30 |
|
| 31 |
sec4title: '4. Аккаунты пользователей',
|
|
|
|
| 66 |
|
| 67 |
sec3title: '3. Subscription Plans',
|
| 68 |
sec3text: 'We offer the following subscription tiers:',
|
| 69 |
+
sec3list: ['Start ($69/month): 500 conversations', 'Growth ($139/month): 1,500 conversations', 'Enterprise ($349/month): Unlimited conversations'],
|
| 70 |
sec3annual: 'Annual subscriptions receive a 30% discount.',
|
| 71 |
|
| 72 |
sec4title: '4. User Accounts',
|
|
|
|
| 107 |
|
| 108 |
sec3title: '3. Тарифтик пландар',
|
| 109 |
sec3text: 'Биз төмөнкү тарифтерди сунуштайбыз:',
|
| 110 |
+
sec3list: ['Start ($69/ай): 500 диалог', 'Growth ($139/ай): 1,500 диалог', 'Enterprise ($349/ай): Чексиз диалогдор'],
|
| 111 |
sec3annual: 'Жылдык төлөм 30% арзандатуу алат.',
|
| 112 |
|
| 113 |
sec4title: '4. Колдонуучу аккаунттары',
|
frontend/contexts/AuthContext.tsx
CHANGED
|
@@ -25,7 +25,7 @@ interface AuthContextType {
|
|
| 25 |
forgotPassword: (email: string) => Promise<void>
|
| 26 |
resetPassword: (email: string, code: string, newPassword: string) => Promise<void>
|
| 27 |
changePassword: (currentPassword: string, newPassword: string) => Promise<void>
|
| 28 |
-
googleAuth: (token: string, company_name?: string) => Promise<void>
|
| 29 |
logout: () => void
|
| 30 |
setUser: (user: User | null) => void
|
| 31 |
refreshUser: () => Promise<void>
|
|
@@ -540,7 +540,7 @@ export function AuthProvider({ children }: { children: ReactNode }) {
|
|
| 540 |
}
|
| 541 |
}
|
| 542 |
|
| 543 |
-
const googleAuth = async (token: string, company_name?: string) => {
|
| 544 |
try {
|
| 545 |
const API_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8000'
|
| 546 |
const response = await fetch(`${API_URL}/api/v1/auth/google`, {
|
|
@@ -548,7 +548,7 @@ export function AuthProvider({ children }: { children: ReactNode }) {
|
|
| 548 |
headers: {
|
| 549 |
'Content-Type': 'application/json',
|
| 550 |
},
|
| 551 |
-
body: JSON.stringify({ token, company_name }),
|
| 552 |
})
|
| 553 |
|
| 554 |
if (!response.ok) {
|
|
|
|
| 25 |
forgotPassword: (email: string) => Promise<void>
|
| 26 |
resetPassword: (email: string, code: string, newPassword: string) => Promise<void>
|
| 27 |
changePassword: (currentPassword: string, newPassword: string) => Promise<void>
|
| 28 |
+
googleAuth: (token: string, company_name?: string, referral_code?: string | null) => Promise<void>
|
| 29 |
logout: () => void
|
| 30 |
setUser: (user: User | null) => void
|
| 31 |
refreshUser: () => Promise<void>
|
|
|
|
| 540 |
}
|
| 541 |
}
|
| 542 |
|
| 543 |
+
const googleAuth = async (token: string, company_name?: string, referral_code?: string | null) => {
|
| 544 |
try {
|
| 545 |
const API_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8000'
|
| 546 |
const response = await fetch(`${API_URL}/api/v1/auth/google`, {
|
|
|
|
| 548 |
headers: {
|
| 549 |
'Content-Type': 'application/json',
|
| 550 |
},
|
| 551 |
+
body: JSON.stringify({ token, company_name, referral_code }),
|
| 552 |
})
|
| 553 |
|
| 554 |
if (!response.ok) {
|