diff --git a/pos/static/js/pwa-install.js b/pos/static/js/pwa-install.js new file mode 100644 index 0000000..c37ef47 --- /dev/null +++ b/pos/static/js/pwa-install.js @@ -0,0 +1,101 @@ +/** + * Nexus POS — PWA Install Prompt + * Captures beforeinstallprompt and shows a dismissible banner. + */ +(function () { + 'use strict'; + + const STORAGE_KEY = 'nexus_pwa_install_dismissed'; + let deferredPrompt = null; + + function createBanner() { + if (document.getElementById('pwa-install-banner')) return; + + const banner = document.createElement('div'); + banner.id = 'pwa-install-banner'; + banner.innerHTML = ` + 📲 Instala Nexus POS para acceso rápido y modo offline. + + + `; + document.body.appendChild(banner); + + const style = document.createElement('style'); + style.textContent = ` + #pwa-install-banner { + position: fixed; + bottom: 0; left: 0; right: 0; + background: var(--color-surface, #1a1a1a); + color: var(--color-text, #eee); + border-top: 1px solid var(--color-border, #333); + padding: 12px 16px; + display: flex; + align-items: center; + gap: 12px; + font-size: 14px; + z-index: 9999; + box-shadow: 0 -4px 12px rgba(0,0,0,0.3); + } + #pwa-install-banner span { flex: 1; } + #pwa-install-btn { + background: var(--color-primary, #F5A623); + color: #000; + border: none; + padding: 8px 16px; + border-radius: 6px; + font-weight: 600; + cursor: pointer; + } + #pwa-dismiss-btn { + background: none; + border: none; + color: var(--color-text-muted, #888); + font-size: 20px; + cursor: pointer; + line-height: 1; + } + `; + document.head.appendChild(style); + + document.getElementById('pwa-install-btn').addEventListener('click', function () { + if (!deferredPrompt) return; + deferredPrompt.prompt(); + deferredPrompt.userChoice.then(function (choice) { + if (choice.outcome === 'accepted') { + console.log('[PWA] User accepted install'); + } + deferredPrompt = null; + banner.remove(); + }); + }); + + document.getElementById('pwa-dismiss-btn').addEventListener('click', function () { + localStorage.setItem(STORAGE_KEY, Date.now().toString()); + banner.remove(); + }); + } + + window.addEventListener('beforeinstallprompt', function (e) { + e.preventDefault(); + deferredPrompt = e; + + const dismissed = localStorage.getItem(STORAGE_KEY); + if (dismissed && (Date.now() - parseInt(dismissed)) < 7 * 24 * 60 * 60 * 1000) { + return; // dismissed within 7 days + } + + // Wait for DOM to be ready + if (document.readyState === 'loading') { + document.addEventListener('DOMContentLoaded', createBanner); + } else { + createBanner(); + } + }); + + window.addEventListener('appinstalled', function () { + console.log('[PWA] App installed'); + deferredPrompt = null; + const b = document.getElementById('pwa-install-banner'); + if (b) b.remove(); + }); +})(); diff --git a/pos/templates/accounting.html b/pos/templates/accounting.html index 5f792a0..7e290bd 100644 --- a/pos/templates/accounting.html +++ b/pos/templates/accounting.html @@ -495,6 +495,7 @@ + diff --git a/pos/templates/catalog.html b/pos/templates/catalog.html index 7d89c08..b17e88e 100644 --- a/pos/templates/catalog.html +++ b/pos/templates/catalog.html @@ -279,5 +279,6 @@ + diff --git a/pos/templates/config.html b/pos/templates/config.html index 71f80f6..634874a 100644 --- a/pos/templates/config.html +++ b/pos/templates/config.html @@ -688,6 +688,7 @@ + diff --git a/pos/templates/customers.html b/pos/templates/customers.html index 9d98b6b..1bc6841 100644 --- a/pos/templates/customers.html +++ b/pos/templates/customers.html @@ -624,6 +624,7 @@ + diff --git a/pos/templates/dashboard.html b/pos/templates/dashboard.html index 0f58059..a80a284 100644 --- a/pos/templates/dashboard.html +++ b/pos/templates/dashboard.html @@ -352,6 +352,33 @@ + +
+
+ Rendimiento Hoy +
+
+
+
+
+ Ventas por Hora +
+
+ +
+
+
+
+ Top Productos (Hoy) +
+
+ +
+
+
+ @@ -453,13 +480,16 @@ + + + diff --git a/pos/templates/diagrams.html b/pos/templates/diagrams.html index 4c9d1a8..c0674f7 100644 --- a/pos/templates/diagrams.html +++ b/pos/templates/diagrams.html @@ -154,6 +154,7 @@ + diff --git a/pos/templates/fleet.html b/pos/templates/fleet.html index 1ce78aa..0bf2bc5 100644 --- a/pos/templates/fleet.html +++ b/pos/templates/fleet.html @@ -308,6 +308,7 @@ + diff --git a/pos/templates/inventory.html b/pos/templates/inventory.html index b70d91a..c336ada 100644 --- a/pos/templates/inventory.html +++ b/pos/templates/inventory.html @@ -819,6 +819,7 @@ + diff --git a/pos/templates/invoicing.html b/pos/templates/invoicing.html index 2565e91..1c8f036 100644 --- a/pos/templates/invoicing.html +++ b/pos/templates/invoicing.html @@ -1057,6 +1057,7 @@ + diff --git a/pos/templates/login.html b/pos/templates/login.html index 3fb2b47..5f9af7f 100644 --- a/pos/templates/login.html +++ b/pos/templates/login.html @@ -532,6 +532,7 @@ + diff --git a/pos/templates/pos.html b/pos/templates/pos.html index af1f80c..f4a8309 100644 --- a/pos/templates/pos.html +++ b/pos/templates/pos.html @@ -560,5 +560,6 @@ + diff --git a/pos/templates/reports.html b/pos/templates/reports.html index 82891e6..c30547e 100644 --- a/pos/templates/reports.html +++ b/pos/templates/reports.html @@ -323,6 +323,7 @@ +