diff --git a/public/pos/pos-app.js b/public/pos/pos-app.js index 0f1f097..156e0d9 100644 --- a/public/pos/pos-app.js +++ b/public/pos/pos-app.js @@ -783,6 +783,26 @@ function clearCust(){ } // ---------------- save sale ---------------- +// Minimal, self-contained error toast. `toast.error(...)` below used +// to reference a `toast` global that was never defined anywhere in +// this app (no library included, no local implementation) — every +// checkout rejection (e.g. insufficient stock) threw a +// ReferenceError instead of showing the operator anything, so the +// cart just sat there with no feedback. +function showToast(message){ + let el = document.getElementById('posToast'); + if(!el){ + el = document.createElement('div'); + el.id = 'posToast'; + el.style.cssText = 'position:fixed;left:16px;right:16px;bottom:calc(96px + env(safe-area-inset-bottom));max-width:448px;margin:0 auto;background:#c92a2a;color:#fff;padding:14px 16px;border-radius:12px;font-size:14px;font-weight:600;line-height:1.4;box-shadow:0 8px 24px rgba(0,0,0,.25);z-index:999;opacity:0;transition:opacity .15s ease'; + document.body.appendChild(el); + } + el.textContent = message; + el.style.opacity = '1'; + clearTimeout(el._hideTimer); + el._hideTimer = setTimeout(()=>{ el.style.opacity = '0'; }, 5000); +} + async function confirmSale(){ const btn = document.getElementById('confirmBtn'); if(btn.disabled) return; @@ -905,9 +925,9 @@ async function confirmSale(){ : s.stock_item_id; return `${name}: only ${s.available} in stock (you asked for ${s.requested})`; }); - toast.error('Not enough stock — ' + lines.join('; ')); + showToast('Not enough stock — ' + lines.join('; ')); } else { - toast.error('Sale rejected: ' + (serverError.kind === 'other' ? serverError.message : 'Unknown error')); + showToast('Sale rejected: ' + (serverError.kind === 'other' ? serverError.message : 'Unknown error')); } if (btn) { btn.disabled = false; diff --git a/public/pos/sw.js b/public/pos/sw.js index 8249748..1e53a11 100644 --- a/public/pos/sw.js +++ b/public/pos/sw.js @@ -1,5 +1,5 @@ // Service worker — cache app shell, network-first for HTML + theme.js, cache-first for other static. -const CACHE = "pos-v20"; +const CACHE = "pos-v21"; const APP_SHELL = [ './', './index.html',