Added initial version of useAddItem

This commit is contained in:
cond0r
2021-02-18 15:04:46 +02:00
parent 7f0c1eb66c
commit 89cc3d0608
8 changed files with 65 additions and 75 deletions

View File

@@ -5,22 +5,22 @@ import { FetchCartInput } from '@commerce/cart/use-cart'
const fetcher: HookFetcherFn<Cart | null, FetchCartInput> = async ({
options,
input: { cartId },
input: { cartId: checkoutId },
fetch,
}) => {
let checkout
if (cartId) {
if (checkoutId) {
const data = await fetch({
...options,
variables: {
cartId,
checkoutId,
},
})
checkout = data?.node
}
if (checkout?.completedAt || !cartId) {
if (checkout?.completedAt || !checkoutId) {
checkout = await checkoutCreate(fetch)
}