+
+ {/* Articles libres sélectionnés (affichés en tête) */}
+ {selections.filter(s => s.type === 'custom').map(s => (
+
removeSelection(s.name)}
+ style={{
+ display: 'flex', alignItems: 'center', gap: 12,
+ padding: '12px 16px', cursor: 'pointer', minHeight: 56,
+ background: 'rgba(142,192,124,0.12)',
+ borderBottom: '1px solid var(--bg-4)',
+ }}
+ >
+
+ ✓
+
+
+
{s.name}
+
article libre
+
+
+ ))}
+
+ {/* Produits du catalogue */}
+ {filteredProducts.map(p => {
+ const selected = selections.some(s => s.type === 'product' && s.product.id === p.id)
return (
isSelected ? (setSelectedProduct(null), setItemSearch('')) : selectProduct(p)}
+ onClick={() => toggleProduct(p)}
style={{
- padding: '10px 14px',
- cursor: 'pointer',
- background: isSelected ? 'var(--ok)' : 'transparent',
- color: isSelected ? '#1d2021' : 'var(--ink-1)',
- borderBottom: idx < filteredProducts.length - 1 ? '1px solid var(--bg-4)' : 'none',
- display: 'flex', alignItems: 'center', gap: 10,
- userSelect: 'none',
+ display: 'flex', alignItems: 'center', gap: 12,
+ padding: '12px 16px', cursor: 'pointer', minHeight: 56,
+ background: selected ? 'rgba(142,192,124,0.12)' : 'transparent',
+ borderBottom: '1px solid var(--bg-4)',
+ transition: 'background 0.1s',
}}
>
+
+ {selected && ✓}
+
-
+
{p.name}
- {(p.default_unit || p.brand) && (
-
+ {(p.brand || p.default_unit) && (
+
{[p.brand, p.default_unit].filter(Boolean).join(' · ')}
)}
- {isSelected &&
✓}
)
})}
+
+ {/* Article libre si aucun match */}
+ {itemSearch.trim() && filteredProducts.length === 0 && (
+
+ +
+
+ Ajouter "{itemSearch.trim()}"
+
+
+ )}
+
+ {filteredProducts.length === 0 && !itemSearch.trim() && (
+
+ Catalogue vide — utilisez le bouton Articles
+
+ )}
- {/* Case "Ajouter au catalogue" — uniquement si article libre sans correspondance */}
- {!selectedProduct && itemSearch.trim() && filteredProducts.length === 0 && (
-
- )}
-
- {/* Quantité + Unité */}
-
- setNewItemQty(e.target.value)}
- />
- setNewItemUnit(e.target.value)}
- />
-
-
-
+ {/* Bouton confirm sticky */}
+
-
+ >
+ {addSaving ? 'Ajout en cours…' : selections.length === 0 ? 'Sélectionner des articles' : `Ajouter (${selections.length})`}
+
-
+
)}
{showHistoryModal && (