import cn from 'classnames' import type { GetStaticPropsContext, InferGetStaticPropsType } from 'next' import Link from 'next/link' import { useRouter } from 'next/router' import { getConfig } from '@bigcommerce/storefront-data-hooks/api' import getAllPages from '@bigcommerce/storefront-data-hooks/api/operations/get-all-pages' import getSiteInfo from '@bigcommerce/storefront-data-hooks/api/operations/get-site-info' import useSearch from '@bigcommerce/storefront-data-hooks/products/use-search' import { Layout } from '@components/core' import { ProductCard } from '@components/product' import { Container, Grid, Skeleton } from '@components/ui' import rangeMap from '@lib/range-map' import getSlug from '@lib/get-slug' import { filterQuery, getCategoryPath, getDesignerPath, useSearchMeta, } from '@lib/search' export async function getStaticProps({ preview, locale, }: GetStaticPropsContext) { const config = getConfig({ locale }) const { pages } = await getAllPages({ config, preview }) const { categories, brands } = await getSiteInfo({ config, preview }) return { props: { pages, categories, brands }, } } const SORT = Object.entries({ 'latest-desc': 'Latest arrivals', 'trending-desc': 'Trending', 'price-asc': 'Price: Low to high', 'price-desc': 'Price: High to low', }) type SortItemsProps = { q: string | string[] | undefined sort: string | string[] | undefined pathname: string } const SortItems = ({ pathname, sort, q }:SortItemsProps) => { return ( <>