saleor: initial cart integration

This commit is contained in:
Zaiste
2021-04-26 16:24:50 +02:00
parent ef10084e54
commit 19445747f1
9 changed files with 41 additions and 76 deletions

View File

@@ -9,7 +9,7 @@ import {
checkoutToCart,
} from '../utils'
import { Cart, CartItemBody } from '../types'
import { Mutation, MutationCheckoutLineItemsAddArgs } from '../schema'
import { Mutation, MutationCheckoutLinesAddArgs } from '../schema'
export default useAddItem as UseAddItem<typeof handler>
@@ -27,13 +27,13 @@ export const handler: MutationHook<Cart, {}, CartItemBody> = {
})
}
const { checkoutLineItemsAdd } = await fetch<
const { checkoutLinesAdd } = await fetch<
Mutation,
MutationCheckoutLineItemsAddArgs
MutationCheckoutLinesAddArgs
>({
...options,
variables: {
checkoutId: getCheckoutId(),
checkoutId: getCheckoutId().checkoutId,
lineItems: [
{
variantId: item.variantId,
@@ -43,7 +43,7 @@ export const handler: MutationHook<Cart, {}, CartItemBody> = {
},
})
return checkoutToCart(checkoutLineItemsAdd)
return checkoutToCart(checkoutLinesAdd)
},
useHook: ({ fetch }) => () => {
const { mutate } = useCart()