rename checkoutCreate to createCart and remove Shopify checkout API

Signed-off-by: Loan Laux <loan@outgrow.io>
This commit is contained in:
Loan Laux
2021-04-27 18:47:39 +04:00
parent f52978e1a3
commit 3496b2a155
7 changed files with 11 additions and 64 deletions

View File

@@ -0,0 +1,32 @@
import {
REACTION_ANONYMOUS_CART_TOKEN_COOKIE,
SHOPIFY_CHECKOUT_URL_COOKIE,
REACTION_COOKIE_EXPIRE,
} from '../../const'
import createCartMutation from '../../utils/mutations/create-cart'
import Cookies from 'js-cookie'
export const createCart = async (fetch: any) => {
const data = await fetch({
query: createCartMutation,
variables: {
input: {
shopId,
},
},
})
const checkout = data.checkoutCreate?.checkout
const checkoutId = checkout?.id
if (checkoutId) {
const options = {
expires: REACTION_COOKIE_EXPIRE,
}
Cookies.set(REACTION_ANONYMOUS_CART_TOKEN_COOKIE, checkoutId, options)
}
return checkout
}
export default createCart