cleanup, add sorting

This commit is contained in:
Greg Hoskin
2021-04-25 14:20:58 -05:00
parent 6a9c6c3bca
commit a409c373c4
52 changed files with 74 additions and 618 deletions

View File

@@ -4,6 +4,7 @@ import useAddItem, { UseAddItem } from '@commerce/cart/use-add-item'
import useCart from './use-cart'
import { Cart, CartItemBody } from '../types'
import { checkoutToCart } from './utils'
import { getCheckoutId } from '../utils'
import { Mutation, MutationCheckoutLineItemsAddArgs } from '../schema'
import { useCallback } from 'react'
@@ -26,12 +27,12 @@ export const handler: MutationHook<Cart, {}, CartItemBody> = {
const response = await fetch<Mutation, MutationCheckoutLineItemsAddArgs>({
...options,
variables: {
checkoutId: getCheckoutId(),
product_id: item.productId,
quantity: item.quantity,
},
})
// TODO: Fix this Cart type here
return checkoutToCart(response) as any
},
useHook: ({ fetch }) => () => {