base con front

This commit is contained in:
Lucas Tettamanti
2026-01-01 22:49:44 -03:00
parent 863449e21d
commit 5c67b27859
16 changed files with 1038 additions and 27 deletions

24
public/lib/api.js Normal file
View File

@@ -0,0 +1,24 @@
export const api = {
async conversations({ q = "", status = "", state = "" } = {}) {
const u = new URL("/conversations", location.origin);
if (q) u.searchParams.set("q", q);
if (status) u.searchParams.set("status", status);
if (state) u.searchParams.set("state", state);
return fetch(u).then(r => r.json());
},
async runs({ chat_id, limit = 1 } = {}) {
const u = new URL("/runs", location.origin);
if (chat_id) u.searchParams.set("chat_id", chat_id);
u.searchParams.set("limit", String(limit));
return fetch(u).then(r => r.json());
},
async simSend({ chat_id, from_phone, text }) {
return fetch("/sim/send", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ chat_id, from_phone, text }),
}).then(r => r.json());
},
};