merchi_cart 1.3.2 → 1.3.4

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.
@@ -16,6 +16,8 @@ var _cookie = require("./utilities/cookie");
16
16
  var _address = require("./utilities/address");
17
17
  var _job = require("./utilities/job");
18
18
  var _product = require("./utilities/product");
19
+ var _local_storage = require("./utilities/local_storage");
20
+ var _user = require("./utilities/user");
19
21
  var _jsxRuntime = require("react/jsx-runtime");
20
22
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
21
23
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
@@ -425,100 +427,182 @@ var CartProvider = function CartProvider(_ref) {
425
427
  _useState20 = _slicedToArray(_useState19, 2),
426
428
  cartSettingsInvalid = _useState20[0],
427
429
  setCartSettingsInvalid = _useState20[1];
428
-
429
- // Create cart and save cart cookie
430
- function createCartAndCookie(_x) {
430
+ function attachSavedClientIfNeeded(_x) {
431
+ return _attachSavedClientIfNeeded.apply(this, arguments);
432
+ } // Create cart and save cart cookie
433
+ function _attachSavedClientIfNeeded() {
434
+ _attachSavedClientIfNeeded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(cartJson) {
435
+ var _cartJson$client;
436
+ var savedCustomer, _nextCart$client, cartToken, clientEnt, cartEnt, savedCart, nextCart;
437
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
438
+ while (1) switch (_context.prev = _context.next) {
439
+ case 0:
440
+ if (!(cartJson !== null && cartJson !== void 0 && (_cartJson$client = cartJson.client) !== null && _cartJson$client !== void 0 && _cartJson$client.id)) {
441
+ _context.next = 3;
442
+ break;
443
+ }
444
+ setCartClient(cartJson.client);
445
+ return _context.abrupt("return", cartJson);
446
+ case 3:
447
+ savedCustomer = (0, _local_storage.getSavedCheckoutCustomer)(domainId);
448
+ if (savedCustomer !== null && savedCustomer !== void 0 && savedCustomer.id) {
449
+ _context.next = 7;
450
+ break;
451
+ }
452
+ setCartClient(null);
453
+ return _context.abrupt("return", cartJson);
454
+ case 7:
455
+ _context.prev = 7;
456
+ _context.t0 = cartJson.token;
457
+ if (_context.t0) {
458
+ _context.next = 13;
459
+ break;
460
+ }
461
+ _context.next = 12;
462
+ return (0, _cookie.getCartCookieToken)(domainId);
463
+ case 12:
464
+ _context.t0 = _context.sent;
465
+ case 13:
466
+ cartToken = _context.t0;
467
+ clientEnt = (0, _user.makeUser)({
468
+ id: savedCustomer.id
469
+ }, true);
470
+ cartEnt = (0, _cart3.makeCart)(_objectSpread({}, cartJson), false, cartToken);
471
+ cartEnt.client = clientEnt;
472
+ _context.next = 19;
473
+ return cartEnt.save({
474
+ embed: _helpers.cartEmbed
475
+ });
476
+ case 19:
477
+ savedCart = _context.sent;
478
+ nextCart = savedCart.toJson();
479
+ if (!(nextCart !== null && nextCart !== void 0 && (_nextCart$client = nextCart.client) !== null && _nextCart$client !== void 0 && _nextCart$client.id)) {
480
+ _context.next = 24;
481
+ break;
482
+ }
483
+ setCartClient(nextCart.client);
484
+ return _context.abrupt("return", nextCart);
485
+ case 24:
486
+ _context.next = 28;
487
+ break;
488
+ case 26:
489
+ _context.prev = 26;
490
+ _context.t1 = _context["catch"](7);
491
+ case 28:
492
+ setCartClient(null);
493
+ return _context.abrupt("return", cartJson);
494
+ case 30:
495
+ case "end":
496
+ return _context.stop();
497
+ }
498
+ }, _callee, null, [[7, 26]]);
499
+ }));
500
+ return _attachSavedClientIfNeeded.apply(this, arguments);
501
+ }
502
+ function createCartAndCookie(_x2) {
431
503
  return _createCartAndCookie.apply(this, arguments);
432
504
  }
