mirror of
https://github.com/vercel/commerce.git
synced 2025-07-22 20:26:49 +00:00
Moved auth & cart hooks + several fixes
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import useSearch, { UseSearch } from '@commerce/products/use-search'
|
||||
import { SearchProductsData } from '@commerce/types'
|
||||
import { HookHandler } from '@commerce/utils/types'
|
||||
import { SWRHook } from '@commerce/utils/types'
|
||||
import useSearch, { UseSearch } from '@commerce/product/use-search'
|
||||
|
||||
import { ProductEdge } from '@framework/schema'
|
||||
import {
|
||||
getAllProductsQuery,
|
||||
@@ -9,6 +9,8 @@ import {
|
||||
} from '@framework/utils'
|
||||
import type { ShopifyProvider } from '..'
|
||||
|
||||
import { Product } from '@commerce/types'
|
||||
|
||||
export default useSearch as UseSearch<ShopifyProvider>
|
||||
|
||||
export type SearchProductsInput = {
|
||||
@@ -18,7 +20,11 @@ export type SearchProductsInput = {
|
||||
sort?: string
|
||||
}
|
||||
|
||||
export const handler: HookHandler<
|
||||
export type SearchProductsData = {
|
||||
products: Product[]
|
||||
found: boolean
|
||||
}
|
||||
export const handler: SWRHook<
|
||||
SearchProductsData,
|
||||
SearchProductsInput,
|
||||
SearchProductsInput
|
||||
@@ -38,7 +44,7 @@ export const handler: HookHandler<
|
||||
found: !!edges?.length,
|
||||
}
|
||||
},
|
||||
useHook({ input, useData }) {
|
||||
useHook: ({ useData }) => (input = {}) => {
|
||||
return useData({
|
||||
input: [
|
||||
['search', input.search],
|
||||
|
Reference in New Issue
Block a user