Let's say I have a filter data gender array and a sort variable
const gender= ["male","Female"]
// consider this as a dynamic array it can be null or male or female or both male and female
const[sort,setSort]=useState("rec")
//sort will be either rec or asc or desc
const changeGender = ()=>{
Setsearchparams({"gender":gender})
}
const changeSort = ()=>{
Setsearchparams({"sort":sort})
}
Now, if the user clicks on the gender filter the query string should be ?gender=male
if user clicks on the sort, the query string should be ?sort=rec
if the user clicks on the sort after gender filter the query string should be ?gender=male&sort=rec or if gender array has two elements it will then look like ?gender=male,female&sort=rec
and vice versa ?sort=rec&gender=male
How can I achieve such thing so that can I add multiple filters