Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -321,4 +321,50 @@ with gr.Blocks(title="Graffiti Admin Dashboard") as app:
|
|
321 |
save_out = gr.Textbox()
|
322 |
save_btn.click(save_users, users_tbl, save_out)
|
323 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
324 |
app.launch()
|
|
|
|
321 |
save_out = gr.Textbox()
|
322 |
save_btn.click(save_users, users_tbl, save_out)
|
323 |
|
324 |
+
# -------------------- Self Sourced Leads --------------------
|
325 |
+
SHEET_MAP = {
|
326 |
+
"Alice": "https://docs.google.com/spreadsheets/d/18qFpkbE2CwVOgiB6Xz4m2Ep7ZA29p5xV",
|
327 |
+
"Bob": "https://docs.google.com/spreadsheets/d/1EKngyAvq_3hzQMAOVame2nO9LKPJEV0d",
|
328 |
+
"Charlie": "https://docs.google.com/spreadsheets/d/164OTu1keBC12-5XFUDXMmLOPMkdAjBOM",
|
329 |
+
"Dave": "https://docs.google.com/spreadsheets/d/1m5e6YXxjK62vtBxYGkJSyHpHT7lnirg6"
|
330 |
+
}
|
331 |
+
|
332 |
+
def load_leads_data(rep_name):
|
333 |
+
if rep_name not in SHEET_MAP:
|
334 |
+
return pd.DataFrame([{"Error": f"No sheet available for '{rep_name}'"}])
|
335 |
+
|
336 |
+
sheet_url = SHEET_MAP[rep_name]
|
337 |
+
try:
|
338 |
+
sheet = client.open_by_url(sheet_url)
|
339 |
+
worksheet = sheet.get_worksheet(0)
|
340 |
+
data = worksheet.get_all_values()
|
341 |
+
if not data:
|
342 |
+
return pd.DataFrame([{"Info": "No data available"}])
|
343 |
+
return pd.DataFrame(data[1:], columns=data[0])
|
344 |
+
except Exception as e:
|
345 |
+
return pd.DataFrame([{"Error": str(e)}])
|
346 |
+
|
347 |
+
# (Keep all your existing utility functions, report functions, and other definitions here)
|
348 |
+
|
349 |
+
# -------------------- UI LAYOUT --------------------
|
350 |
+
with gr.Blocks(title="Graffiti Admin Dashboard") as app:
|
351 |
+
gr.Markdown("# 📆 Graffiti Admin Dashboard")
|
352 |
+
|
353 |
+
# (Keep your existing tabs exactly as they are here: Calls, Appointments, Allocated Leads, Quotes, Insights, User Management)
|
354 |
+
|
355 |
+
# -- Self Sourced Leads Tab (New) --
|
356 |
+
with gr.Tab("Self Sourced Leads"):
|
357 |
+
gr.Markdown("## 🔍 Self Sourced Leads by Rep")
|
358 |
+
|
359 |
+
rep_leads = gr.Dropdown(
|
360 |
+
label="Select Rep",
|
361 |
+
choices=list(SHEET_MAP.keys()),
|
362 |
+
allow_custom_value=True
|
363 |
+
)
|
364 |
+
btn_load_leads = gr.Button("Load Leads")
|
365 |
+
tbl_leads = gr.Dataframe(label="Leads Data")
|
366 |
+
|
367 |
+
btn_load_leads.click(load_leads_data, rep_leads, tbl_leads)
|
368 |
+
|
369 |
app.launch()
|
370 |
+
|