|
|
|
|
|
import gradio as gr |
|
from monetization.token_manager import TokenManager |
|
from monetization.affiliate_engine import get_affiliate_recommendations |
|
|
|
|
|
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} |
|
""" |
|
|
|
|
|
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() |
|
|