diff --git a/site/components/search.tsx b/site/components/search.tsx index 75b5b0416..73b1ed868 100644 --- a/site/components/search.tsx +++ b/site/components/search.tsx @@ -25,21 +25,21 @@ import { filterQuery, getCategoryPath, getDesignerPath, + getPaginationPath, useSearchMeta, } from '@lib/search' export default function Search({ categories, brands }: SearchPropsType) { const [activeFilter, setActiveFilter] = useState('') const [toggleFilter, setToggleFilter] = useState(false) - const [page, SetPage] = useState(1) const router = useRouter() const { asPath, locale } = router - const { q, sort } = router.query + const { q, sort, page } = router.query // `q` can be included but because categories and designers can't be searched // in the same way of products, it's better to ignore the search input if one // of those is selected - const query = filterQuery({ sort }) + const query = filterQuery({ sort, page }) const { pathname, category, brand } = useSearchMeta(asPath) const activeCategory = categories.find((cat: any) => cat.slug === category) @@ -52,7 +52,7 @@ export default function Search({ categories, brands }: SearchPropsType) { categoryId: activeCategory?.id, brandId: (activeBrand as any)?.entityId, sort: typeof sort === 'string' ? sort : '', - page: page, + page: typeof page === 'string' ? page : '', locale, }) @@ -343,25 +343,38 @@ export default function Search({ categories, brands }: SearchPropsType) { )}{' '}