433
505
  function _createCartAndCookie() {
434
- _createCartAndCookie = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(callback) {
506
+ _createCartAndCookie = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(callback) {
435
507
  var _cart, _cartJson;
436
- return _regeneratorRuntime().wrap(function _callee$(_context) {
437
- while (1) switch (_context.prev = _context.next) {
508
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
509
+ while (1) switch (_context2.prev = _context2.next) {
438
510
  case 0:
439
511
  setFetchingCart(true);
440
- _context.prev = 1;
512
+ _context2.prev = 1;
441
513
  _cart = (0, _cart3.makeCart)({
442
514
  domain: {
443
515
  id: domainId
444
516
  }
445
517
  }, true);
446
- _context.next = 5;
518
+ _context2.next = 5;
447
519
  return _cart.create({
448
520
  embed: _helpers.cartEmbed
449
521
  });
450
522
  case 5:
451
- _context.next = 7;
523
+ _context2.next = 7;
452
524
  return _cart.toJson();
453
525
  case 7:
454
- _cartJson = _context.sent;
526
+ _cartJson = _context2.sent;
455
527
  if (domainId) (0, _cookie.setCartCookie)(Number(domainId), _cartJson, undefined);
456
- setCartClient(null);
528
+ _context2.next = 11;
529
+ return attachSavedClientIfNeeded(_cartJson);
530
+ case 11:
531
+ _cartJson = _context2.sent;
457
532
  setCart(_objectSpread({}, _cartJson));
458
533
  if (callback) callback();
459
- _context.next = 17;
534
+ _context2.next = 19;
460
535
  break;
461
- case 14:
462
- _context.prev = 14;
463
- _context.t0 = _context["catch"](1);
464
- alertError(_context.t0.errorMessage || _context.t0.message || 'Unable to fetch cart.');
465
- case 17:
466
- _context.prev = 17;
536
+ case 16:
537
+ _context2.prev = 16;
538
+ _context2.t0 = _context2["catch"](1);
539
+ alertError(_context2.t0.errorMessage || _context2.t0.message || 'Unable to fetch cart.');
540
+ case 19:
541
+ _context2.prev = 19;
467
542
  setFetchingCart(false);
468
- return _context.finish(17);
469
- case 20:
543
+ return _context2.finish(19);
544
+ case 22:
470
545
  case "end":
471
- return _context.stop();
546
+ return _context2.stop();
472
547
  }
473
- }, _callee, null, [[1, 14, 17, 20]]);
548
+ }, _callee2, null, [[1, 16, 19, 22]]);
474
549
  }));
475
550
  return _createCartAndCookie.apply(this, arguments);
476
551
  }
