Добавлен блок категорий в POS-терминал: компактные карточки с фильтрацией товаров

This commit is contained in:
2025-11-16 14:09:59 +03:00
parent 8cf076c49e
commit bb51a72f4c
3 changed files with 115 additions and 19 deletions

View File

@@ -10,6 +10,57 @@ function formatMoney(v) {
return (Number(v)).toFixed(2);
}
function renderCategories() {
const grid = document.getElementById('categoryGrid');
grid.innerHTML = '';
// Кнопка "Все"
const allCol = document.createElement('div');
allCol.className = 'col-6 col-sm-4 col-md-3 col-lg-2';
const allCard = document.createElement('div');
allCard.className = 'card category-card' + (currentCategoryId === null ? ' active' : '');
allCard.onclick = () => {
currentCategoryId = null;
renderCategories();
renderProducts();
};
const allBody = document.createElement('div');
allBody.className = 'card-body';
const allName = document.createElement('div');
allName.className = 'category-name';
allName.textContent = 'Все товары';
allBody.appendChild(allName);
allCard.appendChild(allBody);
allCol.appendChild(allCard);
grid.appendChild(allCol);
// Категории
CATEGORIES.forEach(cat => {
const col = document.createElement('div');
col.className = 'col-6 col-sm-4 col-md-3 col-lg-2';
const card = document.createElement('div');
card.className = 'card category-card' + (currentCategoryId === cat.id ? ' active' : '');
card.onclick = () => {
currentCategoryId = cat.id;
renderCategories();
renderProducts();
};
const body = document.createElement('div');
body.className = 'card-body';
const name = document.createElement('div');
name.className = 'category-name';
name.textContent = cat.name;
body.appendChild(name);
card.appendChild(body);
col.appendChild(card);
grid.appendChild(col);
});
}
function renderProducts() {
const grid = document.getElementById('productGrid');
grid.innerHTML = '';
@@ -153,8 +204,6 @@ document.getElementById('scheduleLater').onclick = async () => {
alert('Функционал будет подключен позже: создание заказа на доставку/самовывоз.');
};
// Categories removed from this view - can be added as filter dropdown later if needed
// Search functionality
document.getElementById('searchInput').addEventListener('input', () => {
renderProducts();
@@ -166,5 +215,6 @@ document.getElementById('customerSelectBtn').addEventListener('click', () => {
});
// Инициализация
renderCategories();
renderProducts();
renderCart();