summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreug-vs <eug-vs@keemail.me>2021-04-24 19:03:35 +0300
committereug-vs <eug-vs@keemail.me>2021-04-24 19:18:11 +0300
commitea5c69e11b2758df28f881f9110ca5d4a5d41211 (patch)
tree7ed745d892ddffdb83301819cc84d1b8f7aa9a19
parentaa04c35e73ddd1f2d38de68e437c0c3d697d42e2 (diff)
downloadcommercel-ui-ea5c69e11b2758df28f881f9110ca5d4a5d41211.tar.gz
fix: reset filters correctly
-rw-r--r--src/hooks/useQuery.ts4
-rw-r--r--src/lib/ServiceFilters.tsx2
2 files changed, 3 insertions, 3 deletions
diff --git a/src/hooks/useQuery.ts b/src/hooks/useQuery.ts
index e9a00ec..821dfe4 100644
--- a/src/hooks/useQuery.ts
+++ b/src/hooks/useQuery.ts
@@ -11,8 +11,8 @@ const useQuery = (): UseQuery => {
const query = Object.fromEntries(searchParams);
const setQuery = (newQuery: Record<string, string>): void => {
- const queryString = new URLSearchParams(newQuery);
- history.push({ search: `?${queryString}` });
+ const queryString = new URLSearchParams(newQuery).toString();
+ history.push({ search: queryString && `?${queryString}` });
};
return { query, setQuery };
diff --git a/src/lib/ServiceFilters.tsx b/src/lib/ServiceFilters.tsx
index b3cfae9..a2c645b 100644
--- a/src/lib/ServiceFilters.tsx
+++ b/src/lib/ServiceFilters.tsx
@@ -44,7 +44,7 @@ const ServiceFilters: React.FC = () => {
setQuery(updatedQuery);
};
- const resetFilters = () => history.push(service.route);
+ const resetFilters = () => setQuery({});
return (
<div className="mr-6 flex items-center">