477
- function getCart(_x2) {
552
+ function getCart(_x3) {
478
553
  return _getCart.apply(this, arguments);
479
554
  }
480
555
  function _getCart() {
481
- _getCart = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(cartIdAndToken) {
556
+ _getCart = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(cartIdAndToken) {
482
557
  var id, _cart2, _cartJson2;
483
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
484
- while (1) switch (_context2.prev = _context2.next) {
558
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
559
+ while (1) switch (_context3.prev = _context3.next) {
485
560
  case 0:
486
561
  id = Number(cartIdAndToken[0]); // Set the cart token on the merchi entity
487
562
  if (cartIdAndToken[1]) merchi.cartToken = cartIdAndToken[1];
488
563
  setFetchingCart(true);
489
- _context2.prev = 3;
490
- _context2.next = 6;
564
+ _context3.prev = 3;
565
+ _context3.next = 6;
491
566
  return merchi.Cart.get(id, {
492
567
  embed: _helpers.cartEmbed
493
568
  });
494
569
  case 6:
495
- _cart2 = _context2.sent;
496
- _context2.next = 9;
570
+ _cart2 = _context3.sent;
571
+ _context3.next = 9;
497
572
  return _cart2.toJson();
498
573
  case 9:
499
- _cartJson2 = _context2.sent;
500
- if ((0, _cart3.stripeIsValidAndActive)(_cartJson2)) {
501
- setCart(_objectSpread({}, _cartJson2));
502
- } else {
503
- 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.");
504
- setCartSettingsInvalid(true);
574
+ _cartJson2 = _context3.sent;
575
+ if (!(0, _cart3.stripeIsValidAndActive)(_cartJson2)) {
576
+ _context3.next = 17;
577
+ break;
505
578
  }
506
- _context2.next = 17;
507
- break;
579
+ _context3.next = 13;
580
+ return attachSavedClientIfNeeded(_cartJson2);
508
581
  case 13:
509
- _context2.prev = 13;
510
- _context2.t0 = _context2["catch"](3);
511
- _context2.next = 17;
512
- return createCartAndCookie();
582
+ _cartJson2 = _context3.sent;
583
+ setCart(_objectSpread({}, _cartJson2));
584
+ _context3.next = 19;
585
+ break;
513
586
  case 17:
514
- _context2.prev = 17;
587
+ 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.");
588
+ setCartSettingsInvalid(true);
589
+ case 19:
590
+ _context3.next = 25;
591
+ break;
592
+ case 21:
593
+ _context3.prev = 21;
594
+ _context3.t0 = _context3["catch"](3);
595
+ _context3.next = 25;
596
+ return createCartAndCookie();
597
+ case 25:
598
+ _context3.prev = 25;
515
599
  setFetchingCart(false);
516
- return _context2.finish(17);
517
- case 20:
600
+ return _context3.finish(25);
601
+ case 28:
518
602
  case "end":
519
- return _context2.stop();
603
+ return _context3.stop();
520
604
  }
521
- }, _callee2, null, [[3, 13, 17, 20]]);
605
+ }, _callee3, null, [[3, 21, 25, 28]]);
522
606
  }));
523
607
  return _getCart.apply(this, arguments);
524
608
  }
@@ -526,15 +610,15 @@ var CartProvider = function CartProvider(_ref) {
526
610
  return _actionGetMerchiCart.apply(this, arguments);
527
611
  }
528
612
  function _actionGetMerchiCart() {
529
- _actionGetMerchiCart = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
613
+ _actionGetMerchiCart = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
530
614
  var cartIdAndToken;
531
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
532
- while (1) switch (_context3.prev = _context3.next) {
615
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
616
+ while (1) switch (_context4.prev = _context4.next) {
533
617
  case 0:
534
- _context3.next = 2;
618
+ _context4.next = 2;
535
619
  return (0, _cookie.getCartCookie)(domainId);
536
620
  case 2:
537
- cartIdAndToken = _context3.sent;
621
+ cartIdAndToken = _context4.sent;
538
622
  if (cartIdAndToken) {
539
623
  getCart(cartIdAndToken);
540
624
  } else {
@@ -542,30 +626,30 @@ var CartProvider = function CartProvider(_ref) {
542
626
  }
543
627
  case 4:
544
628
  case "end":
545
- return _context3.stop();
629
+ return _context4.stop();
546
630
  }
547
- }, _callee3);
631
+ }, _callee4);
548
632
  }));
549
633
  return _actionGetMerchiCart.apply(this, arguments);
550
634
  }
551
- function clearCart(_x3) {
635
+ function clearCart(_x4) {
552
636
  return _clearCart.apply(this, arguments);
553
637
  }
554
638
  function _clearCart() {
555
- _clearCart = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(callback) {
556
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
557
- while (1) switch (_context4.prev = _context4.next) {
639
+ _clearCart = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(callback) {
640
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
641
+ while (1) switch (_context5.prev = _context5.next) {
558
642
  case 0:
559
- _context4.next = 2;
643
+ _context5.next = 2;
560
644
  return createCartAndCookie();
561
645
  case 2:
562
646
  if (callback) callback();
563
647
  closeClearCart();
564
648
  case 4:
565
649
  case "end":
566
- return _context4.stop();
650
+ return _context5.stop();
567
651
  }
568
- }, _callee4);
652
+ }, _callee5);
569
653
  }));
