changes
This commit is contained in:
@@ -80,6 +80,9 @@ export function ProductsGrid({ products, brands }: ProductsGridProps) {
|
||||
const urlSearch = searchParams.get('search') || '';
|
||||
const urlBrand = searchParams.get('brand') || '';
|
||||
const urlCategory = searchParams.get('category') || 'all';
|
||||
const urlPriceMax = searchParams.get('priceMax') || '';
|
||||
const urlRoom = searchParams.get('room') || '';
|
||||
const urlUnits = searchParams.get('units') || '';
|
||||
|
||||
const [category, setCategory] = useState<'all' | 'scienne' | 'multisplit' | 'podlogowe' | 'jednostka-scienna'>(
|
||||
urlCategory as 'all' | 'scienne' | 'multisplit' | 'podlogowe' | 'jednostka-scienna'
|
||||
@@ -87,10 +90,10 @@ export function ProductsGrid({ products, brands }: ProductsGridProps) {
|
||||
const [selectedBrands, setSelectedBrands] = useState<string[]>(urlBrand ? [urlBrand] : []);
|
||||
const [searchQuery, setSearchQuery] = useState(urlSearch);
|
||||
const [priceMin, setPriceMin] = useState('');
|
||||
const [priceMax, setPriceMax] = useState('');
|
||||
const [selectedRooms, setSelectedRooms] = useState<string[]>([]);
|
||||
const [priceMax, setPriceMax] = useState(urlPriceMax);
|
||||
const [selectedRooms, setSelectedRooms] = useState<string[]>(urlRoom ? [urlRoom] : []);
|
||||
const [selectedColors, setSelectedColors] = useState<string[]>([]);
|
||||
const [selectedUnitCounts, setSelectedUnitCounts] = useState<number[]>([]);
|
||||
const [selectedUnitCounts, setSelectedUnitCounts] = useState<number[]>(urlUnits ? [parseInt(urlUnits)] : []);
|
||||
|
||||
const [page, setPage] = useState(1);
|
||||
const [mobileSidebarOpen, setMobileSidebarOpen] = useState(false);
|
||||
@@ -104,10 +107,13 @@ export function ProductsGrid({ products, brands }: ProductsGridProps) {
|
||||
} else {
|
||||
setCategory('all');
|
||||
}
|
||||
setPriceMax(urlPriceMax);
|
||||
setSelectedRooms(urlRoom ? [urlRoom] : []);
|
||||
setSelectedUnitCounts(urlUnits ? [parseInt(urlUnits)] : []);
|
||||
setPage(1);
|
||||
}, 0);
|
||||
return () => clearTimeout(timer);
|
||||
}, [urlSearch, urlBrand, urlCategory]);
|
||||
}, [urlSearch, urlBrand, urlCategory, urlPriceMax, urlRoom, urlUnits]);
|
||||
|
||||
const toggleBrand = (b: string) => {
|
||||
setSelectedBrands(prev => prev.includes(b) ? prev.filter(x => x !== b) : [...prev, b]);
|
||||
|
||||
Reference in New Issue
Block a user