- {/* Изображение товара */}
-
- {/* 🚫 ОВЕРЛЕЙ НЕДОСТУПНОСТИ */}
- {(() => {
- const totalStock = product.stock || (product as any).quantity || 0
- const orderedStock = (product as any).ordered || 0
- const availableStock = totalStock - orderedStock
-
- if (availableStock <= 0) {
- return (
-
- )
- }
- return null
- })()}
- {product.images && product.images.length > 0 && product.images[0] ? (
-
- ) : product.mainImage ? (
-
- ) : (
-
-
-
- )}
- {selectedQuantity > 0 && (
-
-
- {selectedQuantity > 999 ? '999+' : selectedQuantity}
-
-
- )}
-
-
- {/* Информация о товаре */}
-
-
- {product.name}
-
-
- {product.category && (
-
- {product.category.name.slice(0, 10)}
-
- )}
- {/* 🚨 ИНДИКАТОР НИЗКИХ ОСТАТКОВ согласно правилам (раздел 6.3) */}
- {(() => {
- const totalStock = product.stock || product.quantity || 0
- const orderedStock = product.ordered || 0
- const availableStock = totalStock - orderedStock
-
- if (availableStock <= 0) {
- return (
-
- Нет в наличии
-
- )
- } else if (availableStock <= 10) {
- return (
-
- Мало остатков
-
- )
- }
- return null
- })()}
-
-
-
- {formatCurrency(product.price)}
-
- {/* 📊 АКТУАЛЬНЫЙ ОСТАТОК согласно правилам (раздел 6.4.2) */}
-
- {(() => {
- const totalStock = product.stock || product.quantity || 0
- const orderedStock = product.ordered || 0
- const availableStock = totalStock - orderedStock
-
- return (
-
-
- Доступно: {availableStock}
-
- {orderedStock > 0 && (
- Заказано: {orderedStock}
- )}
-
- )
- })()}
-
-
-
-
- {/* Управление количеством */}
-
- {(() => {
- const totalStock = product.stock || (product as any).quantity || 0
- const orderedStock = (product as any).ordered || 0
- const availableStock = totalStock - orderedStock
-
- return (
-
-
-
{
- let inputValue = e.target.value
-
- // Удаляем все нецифровые символы
- inputValue = inputValue.replace(/[^0-9]/g, '')
-
- // Удаляем ведущие нули
- inputValue = inputValue.replace(/^0+/, '')
-
- // Если строка пустая после удаления нулей, устанавливаем 0
- const numericValue = inputValue === '' ? 0 : parseInt(inputValue)
-
- // Ограничиваем значение максимумом доступного остатка
- const clampedValue = Math.min(numericValue, availableStock, 99999)
-
- updateConsumableQuantity(product.id, clampedValue)
- }}
- onBlur={(e) => {
- // При потере фокуса, если поле пустое, устанавливаем 0
- if (e.target.value === '') {
- updateConsumableQuantity(product.id, 0)
- }
- }}
- className="w-16 h-7 text-center text-sm bg-white/10 border-white/20 text-white rounded px-1 focus:ring-2 focus:ring-purple-400/50 focus:border-purple-400/50"
- placeholder="0"
- />
-
-
- )
- })()}
-
- {selectedQuantity > 0 && (
-
-
- {formatCurrency(product.price * selectedQuantity)}
-
-
- )}
-
-
-
- {/* Hover эффект */}
-