dashboard

This commit is contained in:
Lucas Tettamanti
2026-01-27 02:41:39 -03:00
parent 493f26af17
commit df9420b954
19 changed files with 2105 additions and 111 deletions

View File

@@ -185,13 +185,23 @@ export const api = {
return fetch("/products/sync-from-woo", { method: "POST" }).then(r => r.json());
},
// --- Testing ---
async listRecentOrders({ limit = 20 } = {}) {
const u = new URL("/test/orders", location.origin);
// --- Orders & Stats ---
async listOrders({ page = 1, limit = 50 } = {}) {
const u = new URL("/api/orders", location.origin);
u.searchParams.set("page", String(page));
u.searchParams.set("limit", String(limit));
return fetch(u).then(r => r.json());
},
async getOrderStats() {
return fetch("/api/stats/orders").then(r => r.json());
},
// Alias para compatibilidad
async listRecentOrders({ limit = 20 } = {}) {
return this.listOrders({ page: 1, limit });
},
async getProductsWithStock() {
return fetch("/test/products-with-stock").then(r => r.json());
},

View File

@@ -2,7 +2,8 @@ import { emit } from "./bus.js";
// Mapeo de rutas a vistas
const ROUTES = [
{ pattern: /^\/$/, view: "chat", params: [] },
{ pattern: /^\/$/, view: "home", params: [] },
{ pattern: /^\/home$/, view: "home", params: [] },
{ pattern: /^\/chat$/, view: "chat", params: [] },
{ pattern: /^\/conversaciones$/, view: "conversations", params: [] },
{ pattern: /^\/usuarios$/, view: "users", params: [] },
@@ -23,6 +24,7 @@ const ROUTES = [
// Mapeo de vistas a rutas base (para navegación sin parámetros)
const VIEW_TO_PATH = {
home: "/home",
chat: "/chat",
conversations: "/conversaciones",
users: "/usuarios",
@@ -54,8 +56,8 @@ export function parseRoute(pathname) {
}
}
// Fallback a chat si no matchea ninguna ruta
return { view: "chat", params: {} };
// Fallback a home si no matchea ninguna ruta
return { view: "home", params: {} };
}
/**