'use client'; import { SearchIcon, SlidersHorizontal } from 'lucide-react'; import { useState } from 'react'; import { Button } from '@/components/ui/button'; import { Card, CardContent, CardFooter, CardHeader, CardTitle, } from '@/components/ui/card'; import { Checkbox } from '@/components/ui/checkbox'; import { Input } from '@/components/ui/input'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '@/components/ui/select'; import { Slider } from '@/components/ui/slider'; // Mock product data const products = [ { id: 1, name: 'Laptop', category: 'Electronics', price: 999.99 }, { id: 2, name: 'Smartphone', category: 'Electronics', price: 699.99 }, { id: 3, name: 'Headphones', category: 'Electronics', price: 199.99 }, { id: 4, name: 'T-shirt', category: 'Clothing', price: 24.99 }, { id: 5, name: 'Jeans', category: 'Clothing', price: 49.99 }, { id: 6, name: 'Sneakers', category: 'Footwear', price: 89.99 }, { id: 7, name: 'Watch', category: 'Accessories', price: 149.99 }, { id: 8, name: 'Backpack', category: 'Accessories', price: 79.99 }, ]; const categories = ['Electronics', 'Clothing', 'Footwear', 'Accessories']; export function ProductListComponent() { const [priceRange, setPriceRange] = useState([0, 1000]); const [selectedCategories, setSelectedCategories] = useState([]); const [searchQuery, setSearchQuery] = useState(''); const [sortBy, setSortBy] = useState('name'); const handleCategoryChange = (category: string) => { setSelectedCategories((prev) => prev.includes(category) ? prev.filter((c) => c !== category) : [...prev, category], ); }; const filteredProducts = products .filter( (product) => (selectedCategories.length === 0 || selectedCategories.includes(product.category)) && product.price >= priceRange[0] && product.price <= priceRange[1] && product.name.toLowerCase().includes(searchQuery.toLowerCase()), ) .sort((a, b) => { if (sortBy === 'price') return a.price - b.price; return a.name.localeCompare(b.name); }); return (
{/* Sidebar with filters */} {/* Main content */}
setSearchQuery(e.target.value)} />
{filteredProducts.map((product) => ( {product.name}

Category: {product.category}

${product.price.toFixed(2)}

))}
); }