Next.js Discord

Discord Forum

Combining different filter

Unanswered
Singapura posted this in #help-forum
Open in Discord
SingapuraOP
Hi, I have a site with some cards (personnel) on them and have 3 different dropdown filters (multiple checkboxes can be clicked in each dropdown). I can get it to filter on any single dropdown but haven't figured out how to combine them. Would really appreciate any help.

`` useEffect(() => { const params = new URLSearchParams(); if (selectedOffices.length > 0) { params.append('offices', selectedOffices.join(',')); } if (selectedRecruits.length > 0) { params.append('recruiters', selectedRecruits.join(',')); } if (selectedCompanies.length > 0) { params.append('companies', selectedCompanies.join(',')); } const query = params.size ? '?' + params.toString() : ''; const path =/recruits${query ? ${query} : ''}`;

const timer = setTimeout(() => {
router.push(path, undefined);
}, 100);

return () => clearTimeout(timer);
}, [selectedOffices, selectedRecruits, selectedCompanies, router]);

0 Replies