diff --git a/dashboard.html b/dashboard.html index f3c3cdf..2b6216c 100644 --- a/dashboard.html +++ b/dashboard.html @@ -603,9 +603,16 @@
-
Phone: ${s.phone || "unknown"}
-
- ${statusText} +
+ ${s.name ? `${s.name} (${s.phone || 'unknown'})` : `Phone: ${s.phone || "unknown"}`} +
+
+
+ ${statusText} +
+
Summary: ${s.summary || "No summary yet."}
@@ -621,6 +628,42 @@ list.appendChild(card); }); + + list.querySelectorAll(".deleteSessionBtn").forEach(btn => { + btn.addEventListener("click", () => { + const phone = btn.dataset.phone; + const id = btn.dataset.id; + if (id && phone && phone !== 'unknown') { + deleteSession(id, phone); + } + }); + }); + } + + async function deleteSession(id, phone) { + if (!confirm(`Delete session for ${phone} and all its chat history?`)) return; + + const { error: historyError } = await supabaseClient + .from('n8n_chat_histories') + .delete() + .eq('session_id', id); + + if (historyError) { + alert('Error deleting chat history: ' + historyError.message); + return; + } + + const { error: sessionError } = await supabaseClient + .from('sessions') + .delete() + .eq('id', id); + + if (sessionError) { + alert('Error deleting session: ' + sessionError.message); + return; + } + + await loadSessions(); } // =============================