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