570
654
  return _clearCart.apply(this, arguments);
571
655
  }
@@ -573,58 +657,59 @@ var CartProvider = function CartProvider(_ref) {
573
657
  _useState22 = _slicedToArray(_useState21, 2),
574
658
  fetchingShipmentGroups = _useState22[0],
575
659
  setFetchingShipmentGroups = _useState22[1];
576
- function updateCartShipmentAddress(_x4) {
660
+ function updateCartShipmentAddress(_x5) {
577
661
  return _updateCartShipmentAddress.apply(this, arguments);
578
662
  }
579
663
  function _updateCartShipmentAddress() {
580
- _updateCartShipmentAddress = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(address) {
664
+ _updateCartShipmentAddress = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(address) {
581
665
  var token, receiverAddress, cartEnt, _cartJson3, query, cartWithShipmentGroups;
582
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
583
- while (1) switch (_context5.prev = _context5.next) {
666
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
667
+ while (1) switch (_context6.prev = _context6.next) {
584
668
  case 0:
585
- _context5.next = 2;
669
+ _context6.next = 2;
586
670
  return (0, _cookie.getCartCookieToken)(domainId);
587
671
  case 2:
588
- token = _context5.sent;
672
+ token = _context6.sent;
589
673
  receiverAddress = (0, _address.makeAddress)(address, true);
590
674
  cartEnt = (0, _cart3.makeCart)(cart, false, token);
591
675
  setFetchingShipmentGroups(true);
592
- _context5.prev = 6;
676
+ _context6.prev = 6;
593
677
  cartEnt.receiverAddress = receiverAddress;
594
- _context5.next = 10;
678
+ _context6.next = 10;
595
679
  return cartEnt.save({
596
680
  embed: _helpers.cartEmbed
597
681
  });
598
682
  case 10:
599
- cartEnt = _context5.sent;
683
+ cartEnt = _context6.sent;
600
684
  _cartJson3 = cartEnt.toJson();
685
+ (0, _local_storage.saveCheckoutAddress)(domainId, address);
601
686
  query = [];
602
687
  query.push(['cart_token', cart.token]);
603
- _context5.next = 16;
688
+ _context6.next = 17;
604
689
  return merchi.authenticatedFetch("/generate-cart-shipment-quotes/".concat(cart.id, "/"), {
605
690
  method: 'GET',
606
691
  query: query
607
692
  });
608
- case 16:
609
- cartWithShipmentGroups = _context5.sent;
693
+ case 17:
694
+ cartWithShipmentGroups = _context6.sent;
610
695
  setCart(_objectSpread(_objectSpread({}, _cartJson3), {}, {
611
696
  shipmentGroups: cartWithShipmentGroups.shipmentGroups || []
612
697
  }));
613
- _context5.next = 23;
698
+ _context6.next = 24;
614
699
  break;
615
- case 20:
616
- _context5.prev = 20;
617
- _context5.t0 = _context5["catch"](6);
618
- alertError(_context5.t0.errorMessage || _context5.t0.message || 'Unable to set address');
619
- case 23:
620
- _context5.prev = 23;
700
+ case 21:
701
+ _context6.prev = 21;
702
+ _context6.t0 = _context6["catch"](6);
703
+ alertError(_context6.t0.errorMessage || _context6.t0.message || 'Unable to set address');
704
+ case 24:
705
+ _context6.prev = 24;
621
706
  setFetchingShipmentGroups(false);
622
- return _context5.finish(23);
623
- case 26:
707
+ return _context6.finish(24);
708
+ case 27:
624
709
  case "end":
625
- return _context5.stop();
710
+ return _context6.stop();
626
711
  }
627
- }, _callee5, null, [[6, 20, 23, 26]]);
712
+ }, _callee6, null, [[6, 21, 24, 27]]);
628
713
  }));
629
714
  return _updateCartShipmentAddress.apply(this, arguments);
630
715
  }
