diff --git a/assets/js/app.js b/assets/js/app.js index 016cd4c..3b396ec 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -1352,7 +1352,16 @@ async function loadCustomLocations() { console.warn('[EverShelf] Could not load custom locations:', e); } } - +function renderLocationButtons(containerId, activeKey, onClickFnName) { + const container = document.getElementById(containerId); + if (!container) return; + const keys = Object.keys(LOCATIONS); + container.innerHTML = keys.map(key => { + const info = LOCATIONS[key]; + const isActive = key === activeKey ? 'active' : ''; + return ``; + }).join(''); +} /** * Render location selector buttons dynamically into a container. * @param {string} containerId - DOM id of the container holding the buttons @@ -9345,6 +9354,7 @@ async function saveEditedProductInfo() { // ===== ADD TO INVENTORY ===== function showAddForm() { + renderLocationButtons('location-selector-add', document.getElementById('add-location')?.value || 'dispensa', 'selectLocation'); const catIcon = CATEGORY_ICONS[mapToLocalCategory(currentProduct.category, currentProduct.name)] || '📦'; document.getElementById('add-product-preview').innerHTML = ` ${currentProduct.image_url ?