Skip to content

Commit

Permalink
fix: cart error in better place
Browse files Browse the repository at this point in the history
  • Loading branch information
Fifciuu committed Mar 12, 2021
1 parent e8f2858 commit bd0184e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/core/core/src/factories/useCartFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ export const useCartFactory = <CART, CART_ITEM, PRODUCT, COUPON>(

try {
loading.value = true;
error.value.removeItem = null;
const updatedCart = await _factoryParams.removeItem({
currentCart: cart.value,
product,
customQuery
});
error.value.removeItem = null;
cart.value = updatedCart;
} catch (err) {
error.value.removeItem = err;
Expand All @@ -96,13 +96,13 @@ export const useCartFactory = <CART, CART_ITEM, PRODUCT, COUPON>(
if (quantity && quantity > 0) {
try {
loading.value = true;
error.value.updateItemQty = null;
const updatedCart = await _factoryParams.updateItemQty({
currentCart: cart.value,
product,
quantity,
customQuery
});
error.value.updateItemQty = null;
cart.value = updatedCart;
} catch (err) {
error.value.updateItemQty = err;
Expand All @@ -129,8 +129,8 @@ export const useCartFactory = <CART, CART_ITEM, PRODUCT, COUPON>(
}
try {
loading.value = true;
error.value.load = null;
cart.value = await _factoryParams.load({ customQuery });
error.value.load = null;
} catch (err) {
error.value.load = err;
Logger.error('useCart/load', err);
Expand All @@ -144,8 +144,8 @@ export const useCartFactory = <CART, CART_ITEM, PRODUCT, COUPON>(

try {
loading.value = true;
error.value.clear = null;
const updatedCart = await _factoryParams.clear({ currentCart: cart.value });
error.value.clear = null;
cart.value = updatedCart;
} catch (err) {
error.value.clear = err;
Expand All @@ -167,12 +167,12 @@ export const useCartFactory = <CART, CART_ITEM, PRODUCT, COUPON>(

try {
loading.value = true;
error.value.applyCoupon = null;
const { updatedCart } = await _factoryParams.applyCoupon({
currentCart: cart.value,
couponCode,
customQuery
});
error.value.applyCoupon = null;
cart.value = updatedCart;
} catch (err) {
error.value.applyCoupon = err;
Expand All @@ -187,12 +187,12 @@ export const useCartFactory = <CART, CART_ITEM, PRODUCT, COUPON>(

try {
loading.value = true;
error.value.removeCoupon = null;
const { updatedCart } = await _factoryParams.removeCoupon({
currentCart: cart.value,
coupon,
customQuery
});
error.value.removeCoupon = null;
cart.value = updatedCart;
loading.value = false;
} catch (err) {
Expand Down

0 comments on commit bd0184e

Please sign in to comment.