forked from crowetic/commerce
Merge branch 'master' of github.com:okbel/e-comm-example
This commit is contained in:
commit
81f4771c4d
@ -1,5 +1,5 @@
|
||||
import { ConfigInterface } from 'swr'
|
||||
import { HookFetcher } from '@lib/commerce/utils/types'
|
||||
import type { HookFetcher } from '@lib/commerce/utils/types'
|
||||
import type { SwrOptions } from '@lib/commerce/utils/use-data'
|
||||
import useCommerceCart, { CartInput } from '@lib/commerce/cart/use-cart'
|
||||
import type { Cart } from '../api/cart'
|
||||
|
||||
@ -20,10 +20,10 @@ export const fetcher: HookFetcher<Cart | null, CartInput> = (
|
||||
|
||||
export function extendHook(
|
||||
customFetcher: typeof fetcher,
|
||||
swrOptions?: ConfigInterface
|
||||
swrOptions?: SwrOptions<Cart | null, CartInput>
|
||||
) {
|
||||
const useCart = () => {
|
||||
const cart = useCommerceCart<Cart | null>(defaultOpts, [], customFetcher, {
|
||||
const cart = useCommerceCart(defaultOpts, [], customFetcher, {
|
||||
revalidateOnFocus: false,
|
||||
...swrOptions,
|
||||
})
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { ConfigInterface } from 'swr'
|
||||
import { HookFetcher } from '@lib/commerce/utils/types'
|
||||
import type { HookFetcher } from '@lib/commerce/utils/types'
|
||||
import type { SwrOptions } from '@lib/commerce/utils/use-data'
|
||||
import useCommerceSearch from '@lib/commerce/products/use-search'
|
||||
import type { SearchProductsData } from '../api/catalog/products'
|
||||
|
||||
@ -38,10 +38,10 @@ export const fetcher: HookFetcher<SearchProductsData, SearchProductsInput> = (
|
||||
|
||||
export function extendHook(
|
||||
customFetcher: typeof fetcher,
|
||||
swrOptions?: ConfigInterface
|
||||
swrOptions?: SwrOptions<SearchProductsData, SearchProductsInput>
|
||||
) {
|
||||
const useSearch = (input: SearchProductsInput = {}) => {
|
||||
const response = useCommerceSearch<SearchProductsData>(
|
||||
const response = useCommerceSearch(
|
||||
defaultOpts,
|
||||
[
|
||||
['search', input.search],
|
||||
@ -49,7 +49,7 @@ export function extendHook(
|
||||
['brandId', input.brandId],
|
||||
['sort', input.sort],
|
||||
],
|
||||
customFetcher as any,
|
||||
customFetcher,
|
||||
{ revalidateOnFocus: false, ...swrOptions }
|
||||
)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user