forked from crowetic/commerce
Export the extend fn
This commit is contained in:
parent
22ba0d7315
commit
d67c728e80
@ -19,7 +19,7 @@ export const fetcher: HookFetcher<Cart | null, HookDeps[]> = (
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function extend(customFetcher: typeof fetcher) {
|
export function extendHook(customFetcher: typeof fetcher) {
|
||||||
const useCart = () => {
|
const useCart = () => {
|
||||||
const cart = useCommerceCart<Cart | null>(
|
const cart = useCommerceCart<Cart | null>(
|
||||||
[defaultOpts.url, undefined],
|
[defaultOpts.url, undefined],
|
||||||
@ -40,9 +40,9 @@ function extend(customFetcher: typeof fetcher) {
|
|||||||
return cart
|
return cart
|
||||||
}
|
}
|
||||||
|
|
||||||
useCart.extend = extend
|
useCart.extend = extendHook
|
||||||
|
|
||||||
return useCart
|
return useCart
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useCart = extend(fetcher)
|
export const useCart = extendHook(fetcher)
|
||||||
|
@ -32,7 +32,7 @@ export const fetcher: HookFetcher<Cart, AddItemBody> = (
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function extend(customFetcher: typeof fetcher) {
|
export function extendHook(customFetcher: typeof fetcher) {
|
||||||
const useAddItem = () => {
|
const useAddItem = () => {
|
||||||
const { mutate } = useCart()
|
const { mutate } = useCart()
|
||||||
const fn = useCartAddItem<Cart, AddItemBody>(defaultOpts, customFetcher)
|
const fn = useCartAddItem<Cart, AddItemBody>(defaultOpts, customFetcher)
|
||||||
@ -47,9 +47,9 @@ function extend(customFetcher: typeof fetcher) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
useAddItem.extend = extend
|
useAddItem.extend = extendHook
|
||||||
|
|
||||||
return useAddItem
|
return useAddItem
|
||||||
}
|
}
|
||||||
|
|
||||||
export default extend(fetcher)
|
export default extendHook(fetcher)
|
||||||
|
@ -25,7 +25,7 @@ export const fetcher: HookFetcher<Cart | null, RemoveItemBody> = (
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function extend(customFetcher: typeof fetcher) {
|
export function extendHook(customFetcher: typeof fetcher) {
|
||||||
const useRemoveItem = (item?: any) => {
|
const useRemoveItem = (item?: any) => {
|
||||||
const { mutate } = useCart()
|
const { mutate } = useCart()
|
||||||
const fn = useCartRemoveItem<Cart | null, RemoveItemBody>(
|
const fn = useCartRemoveItem<Cart | null, RemoveItemBody>(
|
||||||
@ -43,9 +43,9 @@ function extend(customFetcher: typeof fetcher) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
useRemoveItem.extend = extend
|
useRemoveItem.extend = extendHook
|
||||||
|
|
||||||
return useRemoveItem
|
return useRemoveItem
|
||||||
}
|
}
|
||||||
|
|
||||||
export default extend(fetcher)
|
export default extendHook(fetcher)
|
||||||
|
@ -34,7 +34,7 @@ export const fetcher: HookFetcher<Cart | null, UpdateItemBody> = (
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function extend(customFetcher: typeof fetcher, cfg?: { wait?: number }) {
|
function extendHook(customFetcher: typeof fetcher, cfg?: { wait?: number }) {
|
||||||
const useUpdateItem = (item?: any) => {
|
const useUpdateItem = (item?: any) => {
|
||||||
const { mutate } = useCart()
|
const { mutate } = useCart()
|
||||||
const fn = useCartUpdateItem<Cart | null, UpdateItemBody>(
|
const fn = useCartUpdateItem<Cart | null, UpdateItemBody>(
|
||||||
@ -59,9 +59,9 @@ function extend(customFetcher: typeof fetcher, cfg?: { wait?: number }) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
useUpdateItem.extend = extend
|
useUpdateItem.extend = extendHook
|
||||||
|
|
||||||
return useUpdateItem
|
return useUpdateItem
|
||||||
}
|
}
|
||||||
|
|
||||||
export default extend(fetcher)
|
export default extendHook(fetcher)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user