From 7020890b0e837eb0d1d99c80a44192c702465465 Mon Sep 17 00:00:00 2001 From: consultoria-as Date: Tue, 26 May 2026 08:42:17 +0000 Subject: [PATCH] feat(ui): dashboard skeletons, empty states, Cmd+K registration, improved loading states --- pos/static/js/dashboard.js | 40 +++++++++++++++++++++++++++++++----- pos/templates/dashboard.html | 32 +++++++++++++++++------------ 2 files changed, 54 insertions(+), 18 deletions(-) diff --git a/pos/static/js/dashboard.js b/pos/static/js/dashboard.js index 79611a9..fd42637 100644 --- a/pos/static/js/dashboard.js +++ b/pos/static/js/dashboard.js @@ -208,7 +208,7 @@ const Dashboard = (() => { function setKpiError(valueId, metaId) { const v = document.getElementById(valueId); const m = document.getElementById(metaId); - if (v) v.textContent = '--'; + if (v) v.innerHTML = '--'; if (m) m.innerHTML = 'Error al cargar'; } @@ -225,7 +225,12 @@ const Dashboard = (() => { if (!container) return; if (!registers || registers.length === 0) { - container.innerHTML = '
Sin cajas registradas hoy
'; + container.innerHTML = renderEmptyState({ + icon: '', + title: 'Sin cajas hoy', + subtitle: 'Ninguna caja ha sido abierta el día de hoy.', + action: 'Abrir POS' + }); return; } @@ -326,7 +331,12 @@ const Dashboard = (() => { if (!container) return; if (!data || !data.data || data.data.length === 0) { - container.innerHTML = '
Sin ventas hoy
'; + container.innerHTML = renderEmptyState({ + icon: '', + title: 'Sin ventas hoy', + subtitle: 'Aún no hay transacciones registradas el día de hoy.', + action: 'Nueva venta' + }); return; } @@ -353,7 +363,11 @@ const Dashboard = (() => { const sorted = Object.values(productMap).sort((a, b) => b.revenue - a.revenue).slice(0, 5); if (sorted.length === 0) { - container.innerHTML = '
Sin productos vendidos
'; + container.innerHTML = renderEmptyState({ + icon: '', + title: 'Sin productos vendidos', + subtitle: 'No hay suficiente información para mostrar el ranking.' + }); return; } @@ -444,7 +458,12 @@ const Dashboard = (() => { if (!tbody) return; if (!data || !data.data || data.data.length === 0) { - tbody.innerHTML = 'Sin ventas hoy'; + tbody.innerHTML = '' + renderEmptyState({ + icon: '', + title: 'Sin ventas hoy', + subtitle: 'Aún no hay transacciones registradas.', + action: 'Nueva venta' + }) + ''; return; } @@ -526,6 +545,17 @@ const Dashboard = (() => { }, 120000); } + // Register Cmd+K items + if (typeof registerCmdKItem === 'function') { + registerCmdKItem({ group: 'Principal', label: 'Dashboard', href: '/pos/dashboard', icon: '📊' }); + registerCmdKItem({ group: 'Principal', label: 'POS Ventas', href: '/pos/sale', icon: '🛒' }); + registerCmdKItem({ group: 'Principal', label: 'Catálogo', href: '/pos/catalog', icon: '📁' }); + registerCmdKItem({ group: 'Principal', label: 'Clientes', href: '/pos/customers', icon: '👤' }); + registerCmdKItem({ group: 'Principal', label: 'Facturación', href: '/pos/invoicing', icon: '📄' }); + registerCmdKItem({ group: 'Principal', label: 'Reportes', href: '/pos/reports', icon: '📈' }); + registerCmdKItem({ group: 'Principal', label: 'Configuración', href: '/pos/config', icon: '⚙️' }); + } + document.addEventListener('DOMContentLoaded', init); return { init, setTheme }; diff --git a/pos/templates/dashboard.html b/pos/templates/dashboard.html index ac431f3..4f07767 100644 --- a/pos/templates/dashboard.html +++ b/pos/templates/dashboard.html @@ -255,9 +255,9 @@ -
--
+
- Cargando... +
@@ -273,9 +273,9 @@ -
--
+
- Cargando... +
@@ -291,9 +291,9 @@ -
--
+
- Cargando... +
@@ -308,9 +308,9 @@ -
--
+
- Cargando... +
@@ -399,7 +399,9 @@ Ver todos
-
Cargando...
+
+
+
@@ -412,7 +414,8 @@ Gestionar
-
Cargando...
+
+
@@ -429,7 +432,8 @@ Gestionar todo →
-
Cargando alertas...
+
+
@@ -467,7 +471,9 @@ - Cargando ventas recientes... +
+
+
@@ -487,7 +493,7 @@ - +