Moved auth & cart hooks + several fixes

This commit is contained in:
cond0r
2021-02-22 14:06:34 +02:00
parent 005fe9d6c9
commit 528d7556a8
53 changed files with 447 additions and 331 deletions

View File

@@ -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],