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.
- package/esm/CartProvider.js +239 -154
- package/esm/components/CustomCartProductForm.js +129 -0
- package/esm/components/product-form-sdk-externals.js +35 -0
- package/esm/forms/FormNewCustomer.js +22 -13
- package/esm/forms/FormReturningCustomer.js +18 -16
- package/esm/forms/FormShipmentAddressAndNotes.js +14 -11
- package/esm/utilities/customForm.js +57 -0
- package/esm/utilities/index.js +1 -0
- package/esm/utilities/local_storage.js +85 -0
- package/lib/CartProvider.js +239 -154
- package/lib/components/CustomCartProductForm.js +137 -0
- package/lib/components/product-form-sdk-externals.js +42 -0
- package/lib/forms/FormNewCustomer.js +22 -13
- package/lib/forms/FormReturningCustomer.js +18 -16
- package/lib/forms/FormShipmentAddressAndNotes.js +14 -11
- package/lib/utilities/customForm.js +64 -0
- package/lib/utilities/index.js +11 -0
- package/lib/utilities/local_storage.js +96 -0
- package/package.json +1 -1
- package/src/CartProvider.tsx +39 -3
- package/src/forms/FormNewCustomer.tsx +19 -3
- package/src/forms/FormReturningCustomer.tsx +15 -8
- package/src/forms/FormShipmentAddressAndNotes.tsx +12 -1
- package/src/utilities/index.ts +1 -0
- package/src/utilities/local_storage.ts +130 -0
package/esm/CartProvider.js
CHANGED
|
@@ -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
|
-
|
|
423
|
-
|
|
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
|
|
499
|
+
_createCartAndCookie = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(callback) {
|
|
428
500
|
var _cart, _cartJson;
|
|
429
|
-
return _regeneratorRuntime().wrap(function
|
|
430
|
-
while (1) switch (
|
|
501
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
502
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
431
503
|
case 0:
|
|
432
504
|
setFetchingCart(true);
|
|
433
|
-
|
|
505
|
+
_context2.prev = 1;
|
|
434
506
|
_cart = makeCart({
|
|
435
507
|
domain: {
|
|
436
508
|
id: domainId
|
|
437
509
|
}
|
|
438
510
|
}, true);
|
|
439
|
-
|
|
511
|
+
_context2.next = 5;
|
|
440
512
|
return _cart.create({
|
|
441
513
|
embed: cartEmbed
|
|
442
514
|
});
|
|
443
515
|
case 5:
|
|
444
|
-
|
|
516
|
+
_context2.next = 7;
|
|
445
517
|
return _cart.toJson();
|
|
446
518
|
case 7:
|
|
447
|
-
_cartJson =
|
|
519
|
+
_cartJson = _context2.sent;
|
|
448
520
|
if (domainId) setCartCookie(Number(domainId), _cartJson, undefined);
|
|
449
|
-
|
|
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
|
-
|
|
527
|
+
_context2.next = 19;
|
|
453
528
|
break;
|
|
454
|
-
case
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
alertError(
|
|
458
|
-
case
|
|
459
|
-
|
|
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
|
|
462
|
-
case
|
|
536
|
+
return _context2.finish(19);
|
|
537
|
+
case 22:
|
|
463
538
|
case "end":
|
|
464
|
-
return
|
|
539
|
+
return _context2.stop();
|
|
465
540
|
}
|
|
466
|
-
},
|
|
541
|
+
}, _callee2, null, [[1, 16, 19, 22]]);
|
|
467
542
|
}));
|
|
468
543
|
return _createCartAndCookie.apply(this, arguments);
|
|
469
544
|
}
|
|
470
|
-
function getCart(
|
|
545
|
+
function getCart(_x3) {
|
|
471
546
|
return _getCart.apply(this, arguments);
|
|
472
547
|
}
|
|
473
548
|
function _getCart() {
|
|
474
|
-
_getCart = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
549
|
+
_getCart = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(cartIdAndToken) {
|
|
475
550
|
var id, _cart2, _cartJson2;
|
|
476
|
-
return _regeneratorRuntime().wrap(function
|
|
477
|
-
while (1) switch (
|
|
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
|
-
|
|
483
|
-
|
|
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 =
|
|
489
|
-
|
|
563
|
+
_cart2 = _context3.sent;
|
|
564
|
+
_context3.next = 9;
|
|
490
565
|
return _cart2.toJson();
|
|
491
566
|
case 9:
|
|
492
|
-
_cartJson2 =
|
|
493
|
-
if (stripeIsValidAndActive(_cartJson2)) {
|
|
494
|
-
|
|
495
|
-
|
|
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
|
-
|
|
500
|
-
|
|
572
|
+
_context3.next = 13;
|
|
573
|
+
return attachSavedClientIfNeeded(_cartJson2);
|
|
501
574
|
case 13:
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
575
|
+
_cartJson2 = _context3.sent;
|
|
576
|
+
setCart(_objectSpread({}, _cartJson2));
|
|
577
|
+
_context3.next = 19;
|
|
578
|
+
break;
|
|
506
579
|
case 17:
|
|
507
|
-
|
|
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
|
|
510
|
-
case
|
|
593
|
+
return _context3.finish(25);
|
|
594
|
+
case 28:
|
|
511
595
|
case "end":
|
|
512
|
-
return
|
|
596
|
+
return _context3.stop();
|
|
513
597
|
}
|
|
514
|
-
},
|
|
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
|
|
606
|
+
_actionGetMerchiCart = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
523
607
|
var cartIdAndToken;
|
|
524
|
-
return _regeneratorRuntime().wrap(function
|
|
525
|
-
while (1) switch (
|
|
608
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
609
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
526
610
|
case 0:
|
|
527
|
-
|
|
611
|
+
_context4.next = 2;
|
|
528
612
|
return getCartCookie(domainId);
|
|
529
613
|
case 2:
|
|
530
|
-
cartIdAndToken =
|
|
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
|
|
622
|
+
return _context4.stop();
|
|
539
623
|
}
|
|
540
|
-
},
|
|
624
|
+
}, _callee4);
|
|
541
625
|
}));
|
|
542
626
|
return _actionGetMerchiCart.apply(this, arguments);
|
|
543
627
|
}
|
|
544
|
-
function clearCart(
|
|
628
|
+
function clearCart(_x4) {
|
|
545
629
|
return _clearCart.apply(this, arguments);
|
|
546
630
|
}
|
|
547
631
|
function _clearCart() {
|
|
548
|
-
_clearCart = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
549
|
-
return _regeneratorRuntime().wrap(function
|
|
550
|
-
while (1) switch (
|
|
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
|
-
|
|
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
|
|
643
|
+
return _context5.stop();
|
|
560
644
|
}
|
|
561
|
-
},
|
|
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(
|
|
653
|
+
function updateCartShipmentAddress(_x5) {
|
|
570
654
|
return _updateCartShipmentAddress.apply(this, arguments);
|
|
571
655
|
}
|
|
572
656
|
function _updateCartShipmentAddress() {
|
|
573
|
-
_updateCartShipmentAddress = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
657
|
+
_updateCartShipmentAddress = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(address) {
|
|
574
658
|
var token, receiverAddress, cartEnt, _cartJson3, query, cartWithShipmentGroups;
|
|
575
|
-
return _regeneratorRuntime().wrap(function
|
|
576
|
-
while (1) switch (
|
|
659
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
660
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
577
661
|
case 0:
|
|
578
|
-
|
|
662
|
+
_context6.next = 2;
|
|
579
663
|
return getCartCookieToken(domainId);
|
|
580
664
|
case 2:
|
|
581
|
-
token =
|
|
665
|
+
token = _context6.sent;
|
|
582
666
|
receiverAddress = makeAddress(address, true);
|
|
583
667
|
cartEnt = makeCart(cart, false, token);
|
|
584
668
|
setFetchingShipmentGroups(true);
|
|
585
|
-
|
|
669
|
+
_context6.prev = 6;
|
|
586
670
|
cartEnt.receiverAddress = receiverAddress;
|
|
587
|
-
|
|
671
|
+
_context6.next = 10;
|
|
588
672
|
return cartEnt.save({
|
|
589
673
|
embed: cartEmbed
|
|
590
674
|
});
|
|
591
675
|
case 10:
|
|
592
|
-
cartEnt =
|
|
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
|
-
|
|
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
|
|
602
|
-
cartWithShipmentGroups =
|
|
686
|
+
case 17:
|
|
687
|
+
cartWithShipmentGroups = _context6.sent;
|
|
603
688
|
setCart(_objectSpread(_objectSpread({}, _cartJson3), {}, {
|
|
604
689
|
shipmentGroups: cartWithShipmentGroups.shipmentGroups || []
|
|
605
690
|
}));
|
|
606
|
-
|
|
691
|
+
_context6.next = 24;
|
|
607
692
|
break;
|
|
608
|
-
case
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
alertError(
|
|
612
|
-
case
|
|
613
|
-
|
|
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
|
|
616
|
-
case
|
|
700
|
+
return _context6.finish(24);
|
|
701
|
+
case 27:
|
|
617
702
|
case "end":
|
|
618
|
-
return
|
|
703
|
+
return _context6.stop();
|
|
619
704
|
}
|
|
620
|
-
},
|
|
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
|
|
713
|
+
_getCartShipmentOptions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
629
714
|
var query, cartWithGroups;
|
|
630
|
-
return _regeneratorRuntime().wrap(function
|
|
631
|
-
while (1) switch (
|
|
715
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
716
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
632
717
|
case 0:
|
|
633
718
|
setFetchingShipmentGroups(true);
|
|
634
|
-
|
|
719
|
+
_context7.prev = 1;
|
|
635
720
|
query = [];
|
|
636
721
|
query.push(['cart_token', cart.token]);
|
|
637
|
-
|
|
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 =
|
|
728
|
+
cartWithGroups = _context7.sent;
|
|
644
729
|
setCart(_objectSpread(_objectSpread({}, cart), {}, {
|
|
645
730
|
shipmentGroups: cartWithGroups.shipmentGroups || []
|
|
646
731
|
}));
|
|
647
|
-
|
|
732
|
+
_context7.next = 13;
|
|
648
733
|
break;
|
|
649
734
|
case 10:
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
alertError(
|
|
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
|
-
|
|
739
|
+
_context7.prev = 13;
|
|
655
740
|
setFetchingShipmentGroups(false);
|
|
656
|
-
return
|
|
741
|
+
return _context7.finish(13);
|
|
657
742
|
case 16:
|
|
658
743
|
case "end":
|
|
659
|
-
return
|
|
744
|
+
return _context7.stop();
|
|
660
745
|
}
|
|
661
|
-
},
|
|
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
|
|
754
|
+
_getMerchiCartValues = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
670
755
|
var _ref2, cartItems, currency, subtotalCost, taxAmount, totalCost, cartItemsCount;
|
|
671
|
-
return _regeneratorRuntime().wrap(function
|
|
672
|
-
while (1) switch (
|
|
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
|
|
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
|
|
771
|
+
return _context8.stop();
|
|
687
772
|
}
|
|
688
|
-
},
|
|
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
|
|
697
|
-
return _regeneratorRuntime().wrap(function
|
|
698
|
-
while (1) switch (
|
|
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
|
|
785
|
+
return _context9.abrupt("return", fetchingCart);
|
|
701
786
|
case 1:
|
|
702
787
|
case "end":
|
|
703
|
-
return
|
|
788
|
+
return _context9.stop();
|
|
704
789
|
}
|
|
705
|
-
},
|
|
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
|
|
804
|
+
_actionFetchTheme = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
720
805
|
var domain, theme;
|
|
721
|
-
return _regeneratorRuntime().wrap(function
|
|
722
|
-
while (1) switch (
|
|
806
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
807
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
723
808
|
case 0:
|
|
724
809
|
setLoading(true);
|
|
725
|
-
|
|
726
|
-
|
|
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 =
|
|
820
|
+
domain = _context10.sent;
|
|
736
821
|
theme = domain.activeTheme;
|
|
737
|
-
|
|
822
|
+
_context10.next = 8;
|
|
738
823
|
return appendStyleSheetText(theme.mainCss, function () {
|
|
739
824
|
return setLoading(false);
|
|
740
825
|
});
|
|
741
826
|
case 8:
|
|
742
|
-
|
|
827
|
+
_context10.next = 14;
|
|
743
828
|
break;
|
|
744
829
|
case 10:
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
alertError(
|
|
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
|
|
836
|
+
return _context10.stop();
|
|
752
837
|
}
|
|
753
|
-
},
|
|
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
|
|
762
|
-
return _regeneratorRuntime().wrap(function
|
|
763
|
-
while (1) switch (
|
|
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
|
-
|
|
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
|
|
856
|
+
return _context11.stop();
|
|
772
857
|
}
|
|
773
|
-
},
|
|
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
|
|
782
|
-
return _regeneratorRuntime().wrap(function
|
|
783
|
-
while (1) switch (
|
|
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
|
-
|
|
870
|
+
_context12.next = 2;
|
|
786
871
|
return actionGetMerchiCart();
|
|
787
872
|
case 2:
|
|
788
873
|
case "end":
|
|
789
|
-
return
|
|
874
|
+
return _context12.stop();
|
|
790
875
|
}
|
|
791
|
-
},
|
|
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(
|
|
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
|
|
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
|
|
810
|
-
while (1) switch (
|
|
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
|
-
|
|
899
|
+
_context13.next = 4;
|
|
815
900
|
return getCartCookieToken(domainId);
|
|
816
901
|
case 4:
|
|
817
|
-
cartToken =
|
|
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
|
-
|
|
832
|
-
|
|
916
|
+
_context13.prev = 16;
|
|
917
|
+
_context13.next = 19;
|
|
833
918
|
return cartItemEnt.create();
|
|
834
919
|
case 19:
|
|
835
|
-
item =
|
|
836
|
-
|
|
920
|
+
item = _context13.sent;
|
|
921
|
+
_context13.next = 22;
|
|
837
922
|
return item.toJson();
|
|
838
923
|
case 22:
|
|
839
|
-
itemJson =
|
|
924
|
+
itemJson = _context13.sent;
|
|
840
925
|
onSuccess(itemJson);
|
|
841
|
-
|
|
926
|
+
_context13.next = 29;
|
|
842
927
|
break;
|
|
843
928
|
case 26:
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
onError(
|
|
929
|
+
_context13.prev = 26;
|
|
930
|
+
_context13.t0 = _context13["catch"](16);
|
|
931
|
+
onError(_context13.t0);
|
|
847
932
|
case 29:
|
|
848
|
-
|
|
933
|
+
_context13.prev = 29;
|
|
849
934
|
setFetchingCart(false);
|
|
850
|
-
return
|
|
935
|
+
return _context13.finish(29);
|
|
851
936
|
case 32:
|
|
852
937
|
case "end":
|
|
853
|
-
return
|
|
938
|
+
return _context13.stop();
|
|
854
939
|
}
|
|
855
|
-
},
|
|
940
|
+
}, _callee13, null, [[16, 26, 29, 32]]);
|
|
856
941
|
}));
|
|
857
942
|
return _addCartItem.apply(this, arguments);
|
|
858
943
|
}
|