Spaces:
Paused
Paused
CBV01 commited on
Commit Β·
fd477ea
1
Parent(s): e8ea947
Remove all feature restrictions on Unlimited plan: enforce natural 100-keyword batch and unlimited scrapers, campaigns, and accounts
Browse files- backend/database.py +3 -3
- backend/main.py +67 -35
- frontend/src/app/page.tsx +11 -10
- frontend/src/app/scraper/page.tsx +5 -4
- frontend/src/components/Sidebar.tsx +13 -12
backend/database.py
CHANGED
|
@@ -432,13 +432,13 @@ def init_db():
|
|
| 432 |
# Basic: 15 keywords, 2 templates
|
| 433 |
# Standard: 30 keywords, 5 templates
|
| 434 |
# Premium: 50 keywords, 10 templates
|
| 435 |
-
# Unlimited:
|
| 436 |
try:
|
| 437 |
conn.execute("UPDATE plans SET max_daily_keywords = 5, max_templates = 1 WHERE key = 'free'")
|
| 438 |
conn.execute("UPDATE plans SET max_daily_keywords = 15, max_templates = 2 WHERE key = 'basic'")
|
| 439 |
conn.execute("UPDATE plans SET max_daily_keywords = 30, max_templates = 5 WHERE key = 'standard'")
|
| 440 |
conn.execute("UPDATE plans SET max_daily_keywords = 50, max_templates = 10 WHERE key = 'premium'")
|
| 441 |
-
conn.execute("UPDATE plans SET max_daily_keywords =
|
| 442 |
if hasattr(conn, "commit"): conn.commit()
|
| 443 |
except Exception:
|
| 444 |
pass
|
|
@@ -607,7 +607,7 @@ def init_db():
|
|
| 607 |
("basic", "Growth Basic", 2000, 50, 2, 15, 100, 2, 1, json.dumps(["50 Daily Campaigns", "2 Templates", "15 AI Keywords", "Fleet Compare (2 Accounts)", "Priority Support"])),
|
| 608 |
("standard", "Pro Standard", 3500, 150, 5, 30, 250, 5, 1, json.dumps(["150 Daily Campaigns", "5 Templates", "30 AI Keywords", "Fleet Compare (5 Accounts)", "Bulk Join Minimizer", "24/7 Support"])),
|
| 609 |
("premium", "Enterprise Premium", 5000, 300, 10, 50, 500, 10, 1, json.dumps(["300 Daily Campaigns", "10 Templates", "50 AI Keywords", "Fleet Compare (10 Accounts)", "Bulk Join Minimizer", "Dedicated Manager"])),
|
| 610 |
-
("unlimited", "Owner Unlimited", 0, 999999,
|
| 611 |
]
|
| 612 |
for p in default_plans:
|
| 613 |
# Use INSERT OR REPLACE if the key matches, to force update existing seeds
|
|
|
|
| 432 |
# Basic: 15 keywords, 2 templates
|
| 433 |
# Standard: 30 keywords, 5 templates
|
| 434 |
# Premium: 50 keywords, 10 templates
|
| 435 |
+
# Unlimited: Full unrestricted limits
|
| 436 |
try:
|
| 437 |
conn.execute("UPDATE plans SET max_daily_keywords = 5, max_templates = 1 WHERE key = 'free'")
|
| 438 |
conn.execute("UPDATE plans SET max_daily_keywords = 15, max_templates = 2 WHERE key = 'basic'")
|
| 439 |
conn.execute("UPDATE plans SET max_daily_keywords = 30, max_templates = 5 WHERE key = 'standard'")
|
| 440 |
conn.execute("UPDATE plans SET max_daily_keywords = 50, max_templates = 10 WHERE key = 'premium'")
|
| 441 |
+
conn.execute("UPDATE plans SET max_daily_keywords = 999999, max_templates = 999999, max_accounts = 999999, max_daily_campaigns = 999999, scrape_limit = 999999 WHERE key = 'unlimited'")
|
| 442 |
if hasattr(conn, "commit"): conn.commit()
|
| 443 |
except Exception:
|
| 444 |
pass
|
|
|
|
| 607 |
("basic", "Growth Basic", 2000, 50, 2, 15, 100, 2, 1, json.dumps(["50 Daily Campaigns", "2 Templates", "15 AI Keywords", "Fleet Compare (2 Accounts)", "Priority Support"])),
|
| 608 |
("standard", "Pro Standard", 3500, 150, 5, 30, 250, 5, 1, json.dumps(["150 Daily Campaigns", "5 Templates", "30 AI Keywords", "Fleet Compare (5 Accounts)", "Bulk Join Minimizer", "24/7 Support"])),
|
| 609 |
("premium", "Enterprise Premium", 5000, 300, 10, 50, 500, 10, 1, json.dumps(["300 Daily Campaigns", "10 Templates", "50 AI Keywords", "Fleet Compare (10 Accounts)", "Bulk Join Minimizer", "Dedicated Manager"])),
|
| 610 |
+
("unlimited", "Owner Unlimited", 0, 999999, 999999, 999999, 999999, 999999, 1, json.dumps(["Absolute Control", "Unlimited Templates", "Full 100 AI Keywords Batch", "Unlimited Scrapes", "Unlimited Accounts", "Admin Privilege"]))
|
| 611 |
]
|
| 612 |
for p in default_plans:
|
| 613 |
# Use INSERT OR REPLACE if the key matches, to force update existing seeds
|
backend/main.py
CHANGED
|
@@ -87,7 +87,7 @@ def get_plan_configs() -> Dict[str, Dict[str, Any]]:
|
|
| 87 |
"basic": {"max_daily_campaigns": 50, "max_accounts": 2, "max_daily_keywords": 15, "scrape_limit": 100, "max_templates": 2, "has_premium_access": True},
|
| 88 |
"standard": {"max_daily_campaigns": 150, "max_accounts": 5, "max_daily_keywords": 30, "scrape_limit": 250, "max_templates": 5, "has_premium_access": True},
|
| 89 |
"premium": {"max_daily_campaigns": 300, "max_accounts": 10, "max_daily_keywords": 50, "scrape_limit": 500, "max_templates": 10, "has_premium_access": True},
|
| 90 |
-
"unlimited": {"max_daily_campaigns": 999999, "max_accounts":
|
| 91 |
}
|
| 92 |
conn = None
|
| 93 |
try:
|
|
@@ -2906,16 +2906,17 @@ async def scrape_keyword_stream(
|
|
| 2906 |
if hasattr(conn, "close"): conn.close()
|
| 2907 |
raise HTTPException(status_code=403, detail=f"Access Denied: The {plan.capitalize()} plan does not include Scraper access. Upgrade to UNLOCK.")
|
| 2908 |
|
| 2909 |
-
|
| 2910 |
-
|
|
|
|
| 2911 |
current_keywords = int(user_row["daily_keyword_count"] or 0)
|
| 2912 |
|
| 2913 |
-
if
|
| 2914 |
if hasattr(conn, "close"): conn.close()
|
| 2915 |
raise HTTPException(status_code=403, detail="Daily usage limit reached for scraping. Reset at Midnight UTC.")
|
| 2916 |
|
| 2917 |
# Increment keyword use and Log Search Intelligence
|
| 2918 |
-
if
|
| 2919 |
conn.execute("UPDATE users SET daily_keyword_count = daily_keyword_count + 1 WHERE id = ?", (user_id,))
|
| 2920 |
|
| 2921 |
# Unified global logging for Admin
|
|
@@ -3082,16 +3083,17 @@ async def scrape_keyword(
|
|
| 3082 |
plan = (user_row["plan"] or "free")
|
| 3083 |
plan_cfg = get_plan_configs().get(plan, get_plan_configs()["free"])
|
| 3084 |
|
| 3085 |
-
|
|
|
|
| 3086 |
current_keywords = int(user_row["daily_keyword_count"] or 0)
|
| 3087 |
-
scrape_limit = int(user_row["scrape_limit"] or plan_cfg["scrape_limit"])
|
| 3088 |
|
| 3089 |
-
if
|
| 3090 |
if hasattr(conn, "close"): conn.close()
|
| 3091 |
raise HTTPException(status_code=403, detail="Daily search limit reached.")
|
| 3092 |
|
| 3093 |
# Increment search count and Log Keyword
|
| 3094 |
-
if
|
| 3095 |
conn.execute("UPDATE users SET daily_keyword_count = daily_keyword_count + 1 WHERE id = ?", (user_id,))
|
| 3096 |
|
| 3097 |
# Global log for admin
|
|
@@ -3889,7 +3891,7 @@ async def update_user_vitals(uid: str, req: UserVitalsUpdateRequest, admin_id: s
|
|
| 3889 |
"basic": {"scrape_limit": 100, "max_accounts": 2, "max_daily_campaigns": 50, "max_daily_keywords": 15, "max_templates": 2, "price": 2000},
|
| 3890 |
"standard": {"scrape_limit": 250, "max_accounts": 5, "max_daily_campaigns": 150, "max_daily_keywords": 30, "max_templates": 5, "price": 3500},
|
| 3891 |
"premium": {"scrape_limit": 500, "max_accounts": 10, "max_daily_campaigns": 300, "max_daily_keywords": 50, "max_templates": 10, "price": 5000},
|
| 3892 |
-
"unlimited": {"scrape_limit":
|
| 3893 |
}
|
| 3894 |
|
| 3895 |
if plan_row:
|
|
@@ -3898,11 +3900,18 @@ async def update_user_vitals(uid: str, req: UserVitalsUpdateRequest, admin_id: s
|
|
| 3898 |
plan_cfg = DEFAULTS.get(req.plan, DEFAULTS["free"])
|
| 3899 |
|
| 3900 |
# Use provided override values or fall back to plan defaults
|
| 3901 |
-
|
| 3902 |
-
|
| 3903 |
-
|
| 3904 |
-
|
| 3905 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3906 |
|
| 3907 |
# Handle Subscription Dates
|
| 3908 |
activated_at = None
|
|
@@ -4174,8 +4183,9 @@ async def get_user_status(user_id: str = Depends(get_current_user_id)):
|
|
| 4174 |
if hasattr(conn, "close"): conn.close()
|
| 4175 |
|
| 4176 |
# Tier mapping
|
| 4177 |
-
user_role = row["role"] if ("role" in row.keys() and row["role"]) else "user"
|
| 4178 |
active_plan = "unlimited" if user_role == "admin" else (row["plan"] or "free")
|
|
|
|
| 4179 |
p_cfg = get_plan_configs().get(active_plan, get_plan_configs()["free"])
|
| 4180 |
|
| 4181 |
allowed_speeds = ["balanced"]
|
|
@@ -4183,18 +4193,28 @@ async def get_user_status(user_id: str = Depends(get_current_user_id)):
|
|
| 4183 |
allowed_speeds = ["balanced", "turbo"]
|
| 4184 |
elif active_plan == "standard":
|
| 4185 |
allowed_speeds = ["balanced", "turbo", "stealth"]
|
| 4186 |
-
elif active_plan
|
| 4187 |
allowed_speeds = ["balanced", "turbo", "stealth", "ultra"]
|
| 4188 |
|
| 4189 |
-
|
| 4190 |
-
|
| 4191 |
-
|
| 4192 |
-
|
| 4193 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4194 |
|
| 4195 |
return {
|
| 4196 |
"status": "success",
|
| 4197 |
"plan": active_plan,
|
|
|
|
| 4198 |
"original_plan": row["original_plan"] or "free",
|
| 4199 |
"active_coupon_code": row["active_coupon_code"],
|
| 4200 |
"coupon_expires_at": row["coupon_expires_at"],
|
|
@@ -4213,10 +4233,10 @@ async def get_user_status(user_id: str = Depends(get_current_user_id)):
|
|
| 4213 |
"has_proof": bool(row["payment_proof"]),
|
| 4214 |
"plan_expires_at": row["plan_expires_at"],
|
| 4215 |
"allowed_speeds": allowed_speeds,
|
| 4216 |
-
"has_spintax": active_plan != "free",
|
| 4217 |
-
"has_fleet_compare": active_plan != "free",
|
| 4218 |
"can_export_csv": True,
|
| 4219 |
-
"ai_keyword_cap":
|
| 4220 |
}
|
| 4221 |
|
| 4222 |
@app.post("/api/monetization/apply-coupon")
|
|
@@ -4394,7 +4414,7 @@ async def approve_payment_request(req_id: int, admin_id: str = Depends(get_curre
|
|
| 4394 |
"basic": {"scrape_limit": 100, "max_accounts": 2, "max_daily_campaigns": 50, "max_daily_keywords": 15, "max_templates": 2, "price": 2000},
|
| 4395 |
"standard": {"scrape_limit": 250, "max_accounts": 5, "max_daily_campaigns": 150, "max_daily_keywords": 30, "max_templates": 5, "price": 3500},
|
| 4396 |
"premium": {"scrape_limit": 500, "max_accounts": 10, "max_daily_campaigns": 300, "max_daily_keywords": 50, "max_templates": 10, "price": 5000},
|
| 4397 |
-
"unlimited": {"scrape_limit":
|
| 4398 |
}
|
| 4399 |
plan_cfg = dict(plan_row) if plan_row else DEFAULTS.get(plan_key, DEFAULTS["basic"])
|
| 4400 |
|
|
@@ -5516,12 +5536,14 @@ async def suggest_ai_keywords(req: AISuggestRequest, user_id: str = Depends(get_
|
|
| 5516 |
key = (req.api_key or "").strip()
|
| 5517 |
|
| 5518 |
# Enforce tiered keyword limits:
|
| 5519 |
-
# Free: 5, Basic: 15, Standard: 30, Premium: 50, Unlimited: 100
|
| 5520 |
conn_u = get_db_connection()
|
| 5521 |
-
u_row = conn_u.execute("SELECT plan, max_daily_keywords FROM users WHERE id = ?", (user_id,)).fetchone()
|
| 5522 |
if hasattr(conn_u, "close"): conn_u.close()
|
| 5523 |
-
|
| 5524 |
-
|
|
|
|
|
|
|
| 5525 |
|
| 5526 |
KEYWORD_LIMITS = {
|
| 5527 |
"free": 5,
|
|
@@ -5530,8 +5552,14 @@ async def suggest_ai_keywords(req: AISuggestRequest, user_id: str = Depends(get_
|
|
| 5530 |
"premium": 50,
|
| 5531 |
"unlimited": 100
|
| 5532 |
}
|
| 5533 |
-
|
| 5534 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5535 |
selected_model = (req.model or "").strip() or "meta-llama/llama-3.3-70b-instruct"
|
| 5536 |
|
| 5537 |
if not key:
|
|
@@ -5646,15 +5674,19 @@ async def suggest_ai_keywords(req: AISuggestRequest, user_id: str = Depends(get_
|
|
| 5646 |
seen.add(norm)
|
| 5647 |
clean_keywords.append(be)
|
| 5648 |
|
| 5649 |
-
# Strictly limit to plan allowance
|
| 5650 |
-
|
|
|
|
|
|
|
|
|
|
| 5651 |
|
| 5652 |
return {
|
| 5653 |
"seed": seed,
|
| 5654 |
"keywords": clean_keywords,
|
| 5655 |
"total": len(clean_keywords),
|
| 5656 |
-
"max_allowed": max_allowed,
|
| 5657 |
"plan": user_plan,
|
|
|
|
| 5658 |
"source": "openrouter",
|
| 5659 |
"model": selected_model,
|
| 5660 |
"error_note": error_note,
|
|
|
|
| 87 |
"basic": {"max_daily_campaigns": 50, "max_accounts": 2, "max_daily_keywords": 15, "scrape_limit": 100, "max_templates": 2, "has_premium_access": True},
|
| 88 |
"standard": {"max_daily_campaigns": 150, "max_accounts": 5, "max_daily_keywords": 30, "scrape_limit": 250, "max_templates": 5, "has_premium_access": True},
|
| 89 |
"premium": {"max_daily_campaigns": 300, "max_accounts": 10, "max_daily_keywords": 50, "scrape_limit": 500, "max_templates": 10, "has_premium_access": True},
|
| 90 |
+
"unlimited": {"max_daily_campaigns": 999999, "max_accounts": 999999, "max_daily_keywords": 999999, "scrape_limit": 999999, "max_templates": 999999, "has_premium_access": True}
|
| 91 |
}
|
| 92 |
conn = None
|
| 93 |
try:
|
|
|
|
| 2906 |
if hasattr(conn, "close"): conn.close()
|
| 2907 |
raise HTTPException(status_code=403, detail=f"Access Denied: The {plan.capitalize()} plan does not include Scraper access. Upgrade to UNLOCK.")
|
| 2908 |
|
| 2909 |
+
is_unlimited_plan = plan.lower() in ("unlimited", "admin", "lifetime", "enterprise") or user_id == "admin_virtual_id"
|
| 2910 |
+
allowed_limit = 999999 if is_unlimited_plan else (user_row["scrape_limit"] or plan_cfg["scrape_limit"])
|
| 2911 |
+
max_keywords = 999999 if is_unlimited_plan else int(user_row["max_daily_keywords"] or plan_cfg["max_daily_keywords"])
|
| 2912 |
current_keywords = int(user_row["daily_keyword_count"] or 0)
|
| 2913 |
|
| 2914 |
+
if not is_unlimited_plan and current_keywords >= max_keywords:
|
| 2915 |
if hasattr(conn, "close"): conn.close()
|
| 2916 |
raise HTTPException(status_code=403, detail="Daily usage limit reached for scraping. Reset at Midnight UTC.")
|
| 2917 |
|
| 2918 |
# Increment keyword use and Log Search Intelligence
|
| 2919 |
+
if not is_unlimited_plan:
|
| 2920 |
conn.execute("UPDATE users SET daily_keyword_count = daily_keyword_count + 1 WHERE id = ?", (user_id,))
|
| 2921 |
|
| 2922 |
# Unified global logging for Admin
|
|
|
|
| 3083 |
plan = (user_row["plan"] or "free")
|
| 3084 |
plan_cfg = get_plan_configs().get(plan, get_plan_configs()["free"])
|
| 3085 |
|
| 3086 |
+
is_unlimited_plan = plan.lower() in ("unlimited", "admin", "lifetime", "enterprise") or user_id == "admin_virtual_id"
|
| 3087 |
+
max_keywords = 999999 if is_unlimited_plan else int(user_row["max_daily_keywords"] or plan_cfg["max_daily_keywords"])
|
| 3088 |
current_keywords = int(user_row["daily_keyword_count"] or 0)
|
| 3089 |
+
scrape_limit = 999999 if is_unlimited_plan else int(user_row["scrape_limit"] or plan_cfg["scrape_limit"])
|
| 3090 |
|
| 3091 |
+
if not is_unlimited_plan and current_keywords >= max_keywords:
|
| 3092 |
if hasattr(conn, "close"): conn.close()
|
| 3093 |
raise HTTPException(status_code=403, detail="Daily search limit reached.")
|
| 3094 |
|
| 3095 |
# Increment search count and Log Keyword
|
| 3096 |
+
if not is_unlimited_plan:
|
| 3097 |
conn.execute("UPDATE users SET daily_keyword_count = daily_keyword_count + 1 WHERE id = ?", (user_id,))
|
| 3098 |
|
| 3099 |
# Global log for admin
|
|
|
|
| 3891 |
"basic": {"scrape_limit": 100, "max_accounts": 2, "max_daily_campaigns": 50, "max_daily_keywords": 15, "max_templates": 2, "price": 2000},
|
| 3892 |
"standard": {"scrape_limit": 250, "max_accounts": 5, "max_daily_campaigns": 150, "max_daily_keywords": 30, "max_templates": 5, "price": 3500},
|
| 3893 |
"premium": {"scrape_limit": 500, "max_accounts": 10, "max_daily_campaigns": 300, "max_daily_keywords": 50, "max_templates": 10, "price": 5000},
|
| 3894 |
+
"unlimited": {"scrape_limit": 999999, "max_accounts": 999999, "max_daily_campaigns": 999999, "max_daily_keywords": 999999, "max_templates": 999999, "price": 0},
|
| 3895 |
}
|
| 3896 |
|
| 3897 |
if plan_row:
|
|
|
|
| 3900 |
plan_cfg = DEFAULTS.get(req.plan, DEFAULTS["free"])
|
| 3901 |
|
| 3902 |
# Use provided override values or fall back to plan defaults
|
| 3903 |
+
if req.plan and req.plan.lower() in ("unlimited", "admin", "lifetime", "enterprise"):
|
| 3904 |
+
s_limit = 999999
|
| 3905 |
+
m_acc = 999999
|
| 3906 |
+
m_camp = 999999
|
| 3907 |
+
m_key = 999999
|
| 3908 |
+
m_tmpl = 999999
|
| 3909 |
+
else:
|
| 3910 |
+
s_limit = req.scrape_limit if req.scrape_limit is not None else plan_cfg["scrape_limit"]
|
| 3911 |
+
m_acc = req.max_accounts if req.max_accounts is not None else plan_cfg["max_accounts"]
|
| 3912 |
+
m_camp = req.max_daily_campaigns if req.max_daily_campaigns is not None else plan_cfg["max_daily_campaigns"]
|
| 3913 |
+
m_key = req.max_daily_keywords if req.max_daily_keywords is not None else plan_cfg["max_daily_keywords"]
|
| 3914 |
+
m_tmpl = plan_cfg.get("max_templates", 1)
|
| 3915 |
|
| 3916 |
# Handle Subscription Dates
|
| 3917 |
activated_at = None
|
|
|
|
| 4183 |
if hasattr(conn, "close"): conn.close()
|
| 4184 |
|
| 4185 |
# Tier mapping
|
| 4186 |
+
user_role = str(row["role"] if ("role" in row.keys() and row["role"]) else "user").lower().strip()
|
| 4187 |
active_plan = "unlimited" if user_role == "admin" else (row["plan"] or "free")
|
| 4188 |
+
is_unlimited = active_plan.lower() in ["unlimited", "admin", "lifetime", "enterprise"] or user_role == "admin"
|
| 4189 |
p_cfg = get_plan_configs().get(active_plan, get_plan_configs()["free"])
|
| 4190 |
|
| 4191 |
allowed_speeds = ["balanced"]
|
|
|
|
| 4193 |
allowed_speeds = ["balanced", "turbo"]
|
| 4194 |
elif active_plan == "standard":
|
| 4195 |
allowed_speeds = ["balanced", "turbo", "stealth"]
|
| 4196 |
+
elif is_unlimited or active_plan == "premium":
|
| 4197 |
allowed_speeds = ["balanced", "turbo", "stealth", "ultra"]
|
| 4198 |
|
| 4199 |
+
if is_unlimited:
|
| 4200 |
+
max_camps = 999999
|
| 4201 |
+
max_kws = 999999
|
| 4202 |
+
scrape_lim = 999999
|
| 4203 |
+
max_accs = 999999
|
| 4204 |
+
max_tpls = 999999
|
| 4205 |
+
ai_kw_cap = 100
|
| 4206 |
+
else:
|
| 4207 |
+
max_camps = row["max_daily_campaigns"] or p_cfg["max_daily_campaigns"]
|
| 4208 |
+
max_kws = row["max_daily_keywords"] or p_cfg["max_daily_keywords"]
|
| 4209 |
+
scrape_lim = row["scrape_limit"] or p_cfg["scrape_limit"]
|
| 4210 |
+
max_accs = row["max_accounts"] or p_cfg["max_accounts"]
|
| 4211 |
+
max_tpls = row["max_templates"] or p_cfg.get("max_templates", 1)
|
| 4212 |
+
ai_kw_cap = min(100, max_kws)
|
| 4213 |
|
| 4214 |
return {
|
| 4215 |
"status": "success",
|
| 4216 |
"plan": active_plan,
|
| 4217 |
+
"is_unlimited": is_unlimited,
|
| 4218 |
"original_plan": row["original_plan"] or "free",
|
| 4219 |
"active_coupon_code": row["active_coupon_code"],
|
| 4220 |
"coupon_expires_at": row["coupon_expires_at"],
|
|
|
|
| 4233 |
"has_proof": bool(row["payment_proof"]),
|
| 4234 |
"plan_expires_at": row["plan_expires_at"],
|
| 4235 |
"allowed_speeds": allowed_speeds,
|
| 4236 |
+
"has_spintax": is_unlimited or active_plan != "free",
|
| 4237 |
+
"has_fleet_compare": is_unlimited or active_plan != "free",
|
| 4238 |
"can_export_csv": True,
|
| 4239 |
+
"ai_keyword_cap": ai_kw_cap
|
| 4240 |
}
|
| 4241 |
|
| 4242 |
@app.post("/api/monetization/apply-coupon")
|
|
|
|
| 4414 |
"basic": {"scrape_limit": 100, "max_accounts": 2, "max_daily_campaigns": 50, "max_daily_keywords": 15, "max_templates": 2, "price": 2000},
|
| 4415 |
"standard": {"scrape_limit": 250, "max_accounts": 5, "max_daily_campaigns": 150, "max_daily_keywords": 30, "max_templates": 5, "price": 3500},
|
| 4416 |
"premium": {"scrape_limit": 500, "max_accounts": 10, "max_daily_campaigns": 300, "max_daily_keywords": 50, "max_templates": 10, "price": 5000},
|
| 4417 |
+
"unlimited": {"scrape_limit": 999999, "max_accounts": 999999, "max_daily_campaigns": 999999, "max_daily_keywords": 999999, "max_templates": 999999, "price": 0},
|
| 4418 |
}
|
| 4419 |
plan_cfg = dict(plan_row) if plan_row else DEFAULTS.get(plan_key, DEFAULTS["basic"])
|
| 4420 |
|
|
|
|
| 5536 |
key = (req.api_key or "").strip()
|
| 5537 |
|
| 5538 |
# Enforce tiered keyword limits:
|
| 5539 |
+
# Free: 5, Basic: 15, Standard: 30, Premium: 50, Unlimited: 100 (Full natural batch)
|
| 5540 |
conn_u = get_db_connection()
|
| 5541 |
+
u_row = conn_u.execute("SELECT plan, max_daily_keywords, role FROM users WHERE id = ?", (user_id,)).fetchone()
|
| 5542 |
if hasattr(conn_u, "close"): conn_u.close()
|
| 5543 |
+
|
| 5544 |
+
user_plan = (u_row["plan"] if u_row and "plan" in u_row.keys() and u_row["plan"] else (u_row[0] if u_row and u_row[0] else "free")).lower().strip()
|
| 5545 |
+
user_role = (u_row["role"] if u_row and "role" in u_row.keys() and u_row["role"] else (u_row[2] if u_row and len(u_row) > 2 and u_row[2] else "user")).lower().strip()
|
| 5546 |
+
is_unlimited = user_plan in ("unlimited", "admin", "lifetime", "enterprise") or user_role == "admin"
|
| 5547 |
|
| 5548 |
KEYWORD_LIMITS = {
|
| 5549 |
"free": 5,
|
|
|
|
| 5552 |
"premium": 50,
|
| 5553 |
"unlimited": 100
|
| 5554 |
}
|
| 5555 |
+
|
| 5556 |
+
if is_unlimited:
|
| 5557 |
+
max_allowed = 100
|
| 5558 |
+
target_count = 100
|
| 5559 |
+
else:
|
| 5560 |
+
custom_keywords_cap = u_row["max_daily_keywords"] if u_row and "max_daily_keywords" in u_row.keys() else (u_row[1] if u_row and len(u_row) > 1 else None)
|
| 5561 |
+
max_allowed = int(custom_keywords_cap) if (custom_keywords_cap and int(custom_keywords_cap) > 0) else KEYWORD_LIMITS.get(user_plan, 5)
|
| 5562 |
+
target_count = min(max_allowed, max(5, req.count or max_allowed))
|
| 5563 |
selected_model = (req.model or "").strip() or "meta-llama/llama-3.3-70b-instruct"
|
| 5564 |
|
| 5565 |
if not key:
|
|
|
|
| 5674 |
seen.add(norm)
|
| 5675 |
clean_keywords.append(be)
|
| 5676 |
|
| 5677 |
+
# Strictly limit to plan allowance if not unlimited
|
| 5678 |
+
if not is_unlimited:
|
| 5679 |
+
clean_keywords = clean_keywords[:max_allowed]
|
| 5680 |
+
else:
|
| 5681 |
+
clean_keywords = clean_keywords[:100]
|
| 5682 |
|
| 5683 |
return {
|
| 5684 |
"seed": seed,
|
| 5685 |
"keywords": clean_keywords,
|
| 5686 |
"total": len(clean_keywords),
|
| 5687 |
+
"max_allowed": 100 if is_unlimited else max_allowed,
|
| 5688 |
"plan": user_plan,
|
| 5689 |
+
"is_unlimited": is_unlimited,
|
| 5690 |
"source": "openrouter",
|
| 5691 |
"model": selected_model,
|
| 5692 |
"error_note": error_note,
|
frontend/src/app/page.tsx
CHANGED
|
@@ -33,6 +33,7 @@ export default function Dashboard() {
|
|
| 33 |
const [activeTooltip, setActiveTooltip] = useState<{ index: number; x: number; y: number; val: number; date: string } | null>(null);
|
| 34 |
const [isRunningDiagnostics, setIsRunningDiagnostics] = useState(false);
|
| 35 |
const [diagnosticsSuccess, setDiagnosticsSuccess] = useState(false);
|
|
|
|
| 36 |
|
| 37 |
|
| 38 |
// Generate date labels
|
|
@@ -514,20 +515,20 @@ export default function Dashboard() {
|
|
| 514 |
Daily Messages Sent
|
| 515 |
</span>
|
| 516 |
<span className="font-mono text-emerald-400 font-bold">
|
| 517 |
-
{stats?.user_plan?.daily_campaign_count ?? 0} / {stats?.user_plan?.max_daily_campaigns ?? 20}
|
| 518 |
</span>
|
| 519 |
</div>
|
| 520 |
<div className="h-1.5 bg-foreground/5 rounded-full overflow-hidden">
|
| 521 |
<div
|
| 522 |
className="h-full bg-emerald-500 rounded-full transition-all duration-500"
|
| 523 |
style={{
|
| 524 |
-
width: `${Math.min(100, Math.round(((stats?.user_plan?.daily_campaign_count || 0) / (stats?.user_plan?.max_daily_campaigns || 20)) * 100))}%`
|
| 525 |
}}
|
| 526 |
/>
|
| 527 |
</div>
|
| 528 |
<div className="flex justify-between text-[9px] text-foreground/40 font-medium">
|
| 529 |
<span>Resets at midnight UTC</span>
|
| 530 |
-
<span>{Math.max(0, (stats?.user_plan?.max_daily_campaigns || 20) - (stats?.user_plan?.daily_campaign_count || 0))} left today</span>
|
| 531 |
</div>
|
| 532 |
</div>
|
| 533 |
|
|
@@ -539,20 +540,20 @@ export default function Dashboard() {
|
|
| 539 |
Connected Telegram Accounts
|
| 540 |
</span>
|
| 541 |
<span className="font-mono text-indigo-400 font-bold">
|
| 542 |
-
{stats?.counts?.accounts ?? 0} / {stats?.user_plan?.max_accounts ?? 1}
|
| 543 |
</span>
|
| 544 |
</div>
|
| 545 |
<div className="h-1.5 bg-foreground/5 rounded-full overflow-hidden">
|
| 546 |
<div
|
| 547 |
className="h-full bg-gradient-to-r from-indigo-500 to-indigo-400 rounded-full transition-all duration-500"
|
| 548 |
style={{
|
| 549 |
-
width: `${Math.min(100, Math.round(((stats?.counts?.accounts || 0) / (stats?.user_plan?.max_accounts || 1)) * 100))}%`
|
| 550 |
}}
|
| 551 |
/>
|
| 552 |
</div>
|
| 553 |
<div className="flex justify-between text-[9px] text-foreground/40 font-medium">
|
| 554 |
<span>Account sending slots</span>
|
| 555 |
-
<span>{stats?.counts?.accounts || 0} active</span>
|
| 556 |
</div>
|
| 557 |
</div>
|
| 558 |
|
|
@@ -564,20 +565,20 @@ export default function Dashboard() {
|
|
| 564 |
AI Keyword Searches
|
| 565 |
</span>
|
| 566 |
<span className="font-mono text-purple-400 font-bold">
|
| 567 |
-
{stats?.user_plan?.daily_keyword_count ?? 0} / {stats?.user_plan?.max_daily_keywords ?? 5}
|
| 568 |
</span>
|
| 569 |
</div>
|
| 570 |
<div className="h-1.5 bg-foreground/5 rounded-full overflow-hidden">
|
| 571 |
<div
|
| 572 |
className="h-full bg-purple-500 rounded-full transition-all duration-500"
|
| 573 |
style={{
|
| 574 |
-
width: `${Math.min(100, Math.round(((stats?.user_plan?.daily_keyword_count || 0) / (stats?.user_plan?.max_daily_keywords || 5)) * 100))}%`
|
| 575 |
}}
|
| 576 |
/>
|
| 577 |
</div>
|
| 578 |
<div className="flex justify-between text-[9px] text-foreground/40 font-medium">
|
| 579 |
<span>Smart audience finder</span>
|
| 580 |
-
<span>{Math.max(0, (stats?.user_plan?.max_daily_keywords || 5) - (stats?.user_plan?.daily_keyword_count || 0))} searches left</span>
|
| 581 |
</div>
|
| 582 |
</div>
|
| 583 |
|
|
@@ -588,7 +589,7 @@ export default function Dashboard() {
|
|
| 588 |
Scrape Capacity Per Group
|
| 589 |
</span>
|
| 590 |
<span className="font-mono text-cyan-400 font-bold">
|
| 591 |
-
{stats?.user_plan?.scrape_limit ?? 50} leads/search
|
| 592 |
</span>
|
| 593 |
</div>
|
| 594 |
</div>
|
|
|
|
| 33 |
const [activeTooltip, setActiveTooltip] = useState<{ index: number; x: number; y: number; val: number; date: string } | null>(null);
|
| 34 |
const [isRunningDiagnostics, setIsRunningDiagnostics] = useState(false);
|
| 35 |
const [diagnosticsSuccess, setDiagnosticsSuccess] = useState(false);
|
| 36 |
+
const isUnlimited = (stats?.user_plan?.plan || '').toLowerCase() === 'unlimited' || Boolean(stats?.user_plan?.is_unlimited) || ((stats?.user_plan?.max_daily_campaigns || 0) >= 99999);
|
| 37 |
|
| 38 |
|
| 39 |
// Generate date labels
|
|
|
|
| 515 |
Daily Messages Sent
|
| 516 |
</span>
|
| 517 |
<span className="font-mono text-emerald-400 font-bold">
|
| 518 |
+
{isUnlimited ? `${stats?.user_plan?.daily_campaign_count ?? 0} / β Unlimited` : `${stats?.user_plan?.daily_campaign_count ?? 0} / ${stats?.user_plan?.max_daily_campaigns ?? 20}`}
|
| 519 |
</span>
|
| 520 |
</div>
|
| 521 |
<div className="h-1.5 bg-foreground/5 rounded-full overflow-hidden">
|
| 522 |
<div
|
| 523 |
className="h-full bg-emerald-500 rounded-full transition-all duration-500"
|
| 524 |
style={{
|
| 525 |
+
width: `${isUnlimited ? 100 : Math.min(100, Math.round(((stats?.user_plan?.daily_campaign_count || 0) / (stats?.user_plan?.max_daily_campaigns || 20)) * 100))}%`
|
| 526 |
}}
|
| 527 |
/>
|
| 528 |
</div>
|
| 529 |
<div className="flex justify-between text-[9px] text-foreground/40 font-medium">
|
| 530 |
<span>Resets at midnight UTC</span>
|
| 531 |
+
<span>{isUnlimited ? 'β Unlimited broadcasts' : `${Math.max(0, (stats?.user_plan?.max_daily_campaigns || 20) - (stats?.user_plan?.daily_campaign_count || 0))} left today`}</span>
|
| 532 |
</div>
|
| 533 |
</div>
|
| 534 |
|
|
|
|
| 540 |
Connected Telegram Accounts
|
| 541 |
</span>
|
| 542 |
<span className="font-mono text-indigo-400 font-bold">
|
| 543 |
+
{isUnlimited ? `${stats?.counts?.accounts ?? 0} / β Unlimited` : `${stats?.counts?.accounts ?? 0} / ${stats?.user_plan?.max_accounts ?? 1}`}
|
| 544 |
</span>
|
| 545 |
</div>
|
| 546 |
<div className="h-1.5 bg-foreground/5 rounded-full overflow-hidden">
|
| 547 |
<div
|
| 548 |
className="h-full bg-gradient-to-r from-indigo-500 to-indigo-400 rounded-full transition-all duration-500"
|
| 549 |
style={{
|
| 550 |
+
width: `${isUnlimited ? 100 : Math.min(100, Math.round(((stats?.counts?.accounts || 0) / (stats?.user_plan?.max_accounts || 1)) * 100))}%`
|
| 551 |
}}
|
| 552 |
/>
|
| 553 |
</div>
|
| 554 |
<div className="flex justify-between text-[9px] text-foreground/40 font-medium">
|
| 555 |
<span>Account sending slots</span>
|
| 556 |
+
<span>{isUnlimited ? 'β Unlimited active slots' : `${stats?.counts?.accounts || 0} active`}</span>
|
| 557 |
</div>
|
| 558 |
</div>
|
| 559 |
|
|
|
|
| 565 |
AI Keyword Searches
|
| 566 |
</span>
|
| 567 |
<span className="font-mono text-purple-400 font-bold">
|
| 568 |
+
{isUnlimited ? `${stats?.user_plan?.daily_keyword_count ?? 0} / β Unlimited` : `${stats?.user_plan?.daily_keyword_count ?? 0} / ${stats?.user_plan?.max_daily_keywords ?? 5}`}
|
| 569 |
</span>
|
| 570 |
</div>
|
| 571 |
<div className="h-1.5 bg-foreground/5 rounded-full overflow-hidden">
|
| 572 |
<div
|
| 573 |
className="h-full bg-purple-500 rounded-full transition-all duration-500"
|
| 574 |
style={{
|
| 575 |
+
width: `${isUnlimited ? 100 : Math.min(100, Math.round(((stats?.user_plan?.daily_keyword_count || 0) / (stats?.user_plan?.max_daily_keywords || 5)) * 100))}%`
|
| 576 |
}}
|
| 577 |
/>
|
| 578 |
</div>
|
| 579 |
<div className="flex justify-between text-[9px] text-foreground/40 font-medium">
|
| 580 |
<span>Smart audience finder</span>
|
| 581 |
+
<span>{isUnlimited ? 'β Unlimited searches' : `${Math.max(0, (stats?.user_plan?.max_daily_keywords || 5) - (stats?.user_plan?.daily_keyword_count || 0))} searches left`}</span>
|
| 582 |
</div>
|
| 583 |
</div>
|
| 584 |
|
|
|
|
| 589 |
Scrape Capacity Per Group
|
| 590 |
</span>
|
| 591 |
<span className="font-mono text-cyan-400 font-bold">
|
| 592 |
+
{isUnlimited ? 'β Unlimited leads/search' : `${stats?.user_plan?.scrape_limit ?? 50} leads/search`}
|
| 593 |
</span>
|
| 594 |
</div>
|
| 595 |
</div>
|
frontend/src/app/scraper/page.tsx
CHANGED
|
@@ -413,9 +413,10 @@ export default function ScraperPage() {
|
|
| 413 |
if (data.is_free_limit || (data.error_note && data.error_note.includes('FREE_MODEL_LIMIT'))) {
|
| 414 |
setFreeModelLimitAlert(data.error_note || `The free model '${storedModel}' has reached OpenRouter's free tier rate limit. Fallback keyword intelligence was provided.`);
|
| 415 |
}
|
| 416 |
-
const
|
|
|
|
| 417 |
? ` (${(data.plan || 'Free').toUpperCase()} plan cap: ${data.max_allowed})`
|
| 418 |
-
: '';
|
| 419 |
setSuccessMsg(`Generated ${data.keywords.length} AI keywords${capNotice}!`);
|
| 420 |
setTimeout(() => setSuccessMsg(''), 4500);
|
| 421 |
} else {
|
|
@@ -1113,9 +1114,9 @@ export default function ScraperPage() {
|
|
| 1113 |
AI Suggestions for <span className="text-indigo-400 font-extrabold">"{suggestionSeed}"</span>
|
| 1114 |
</h4>
|
| 1115 |
<span className="text-[10px] px-2 py-0.2 rounded-full bg-indigo-500/15 text-indigo-400 font-bold border border-indigo-500/20">
|
| 1116 |
-
{suggestions.length} keywords {suggestionsMaxAllowed && suggestionsMaxAllowed < 100 ? `(Cap: ${suggestionsMaxAllowed})` : ''}
|
| 1117 |
</span>
|
| 1118 |
-
{suggestionsMaxAllowed && suggestionsMaxAllowed < 100 && (
|
| 1119 |
<span className="text-[10px] px-2 py-0.2 rounded-full bg-amber-500/15 text-amber-300 font-bold border border-amber-500/25">
|
| 1120 |
Plan: {(suggestionsPlan || 'Free').toUpperCase()}
|
| 1121 |
</span>
|
|
|
|
| 413 |
if (data.is_free_limit || (data.error_note && data.error_note.includes('FREE_MODEL_LIMIT'))) {
|
| 414 |
setFreeModelLimitAlert(data.error_note || `The free model '${storedModel}' has reached OpenRouter's free tier rate limit. Fallback keyword intelligence was provided.`);
|
| 415 |
}
|
| 416 |
+
const isUnlimited = (data.plan || '').toLowerCase() === 'unlimited' || Boolean(data.is_unlimited) || (data.max_allowed >= 100);
|
| 417 |
+
const capNotice = !isUnlimited && data.max_allowed && data.max_allowed < 100
|
| 418 |
? ` (${(data.plan || 'Free').toUpperCase()} plan cap: ${data.max_allowed})`
|
| 419 |
+
: (isUnlimited ? ' (Unlimited Plan)' : '');
|
| 420 |
setSuccessMsg(`Generated ${data.keywords.length} AI keywords${capNotice}!`);
|
| 421 |
setTimeout(() => setSuccessMsg(''), 4500);
|
| 422 |
} else {
|
|
|
|
| 1114 |
AI Suggestions for <span className="text-indigo-400 font-extrabold">"{suggestionSeed}"</span>
|
| 1115 |
</h4>
|
| 1116 |
<span className="text-[10px] px-2 py-0.2 rounded-full bg-indigo-500/15 text-indigo-400 font-bold border border-indigo-500/20">
|
| 1117 |
+
{suggestions.length} keywords {(suggestionsPlan || '').toLowerCase() === 'unlimited' || (suggestionsMaxAllowed && suggestionsMaxAllowed >= 100) ? 'β’ Unlimited Plan' : (suggestionsMaxAllowed && suggestionsMaxAllowed < 100 ? `(Cap: ${suggestionsMaxAllowed})` : '')}
|
| 1118 |
</span>
|
| 1119 |
+
{(suggestionsPlan || '').toLowerCase() !== 'unlimited' && suggestionsMaxAllowed && suggestionsMaxAllowed < 100 && (
|
| 1120 |
<span className="text-[10px] px-2 py-0.2 rounded-full bg-amber-500/15 text-amber-300 font-bold border border-amber-500/25">
|
| 1121 |
Plan: {(suggestionsPlan || 'Free').toUpperCase()}
|
| 1122 |
</span>
|
frontend/src/components/Sidebar.tsx
CHANGED
|
@@ -58,6 +58,7 @@ export function Sidebar({ children }: { children: React.ReactNode }) {
|
|
| 58 |
const [user, setUser] = useState<any>(null);
|
| 59 |
const [status, setStatus] = useState<any>(null);
|
| 60 |
const [loading, setLoading] = useState(true);
|
|
|
|
| 61 |
|
| 62 |
useEffect(() => {
|
| 63 |
setMounted(true);
|
|
@@ -429,12 +430,12 @@ export function Sidebar({ children }: { children: React.ReactNode }) {
|
|
| 429 |
<div className="space-y-1">
|
| 430 |
<div className="flex justify-between text-[9px] font-bold text-foreground/30 uppercase">
|
| 431 |
<span>Templates Saved</span>
|
| 432 |
-
<span>{status?.template_count || 0} / {status?.max_templates || 1}</span>
|
| 433 |
</div>
|
| 434 |
<div className="h-1 w-full bg-foreground/5 rounded-full overflow-hidden">
|
| 435 |
<div
|
| 436 |
className="h-full bg-indigo-500 transition-all duration-1000"
|
| 437 |
-
style={{ width: `${Math.min(100, ((status?.template_count || 0) / (status?.max_templates || 1)) * 100)}%` }}
|
| 438 |
/>
|
| 439 |
</div>
|
| 440 |
</div>
|
|
@@ -443,12 +444,12 @@ export function Sidebar({ children }: { children: React.ReactNode }) {
|
|
| 443 |
<div className="space-y-1">
|
| 444 |
<div className="flex justify-between text-[9px] font-bold text-foreground/30 uppercase">
|
| 445 |
<span>Daily Campaigns</span>
|
| 446 |
-
<span>{status?.daily_campaign_count || 0} / {status?.max_daily_campaigns || 20}</span>
|
| 447 |
</div>
|
| 448 |
<div className="h-1 w-full bg-foreground/5 rounded-full overflow-hidden">
|
| 449 |
<div
|
| 450 |
className="h-full bg-blue-500 transition-all duration-1000"
|
| 451 |
-
style={{ width: `${Math.min(100, ((status?.daily_campaign_count || 0) / (status?.max_daily_campaigns || 20)) * 100)}%` }}
|
| 452 |
/>
|
| 453 |
</div>
|
| 454 |
</div>
|
|
@@ -459,12 +460,12 @@ export function Sidebar({ children }: { children: React.ReactNode }) {
|
|
| 459 |
<div className="space-y-1">
|
| 460 |
<div className="flex justify-between text-[9px] font-bold text-foreground/30 uppercase">
|
| 461 |
<span>Keywords Searched</span>
|
| 462 |
-
<span>{status?.daily_keyword_count || 0} / {status?.max_daily_keywords || 5}</span>
|
| 463 |
</div>
|
| 464 |
<div className="h-1 w-full bg-foreground/5 rounded-full overflow-hidden">
|
| 465 |
<div
|
| 466 |
className="h-full bg-emerald-500 transition-all duration-1000"
|
| 467 |
-
style={{ width: `${Math.min(100, ((status?.daily_keyword_count || 0) / (status?.max_daily_keywords || 5)) * 100)}%` }}
|
| 468 |
/>
|
| 469 |
</div>
|
| 470 |
</div>
|
|
@@ -472,7 +473,7 @@ export function Sidebar({ children }: { children: React.ReactNode }) {
|
|
| 472 |
{/* Scrape Power */}
|
| 473 |
<div className="flex justify-between text-[9px] font-bold text-foreground/30 uppercase pt-1">
|
| 474 |
<span>Scrape Limit</span>
|
| 475 |
-
<span className="text-foreground/60">{status?.scrape_limit || 50} / search</span>
|
| 476 |
</div>
|
| 477 |
</>
|
| 478 |
)}
|
|
@@ -553,27 +554,27 @@ export function Sidebar({ children }: { children: React.ReactNode }) {
|
|
| 553 |
<div className="space-y-2 text-xs max-h-[55vh] overflow-y-auto custom-scrollbar pr-1">
|
| 554 |
<div className="p-2.5 rounded-xl bg-input/40 border border-border/60 flex items-center justify-between">
|
| 555 |
<span className="text-foreground/60 text-[11px]">1. Telegram Accounts</span>
|
| 556 |
-
<span className="font-bold text-foreground text-[11px] font-mono">{status?.max_accounts || 1} Allowed</span>
|
| 557 |
</div>
|
| 558 |
|
| 559 |
<div className="p-2.5 rounded-xl bg-input/40 border border-border/60 flex items-center justify-between">
|
| 560 |
<span className="text-foreground/60 text-[11px]">2. Daily Campaigns</span>
|
| 561 |
-
<span className="font-bold text-foreground text-[11px] font-mono">{status?.daily_campaign_count || 0} / {status?.max_daily_campaigns || 20}</span>
|
| 562 |
</div>
|
| 563 |
|
| 564 |
<div className="p-2.5 rounded-xl bg-input/40 border border-border/60 flex items-center justify-between">
|
| 565 |
<span className="text-foreground/60 text-[11px]">3. Scraper Power</span>
|
| 566 |
-
<span className="font-bold text-foreground text-[11px] font-mono">{status?.scrape_limit || 50} groups / search</span>
|
| 567 |
</div>
|
| 568 |
|
| 569 |
<div className="p-2.5 rounded-xl bg-input/40 border border-border/60 flex items-center justify-between">
|
| 570 |
<span className="text-foreground/60 text-[11px]">4. AI Keyword Suggestions</span>
|
| 571 |
-
<span className="font-bold text-foreground text-[11px] font-mono">{status?.ai_keyword_cap || 5} per prompt</span>
|
| 572 |
</div>
|
| 573 |
|
| 574 |
<div className="p-2.5 rounded-xl bg-input/40 border border-border/60 flex items-center justify-between">
|
| 575 |
<span className="text-foreground/60 text-[11px]">5. Saved Templates</span>
|
| 576 |
-
<span className="font-bold text-foreground text-[11px] font-mono">{status?.template_count || 0} / {status?.max_templates || 1}</span>
|
| 577 |
</div>
|
| 578 |
|
| 579 |
<div className="p-2.5 rounded-xl bg-input/40 border border-border/60 flex items-center justify-between">
|
|
|
|
| 58 |
const [user, setUser] = useState<any>(null);
|
| 59 |
const [status, setStatus] = useState<any>(null);
|
| 60 |
const [loading, setLoading] = useState(true);
|
| 61 |
+
const isUnlimited = (status?.plan || '').toLowerCase() === 'unlimited' || Boolean(status?.is_unlimited) || ((status?.max_daily_campaigns || 0) >= 99999);
|
| 62 |
|
| 63 |
useEffect(() => {
|
| 64 |
setMounted(true);
|
|
|
|
| 430 |
<div className="space-y-1">
|
| 431 |
<div className="flex justify-between text-[9px] font-bold text-foreground/30 uppercase">
|
| 432 |
<span>Templates Saved</span>
|
| 433 |
+
<span>{isUnlimited ? `${status?.template_count || 0} / β Unlimited` : `${status?.template_count || 0} / ${status?.max_templates || 1}`}</span>
|
| 434 |
</div>
|
| 435 |
<div className="h-1 w-full bg-foreground/5 rounded-full overflow-hidden">
|
| 436 |
<div
|
| 437 |
className="h-full bg-indigo-500 transition-all duration-1000"
|
| 438 |
+
style={{ width: `${isUnlimited ? 100 : Math.min(100, ((status?.template_count || 0) / (status?.max_templates || 1)) * 100)}%` }}
|
| 439 |
/>
|
| 440 |
</div>
|
| 441 |
</div>
|
|
|
|
| 444 |
<div className="space-y-1">
|
| 445 |
<div className="flex justify-between text-[9px] font-bold text-foreground/30 uppercase">
|
| 446 |
<span>Daily Campaigns</span>
|
| 447 |
+
<span>{isUnlimited ? `${status?.daily_campaign_count || 0} / β Unlimited` : `${status?.daily_campaign_count || 0} / ${status?.max_daily_campaigns || 20}`}</span>
|
| 448 |
</div>
|
| 449 |
<div className="h-1 w-full bg-foreground/5 rounded-full overflow-hidden">
|
| 450 |
<div
|
| 451 |
className="h-full bg-blue-500 transition-all duration-1000"
|
| 452 |
+
style={{ width: `${isUnlimited ? 100 : Math.min(100, ((status?.daily_campaign_count || 0) / (status?.max_daily_campaigns || 20)) * 100)}%` }}
|
| 453 |
/>
|
| 454 |
</div>
|
| 455 |
</div>
|
|
|
|
| 460 |
<div className="space-y-1">
|
| 461 |
<div className="flex justify-between text-[9px] font-bold text-foreground/30 uppercase">
|
| 462 |
<span>Keywords Searched</span>
|
| 463 |
+
<span>{isUnlimited ? `${status?.daily_keyword_count || 0} / β Unlimited` : `${status?.daily_keyword_count || 0} / ${status?.max_daily_keywords || 5}`}</span>
|
| 464 |
</div>
|
| 465 |
<div className="h-1 w-full bg-foreground/5 rounded-full overflow-hidden">
|
| 466 |
<div
|
| 467 |
className="h-full bg-emerald-500 transition-all duration-1000"
|
| 468 |
+
style={{ width: `${isUnlimited ? 100 : Math.min(100, ((status?.daily_keyword_count || 0) / (status?.max_daily_keywords || 5)) * 100)}%` }}
|
| 469 |
/>
|
| 470 |
</div>
|
| 471 |
</div>
|
|
|
|
| 473 |
{/* Scrape Power */}
|
| 474 |
<div className="flex justify-between text-[9px] font-bold text-foreground/30 uppercase pt-1">
|
| 475 |
<span>Scrape Limit</span>
|
| 476 |
+
<span className="text-foreground/60">{isUnlimited ? 'β Unlimited' : `${status?.scrape_limit || 50} / search`}</span>
|
| 477 |
</div>
|
| 478 |
</>
|
| 479 |
)}
|
|
|
|
| 554 |
<div className="space-y-2 text-xs max-h-[55vh] overflow-y-auto custom-scrollbar pr-1">
|
| 555 |
<div className="p-2.5 rounded-xl bg-input/40 border border-border/60 flex items-center justify-between">
|
| 556 |
<span className="text-foreground/60 text-[11px]">1. Telegram Accounts</span>
|
| 557 |
+
<span className="font-bold text-foreground text-[11px] font-mono">{isUnlimited ? 'β Unlimited Allowed' : `${status?.max_accounts || 1} Allowed`}</span>
|
| 558 |
</div>
|
| 559 |
|
| 560 |
<div className="p-2.5 rounded-xl bg-input/40 border border-border/60 flex items-center justify-between">
|
| 561 |
<span className="text-foreground/60 text-[11px]">2. Daily Campaigns</span>
|
| 562 |
+
<span className="font-bold text-foreground text-[11px] font-mono">{isUnlimited ? `${status?.daily_campaign_count || 0} / β Unlimited` : `${status?.daily_campaign_count || 0} / ${status?.max_daily_campaigns || 20}`}</span>
|
| 563 |
</div>
|
| 564 |
|
| 565 |
<div className="p-2.5 rounded-xl bg-input/40 border border-border/60 flex items-center justify-between">
|
| 566 |
<span className="text-foreground/60 text-[11px]">3. Scraper Power</span>
|
| 567 |
+
<span className="font-bold text-foreground text-[11px] font-mono">{isUnlimited ? 'β Unlimited (1,500+ groups)' : `${status?.scrape_limit || 50} groups / search`}</span>
|
| 568 |
</div>
|
| 569 |
|
| 570 |
<div className="p-2.5 rounded-xl bg-input/40 border border-border/60 flex items-center justify-between">
|
| 571 |
<span className="text-foreground/60 text-[11px]">4. AI Keyword Suggestions</span>
|
| 572 |
+
<span className="font-bold text-foreground text-[11px] font-mono">{isUnlimited ? '100 per prompt (Natural Max)' : `${status?.ai_keyword_cap || 5} per prompt`}</span>
|
| 573 |
</div>
|
| 574 |
|
| 575 |
<div className="p-2.5 rounded-xl bg-input/40 border border-border/60 flex items-center justify-between">
|
| 576 |
<span className="text-foreground/60 text-[11px]">5. Saved Templates</span>
|
| 577 |
+
<span className="font-bold text-foreground text-[11px] font-mono">{isUnlimited ? `${status?.template_count || 0} / β Unlimited` : `${status?.template_count || 0} / ${status?.max_templates || 1}`}</span>
|
| 578 |
</div>
|
| 579 |
|
| 580 |
<div className="p-2.5 rounded-xl bg-input/40 border border-border/60 flex items-center justify-between">
|