diff --git a/js/views/ShoppingList.js b/js/views/ShoppingList.js index 9334dc3..f1e3ba8 100644 --- a/js/views/ShoppingList.js +++ b/js/views/ShoppingList.js @@ -123,8 +123,6 @@ function renderBoard() { if (!root) return; const items = getKitchenItems(); - const unchecked = items.filter((i) => !i.checked); - const checked = items.filter((i) => i.checked); if (items.length === 0) { root.innerHTML = ` @@ -138,37 +136,20 @@ function renderBoard() { return; } - let html = ''; - - // Unchecked items grouped by category - if (unchecked.length > 0) { - const groups = groupItemsByCategory(unchecked); - html += groups.map(({ cat, items: catItems }) => { - const icon = CATEGORY_ICONS[cat] || 'fa-jar'; - return ` -
-
- -

${esc(categoryLabel(cat))}

- ${catItems.length} -
- ${catItems.map((item) => itemRowHtml(item)).join('')} -
`; - }).join(''); - } - - // Checked items at the bottom - if (checked.length > 0) { - html += ` -
+ const groups = groupItemsByCategory(items); + const html = groups.map(({ cat, items: catItems }) => { + const icon = CATEGORY_ICONS[cat] || 'fa-jar'; + const uncheckedCount = catItems.filter((i) => !i.checked).length; + return ` +
- -

Kupione

- ${checked.length} + +

${esc(categoryLabel(cat))}

+ ${uncheckedCount}/${catItems.length}
- ${checked.map((item) => itemRowHtml(item)).join('')} + ${catItems.map((item) => itemRowHtml(item)).join('')}
`; - } + }).join(''); root.innerHTML = html; bindRowEvents(root);