@@ -632,40 +717,40 @@ var CartProvider = function CartProvider(_ref) {
632
717
  return _getCartShipmentOptions.apply(this, arguments);
633
718
  }
634
719
  function _getCartShipmentOptions() {
635
- _getCartShipmentOptions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
720
+ _getCartShipmentOptions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
636
721
  var query, cartWithGroups;
637
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
638
- while (1) switch (_context6.prev = _context6.next) {
722
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
723
+ while (1) switch (_context7.prev = _context7.next) {
639
724
  case 0:
640
725
  setFetchingShipmentGroups(true);
641
- _context6.prev = 1;
726
+ _context7.prev = 1;
642
727
  query = [];
643
728
  query.push(['cart_token', cart.token]);
644
- _context6.next = 6;
729
+ _context7.next = 6;
645
730
  return merchi.authenticatedFetch("/generate-cart-shipment-quotes/".concat(cart.id, "/"), {
646
731
  method: 'GET',
647
732
  query: query
648
733
  });
649
734
  case 6:
650
- cartWithGroups = _context6.sent;
735
+ cartWithGroups = _context7.sent;
651
736
  setCart(_objectSpread(_objectSpread({}, cart), {}, {
652
737
  shipmentGroups: cartWithGroups.shipmentGroups || []
653
738
  }));
654
- _context6.next = 13;
739
+ _context7.next = 13;
655
740
  break;
656
741
  case 10:
657
- _context6.prev = 10;
658
- _context6.t0 = _context6["catch"](1);
659
- alertError(_context6.t0.errorMessage || _context6.t0.message || 'Unable to fetch shipment options');
742
+ _context7.prev = 10;
743
+ _context7.t0 = _context7["catch"](1);
744
+ alertError(_context7.t0.errorMessage || _context7.t0.message || 'Unable to fetch shipment options');
660
745
  case 13:
661
- _context6.prev = 13;
746
+ _context7.prev = 13;
662
747
  setFetchingShipmentGroups(false);
663
- return _context6.finish(13);
748
+ return _context7.finish(13);
664
749
  case 16:
665
750
  case "end":
666
- return _context6.stop();
751
+ return _context7.stop();
667
752
  }
668
- }, _callee6, null, [[1, 10, 13, 16]]);
753
+ }, _callee7, null, [[1, 10, 13, 16]]);
669
754
  }));
670
755
  return _getCartShipmentOptions.apply(this, arguments);
671
756
  }
@@ -673,14 +758,14 @@ var CartProvider = function CartProvider(_ref) {
673
758
  return _getMerchiCartValues.apply(this, arguments);
674
759
  }
675
760
  function _getMerchiCartValues() {
676
- _getMerchiCartValues = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
761
+ _getMerchiCartValues = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
677
762
  var _ref2, cartItems, currency, subtotalCost, taxAmount, totalCost, cartItemsCount;
678
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
679
- while (1) switch (_context7.prev = _context7.next) {
763
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
764
+ while (1) switch (_context8.prev = _context8.next) {
680
765
  case 0:
681
766
  _ref2 = cart, cartItems = _ref2.cartItems, currency = _ref2.currency, subtotalCost = _ref2.subtotalCost, taxAmount = _ref2.taxAmount, totalCost = _ref2.totalCost;
682
767
  cartItemsCount = cartItems ? cartItems.length : 0;
683
- return _context7.abrupt("return", {
768
+ return _context8.abrupt("return", {
684
769
  cart: cart,
685
770
  cartItemsCount: cartItemsCount,
686
771
  currency: currency || '',
@@ -690,9 +775,9 @@ var CartProvider = function CartProvider(_ref) {
690
775
  });
691
776
  case 3:
692
777
  case "end":
693
- return _context7.stop();
778
+ return _context8.stop();
694
779
  }
695
- }, _callee7);
780
+ }, _callee8);
696
781
  }));
697
782
  return _getMerchiCartValues.apply(this, arguments);
698
783
  }
@@ -700,16 +785,16 @@ var CartProvider = function CartProvider(_ref) {
700
785
  return _isMerchiCartFetching.apply(this, arguments);
701
786
  }
