diff --git a/framework/bigcommerce/product/use-search.tsx b/framework/bigcommerce/product/use-search.tsx index 59355e64e..0ee135032 100644 --- a/framework/bigcommerce/product/use-search.tsx +++ b/framework/bigcommerce/product/use-search.tsx @@ -1,9 +1,16 @@ import { SWRHook } from '@commerce/utils/types' import useSearch, { UseSearch } from '@commerce/product/use-search' -import { SearchProductsData, SearchProductsInput } from '@commerce/types' +import type { SearchProductsData } from '../api/catalog/products' export default useSearch as UseSearch +export type SearchProductsInput = { + search?: string + categoryId?: number + brandId?: number + sort?: string +} + export const handler: SWRHook< SearchProductsData, SearchProductsInput, diff --git a/framework/commerce/types.ts b/framework/commerce/types.ts index 07069186e..86361fd9f 100644 --- a/framework/commerce/types.ts +++ b/framework/commerce/types.ts @@ -1,5 +1,6 @@ import type { Wishlist as BCWishlist } from '../bigcommerce/api/wishlist' import type { Customer as BCCustomer } from '../bigcommerce/api/customers' +import type { SearchProductsData as BCSearchProductsData } from '../bigcommerce/api/catalog/products' export type Discount = { // The value of the discount, can be an amount or percentage @@ -96,18 +97,8 @@ export interface Wishlist extends BCWishlist {} // TODO: Properly define this type export interface Customer extends BCCustomer {} -export type SearchProductsData = { - products: Product[] - found: boolean -} - -export type SearchProductsInput = { - search?: string - categoryId?: string - brandId?: string - sort?: string - locale?: string -} +// TODO: Properly define this type +export interface SearchProductsData extends BCSearchProductsData {} /** * Cart mutations diff --git a/framework/shopify/product/use-search.tsx b/framework/shopify/product/use-search.tsx index db5570747..632dd9937 100644 --- a/framework/shopify/product/use-search.tsx +++ b/framework/shopify/product/use-search.tsx @@ -1,7 +1,6 @@ import { SWRHook } from '@commerce/utils/types' +import { Product } from '@commerce/types' import useSearch, { UseSearch } from '@commerce/product/use-search' -import { SearchProductsInput, SearchProductsData } from '@commerce/types' - import { ProductEdge } from '../schema' import { @@ -11,6 +10,19 @@ import { normalizeProduct, } from '../utils' +export type SearchProductsInput = { + search?: string + categoryId?: string + brandId?: string + sort?: string + locale?: string +} + +export type SearchProductsData = { + products: Product[] + found: boolean +} + export default useSearch as UseSearch export const handler: SWRHook< diff --git a/framework/shopify/utils/get-search-variables.ts b/framework/shopify/utils/get-search-variables.ts index 4514be72d..a5ae15485 100644 --- a/framework/shopify/utils/get-search-variables.ts +++ b/framework/shopify/utils/get-search-variables.ts @@ -1,5 +1,5 @@ +import { SearchProductsInput } from '@framework/product/use-search' import getSortVariables from './get-sort-variables' -import type { SearchProductsInput } from '@commerce/types' export const getSearchVariables = ({ brandId, diff --git a/pages/index.tsx b/pages/index.tsx index eae150dc0..3baf518c4 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -23,14 +23,14 @@ export async function getStaticProps({ }) // const { categories, brands } = await getSiteInfo({ config, preview }) - // const { pages } = await getAllPages({ config, preview }) + const { pages } = await getAllPages({ config, preview }) return { props: { products, categories: [], brands: [], - pages: [], + pages, }, revalidate: 14400, } diff --git a/pages/search.tsx b/pages/search.tsx index 5abae4668..19069a97b 100644 --- a/pages/search.tsx +++ b/pages/search.tsx @@ -81,7 +81,9 @@ export default function Search({ categoryId: activeCategory?.entityId, brandId: (activeBrand as any)?.entityId, sort: typeof sort === 'string' ? sort : '', - locale, + ...(process.env.COMMERCE_PROVIDER === 'shopify' && { + locale, + }), }) const handleClick = (event: any, filter: string) => { diff --git a/tsconfig.json b/tsconfig.json index 1a6c28831..9e712fb18 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -22,8 +22,8 @@ "@components/*": ["components/*"], "@commerce": ["framework/commerce"], "@commerce/*": ["framework/commerce/*"], - "@framework": ["framework/vendure"], - "@framework/*": ["framework/vendure/*"] + "@framework": ["framework/bigcommerce"], + "@framework/*": ["framework/bigcommerce/*"] } }, "include": ["next-env.d.ts", "**/*.d.ts", "**/*.ts", "**/*.tsx", "**/*.js"],