From e3591302b7ea2e3cb3febf4616e5d7ce062a5186 Mon Sep 17 00:00:00 2001 From: Luis Alvarez Date: Tue, 13 Oct 2020 22:43:11 -0500 Subject: [PATCH] Added sort filters to the UI --- pages/search.tsx | 49 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 5 deletions(-) diff --git a/pages/search.tsx b/pages/search.tsx index 7d29968aa..ded6957b4 100644 --- a/pages/search.tsx +++ b/pages/search.tsx @@ -25,6 +25,8 @@ export default function Home({ const { asPath } = router const { q, sort } = router.query const query = filterQuery({ q, sort }) + const pathname = asPath.split('?')[0] + const { category, brand } = useSearchMeta(asPath) const activeCategory = categories.find( (cat) => getSlug(cat.path) === category @@ -32,6 +34,7 @@ export default function Home({ const activeBrand = brands.find( (b) => getSlug(b.node.path) === `brands/${brand}` )?.node + const { data } = useSearch({ search: typeof q === 'string' ? q : '', categoryId: activeCategory?.entityId, @@ -120,17 +123,53 @@ export default function Home({
  • Relevance
  • -
  • Latest arrivals
  • -
  • Trending
  • -
  • Price: Low to high
  • -
  • Price: High to low
  • +
  • + + Latest arrivals + +
  • +
  • + + Trending + +
  • +
  • + + Price: Low to high + +
  • +
  • + + Price: High to low + +