702
787
  function _isMerchiCartFetching() {
703
- _isMerchiCartFetching = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
704
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
705
- while (1) switch (_context8.prev = _context8.next) {
788
+ _isMerchiCartFetching = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
789
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
790
+ while (1) switch (_context9.prev = _context9.next) {
706
791
  case 0:
707
- return _context8.abrupt("return", fetchingCart);
792
+ return _context9.abrupt("return", fetchingCart);
708
793
  case 1:
709
794
  case "end":
710
- return _context8.stop();
795
+ return _context9.stop();
711
796
  }
712
- }, _callee8);
797
+ }, _callee9);
713
798
  }));
714
799
  return _isMerchiCartFetching.apply(this, arguments);
715
800
  }
@@ -723,14 +808,14 @@ var CartProvider = function CartProvider(_ref) {
723
808
  return _actionFetchTheme.apply(this, arguments);
724
809
  }
725
810
  function _actionFetchTheme() {
726
- _actionFetchTheme = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
811
+ _actionFetchTheme = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
727
812
  var domain, theme;
728
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
729
- while (1) switch (_context9.prev = _context9.next) {
813
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
814
+ while (1) switch (_context10.prev = _context10.next) {
730
815
  case 0:
731
816
  setLoading(true);
732
- _context9.prev = 1;
733
- _context9.next = 4;
817
+ _context10.prev = 1;
818
+ _context10.next = 4;
734
819
  return merchi.Domain.get(domainId, {
735
820
  embed: {
736
821
  activeTheme: {
@@ -739,25 +824,25 @@ var CartProvider = function CartProvider(_ref) {
739
824
  }
740
825
  });
741
826
  case 4:
742
- domain = _context9.sent;
827
+ domain = _context10.sent;
743
828
  theme = domain.activeTheme;
744
- _context9.next = 8;
829
+ _context10.next = 8;
745
830
  return (0, _helpers.appendStyleSheetText)(theme.mainCss, function () {
746
831
  return setLoading(false);
747
832
  });
748
833
  case 8:
749
- _context9.next = 14;
834
+ _context10.next = 14;
750
835
  break;
751
836
  case 10:
752
- _context9.prev = 10;
753
- _context9.t0 = _context9["catch"](1);
754
- alertError(_context9.t0.errorMessage || _context9.t0.message || 'Error fetching domain theme.');
837
+ _context10.prev = 10;
838
+ _context10.t0 = _context10["catch"](1);
839
+ alertError(_context10.t0.errorMessage || _context10.t0.message || 'Error fetching domain theme.');
755
840
  setLoading(false);
756
841
  case 14:
757
842
  case "end":
758
- return _context9.stop();
843
+ return _context10.stop();
759
844
  }
760
- }, _callee9, null, [[1, 10]]);
845
+ }, _callee10, null, [[1, 10]]);
761
846
  }));
762
847
  return _actionFetchTheme.apply(this, arguments);
763
848
  }
@@ -765,19 +850,19 @@ var CartProvider = function CartProvider(_ref) {
765
850
  return _setCartComplete.apply(this, arguments);
766
851
  }
767
852
  function _setCartComplete() {
768
- _setCartComplete = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
769
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
770
- while (1) switch (_context10.prev = _context10.next) {
853
+ _setCartComplete = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
854
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
855
+ while (1) switch (_context11.prev = _context11.next) {
771
856
  case 0:
772
- _context10.next = 2;
857
+ _context11.next = 2;
773
858
  return createCartAndCookie();
774
859
  case 2:
775
860
  location.reload();
776
861
  case 3:
777
862
  case "end":
778
- return _context10.stop();
863
+ return _context11.stop();
779
864
  }
780
- }, _callee10);
865
+ }, _callee11);
781
866
  }));
782
867
  return _setCartComplete.apply(this, arguments);
783
868
  }
@@ -785,17 +870,17 @@ var CartProvider = function CartProvider(_ref) {
785
870
  return _refetchCart.apply(this, arguments);
786
871
  }
