File size: 1,533 Bytes
3c39169
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# user_dashboard.py - Gradio-based interface to view token usage and affiliate stats

import gradio as gr
from monetization.token_manager import TokenManager
from monetization.affiliate_engine import get_affiliate_recommendations

# Simulated app + earnings tracker
USER_APPS = {
    "user_001": [
        {"title": "WaveBot", "category": "retail", "clicks": 8, "revenue": 2.55},
        {"title": "EduHelper", "category": "educational", "clicks": 13, "revenue": 5.20}
    ]
}

tm = TokenManager()
tm.register_user("user_001")

def dashboard_view(user_id):
    balance = tm.check_balance(user_id)
    apps = USER_APPS.get(user_id, [])
    total_revenue = sum(app['revenue'] for app in apps)

    app_display = "\n".join([f"πŸ“¦ {a['title']} ({a['category']}): ${a['revenue']:.2f} from {a['clicks']} clicks" for a in apps])
    recs = get_affiliate_recommendations(apps[0]['category'] if apps else "creative")
    rec_display = "\n".join([f"πŸ”— [{r['name']}]({r['url']})" for r in recs])

    return f"""
πŸͺ™ Tokens: {balance}
πŸ’° Total Affiliate Revenue: ${total_revenue:.2f}

**Your Apps:**
{app_display}

**Suggested Monetization Products:**
{rec_display}
"""

# Launch dashboard
if __name__ == "__main__":
    with gr.Blocks() as dash:
        gr.Markdown("""# πŸ“Š Your RoboSage Creator Dashboard""")
        uid = gr.Textbox(label="Enter your User ID", value="user_001")
        output = gr.Markdown()
        go = gr.Button("Load Dashboard")
        go.click(fn=dashboard_view, inputs=uid, outputs=output)
    dash.launch()