mirror of
https://github.com/vercel/commerce.git
synced 2025-07-26 19:51:23 +00:00
changes
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import { useCallback } from 'react'
|
||||
import { CommerceError } from '@commerce/utils/errors'
|
||||
import useCart from './use-cart'
|
||||
import useCartAddItem, {
|
||||
AddItemInput as UseAddItemInput,
|
||||
@@ -47,7 +46,7 @@ export function extendHook(customFetcher: typeof fetcher) {
|
||||
quantity: input.quantity ?? 1,
|
||||
},
|
||||
],
|
||||
checkoutId: getCheckoutId(cart?.id),
|
||||
checkoutId: getCheckoutId(cart?.id)!,
|
||||
})
|
||||
await mutate(data, false)
|
||||
return data
|
||||
|
@@ -44,7 +44,7 @@ export function extendHook(
|
||||
) {
|
||||
const useCart = () => {
|
||||
const response = useCommerceCart(defaultOpts, [], customFetcher, {
|
||||
revalidateOnFocus: false,
|
||||
revalidateOnFocus: true,
|
||||
...swrOptions,
|
||||
})
|
||||
const res = useResponse(response, {
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
SHOPIFY_CHECKOUT_ID_COOKIE,
|
||||
SHOPIFY_CHECKOUT_URL_COOKIE,
|
||||
} from '@framework/const'
|
||||
} from '@framework/config'
|
||||
import checkoutCreateMutation from '@framework/utils/mutations/checkout-create'
|
||||
import Cookies from 'js-cookie'
|
||||
|
||||
|
@@ -7,13 +7,8 @@ const checkoutToCart = (checkoutResponse?: {
|
||||
checkout: Checkout
|
||||
userErrors?: UserError[]
|
||||
}): Maybe<Cart> => {
|
||||
if (!checkoutResponse) {
|
||||
throw new CommerceError({
|
||||
message: 'Missing checkout details from response cart Response',
|
||||
})
|
||||
}
|
||||
|
||||
const { checkout, userErrors } = checkoutResponse
|
||||
const checkout = checkoutResponse?.checkout
|
||||
const userErrors = checkoutResponse?.userErrors
|
||||
|
||||
if (userErrors && userErrors.length) {
|
||||
throw new ValidationError({
|
||||
@@ -22,7 +17,7 @@ const checkoutToCart = (checkoutResponse?: {
|
||||
}
|
||||
|
||||
if (!checkout) {
|
||||
throw new ValidationError({
|
||||
throw new CommerceError({
|
||||
message: 'Missing checkout details from response cart Response',
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user