Hide filaments with zero inventory from table
- Added filter to exclude filaments with kolicina === 0 - Updated filter options to only show values from filaments with inventory - This removes clutter and makes the table show only available products 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -38,16 +38,24 @@ const FilamentTableV2: React.FC<FilamentTableV2Props> = ({ filaments }) => {
|
|||||||
return filaments;
|
return filaments;
|
||||||
}, [filaments]);
|
}, [filaments]);
|
||||||
|
|
||||||
// Get unique values for filters
|
// Get unique values for filters (only from filaments with inventory)
|
||||||
const uniqueValues = useMemo(() => ({
|
const uniqueValues = useMemo(() => {
|
||||||
materials: [...new Set(normalizedFilaments.map(f => f.tip))].sort(),
|
const filamentsWithInventory = normalizedFilaments.filter(f => f.kolicina > 0);
|
||||||
finishes: [...new Set(normalizedFilaments.map(f => f.finish))].sort(),
|
return {
|
||||||
colors: availableColors ? availableColors.map(c => c.name) : [...new Set(normalizedFilaments.map(f => f.boja))].sort()
|
materials: [...new Set(filamentsWithInventory.map(f => f.tip))].sort(),
|
||||||
}), [normalizedFilaments, availableColors]);
|
finishes: [...new Set(filamentsWithInventory.map(f => f.finish))].sort(),
|
||||||
|
colors: [...new Set(filamentsWithInventory.map(f => f.boja))].sort()
|
||||||
|
};
|
||||||
|
}, [normalizedFilaments]);
|
||||||
|
|
||||||
// Filter and sort filaments
|
// Filter and sort filaments
|
||||||
const filteredAndSortedFilaments = useMemo(() => {
|
const filteredAndSortedFilaments = useMemo(() => {
|
||||||
let filtered = normalizedFilaments.filter(filament => {
|
let filtered = normalizedFilaments.filter(filament => {
|
||||||
|
// First, filter out filaments with zero inventory
|
||||||
|
if (filament.kolicina === 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Search filter
|
// Search filter
|
||||||
const searchLower = searchTerm.toLowerCase();
|
const searchLower = searchTerm.toLowerCase();
|
||||||
const matchesSearch =
|
const matchesSearch =
|
||||||
|
|||||||
Reference in New Issue
Block a user