enable add and remove items (update) from cart. Update Search

This commit is contained in:
Greg Hoskin
2021-04-04 16:16:27 -06:00
parent 18936b7544
commit d0a04a8fe9
7 changed files with 41 additions and 50 deletions

View File

@@ -17,26 +17,11 @@ export type CheckoutPayload =
const checkoutToCart = (checkoutPayload?: Maybe<CheckoutPayload>): Cart => {
if (!checkoutPayload) {
throw new CommerceError({
message: 'Invalid response from Shopify',
message: 'Invalid response from Swell',
})
}
const checkout = checkoutPayload?.checkout
const userErrors = checkoutPayload?.userErrors
if (userErrors && userErrors.length) {
throw new ValidationError({
message: userErrors[0].message,
})
}
if (!checkout) {
throw new CommerceError({
message: 'Invalid response from Shopify',
})
}
return normalizeCart(checkout)
return normalizeCart(checkoutPayload)
}
export default checkoutToCart