4
0
forked from crowetic/commerce

Added useRemoveItem and other fixes

This commit is contained in:
Luis Alvarez
2020-10-26 18:25:35 -05:00
parent 2cd41ee135
commit 0f4f061cbd
8 changed files with 68 additions and 33 deletions

View File

@@ -26,7 +26,7 @@ export const fetcher: HookFetcher<Cart | null, RemoveItemBody> = (
}
export function extendHook(customFetcher: typeof fetcher) {
const useRemoveItem = (item?: any) => {
const useRemoveItem = () => {
const { mutate } = useCart()
const fn = useCartRemoveItem<Cart | null, RemoveItemBody>(
defaultOpts,
@@ -35,7 +35,7 @@ export function extendHook(customFetcher: typeof fetcher) {
return useCallback(
async function removeItem(input: RemoveItemInput) {
const data = await fn({ itemId: input.id ?? item?.id })
const data = await fn({ itemId: input.id })
await mutate(data, false)
return data
},