ux improved

This commit is contained in:
Lucas Tettamanti
2026-01-17 04:13:35 -03:00
parent 98e3d78e3d
commit 63b9ecef61
35 changed files with 4266 additions and 75 deletions

View File

@@ -57,4 +57,79 @@ export const api = {
if (!chat_id) throw new Error("chat_id_required");
return fetch(`/conversations/${encodeURIComponent(chat_id)}/retry-last`, { method: "POST" }).then(r => r.json());
},
// Products CRUD
async products({ q = "", limit = 2000, offset = 0 } = {}) {
const u = new URL("/products", location.origin);
if (q) u.searchParams.set("q", q);
u.searchParams.set("limit", String(limit));
u.searchParams.set("offset", String(offset));
return fetch(u).then(r => r.json());
},
async productById(id) {
if (!id) return null;
return fetch(`/products/${encodeURIComponent(id)}`).then(r => r.json());
},
async syncProducts() {
return fetch("/products/sync", { method: "POST" }).then(r => r.json());
},
// Aliases CRUD
async aliases({ q = "", woo_product_id = null, limit = 200 } = {}) {
const u = new URL("/aliases", location.origin);
if (q) u.searchParams.set("q", q);
if (woo_product_id) u.searchParams.set("woo_product_id", String(woo_product_id));
u.searchParams.set("limit", String(limit));
return fetch(u).then(r => r.json());
},
async createAlias(data) {
return fetch("/aliases", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(data),
}).then(r => r.json());
},
async updateAlias(alias, data) {
return fetch(`/aliases/${encodeURIComponent(alias)}`, {
method: "PUT",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(data),
}).then(r => r.json());
},
async deleteAlias(alias) {
return fetch(`/aliases/${encodeURIComponent(alias)}`, { method: "DELETE" }).then(r => r.json());
},
// Recommendations CRUD
async recommendations({ q = "", limit = 200 } = {}) {
const u = new URL("/recommendations", location.origin);
if (q) u.searchParams.set("q", q);
u.searchParams.set("limit", String(limit));
return fetch(u).then(r => r.json());
},
async createRecommendation(data) {
return fetch("/recommendations", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(data),
}).then(r => r.json());
},
async updateRecommendation(id, data) {
return fetch(`/recommendations/${encodeURIComponent(id)}`, {
method: "PUT",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(data),
}).then(r => r.json());
},
async deleteRecommendation(id) {
return fetch(`/recommendations/${encodeURIComponent(id)}`, { method: "DELETE" }).then(r => r.json());
},
};