feat(ui): implementar barra flotante reactiva con boton verde de pre-orden para padres en web y pwa, y reparar boton de ajustes

This commit is contained in:
unknown
2026-10-09 09:22:54 -06:00
parent 84c733ad9f
commit 038193024d
4 changed files with 204 additions and 66 deletions
+82 -21
View File
@@ -1119,24 +1119,32 @@ body.dark-mode .menu-smart-search-empty {
transform: scale(0.9); transform: scale(0.9);
} }
/* Barra Flotante de Carrito / Pre-orden */ /* Barra Flotante de Carrito / Pre-orden (Web & Móvil) */
.floating-cart-bar { .floating-cart-bar {
position: fixed; position: fixed;
bottom: 16px; bottom: 24px;
left: 16px; left: 50%;
right: 16px; transform: translateX(-50%);
max-width: 448px; width: calc(100% - 32px);
margin: 0 auto; max-width: 490px;
background: #0f172a; background: #0f172a;
color: white; color: white;
border-radius: 20px; border-radius: 20px;
padding: 12px 18px; padding: 11px 18px;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
box-shadow: 0 10px 25px rgba(0,0,0,0.4); box-shadow: 0 12px 32px rgba(15, 23, 42, 0.45);
z-index: 50; border: 1.5px solid rgba(255, 255, 255, 0.14);
z-index: 105;
cursor: pointer; cursor: pointer;
transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.2s ease;
user-select: none;
}
.floating-cart-bar:hover {
transform: translateX(-50%) translateY(-2px);
box-shadow: 0 16px 38px rgba(15, 23, 42, 0.55);
} }
@media (max-width: 640px) { @media (max-width: 640px) {
@@ -1144,13 +1152,20 @@ body.dark-mode .menu-smart-search-empty {
bottom: calc(72px + var(--safe-bottom)); bottom: calc(72px + var(--safe-bottom));
left: 12px; left: 12px;
right: 12px; right: 12px;
width: auto;
transform: none;
padding: 10px 14px; padding: 10px 14px;
border-radius: 18px;
}
.floating-cart-bar:hover {
transform: none;
} }
} }
body.dark-mode .floating-cart-bar { body.dark-mode .floating-cart-bar {
background: #0284c7; background: #1e293b;
border: 1px solid rgba(255, 255, 255, 0.2); border: 1.5px solid rgba(56, 189, 248, 0.3);
box-shadow: 0 12px 32px rgba(0, 0, 0, 0.65);
} }
.cart-summary { .cart-summary {
@@ -1160,28 +1175,74 @@ body.dark-mode .floating-cart-bar {
} }
.cart-count-badge { .cart-count-badge {
background: var(--accent); background: #10b981;
color: #0f172a; color: #ffffff;
font-weight: 900; font-weight: 900;
padding: 4px 10px; padding: 5px 12px;
border-radius: 12px; border-radius: 12px;
font-size: 0.9rem; font-size: 0.88rem;
letter-spacing: 0.2px;
display: inline-flex;
align-items: center;
gap: 4px;
box-shadow: 0 2px 8px rgba(16, 185, 129, 0.35);
} }
.cart-total-text { .cart-total-text {
font-size: 1.1rem; font-size: 1.18rem;
font-weight: 800; font-weight: 900;
color: #ffffff;
letter-spacing: -0.3px;
} }
.cart-action-btn { .cart-action-btn {
background: var(--secondary); background: linear-gradient(135deg, #10b981, #059669);
color: white; color: white;
border: none; border: none;
padding: 8px 16px; padding: 9px 18px;
border-radius: 12px; border-radius: 14px;
font-weight: 800; font-weight: 800;
font-size: 0.9rem; font-size: 0.92rem;
cursor: pointer; cursor: pointer;
display: inline-flex;
align-items: center;
gap: 8px;
box-shadow: 0 4px 14px rgba(16, 185, 129, 0.45);
transition: all 0.2s ease;
}
.cart-action-btn:hover {
background: linear-gradient(135deg, #059669, #047857);
box-shadow: 0 6px 18px rgba(16, 185, 129, 0.55);
transform: translateY(-1px);
}
.cart-action-btn:active {
transform: scale(0.96);
}
@keyframes cartBump {
0% { transform: translateX(-50%) scale(1); }
25% { transform: translateX(-50%) scale(1.06); }
50% { transform: translateX(-50%) scale(0.97); }
100% { transform: translateX(-50%) scale(1); }
}
@keyframes cartBumpMobile {
0% { transform: scale(1); }
25% { transform: scale(1.05); }
50% { transform: scale(0.97); }
100% { transform: scale(1); }
}
.floating-cart-bar.cart-bump {
animation: cartBump 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@media (max-width: 640px) {
.floating-cart-bar.cart-bump {
animation: cartBumpMobile 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
} }
/* ========================================================================== /* ==========================================================================
+30 -21
View File
@@ -11,9 +11,9 @@
<meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"> <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="apple-mobile-web-app-title" content="SiboPay"> <meta name="apple-mobile-web-app-title" content="SiboPay">
<link rel="preload" href="/css/styles.css?v=18.1" as="style"> <link rel="preload" href="/css/styles.css?v=19.4" as="style">
<link rel="preload" href="/js/app.js?v=18.1" as="script"> <link rel="preload" href="/js/app.js?v=19.4" as="script">
<link rel="stylesheet" href="/css/styles.css?v=18.1"> <link rel="stylesheet" href="/css/styles.css?v=19.4">
<link rel="stylesheet" href="/css/desktop.css?v=2.2"> <link rel="stylesheet" href="/css/desktop.css?v=2.2">
<style> <style>
/* Transiciones suaves */ /* Transiciones suaves */
@@ -2486,6 +2486,9 @@
</button> </button>
<button id="btnThemeToggle" onclick="toggleTheme()" class="theme-toggle-btn" title="Alternar Modo Oscuro / Modo Claro" style="display: inline-flex; align-items: center; justify-content: center;"> <button id="btnThemeToggle" onclick="toggleTheme()" class="theme-toggle-btn" title="Alternar Modo Oscuro / Modo Claro" style="display: inline-flex; align-items: center; justify-content: center;">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"/></svg> <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"/></svg>
<button id="btnTopAjustes" onclick="abrirModalAjustesCuenta()" class="mode-btn" style="background: var(--bg-main); border: 1.5px solid var(--border); font-size: 0.8rem; font-weight: 800; border-radius: 10px; padding: 7px 11px; cursor: pointer; color: var(--text-main); display: inline-flex; align-items: center; gap: 6px;" title="Mi Cuenta, Ajustes y Privacidad">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"/></svg>
<span>Ajustes</span>
</button> </button>
<button id="btnModePadres" onclick="toggleParentPanel(true)" class="mode-btn" style="background: var(--bg-main); border: 1.5px solid var(--border); font-size: 0.8rem; font-weight: 800; border-radius: 10px; padding: 7px 11px; cursor: pointer; color: var(--text-main); display: inline-flex; align-items: center; gap: 6px;" title="Acceso al Portal de Padres"> <button id="btnModePadres" onclick="toggleParentPanel(true)" class="mode-btn" style="background: var(--bg-main); border: 1.5px solid var(--border); font-size: 0.8rem; font-weight: 800; border-radius: 10px; padding: 7px 11px; cursor: pointer; color: var(--text-main); display: inline-flex; align-items: center; gap: 6px;" title="Acceso al Portal de Padres">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg> <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg>
@@ -2641,18 +2644,6 @@
<!-- Se llena con productos de la soda --> <!-- Se llena con productos de la soda -->
</div> </div>
<!-- BARRA FLOTANTE DE PRE-ORDEN / CARRITO -->
<div class="floating-cart-bar" id="floatingCart" style="display: none;" onclick="openCartModal()">
<div class="cart-summary">
<span class="cart-count-badge" id="cartCountBadge">0</span>
<div class="cart-total-text" id="cartTotalText">₡0</div>
</div>
<button class="cart-action-btn" style="display: flex; align-items: center; justify-content: center; gap: 6px;">
<span>Pedir para el Recreo</span> <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><circle cx="8" cy="21" r="1"/><circle cx="19" cy="21" r="1"/><path d="M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12"/></svg>
</button>
</div>
</div> </div>
<!-- MODAL INMERSIVO: CÓDIGO QR PARA PRESENTAR EN LA SODA (DISEÑO SIBOPAY EXACTO) --> <!-- MODAL INMERSIVO: CÓDIGO QR PARA PRESENTAR EN LA SODA (DISEÑO SIBOPAY EXACTO) -->
@@ -2817,11 +2808,29 @@
</div> </div>
</div> </div>
<!-- BARRA FLOTANTE GLOBAL DE PRE-ORDEN / CARRITO (ALUMNOS Y PORTAL PADRES) -->
<div class="floating-cart-bar" id="floatingCart" style="display: none;" onclick="openCartModal()" title="Ver y confirmar mi pre-orden">
<div class="cart-summary">
<span class="cart-count-badge" id="cartCountBadge">0 ítems</span>
<div class="cart-total-text" id="cartTotalText">₡0</div>
</div>
<button class="cart-action-btn" id="btnCartFloatingAction" type="button" style="display: flex; align-items: center; justify-content: center; gap: 8px;">
<span>Pedir para el Recreo</span>
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
<circle cx="8" cy="21" r="1"/><circle cx="19" cy="21" r="1"/>
<path d="M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12"/>
</svg>
</button>
</div>
<!-- MODAL: CARRITO Y PRE-ORDEN --> <!-- MODAL: CARRITO Y PRE-ORDEN -->
<div class="modal-qr-backdrop" id="modalCart" style="display: none;" onclick="closeCartModal(event)"> <div class="modal-qr-backdrop" id="modalCart" style="display: none;" onclick="closeCartModal(event)">
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 420px; text-align: left;"> <div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 420px; text-align: left;">
<div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #e2e8f0; padding-bottom: 10px; margin-bottom: 12px;"> <div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #e2e8f0; padding-bottom: 10px; margin-bottom: 12px;">
<h3 style="color: #0f172a; font-size: 1.15rem; font-weight: 800;">Mi Pre-Orden Escolar</h3> <div>
<h3 style="color: #0f172a; font-size: 1.15rem; font-weight: 800; margin: 0;">Mi Pre-Orden Escolar</h3>
<span id="modalCartStudentName" style="display: none; font-size: 0.76rem; color: #0284c7; font-weight: 700; margin-top: 2px;"></span>
</div>
<button onclick="closeCartModal()" style="background: none; border: none; font-size: 1.2rem; cursor: pointer; color: #64748b;">✕</button> <button onclick="closeCartModal()" style="background: none; border: none; font-size: 1.2rem; cursor: pointer; color: #64748b;">✕</button>
</div> </div>
@@ -4767,7 +4776,7 @@
<span class="pwa-nav-icon"><svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg></span> <span class="pwa-nav-icon"><svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg></span>
<span class="pwa-nav-label">Padres</span> <span class="pwa-nav-label">Padres</span>
</button> </button>
<button class="pwa-nav-item" id="pwaNavAjustes" onclick="abrirModalAjustesCuenta()" title="Mi Cuenta y Ajustes"> <button class="pwa-nav-item" id="pwaNavAjustes" onclick="pwaNavigateTo('ajustes')" title="Mi Cuenta y Ajustes">
<span class="pwa-nav-icon"><svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"/></svg></span> <span class="pwa-nav-icon"><svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"/></svg></span>
<span class="pwa-nav-label">Ajustes</span> <span class="pwa-nav-label">Ajustes</span>
</button> </button>
@@ -4777,10 +4786,10 @@
</button> </button>
</nav> </nav>
<script src="/js/dialogs.js?v=19.3"></script> <script src="/js/dialogs.js?v=19.4"></script>
<script src="/js/sounds.js?v=19.3"></script> <script src="/js/sounds.js?v=19.4"></script>
<script src="/js/jsQR.js" defer></script> <script src="/js/jsQR.js" defer></script>
<script src="/js/food-icons.js?v=19.3" defer></script> <script src="/js/food-icons.js?v=19.4" defer></script>
<script src="/js/app.js?v=19.3"></script> <script src="/js/app.js?v=19.4"></script>
</body> </body>
</html> </html>
+81 -13
View File
@@ -215,6 +215,8 @@ function showLoginView() {
closeCartModal(); closeCartModal();
closeQrModal(); closeQrModal();
closeTransferModal(); closeTransferModal();
cart = [];
updateCartBar();
} }
// ========================================================================== // ==========================================================================
@@ -713,6 +715,10 @@ function pwaNavigateTo(target) {
closeQrModal(); closeQrModal();
closeTransferModal(); closeTransferModal();
toggleParentPanel(true); toggleParentPanel(true);
} else if (target === 'ajustes') {
const btn = document.getElementById('pwaNavAjustes');
if (btn) btn.classList.add('active');
abrirModalAjustesCuenta();
} }
} }
@@ -1307,16 +1313,34 @@ function addToCart(productId) {
function updateCartBar() { function updateCartBar() {
const bar = document.getElementById('floatingCart'); const bar = document.getElementById('floatingCart');
if (!bar) return;
const countBadge = document.getElementById('cartCountBadge'); const countBadge = document.getElementById('cartCountBadge');
const totalText = document.getElementById('cartTotalText'); const totalText = document.getElementById('cartTotalText');
const totalCount = cart.reduce((sum, item) => sum + item.cantidad, 0); const totalCount = (cart || []).reduce((sum, item) => sum + (item.cantidad || 1), 0);
const totalColones = cart.reduce((sum, item) => sum + (item.product.precio_colones * item.cantidad), 0); const totalColones = (cart || []).reduce((sum, item) => sum + (item.product.precio_colones * (item.cantidad || 1)), 0);
if (totalCount > 0) { // Sincronizar badge de la cabecera en el portal de padres si existe
const parentBadge = document.getElementById('parentCartBadgeCount');
if (parentBadge) {
parentBadge.textContent = totalCount;
}
// Verificar si estamos en vista de estudiante o de padres
const appContainer = document.getElementById('appContainer');
const viewPadres = document.getElementById('viewPadres');
const isStudentView = appContainer && appContainer.style.display !== 'none';
const isParentView = viewPadres && viewPadres.style.display !== 'none';
if (totalCount > 0 && (isStudentView || isParentView)) {
bar.style.display = 'flex'; bar.style.display = 'flex';
countBadge.textContent = `${totalCount} ${totalCount === 1 ? 'ítem' : 'ítems'}`; if (countBadge) countBadge.textContent = `${totalCount} ${totalCount === 1 ? 'ítem' : 'ítems'}`;
totalText.textContent = `₡${totalColones.toLocaleString('es-CR')}`; if (totalText) totalText.textContent = `₡${totalColones.toLocaleString('es-CR')}`;
// Efecto de pulso reactivo en el botón y barra flotante al agregar items
bar.classList.remove('cart-bump');
void bar.offsetWidth; // re-flow
bar.classList.add('cart-bump');
} else { } else {
bar.style.display = 'none'; bar.style.display = 'none';
} }
@@ -1324,7 +1348,19 @@ function updateCartBar() {
function openCartModal() { function openCartModal() {
renderCartModalItems(); renderCartModalItems();
document.getElementById('modalCart').style.display = 'flex';
const studentNameEl = document.getElementById('modalCartStudentName');
if (studentNameEl) {
if (currentUser && currentUser.rol === 'padre' && currentParentChild) {
studentNameEl.textContent = `Pre-orden para: ${currentParentChild.nombre_completo}`;
studentNameEl.style.display = 'block';
} else {
studentNameEl.style.display = 'none';
}
}
const modal = document.getElementById('modalCart');
if (modal) modal.style.display = 'flex';
} }
function closeCartModal(e) { function closeCartModal(e) {
@@ -3880,7 +3916,7 @@ function renderParentCatalog(filterTerm = '') {
<div style="display: flex; align-items: center; justify-content: space-between; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border);"> <div style="display: flex; align-items: center; justify-content: space-between; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border);">
<span style="font-size: 0.95rem; font-weight: 900; color: #0284c7;">₡${prod.precio_colones.toLocaleString('es-CR')}</span> <span style="font-size: 0.95rem; font-weight: 900; color: #0284c7;">₡${prod.precio_colones.toLocaleString('es-CR')}</span>
${isOutOfStock ? `<span style="font-size: 0.7rem; font-weight: 800; color: #ef4444;">Agotado</span>` : ` ${isOutOfStock ? `<span style="font-size: 0.7rem; font-weight: 800; color: #ef4444;">Agotado</span>` : `
<button type="button" class="btn-saas btn-saas-primary" onclick="addParentProductToCart(${prod.id})" style="padding: 5px 10px; font-size: 0.78rem; border-radius: 8px;">+ Pre-ordenar</button> <button type="button" class="btn-saas btn-saas-primary" onclick="addParentProductToCart(${prod.id}, event)" style="padding: 5px 12px; font-size: 0.78rem; font-weight: 800; border-radius: 8px; cursor: pointer; transition: all 0.2s ease;">+ Pre-ordenar</button>
`} `}
</div> </div>
</div> </div>
@@ -3898,13 +3934,31 @@ function quickFilterParentCatalog(term) {
renderParentCatalog(term); renderParentCatalog(term);
} }
function addParentProductToCart(productId) { function addParentProductToCart(productId, event) {
addToCart(productId); addToCart(productId);
const cartBadge = document.getElementById('parentCartBadgeCount'); const cartBadge = document.getElementById('parentCartBadgeCount');
if (cartBadge) { if (cartBadge) {
const totalItems = (cart || []).reduce((acc, it) => acc + (it.cantidad || 1), 0); const totalItems = (cart || []).reduce((acc, it) => acc + (it.cantidad || 1), 0);
cartBadge.textContent = totalItems; cartBadge.textContent = totalItems;
} }
// Micro-interacción visual inmediata en el botón de la tarjeta seleccionada
if (event && event.currentTarget) {
const btn = event.currentTarget;
const origHtml = btn.innerHTML;
btn.style.background = '#10b981';
btn.style.borderColor = '#059669';
btn.style.color = '#ffffff';
btn.style.boxShadow = '0 0 12px rgba(16, 185, 129, 0.45)';
btn.innerHTML = '✓ ¡Agregado!';
setTimeout(() => {
btn.style.background = '';
btn.style.borderColor = '';
btn.style.color = '';
btn.style.boxShadow = '';
btn.innerHTML = origHtml;
}, 750);
}
} }
function renderActiveChildDetails(child) { function renderActiveChildDetails(child) {
@@ -9680,26 +9734,40 @@ function abrirModalAjustesCuenta() {
const chkSound = document.getElementById('chkAjustesSound'); const chkSound = document.getElementById('chkAjustesSound');
const chkHaptic = document.getElementById('chkAjustesHaptic'); const chkHaptic = document.getElementById('chkAjustesHaptic');
if (currentUser) { let user = currentUser;
if (lblNombre) lblNombre.textContent = currentUser.nombre || currentUser.username || 'Usuario'; if (!user) {
try {
const raw = localStorage.getItem('sibopay_user') || localStorage.getItem('recreopay_user');
if (raw) user = JSON.parse(raw);
} catch (_) {}
}
if (user) {
if (lblNombre) lblNombre.textContent = user.nombre || user.username || (currentStudent && currentStudent.nombre_completo) || 'Usuario';
if (lblRol) { if (lblRol) {
let r = currentUser.rol || 'Usuario'; let r = user.rol || 'Usuario';
if (r === 'padre') r = 'Padre / Encargado'; if (r === 'padre') r = 'Padre / Encargado';
else if (r === 'estudiante') r = 'Estudiante / Alumno'; else if (r === 'estudiante') r = 'Estudiante / Alumno';
else if (r === 'cajero') r = 'Cajero de Soda'; else if (r === 'cajero') r = 'Cajero de Soda';
else if (r === 'admin') r = 'Administrador de Soda'; else if (r === 'admin') r = 'Administrador de Soda';
lblRol.textContent = r; lblRol.textContent = r;
} }
} else if (currentStudent) {
if (lblNombre) lblNombre.textContent = currentStudent.nombre_completo || 'Estudiante';
if (lblRol) lblRol.textContent = 'Estudiante / Alumno';
} }
if (chkSound && window.sounds) { try {
if (chkSound && window.sounds && typeof window.sounds.isSoundEnabled === 'function') {
chkSound.checked = window.sounds.isSoundEnabled(); chkSound.checked = window.sounds.isSoundEnabled();
} }
if (chkHaptic && window.sounds) { if (chkHaptic && window.sounds && typeof window.sounds.isHapticEnabled === 'function') {
chkHaptic.checked = window.sounds.isHapticEnabled(); chkHaptic.checked = window.sounds.isHapticEnabled();
} }
} catch (_) {}
modal.style.display = 'flex'; modal.style.display = 'flex';
modal.style.zIndex = '10005';
} }
window.abrirModalAjustesCuenta = abrirModalAjustesCuenta; window.abrirModalAjustesCuenta = abrirModalAjustesCuenta;
+7 -7
View File
@@ -1,5 +1,5 @@
// SiboPay PWA Service Worker v19.3 - Ultra Fast Startup & Stale-While-Revalidate // SiboPay PWA Service Worker v19.4 - Ultra Fast Startup & Stale-While-Revalidate
const CACHE_NAME = 'sibopay-v19.3'; const CACHE_NAME = 'sibopay-v19.4';
const STATIC_ASSETS = [ const STATIC_ASSETS = [
'/', '/',
'/index.html', '/index.html',
@@ -8,13 +8,13 @@ const STATIC_ASSETS = [
'/pistola.html', '/pistola.html',
'/carnet.html', '/carnet.html',
'/manifest.json', '/manifest.json',
'/css/styles.css?v=19.3', '/css/styles.css?v=19.4',
'/css/desktop.css?v=2.2', '/css/desktop.css?v=2.2',
'/js/dialogs.js?v=19.3', '/js/dialogs.js?v=19.4',
'/js/app.js?v=19.3', '/js/app.js?v=19.4',
'/js/pos.js', '/js/pos.js',
'/js/sounds.js?v=19.3', '/js/sounds.js?v=19.4',
'/js/food-icons.js?v=19.3', '/js/food-icons.js?v=19.4',
'/icons/icon-192.png', '/icons/icon-192.png',
'/icons/icon-512.png', '/icons/icon-512.png',
'/img/sibopay-emblem.png', '/img/sibopay-emblem.png',