From c249ebb62d0e0066582a1e806da79fc25e2699ee Mon Sep 17 00:00:00 2001 From: Jun-te Kim Date: Wed, 26 Nov 2025 08:04:28 +0000 Subject: [PATCH] got the link working --- backend/src/dashboard/main.py | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/backend/src/dashboard/main.py b/backend/src/dashboard/main.py index 3c8f598..fe6329b 100644 --- a/backend/src/dashboard/main.py +++ b/backend/src/dashboard/main.py @@ -254,37 +254,50 @@ def update_tables(selected_date, n_clicks): return planned_records, completed_records + +def id_to_link(deal_id): + url = f"https://app.hubspot.com/contacts/145275138/record/0-3/{deal_id}" + return html.Li( + html.A(deal_id, href=url, target="_blank", style={"textDecoration": "none"}) + ) + + # ----------------------------------------------------- # Callback: Modal for Planned + Completed tables # ----------------------------------------------------- @app.callback( Output("hubspot-modal", "is_open"), Output("modal-body", "children"), + Output("planned-table", "selected_rows"), + Output("completed-table", "selected_rows"), Input("planned-table", "selected_rows"), Input("completed-table", "selected_rows"), Input("close-modal", "n_clicks"), State("planned-table", "data"), State("completed-table", "data"), - State("hubspot-modal", "is_open"), + State("hubspot-modal", "is_open") ) def open_modal(planned_rows, completed_rows, close_click, planned_data, completed_data, is_open): if close_click: - return False, "" + return False, "", [], [] - # Planned table click + # Planned table if planned_rows: row = planned_data[planned_rows[0]] - return True, html.Ul([html.Li(i) for i in row["HubSpot IDs"].split(", ")]) + ids = row["HubSpot IDs"].split(", ") + links = [id_to_link(i) for i in ids] + return True, html.Ul(links), [], [] - # Completed table click + # Completed table if completed_rows: row = completed_data[completed_rows[0]] - return True, html.Ul([html.Li(i) for i in row["HubSpot IDs"].split(", ")]) - - return False, "" + ids = row["HubSpot IDs"].split(", ") + links = [id_to_link(i) for i in ids] + return True, html.Ul(links), [], [] + return False, "", [], [] if __name__ == "__main__": app.run(debug=True)