diff --git a/framework/bigcommerce/product/use-search.tsx b/framework/bigcommerce/product/use-search.tsx index 393a8c0b9..0ff767d8a 100644 --- a/framework/bigcommerce/product/use-search.tsx +++ b/framework/bigcommerce/product/use-search.tsx @@ -1,5 +1,5 @@ import { HookHandler } from '@commerce/utils/types' -import useSearch, { UseSearch } from '@commerce/products/use-search' +import useSearch, { UseSearch } from '@commerce/product/use-search' import type { SearchProductsData } from '../api/catalog/products' import type { BigcommerceProvider } from '..' diff --git a/framework/commerce/cart/products/use-search.tsx b/framework/commerce/cart/products/use-search.tsx deleted file mode 100644 index e43ca301a..000000000 --- a/framework/commerce/cart/products/use-search.tsx +++ /dev/null @@ -1,57 +0,0 @@ -import type { SearchProductsData } from '../../types' -import type { - Prop, - HookFetcherFn, - UseHookInput, - UseHookResponse, -} from '../../utils/types' -import defaultFetcher from '../../utils/default-fetcher' -import useData from '../../utils/use-data' -import { Provider, useCommerce } from '../..' -import { BigcommerceProvider } from '@framework' - -export type UseSearchHandler

= Prop< - Prop, - 'useSearch' -> - -export type UseSeachInput

= UseHookInput< - UseSearchHandler

-> - -export type SearchResponse

= UseHookResponse< - UseSearchHandler

-> - -export type UseSearch

= Partial< - UseSeachInput

-> extends UseSeachInput

- ? (input?: UseSeachInput

) => SearchResponse

- : (input: UseSeachInput

) => SearchResponse

- -export const fetcher = defaultFetcher as HookFetcherFn - -export default function useSearch

( - input: UseSeachInput

= {} -) { - const { providerRef, fetcherRef } = useCommerce

() - - const provider = providerRef.current - const opts = provider.products?.useSearch - - const fetcherFn = opts?.fetcher ?? fetcher - const useHook = opts?.useHook ?? ((ctx) => ctx.useData()) - - return useHook({ - input, - useData(ctx) { - const response = useData( - { ...opts!, fetcher: fetcherFn }, - ctx?.input ?? [], - provider.fetcher ?? fetcherRef.current, - ctx?.swrOptions ?? input.swrOptions - ) - return response - }, - }) -} diff --git a/framework/commerce/products/use-search.tsx b/framework/commerce/product/use-search.tsx similarity index 100% rename from framework/commerce/products/use-search.tsx rename to framework/commerce/product/use-search.tsx