diff --git a/components/metrics/FilterTags.js b/components/metrics/FilterTags.js index 4a470ffe..96c00983 100644 --- a/components/metrics/FilterTags.js +++ b/components/metrics/FilterTags.js @@ -4,7 +4,7 @@ import usePageQuery from 'hooks/usePageQuery'; import styles from './FilterTags.module.css'; import useMessages from 'hooks/useMessages'; -export default function FilterTags({ websiteId, params }) { +export default function FilterTags({ params }) { const { formatMessage, labels } = useMessages(); const { router, @@ -18,7 +18,7 @@ export default function FilterTags({ websiteId, params }) { function handleCloseFilter(param) { if (!param) { - router.push(`/websites/${websiteId}${view ? `?view=${view}` : ''}`); + router.push(resolveUrl({ view }, true)); } else { router.push(resolveUrl({ [param]: undefined })); } diff --git a/hooks/usePageQuery.js b/hooks/usePageQuery.js index 55dab688..b2f0acf1 100644 --- a/hooks/usePageQuery.js +++ b/hooks/usePageQuery.js @@ -23,8 +23,8 @@ export default function usePageQuery() { }, {}); }, [search]); - function resolveUrl(params) { - return buildUrl(asPath.split('?')[0], { ...query, ...params }); + function resolveUrl(params, reset) { + return buildUrl(asPath.split('?')[0], { ...(reset ? {} : query), ...params }); } return { pathname, query, resolveUrl, router };