From 39e5530da405c6cecb0dd7feadd877bad5c61576 Mon Sep 17 00:00:00 2001 From: Daniel Arroyo Date: Sun, 23 Aug 2026 23:00:25 -0400 Subject: [PATCH] fix(ventas): add generateUid fallback for non-secure contexts (HTTP) --- src/main/resources/META-INF/resources/static/js/shots.js | 8 +++++++- src/main/resources/templates/PageResource/ventas.html | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/resources/META-INF/resources/static/js/shots.js b/src/main/resources/META-INF/resources/static/js/shots.js index f3c65b9..4f4731a 100644 --- a/src/main/resources/META-INF/resources/static/js/shots.js +++ b/src/main/resources/META-INF/resources/static/js/shots.js @@ -1,4 +1,10 @@ window.shots = { + generateUid() { + if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') { + return crypto.randomUUID(); + } + return Date.now().toString(36) + '-' + Math.random().toString(36).slice(2, 10); + }, WEIGHTS: { Soulshot: { D: 3, C: 3, B: 2, A: 2, S: 2 }, Spiritshot: { D: 5, C: 3, B: 3, A: 2, S: 2 }, @@ -72,7 +78,7 @@ window.shots = { const grado = m[2].toUpperCase(); const cantidad = parseInt(m[3].replace(/[.,]/g, ''), 10); if (!this.WEIGHTS[tipo]?.[grado]) continue; - parsed.push({ uid: crypto.randomUUID(), tipo, grado, cantidad }); + parsed.push({ uid: this.generateUid(), tipo, grado, cantidad }); } return parsed; }, diff --git a/src/main/resources/templates/PageResource/ventas.html b/src/main/resources/templates/PageResource/ventas.html index 175c138..074d571 100644 --- a/src/main/resources/templates/PageResource/ventas.html +++ b/src/main/resources/templates/PageResource/ventas.html @@ -303,7 +303,7 @@ }, addItem() { - this.form.items.push({ uid: crypto.randomUUID(), tipo: '', grado: '', cantidad: null }); + this.form.items.push({ uid: window.shots.generateUid(), tipo: '', grado: '', cantidad: null }); }, removeItem(idx) {