@merchi/cart 1.4.79 → 1.4.80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/CartProvider.js +31 -22
- package/esm/CartProvider.load.test.js +603 -548
- package/lib/CartProvider.js +31 -22
- package/package.json +1 -1
- package/src/CartProvider.load.test.tsx +17 -1
- package/src/CartProvider.tsx +8 -0
package/esm/CartProvider.js
CHANGED
|
@@ -602,7 +602,7 @@ var CartProvider = function CartProvider(_ref) {
|
|
|
602
602
|
// so a later refetch does not put that cart back after the shopper replaced it.
|
|
603
603
|
function _getCart() {
|
|
604
604
|
_getCart = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(cartIdAndToken) {
|
|
605
|
-
var id, _cart2, cartJson, isTest, jobSource, saved, _t6;
|
|
605
|
+
var id, _cartJson$invoice, _cart2, cartJson, isTest, _cartJson$client2, jobSource, saved, _t6;
|
|
606
606
|
return _regenerator().w(function (_context6) {
|
|
607
607
|
while (1) switch (_context6.p = _context6.n) {
|
|
608
608
|
case 0:
|
|
@@ -630,63 +630,72 @@ var CartProvider = function CartProvider(_ref) {
|
|
|
630
630
|
case 4:
|
|
631
631
|
return _context6.a(2, _context6.v);
|
|
632
632
|
case 5:
|
|
633
|
+
if (!(((_cartJson$invoice = cartJson.invoice) === null || _cartJson$invoice === void 0 ? void 0 : _cartJson$invoice.unpaid) === false)) {
|
|
634
|
+
_context6.n = 6;
|
|
635
|
+
break;
|
|
636
|
+
}
|
|
637
|
+
setCartClient((_cartJson$client2 = cartJson.client) !== null && _cartJson$client2 !== void 0 && _cartJson$client2.id ? cartJson.client : null);
|
|
638
|
+
setCart(_objectSpread({}, cartJson));
|
|
639
|
+
dismissInitializationError();
|
|
640
|
+
return _context6.a(2, cartJson);
|
|
641
|
+
case 6:
|
|
633
642
|
jobSource = jobSourceFieldsForApi(captureAndReadJobSource());
|
|
634
643
|
if (!cartNeedsSourceUpdate(cartJson, jobSource)) {
|
|
635
|
-
_context6.n =
|
|
644
|
+
_context6.n = 8;
|
|
636
645
|
break;
|
|
637
646
|
}
|
|
638
|
-
_context6.n =
|
|
647
|
+
_context6.n = 7;
|
|
639
648
|
return merchi.authenticatedFetch("/carts/".concat(_cart2.id, "/"), {
|
|
640
649
|
method: 'PATCH',
|
|
641
650
|
body: appendJobSourceToFormData(_cart2.toFormData(), jobSource),
|
|
642
651
|
query: [['embed', JSON.stringify(cartEmbed)], ['skip_rights', 'y']]
|
|
643
652
|
});
|
|
644
|
-
case
|
|
653
|
+
case 7:
|
|
645
654
|
saved = _context6.v;
|
|
646
655
|
_cart2.fromJson(saved.cart);
|
|
647
656
|
cartJson = _cart2.toJson();
|
|
648
|
-
case
|
|
657
|
+
case 8:
|
|
649
658
|
if (!(stripeIsValidAndActive(cartJson) || isTest)) {
|
|
650
|
-
_context6.n =
|
|
659
|
+
_context6.n = 10;
|
|
651
660
|
break;
|
|
652
661
|
}
|
|
653
|
-
_context6.n =
|
|
662
|
+
_context6.n = 9;
|
|
654
663
|
return attachSavedClientIfNeeded(cartJson);
|
|
655
|
-
case
|
|
664
|
+
case 9:
|
|
656
665
|
cartJson = _context6.v;
|
|
657
666
|
setCart(_objectSpread({}, cartJson));
|
|
658
667
|
dismissInitializationError();
|
|
659
668
|
return _context6.a(2, cartJson);
|
|
660
|
-
case
|
|
669
|
+
case 10:
|
|
661
670
|
console.error("MErhci cart error: Stripe payment " + "options have not been correctly set up. " + "Check the company profile payment options tab " + "to set and edit stripe payment options.");
|
|
662
671
|
setCartSettingsInvalid(true);
|
|
663
|
-
case 10:
|
|
664
|
-
_context6.n = 14;
|
|
665
|
-
break;
|
|
666
672
|
case 11:
|
|
667
|
-
_context6.
|
|
673
|
+
_context6.n = 15;
|
|
674
|
+
break;
|
|
675
|
+
case 12:
|
|
676
|
+
_context6.p = 12;
|
|
668
677
|
_t6 = _context6.v;
|
|
669
678
|
if (!canReplaceMissingCart(_t6)) {
|
|
670
|
-
_context6.n =
|
|
679
|
+
_context6.n = 14;
|
|
671
680
|
break;
|
|
672
681
|
}
|
|
673
|
-
_context6.n =
|
|
682
|
+
_context6.n = 13;
|
|
674
683
|
return createCartAndCookie(undefined, true);
|
|
675
|
-
case 12:
|
|
676
|
-
return _context6.a(2, _context6.v);
|
|
677
684
|
case 13:
|
|
685
|
+
return _context6.a(2, _context6.v);
|
|
686
|
+
case 14:
|
|
678
687
|
// A network/server/auth failure does not mean the saved cart is gone.
|
|
679
688
|
// Preserve its cookie and contents so the shopper can retry the read.
|
|
680
689
|
reportCartFailure(_t6, CART_FAILURE_SOURCES.load);
|
|
681
690
|
showCartError((_t6 === null || _t6 === void 0 ? void 0 : _t6.errorMessage) || (_t6 === null || _t6 === void 0 ? void 0 : _t6.message) || 'Unable to load cart. Please try again.', true);
|
|
682
|
-
case 14:
|
|
683
|
-
_context6.p = 14;
|
|
684
|
-
setFetchingCart(false);
|
|
685
|
-
return _context6.f(14);
|
|
686
691
|
case 15:
|
|
692
|
+
_context6.p = 15;
|
|
693
|
+
setFetchingCart(false);
|
|
694
|
+
return _context6.f(15);
|
|
695
|
+
case 16:
|
|
687
696
|
return _context6.a(2, undefined);
|
|
688
697
|
}
|
|
689
|
-
}, _callee6, null, [[1,
|
|
698
|
+
}, _callee6, null, [[1, 12, 15, 16]]);
|
|
690
699
|
}));
|
|
691
700
|
return _getCart.apply(this, arguments);
|
|
692
701
|
}
|