feat(ui): sustituir emojis por iconografia vectorial SVG minimalista y elegante para alimentos y bebidas
This commit is contained in:
+8
-16
@@ -1677,22 +1677,13 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="display: grid; grid-template-columns: 80px 1fr; gap: 10px; margin-bottom: 10px;">
|
||||
<div>
|
||||
<label style="display: block; font-size: 0.78rem; font-weight: 800; color: var(--text-main); margin-bottom: 3px;">Ícono:</label>
|
||||
<input type="text" id="adminProdIcono" value="🥪" maxlength="4" style="width: 100%; text-align: center; font-size: 1.5rem; padding: 4px; border-radius: 8px; border: 1.5px solid var(--border); box-sizing: border-box; background: var(--card-bg);">
|
||||
</div>
|
||||
<div>
|
||||
<label style="display: block; font-size: 0.78rem; font-weight: 800; color: var(--text-main); margin-bottom: 3px;">Íconos Rápidos:</label>
|
||||
<div style="display: flex; gap: 4px; flex-wrap: wrap;">
|
||||
<button type="button" onclick="selectProdIcon('🥪')" style="padding: 4px 6px; font-size: 1.1rem; border: 1px solid var(--border); border-radius: 6px; background: var(--card-bg); cursor: pointer;">🥪</button>
|
||||
<button type="button" onclick="selectProdIcon('🍎')" style="padding: 4px 6px; font-size: 1.1rem; border: 1px solid var(--border); border-radius: 6px; background: var(--card-bg); cursor: pointer;">🍎</button>
|
||||
<button type="button" onclick="selectProdIcon('🧃')" style="padding: 4px 6px; font-size: 1.1rem; border: 1px solid var(--border); border-radius: 6px; background: var(--card-bg); cursor: pointer;">🧃</button>
|
||||
<button type="button" onclick="selectProdIcon('🍕')" style="padding: 4px 6px; font-size: 1.1rem; border: 1px solid var(--border); border-radius: 6px; background: var(--card-bg); cursor: pointer;">🍕</button>
|
||||
<button type="button" onclick="selectProdIcon('🥗')" style="padding: 4px 6px; font-size: 1.1rem; border: 1px solid var(--border); border-radius: 6px; background: var(--card-bg); cursor: pointer;">🥗</button>
|
||||
<button type="button" onclick="selectProdIcon('🥛')" style="padding: 4px 6px; font-size: 1.1rem; border: 1px solid var(--border); border-radius: 6px; background: var(--card-bg); cursor: pointer;">🥛</button>
|
||||
<button type="button" onclick="selectProdIcon('🍪')" style="padding: 4px 6px; font-size: 1.1rem; border: 1px solid var(--border); border-radius: 6px; background: var(--card-bg); cursor: pointer;">🍪</button>
|
||||
<button type="button" onclick="selectProdIcon('🌮')" style="padding: 4px 6px; font-size: 1.1rem; border: 1px solid var(--border); border-radius: 6px; background: var(--card-bg); cursor: pointer;">🌮</button>
|
||||
<div style="margin-bottom: 12px;">
|
||||
<label style="display: block; font-size: 0.78rem; font-weight: 800; color: var(--text-main); margin-bottom: 6px;">Ícono Vectorial del Alimento:</label>
|
||||
<input type="hidden" id="adminProdIcono" value="sandwich">
|
||||
<div style="display: flex; gap: 12px; align-items: center; background: var(--bg-main, #f8fafc); border: 1.5px solid var(--border); border-radius: 12px; padding: 10px;">
|
||||
<div id="adminProdIconPreview" style="flex-shrink: 0;"></div>
|
||||
<div style="flex: 1; min-width: 0;">
|
||||
<div style="display: flex; gap: 6px; flex-wrap: wrap;" id="adminProdIconPickerList"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -2297,6 +2288,7 @@
|
||||
|
||||
<script src="/js/sounds.js?v=9.6"></script>
|
||||
<script src="/js/jsQR.js"></script>
|
||||
<script src="/js/food-icons.js?v=1.0"></script>
|
||||
<script src="/js/app.js?v=9.6"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+39
-10
@@ -739,9 +739,12 @@ function renderCategories() {
|
||||
`;
|
||||
|
||||
for (const cat of categories) {
|
||||
const iconBadge = window.SiboPayIcons
|
||||
? window.SiboPayIcons.getFoodIconBadge(cat.icono, cat.nombre, 'inline')
|
||||
: `<span>${cat.icono || '🍽️'}</span>`;
|
||||
html += `
|
||||
<button class="cat-pill ${activeCategoryId === cat.id ? 'active' : ''}" onclick="selectCategory(${cat.id})">
|
||||
<span>${cat.icono || '🍽️'}</span> ${cat.nombre}
|
||||
<button class="cat-pill ${activeCategoryId === cat.id ? 'active' : ''}" onclick="selectCategory(${cat.id})" style="display: inline-flex; align-items: center; gap: 6px;">
|
||||
${iconBadge} <span>${cat.nombre}</span>
|
||||
</button>
|
||||
`;
|
||||
}
|
||||
@@ -786,9 +789,15 @@ function renderProducts() {
|
||||
? '<span class="badge-out-of-stock">AGOTADO</span>'
|
||||
: '';
|
||||
|
||||
const iconHtml = window.SiboPayIcons
|
||||
? window.SiboPayIcons.getFoodIconBadge(prod.icono, prod.nombre, 'card')
|
||||
: `<div class="product-icon-wrap">${prod.icono || '🥪'}</div>`;
|
||||
|
||||
return `
|
||||
<div class="product-card ${isOutOfStock ? 'out-of-stock' : ''}">
|
||||
<div class="product-icon-wrap">${prod.icono || '🥪'}</div>
|
||||
<div style="display: flex; justify-content: center; align-items: center; margin-bottom: 8px;">
|
||||
${iconHtml}
|
||||
</div>
|
||||
<div>
|
||||
<div style="display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 4px;">
|
||||
${prod.cumple_mep ? '<span class="badge-mep">MEP Saludable</span>' : ''}
|
||||
@@ -889,11 +898,17 @@ function renderCartModalItems() {
|
||||
list.innerHTML = cart.map((item, idx) => {
|
||||
const subtotal = item.product.precio_colones * item.cantidad;
|
||||
total += subtotal;
|
||||
const itemBadge = window.SiboPayIcons
|
||||
? window.SiboPayIcons.getFoodIconBadge(item.product.icono, item.product.nombre, 'badge')
|
||||
: '';
|
||||
return `
|
||||
<div style="display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid #f1f5f9;">
|
||||
<div>
|
||||
<strong style="font-size: 0.9rem; color: #0f172a;">${item.product.icono ? `${item.product.icono} ` : ''}${item.product.nombre}</strong>
|
||||
<div style="font-size: 0.75rem; color: #64748b;">₡${item.product.precio_colones.toLocaleString('es-CR')} c/u</div>
|
||||
<div style="display: flex; align-items: center; gap: 8px;">
|
||||
${itemBadge}
|
||||
<div>
|
||||
<strong style="font-size: 0.9rem; color: #0f172a;">${item.product.nombre}</strong>
|
||||
<div style="font-size: 0.75rem; color: #64748b;">₡${item.product.precio_colones.toLocaleString('es-CR')} c/u</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="display: flex; align-items: center; gap: 8px;">
|
||||
<button onclick="changeCartQty(${idx}, -1)" style="width: 28px; height: 28px; border-radius: 6px; border: 1px solid #cbd5e1; background: white; font-weight: 800; cursor: pointer;">-</button>
|
||||
@@ -3246,11 +3261,17 @@ function renderAdminInventory(list) {
|
||||
statusPill = `<span style="font-size: 0.7rem; font-weight: 800; color: #166534; background: #dcfce7; padding: 3px 8px; border-radius: 6px;">${p.stock} unid.</span>`;
|
||||
}
|
||||
|
||||
const iconBadge = window.SiboPayIcons
|
||||
? window.SiboPayIcons.getFoodIconBadge(p.icono, p.nombre, 'badge')
|
||||
: `<div style="font-size: 1.8rem; text-align: center; flex-shrink: 0; min-width: 40px;">${p.icono || '🥪'}</div>`;
|
||||
|
||||
return `
|
||||
<div class="inventory-item-row" style="${isOutOfStock ? 'background: #fff1f2;' : ''}">
|
||||
<div class="inventory-item-top" style="display: flex; align-items: center; justify-content: space-between; gap: 10px;">
|
||||
<div style="display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0;">
|
||||
<div style="font-size: 1.8rem; text-align: center; flex-shrink: 0; min-width: 40px;">${p.icono || '🥪'}</div>
|
||||
<div style="flex-shrink: 0; display: flex; align-items: center; justify-content: center;">
|
||||
${iconBadge}
|
||||
</div>
|
||||
<div style="flex: 1; min-width: 0;">
|
||||
<div style="display: flex; align-items: center; gap: 6px; flex-wrap: wrap;">
|
||||
<strong style="font-size: 0.92rem; color: var(--text-main); word-break: break-word;">${p.nombre}</strong>
|
||||
@@ -4483,13 +4504,17 @@ function openCreateProductModal() {
|
||||
document.getElementById('adminProdId').value = '';
|
||||
document.getElementById('adminProdNombre').value = '';
|
||||
document.getElementById('adminProdPrecio').value = '';
|
||||
document.getElementById('adminProdIcono').value = '🥪';
|
||||
document.getElementById('adminProdIcono').value = 'sandwich';
|
||||
document.getElementById('adminProdDescripcion').value = '';
|
||||
document.getElementById('adminProdControlStock').checked = true;
|
||||
toggleStockInput(true);
|
||||
document.getElementById('adminProdStock').value = '15';
|
||||
document.getElementById('adminProdMep').value = '1';
|
||||
|
||||
if (window.SiboPayIcons) {
|
||||
window.SiboPayIcons.renderIconPicker('adminProdIconPickerList', 'adminProdIcono', 'adminProdIconPreview', 'sandwich');
|
||||
}
|
||||
|
||||
const btnDel = document.getElementById('btnDeleteProduct');
|
||||
if (btnDel) btnDel.style.display = 'none';
|
||||
|
||||
@@ -4515,7 +4540,7 @@ function openEditProductModal(prodId) {
|
||||
document.getElementById('adminProdId').value = prod.id;
|
||||
document.getElementById('adminProdNombre').value = prod.nombre || '';
|
||||
document.getElementById('adminProdPrecio').value = prod.precio_colones || 0;
|
||||
document.getElementById('adminProdIcono').value = prod.icono || '🥪';
|
||||
document.getElementById('adminProdIcono').value = prod.icono || 'sandwich';
|
||||
document.getElementById('adminProdDescripcion').value = prod.descripcion || '';
|
||||
|
||||
const hasControl = prod.control_stock === 1;
|
||||
@@ -4524,6 +4549,10 @@ function openEditProductModal(prodId) {
|
||||
document.getElementById('adminProdStock').value = prod.stock !== undefined ? prod.stock : 0;
|
||||
document.getElementById('adminProdMep').value = (prod.cumple_mep !== undefined ? prod.cumple_mep : 1);
|
||||
|
||||
if (window.SiboPayIcons) {
|
||||
window.SiboPayIcons.renderIconPicker('adminProdIconPickerList', 'adminProdIcono', 'adminProdIconPreview', prod.icono || 'sandwich');
|
||||
}
|
||||
|
||||
const btnDel = document.getElementById('btnDeleteProduct');
|
||||
if (btnDel) btnDel.style.display = 'inline-block';
|
||||
|
||||
@@ -4548,7 +4577,7 @@ async function submitAdminProduct(e) {
|
||||
const nombre = document.getElementById('adminProdNombre').value.trim();
|
||||
const categoria_id = parseInt(document.getElementById('adminProdCategoria').value, 10);
|
||||
const precio_colones = parseInt(document.getElementById('adminProdPrecio').value, 10);
|
||||
const icono = document.getElementById('adminProdIcono').value.trim() || '🥪';
|
||||
const icono = document.getElementById('adminProdIcono').value.trim() || 'sandwich';
|
||||
const descripcion = document.getElementById('adminProdDescripcion').value.trim();
|
||||
const control_stock = document.getElementById('adminProdControlStock').checked ? 1 : 0;
|
||||
const stock = parseInt(document.getElementById('adminProdStock').value, 10) || 0;
|
||||
|
||||
@@ -0,0 +1,241 @@
|
||||
/**
|
||||
* SiboPay Food & Beverage Vector Icons (SVG)
|
||||
* Iconografía vectorial fina, minimalista y elegante para productos escolares y soda
|
||||
*/
|
||||
|
||||
(function (window) {
|
||||
'use strict';
|
||||
|
||||
const FOOD_ICONS = {
|
||||
'sandwich': {
|
||||
label: 'Sandwich / Panini',
|
||||
svg: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="M3 11v3a1 1 0 0 0 1 1h16a1 1 0 0 0 1-1v-3"/><path d="M12 4C7 4 4 7 4 9h16c0-2-3-5-8-5Z"/><path d="M4 18h16a1 1 0 0 0 1-1v-1H3v1a1 1 0 0 0 1 1Z"/><line x1="3" y1="13" x2="21" y2="13"/></svg>'
|
||||
},
|
||||
'croissant': {
|
||||
label: 'Empanada / Repostería',
|
||||
svg: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="m4.6 13.4 1.8 1.8a2 2 0 0 0 2.8 0l8.4-8.4a2 2 0 0 0 0-2.8l-1.8-1.8a2 2 0 0 0-2.8 0L4.6 10.6a2 2 0 0 0 0 2.8Z"/><path d="m14.5 9.5-6 6"/><path d="M7 17a5 5 0 0 0 7 7 5 5 0 0 0 7-7"/><path d="M3 13a5 5 0 0 0 7-7"/></svg>'
|
||||
},
|
||||
'utensils': {
|
||||
label: 'Plato Fuerte / Almuerzo',
|
||||
svg: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="M18 2v20"/><path d="M21 15V2v0a5 5 0 0 0-5 5v6c0 1.1.9 2 2 2h3Zm0 0v7"/><path d="M6 2v20"/><path d="M3 7V2h6v5a3 3 0 0 1-6 0v0Z"/></svg>'
|
||||
},
|
||||
'cup-soda': {
|
||||
label: 'Bebida / Fresco Natural',
|
||||
svg: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="m6 8 1.75 12.28A2 2 0 0 0 9.73 22h4.54a2 2 0 0 0 1.98-1.72L18 8"/><path d="M5 8h14"/><path d="M7 15a6.47 6.47 0 0 1 5 0 6.47 6.47 0 0 0 5 0"/><path d="m12 8 1-6h2"/></svg>'
|
||||
},
|
||||
'milk': {
|
||||
label: 'Leche / Lácteos',
|
||||
svg: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="M8 2h8"/><path d="M9 2v3a3 3 0 0 1-.88 2.12L7 8.24A4 4 0 0 0 6 11v9a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2v-9a4 4 0 0 0-1-2.76l-1.12-1.12A3 3 0 0 1 15 5V2"/><line x1="6" y1="15" x2="18" y2="15"/></svg>'
|
||||
},
|
||||
'coffee': {
|
||||
label: 'Café / Infusión Caliente',
|
||||
svg: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="M17 8h1a4 4 0 1 1 0 8h-1"/><path d="M3 8h14v9a4 4 0 0 1-4 4H7a4 4 0 0 1-4-4Z"/><line x1="6" y1="2" x2="6" y2="4"/><line x1="10" y1="2" x2="10" y2="4"/><line x1="14" y1="2" x2="14" y2="4"/></svg>'
|
||||
},
|
||||
'apple': {
|
||||
label: 'Fruta / Saludable',
|
||||
svg: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="M12 20.94c1.5 0 2.75 1.06 4 1.06 3 0 6-8 6-12.22A4.91 4.91 0 0 0 17 5c-2.22 0-4 1.44-5 2-1-.56-2.78-2-5-2a4.9 4.9 0 0 0-5 4.78C2 14 5 22 8 22c1.25 0 2.5-1.06 4-1.06Z"/><path d="M10 2c1 .5 2 2 2 5"/></svg>'
|
||||
},
|
||||
'bowl': {
|
||||
label: 'Bowl / Ensalada / Sopa',
|
||||
svg: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="M4 11h16a1 1 0 0 1 1 1 8 8 0 0 1-16 0 1 1 0 0 1 1-1Z"/><path d="M8 7c0-2 2-3 2-5"/><path d="M12 7c0-2 2-3 2-5"/><path d="M16 7c0-2 2-3 2-5"/></svg>'
|
||||
},
|
||||
'cookie': {
|
||||
label: 'Galleta / Snack',
|
||||
svg: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="M12 2a10 10 0 1 0 10 10 4 4 0 0 1-5-5 4 4 0 0 1-5-5"/><circle cx="8.5" cy="8.5" r="0.75" fill="currentColor"/><circle cx="7" cy="13.5" r="0.75" fill="currentColor"/><circle cx="12" cy="16" r="0.75" fill="currentColor"/><circle cx="16.5" cy="13" r="0.75" fill="currentColor"/><circle cx="11.5" cy="11.5" r="0.75" fill="currentColor"/></svg>'
|
||||
},
|
||||
'pizza': {
|
||||
label: 'Pizza / Taco / Rápida',
|
||||
svg: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="m12 2-9 18a2.5 2.5 0 0 0 2.2 1.3h13.6a2.5 2.5 0 0 0 2.2-1.3L12 2Z"/><circle cx="12" cy="9.5" r="1" fill="currentColor"/><circle cx="9" cy="15.5" r="1" fill="currentColor"/><circle cx="15" cy="15.5" r="1" fill="currentColor"/></svg>'
|
||||
},
|
||||
'meat': {
|
||||
label: 'Carne / Pollo / Proteína',
|
||||
svg: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="m15.4 15.4-3.9 3.9a5.5 5.5 0 1 1-7.8-7.8l3.9-3.9a5.5 5.5 0 0 1 7.8 7.8Z"/><path d="m14 10 4-4"/><circle cx="19" cy="5" r="1.5"/></svg>'
|
||||
},
|
||||
'wheat': {
|
||||
label: 'Cereal / Granola / Avena',
|
||||
svg: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="m2 22 10-10"/><path d="M16 8a4 4 0 0 0-6 0 4 4 0 0 0 0 6 4 4 0 0 0 6 0 4 4 0 0 0 0-6Z"/><path d="M19 5a4 4 0 0 0-6 0 4 4 0 0 0 0 6 4 4 0 0 0 6 0 4 4 0 0 0 0-6Z"/></svg>'
|
||||
},
|
||||
'ice-cream': {
|
||||
label: 'Postre / Gelatina / Helado',
|
||||
svg: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="m7 11 5 11 5-11"/><path d="M12 2a5 5 0 0 0-5 5v4h10V7a5 5 0 0 0-5-5Z"/></svg>'
|
||||
},
|
||||
'store': {
|
||||
label: 'Todos / Menú Completo',
|
||||
svg: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"><path d="m2 7 4.41-4.41A2 2 0 0 1 7.83 2h8.34a2 2 0 0 1 1.42.59L22 7"/><path d="M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8"/><path d="M15 22v-4a2 2 0 0 0-2-2h-2a2 2 0 0 0-2 2v4"/><path d="M2 7h20"/></svg>'
|
||||
}
|
||||
};
|
||||
|
||||
// Mapeo automático de emojis antiguos a iconos SVG elegantes
|
||||
const EMOJI_TO_KEY = {
|
||||
'🥪': 'sandwich',
|
||||
'🥟': 'croissant',
|
||||
'🌮': 'pizza',
|
||||
'🍳': 'utensils',
|
||||
'🍗': 'meat',
|
||||
'🍛': 'utensils',
|
||||
'🍹': 'cup-soda',
|
||||
'🥤': 'cup-soda',
|
||||
'🧃': 'cup-soda',
|
||||
'🥛': 'milk',
|
||||
'🍉': 'apple',
|
||||
'🥣': 'bowl',
|
||||
'🌾': 'wheat',
|
||||
'🍮': 'ice-cream',
|
||||
'🍎': 'apple',
|
||||
'🍕': 'pizza',
|
||||
'🥗': 'bowl',
|
||||
'🍪': 'cookie',
|
||||
'🍽️': 'utensils',
|
||||
'☕': 'coffee',
|
||||
'🥩': 'meat',
|
||||
'🍦': 'ice-cream',
|
||||
'🥑': 'apple',
|
||||
'🥐': 'croissant',
|
||||
'🍞': 'sandwich',
|
||||
'🍔': 'sandwich'
|
||||
};
|
||||
|
||||
/**
|
||||
* Resuelve el identificador de icono SVG a partir de una clave, emoji o nombre de producto
|
||||
*/
|
||||
function resolveIconKey(rawInput, fallbackName) {
|
||||
if (!rawInput && !fallbackName) return 'sandwich';
|
||||
const input = String(rawInput || '').trim();
|
||||
|
||||
// 1. Si coincide directamente con una clave conocida
|
||||
if (FOOD_ICONS[input]) return input;
|
||||
|
||||
// 2. Si coincide con un emoji mapeado
|
||||
if (EMOJI_TO_KEY[input]) return EMOJI_TO_KEY[input];
|
||||
|
||||
// 3. Analizar palabras clave en el nombre del producto
|
||||
const text = (String(fallbackName || '') + ' ' + input).toLowerCase();
|
||||
if (text.includes('empanada') || text.includes('pastel') || text.includes('reposter') || text.includes('croissant')) return 'croissant';
|
||||
if (text.includes('sandwich') || text.includes('emparedado') || text.includes('pan') || text.includes('tostada')) return 'sandwich';
|
||||
if (text.includes('fresco') || text.includes('jugo') || text.includes('te frio') || text.includes('té') || text.includes('gaseosa') || text.includes('bebida') || text.includes('refresco')) return 'cup-soda';
|
||||
if (text.includes('leche') || text.includes('batido')) return 'milk';
|
||||
if (text.includes('cafe') || text.includes('café') || text.includes('chocolate caliente')) return 'coffee';
|
||||
if (text.includes('fruta') || text.includes('manzana') || text.includes('sandia') || text.includes('sandía') || text.includes('pina') || text.includes('piña')) return 'apple';
|
||||
if (text.includes('ensalada') || text.includes('sopa') || text.includes('bowl') || text.includes('yogurt')) return 'bowl';
|
||||
if (text.includes('pinto') || text.includes('casado') || text.includes('almuerzo') || text.includes('arroz') || text.includes('plato')) return 'utensils';
|
||||
if (text.includes('pollo') || text.includes('carne') || text.includes('bistec') || text.includes('chuleta')) return 'meat';
|
||||
if (text.includes('pizza') || text.includes('taco') || text.includes('wrap')) return 'pizza';
|
||||
if (text.includes('galleta') || text.includes('snack') || text.includes('barra') || text.includes('cereal') || text.includes('avena')) return 'cookie';
|
||||
if (text.includes('gelatina') || text.includes('helado') || text.includes('postre') || text.includes('flan')) return 'ice-cream';
|
||||
|
||||
return 'sandwich';
|
||||
}
|
||||
|
||||
/**
|
||||
* Retorna el SVG puro del icono
|
||||
*/
|
||||
function getFoodSvg(rawInput, fallbackName, size = 22) {
|
||||
const key = resolveIconKey(rawInput, fallbackName);
|
||||
const item = FOOD_ICONS[key] || FOOD_ICONS['sandwich'];
|
||||
return item.svg.replace('<svg ', `<svg width="${size}" height="${size}" `);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retorna una insignia circular elegante y limpia con el SVG dentro
|
||||
* variant: 'card' (catálogo POS/PWA 50x50), 'badge' (34x34 para carrito/filas), 'inline' (15x15 para texto)
|
||||
*/
|
||||
function getFoodIconBadge(rawInput, fallbackName, variant = 'card') {
|
||||
const key = resolveIconKey(rawInput, fallbackName);
|
||||
|
||||
if (variant === 'card') {
|
||||
const svg = getFoodSvg(key, null, 24);
|
||||
return `
|
||||
<div class="sibopay-food-badge-card" style="width: 50px; height: 50px; border-radius: 50%; background: #f0f9ff; border: 1.5px solid #bae6fd; color: #0284c7; display: flex; align-items: center; justify-content: center; margin: 0 auto 8px; box-shadow: 0 2px 6px rgba(2, 132, 199, 0.08); flex-shrink: 0; transition: all 0.2s ease;">
|
||||
${svg}
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
if (variant === 'badge') {
|
||||
const svg = getFoodSvg(key, null, 17);
|
||||
return `
|
||||
<div class="sibopay-food-badge-sm" style="width: 34px; height: 34px; border-radius: 9px; background: #f0f9ff; border: 1.2px solid #bae6fd; color: #0284c7; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; margin-right: 8px;">
|
||||
${svg}
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
if (variant === 'inline') {
|
||||
const svg = getFoodSvg(key, null, 15);
|
||||
return `<span style="display: inline-flex; align-items: center; justify-content: center; vertical-align: -2px; color: #0284c7; margin-right: 5px;">${svg}</span>`;
|
||||
}
|
||||
|
||||
return getFoodSvg(key, fallbackName, 20);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renderiza el selector de iconos finos para los modales de creación/edición de productos
|
||||
*/
|
||||
function renderIconPicker(containerId, inputId, previewId, currentKey) {
|
||||
const container = document.getElementById(containerId);
|
||||
const input = document.getElementById(inputId);
|
||||
const preview = document.getElementById(previewId);
|
||||
if (!container) return;
|
||||
|
||||
const resolved = resolveIconKey(currentKey || (input ? input.value : 'sandwich'));
|
||||
if (input) input.value = resolved;
|
||||
if (preview) preview.innerHTML = getFoodIconBadge(resolved, null, 'card');
|
||||
|
||||
const pickerKeys = [
|
||||
'sandwich', 'croissant', 'utensils', 'cup-soda',
|
||||
'milk', 'coffee', 'apple', 'bowl',
|
||||
'cookie', 'pizza', 'meat', 'ice-cream'
|
||||
];
|
||||
|
||||
container.innerHTML = pickerKeys.map(k => {
|
||||
const isAct = (k === resolved);
|
||||
const svg = getFoodSvg(k, null, 18);
|
||||
const label = FOOD_ICONS[k]?.label || k;
|
||||
return `
|
||||
<button type="button"
|
||||
class="btn-food-icon-picker ${isAct ? 'active' : ''}"
|
||||
id="btnFoodPick_${k}"
|
||||
onclick="window.SiboPayIcons.onPickIcon('${k}', '${containerId}', '${inputId}', '${previewId}')"
|
||||
title="${label}"
|
||||
style="width: 38px; height: 38px; border-radius: 8px; border: 1.5px solid ${isAct ? '#0284c7' : 'var(--border)'}; background: ${isAct ? '#f0f9ff' : 'var(--card-bg)'}; color: ${isAct ? '#0284c7' : 'var(--text-muted)'}; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.15s ease;">
|
||||
${svg}
|
||||
</button>
|
||||
`;
|
||||
}).join('');
|
||||
}
|
||||
|
||||
function onPickIcon(key, containerId, inputId, previewId) {
|
||||
const input = document.getElementById(inputId);
|
||||
const preview = document.getElementById(previewId);
|
||||
if (input) input.value = key;
|
||||
if (preview) preview.innerHTML = getFoodIconBadge(key, null, 'card');
|
||||
|
||||
const container = document.getElementById(containerId);
|
||||
if (container) {
|
||||
container.querySelectorAll('.btn-food-icon-picker').forEach(b => {
|
||||
b.classList.remove('active');
|
||||
b.style.borderColor = 'var(--border)';
|
||||
b.style.background = 'var(--card-bg)';
|
||||
b.style.color = 'var(--text-muted)';
|
||||
});
|
||||
const activeBtn = document.getElementById(`btnFoodPick_${key}`);
|
||||
if (activeBtn) {
|
||||
activeBtn.classList.add('active');
|
||||
activeBtn.style.borderColor = '#0284c7';
|
||||
activeBtn.style.background = '#f0f9ff';
|
||||
activeBtn.style.color = '#0284c7';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Exportar al ámbito global
|
||||
window.SiboPayIcons = {
|
||||
FOOD_ICONS,
|
||||
resolveIconKey,
|
||||
getFoodSvg,
|
||||
getFoodIconBadge,
|
||||
renderIconPicker,
|
||||
onPickIcon
|
||||
};
|
||||
|
||||
})(window);
|
||||
+25
-13
@@ -157,13 +157,19 @@ async function loadCatalog() {
|
||||
function renderPosCategories() {
|
||||
const bar = document.getElementById('posCategoriesBar');
|
||||
if (!bar) return;
|
||||
const storeIcon = window.SiboPayIcons ? window.SiboPayIcons.getFoodIconBadge('store', 'Todos', 'inline') : '';
|
||||
bar.innerHTML = `
|
||||
<button class="pos-cat-pill active" onclick="filterPosCat(null, this)">Todos</button>
|
||||
${posCategories.map(c => `
|
||||
<button class="pos-cat-pill" onclick="filterPosCat(${c.id}, this)">
|
||||
<span>${c.icono || '🍽️'}</span> ${c.nombre}
|
||||
</button>
|
||||
`).join('')}
|
||||
<button class="pos-cat-pill active" onclick="filterPosCat(null, this)">
|
||||
${storeIcon}Todos
|
||||
</button>
|
||||
${posCategories.map(c => {
|
||||
const catIcon = window.SiboPayIcons ? window.SiboPayIcons.getFoodIconBadge(c.icono, c.nombre, 'inline') : `<span>${c.icono || '🍽️'}</span> `;
|
||||
return `
|
||||
<button class="pos-cat-pill" onclick="filterPosCat(${c.id}, this)">
|
||||
${catIcon}${c.nombre}
|
||||
</button>
|
||||
`;
|
||||
}).join('')}
|
||||
`;
|
||||
}
|
||||
|
||||
@@ -339,7 +345,7 @@ function renderPosProducts(catId) {
|
||||
title="${isFirstMatch ? 'Primer resultado coincidente (pulsa Enter para cobrar)' : ''}"
|
||||
onclick="${isOutOfStock ? `alert('El producto \\'${prod.nombre.replace(/'/g, "\\'")}\\' se encuentra bloqueado o agotado.')` : `addToPosCart(${prod.id})`}">
|
||||
${isOutOfStock ? '<div style="position: absolute; top: 10px; right: 10px;"><span class="saas-status-badge saas-status-blocked"><span class="saas-dot"></span>BLOQUEADO</span></div>' : (isFirstMatch ? '<div style="position: absolute; top: 8px; right: 8px;"><span class="saas-status-badge saas-status-active" style="font-size: 0.65rem; padding: 2px 6px;">Enter ↵</span></div>' : '')}
|
||||
<div style="font-size: 2.2rem; text-align: center; margin-bottom: 6px;">${prod.icono || '🥪'}</div>
|
||||
${window.SiboPayIcons ? window.SiboPayIcons.getFoodIconBadge(prod.icono, prod.nombre, 'card') : `<div style="font-size: 2.2rem; text-align: center; margin-bottom: 6px;">${prod.icono || '🥪'}</div>`}
|
||||
<div>
|
||||
<div class="prod-title">${prod.nombre}</div>
|
||||
${prod.cumple_mep ? '<span style="font-size: 0.68rem; color: #166534; font-weight: 700; margin-top: 3px; display: inline-flex; align-items: center; gap: 3px;">🌿 MEP Saludable</span>' : ''}
|
||||
@@ -533,11 +539,17 @@ function updatePosCartUI() {
|
||||
list.innerHTML = posCart.map((item, idx) => {
|
||||
const subtotal = item.product.precio_colones * item.cantidad;
|
||||
total += subtotal;
|
||||
const itemBadge = window.SiboPayIcons
|
||||
? window.SiboPayIcons.getFoodIconBadge(item.product.icono, item.product.nombre, 'badge')
|
||||
: '';
|
||||
return `
|
||||
<div class="pos-cart-item">
|
||||
<div style="flex: 1; min-width: 0; word-break: break-word;">
|
||||
<strong style="color: #0f172a; font-size: 0.88rem; font-weight: 800; display: block; line-height: 1.25;">${item.product.icono ? `<span style="margin-right: 5px; font-size: 1rem;">${item.product.icono}</span>` : ''}${item.product.nombre}</strong>
|
||||
<div style="font-size: 0.74rem; color: #64748b; font-weight: 600; margin-top: 3px;">₡${item.product.precio_colones.toLocaleString('es-CR')} c/u</div>
|
||||
<div style="display: flex; align-items: center; min-width: 0; flex: 1;">
|
||||
${itemBadge}
|
||||
<div style="min-width: 0; flex: 1; word-break: break-word;">
|
||||
<strong style="color: #0f172a; font-size: 0.88rem; font-weight: 800; display: block; line-height: 1.25;">${item.product.nombre}</strong>
|
||||
<div style="font-size: 0.74rem; color: #64748b; font-weight: 600; margin-top: 2px;">₡${item.product.precio_colones.toLocaleString('es-CR')} c/u</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="display: flex; align-items: center; gap: 8px; flex-shrink: 0;">
|
||||
<button onclick="changePosQty(${idx}, -1)" class="pos-qty-btn" title="Disminuir">−</button>
|
||||
@@ -1255,7 +1267,7 @@ async function loadPreOrders() {
|
||||
list.innerHTML = orders.map(ord => {
|
||||
const hora = new Date(ord.creado_en).toLocaleTimeString('es-CR', { hour: '2-digit', minute: '2-digit' });
|
||||
const items = Array.isArray(ord.items) ? ord.items : [];
|
||||
const itemsList = items.map(i => `${i.cantidad}x ${i.icono || '🥪'} ${i.nombre}`).join(', ');
|
||||
const itemsList = items.map(i => `${i.cantidad}× ${i.nombre}`).join(' • ');
|
||||
const avatarUrl = ord.foto_url || 'https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?w=150';
|
||||
|
||||
return `
|
||||
@@ -1281,8 +1293,8 @@ async function loadPreOrders() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="pos-preorder-items-box">
|
||||
<span>📦</span>
|
||||
<div class="pos-preorder-items-box" style="display: flex; align-items: center; gap: 8px;">
|
||||
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="#0284c7" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="flex-shrink: 0;"><path d="m7.5 4.27 9 5.15"/><path d="M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z"/><path d="m3.3 7 8.7 5 8.7-5"/><path d="M12 22V12"/></svg>
|
||||
<span style="flex: 1; word-break: break-word;">${itemsList}</span>
|
||||
</div>
|
||||
|
||||
|
||||
+12
-9
@@ -52,10 +52,10 @@
|
||||
<!-- BARRA DE PESTAÑAS MÓVIL (PANTALLAS <= 900px) -->
|
||||
<div class="pos-mobile-nav" id="posMobileNav">
|
||||
<button class="pos-mobile-nav-btn active" id="btnMobileNavCatalog" onclick="switchPosMobileView('catalog')">
|
||||
<span>🥪</span> Catálogo
|
||||
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="display:inline-block; vertical-align:middle; margin-right:4px;"><rect width="7" height="7" x="3" y="3" rx="1"/><rect width="7" height="7" x="14" y="3" rx="1"/><rect width="7" height="7" x="14" y="14" rx="1"/><rect width="7" height="7" x="3" y="14" rx="1"/></svg> Catálogo
|
||||
</button>
|
||||
<button class="pos-mobile-nav-btn" id="btnMobileNavCheckout" onclick="switchPosMobileView('checkout')">
|
||||
<span>💳</span> Caja / Cobro QR
|
||||
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="display:inline-block; vertical-align:middle; margin-right:4px;"><rect width="20" height="14" x="2" y="5" rx="2"/><line x1="2" x2="22" y1="10" y2="10"/></svg> Caja / Cobro QR
|
||||
<span class="pos-mobile-nav-badge" id="mobileCartBadge" style="display: none;">0</span>
|
||||
</button>
|
||||
</div>
|
||||
@@ -85,10 +85,10 @@
|
||||
<span>🔔</span> <span id="lblPosNotificationStatus">Notificaciones</span>
|
||||
</button>
|
||||
<a href="/index.html" class="btn-saas btn-saas-outline" style="height: 30px; font-size: 0.76rem;">
|
||||
<span>👨🍳</span> Admin
|
||||
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="display:inline-block; vertical-align:middle; margin-right:3px;"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/></svg> Admin
|
||||
</a>
|
||||
<a href="/index.html" target="_blank" class="btn-saas btn-saas-outline" style="height: 30px; font-size: 0.76rem; color: #0284c7; border-color: #bae6fd;">
|
||||
<span>📱</span> PWA Estudiante ↗
|
||||
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="display:inline-block; vertical-align:middle; margin-right:3px;"><rect width="14" height="20" x="5" y="2" rx="2" ry="2"/><path d="M12 18h.01"/></svg> PWA Estudiante ↗
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
@@ -96,18 +96,18 @@
|
||||
<!-- TABS DE MODO DE TERMINAL (RESPONSIVE SIN RECORTES) -->
|
||||
<div class="pos-tabs">
|
||||
<button class="pos-tab-btn active" id="tabBtnMostrador" onclick="switchPosTab('mostrador')">
|
||||
<span class="tab-icon">🛒</span>
|
||||
<span class="tab-icon"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="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></span>
|
||||
<span class="tab-label-full">Venta de Mostrador</span>
|
||||
<span class="tab-label-short">Mostrador</span>
|
||||
</button>
|
||||
<button class="pos-tab-btn" id="tabBtnPreordenes" onclick="switchPosTab('preordenes')">
|
||||
<span class="tab-icon">📦</span>
|
||||
<span class="tab-icon"><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="m7.5 4.27 9 5.15"/><path d="M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z"/><path d="m3.3 7 8.7 5 8.7-5"/><path d="M12 22V12"/></svg></span>
|
||||
<span class="tab-label-full">Fila Rápida Pre-Órdenes</span>
|
||||
<span class="tab-label-short">Pre-Órdenes</span>
|
||||
<span id="badgePreordenesCount" style="background: #ef4444; color: white; padding: 2px 7px; border-radius: 10px; font-size: 0.72rem; font-weight: 800;">0</span>
|
||||
</button>
|
||||
<button class="pos-tab-btn" id="tabBtnSinpe" onclick="switchPosTab('sinpe')">
|
||||
<span class="tab-icon">📱</span>
|
||||
<span class="tab-icon"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="14" height="20" x="5" y="2" rx="2" ry="2"/><path d="M12 18h.01"/></svg></span>
|
||||
<span class="tab-label-full">Recargas SINPE</span>
|
||||
<span class="tab-label-short">Recargas SINPE</span>
|
||||
<span id="badgeSinpeCount" style="background: #10b981; color: white; padding: 2px 7px; border-radius: 10px; font-size: 0.72rem; font-weight: 800; display: none;">0</span>
|
||||
@@ -212,7 +212,9 @@
|
||||
<!-- BARRA FLOTANTE DE ACCESO RÁPIDO A CAJA EN MÓVIL -->
|
||||
<div id="posFloatingCheckoutBar" class="pos-floating-checkout-bar" onclick="switchPosMobileView('checkout')" style="display: none;">
|
||||
<div style="display: flex; align-items: center; gap: 10px;">
|
||||
<span style="font-size: 1.3rem;">🛒</span>
|
||||
<div style="width: 36px; height: 36px; border-radius: 50%; background: rgba(56, 189, 248, 0.2); display: flex; align-items: center; justify-content: center; color: #38bdf8;">
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="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>
|
||||
</div>
|
||||
<div>
|
||||
<div style="font-weight: 800; font-size: 0.88rem; color: #ffffff;" id="posFloatingCartText">0 ítems</div>
|
||||
<div style="font-size: 0.72rem; color: #cbd5e1;">Toca para cobrar o escanear QR</div>
|
||||
@@ -446,7 +448,7 @@
|
||||
Cancelar (Esc)
|
||||
</button>
|
||||
<button type="submit" id="btnSubmitQuickProd" class="btn-saas btn-saas-primary" style="flex: 2; height: 38px; background: #0f172a; border-color: #0f172a; font-size: 0.88rem; font-weight: 800;">
|
||||
<span>💾</span> Guardar y Cobrar ➔
|
||||
<span>Guardar y Cobrar ➔</span>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
@@ -455,6 +457,7 @@
|
||||
|
||||
<script src="/js/sounds.js?v=8.6"></script>
|
||||
<script src="/js/jsQR.js"></script>
|
||||
<script src="/js/food-icons.js?v=1.0"></script>
|
||||
<script src="/js/pos.js?v=8.6"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user