787
872
  function _refetchCart() {
788
- _refetchCart = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
789
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
790
- while (1) switch (_context11.prev = _context11.next) {
873
+ _refetchCart = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
874
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
875
+ while (1) switch (_context12.prev = _context12.next) {
791
876
  case 0:
792
- _context11.next = 2;
877
+ _context12.next = 2;
793
878
  return actionGetMerchiCart();
794
879
  case 2:
795
880
  case "end":
796
- return _context11.stop();
881
+ return _context12.stop();
797
882
  }
798
- }, _callee11);
883
+ }, _callee12);
799
884
  }));
800
885
  return _refetchCart.apply(this, arguments);
801
886
  }
@@ -807,21 +892,21 @@ var CartProvider = function CartProvider(_ref) {
807
892
  _useState28 = _slicedToArray(_useState27, 2),
808
893
  loadingTotals = _useState28[0],
809
894
  setLoadingTotals = _useState28[1];
810
- function addCartItem(_x5, _x6, _x7) {
895
+ function addCartItem(_x6, _x7, _x8) {
811
896
  return _addCartItem.apply(this, arguments);
812
897
  }
813
898
  function _addCartItem() {
814
- _addCartItem = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(jobJson, onSuccess, onError) {
899
+ _addCartItem = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(jobJson, onSuccess, onError) {
815
900
  var jobEnt, cartToken, cartEnt, cartItemEnt, cartItemProduct, item, itemJson;
816
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
817
- while (1) switch (_context12.prev = _context12.next) {
901
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
902
+ while (1) switch (_context13.prev = _context13.next) {
818
903
  case 0:
819
904
  setFetchingCart(true);
820
905
  jobEnt = (0, _job.makeJob)(jobJson, true);
821
- _context12.next = 4;
906
+ _context13.next = 4;
822
907
  return (0, _cookie.getCartCookieToken)(domainId);
823
908
  case 4:
824
- cartToken = _context12.sent;
909
+ cartToken = _context13.sent;
825
910
  cartEnt = (0, _cart3.makeCart)(cart, false, cartToken);
826
911
  cartItemEnt = (0, _cart3.makeCartItem)({}, true);
827
912
  cartItemProduct = (0, _product.makeProduct)({
@@ -835,31 +920,31 @@ var CartProvider = function CartProvider(_ref) {
835
920
  cartItemEnt.taxType = jobEnt.taxType;
836
921
  cartItemEnt.ownDrafts = jobEnt.ownDrafts;
837
922
  cartItemEnt.tags = jobEnt.tags;
838
- _context12.prev = 16;
839
- _context12.next = 19;
923
+ _context13.prev = 16;
924
+ _context13.next = 19;
840
925
  return cartItemEnt.create();
841
926
  case 19:
842
- item = _context12.sent;
843
- _context12.next = 22;
927
+ item = _context13.sent;
928
+ _context13.next = 22;
844
929
  return item.toJson();
845
930
  case 22:
846
- itemJson = _context12.sent;
931
+ itemJson = _context13.sent;
847
932
  onSuccess(itemJson);
848
- _context12.next = 29;
933
+ _context13.next = 29;
849
934
  break;
850
935
  case 26:
851
- _context12.prev = 26;
852
- _context12.t0 = _context12["catch"](16);
853
- onError(_context12.t0);
936
+ _context13.prev = 26;
937
+ _context13.t0 = _context13["catch"](16);
938
+ onError(_context13.t0);
854
939
  case 29:
855
- _context12.prev = 29;
940
+ _context13.prev = 29;
856
941
  setFetchingCart(false);
857
- return _context12.finish(29);
942
+ return _context13.finish(29);
858
943
  case 32:
859
944
  case "end":
860
- return _context12.stop();
945
+ return _context13.stop();
861
946
  }
862
- }, _callee12, null, [[16, 26, 29, 32]]);
947
+ }, _callee13, null, [[16, 26, 29, 32]]);
863
948
  }));
864
949
  return _addCartItem.apply(this, arguments);
865
950
  }