merchi_cart 0.0.3-a → 0.0.3-b

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/lib/Cart.js CHANGED
@@ -31,7 +31,6 @@ function CartComponents() {
31
31
  if (includeTheme) {
32
32
  actionFetchTheme(domainId);
33
33
  }
34
- console.log(domainId, 'whjat os tjos');
35
34
  initMerchiCart(domainId);
36
35
  }
37
36
  }, [domainId, includeTheme, initialiseCart]);
@@ -174,7 +174,7 @@ export var sliceCart = createSlice({
174
174
  state.cart.client = action.payload;
175
175
  },
176
176
  setDomainId: function (state, action) {
177
- state.domainId = action.payload.domainId;
177
+ state.domainId = action.payload;
178
178
  },
179
179
  toggleCartOpen: function (state) {
180
180
  state.modalCartOpen = !state.modalCartOpen;
package/lib/store.js CHANGED
@@ -144,11 +144,10 @@ export function actionFetchTheme(id) {
144
144
  dispatch(fetchThemeError());
145
145
  });
146
146
  }
147
- function cartAndCookie() {
147
+ function cartAndCookie(domainId) {
148
148
  return __awaiter(this, void 0, void 0, function () {
149
- var domainId, cart;
149
+ var cart;
150
150
  return __generator(this, function (_a) {
151
- domainId = getStore().stateCart.domainId;
152
151
  console.log(domainId, 'what is this thing in cartAndCookie');
153
152
  cart = makeCart({ domain: { id: domainId } }, true);
154
153
  return [2 /*return*/, cart.create({ embed: cartEmbed })
@@ -170,13 +169,13 @@ function cartAndCookie() {
170
169
  });
171
170
  });
172
171
  }
173
- export function createAndSetNewCartCookie() {
172
+ export function createAndSetNewCartCookie(domainId) {
174
173
  return __awaiter(this, void 0, void 0, function () {
175
174
  return __generator(this, function (_a) {
176
175
  switch (_a.label) {
177
176
  case 0:
178
177
  dispatch(fetchCart());
179
- return [4 /*yield*/, cartAndCookie()];
178
+ return [4 /*yield*/, cartAndCookie(domainId)];
180
179
  case 1:
181
180
  _a.sent();
182
181
  return [2 /*return*/];
@@ -186,12 +185,14 @@ export function createAndSetNewCartCookie() {
186
185
  }
187
186
  export function doClearCart() {
188
187
  return __awaiter(this, void 0, void 0, function () {
188
+ var domainId;
189
189
  return __generator(this, function (_a) {
190
190
  switch (_a.label) {
191
191
  case 0:
192
+ domainId = getStore().stateCart.domainId;
192
193
  dispatch(setCart({}));
193
194
  closeClearCart();
194
- return [4 /*yield*/, createAndSetNewCartCookie()];
195
+ return [4 /*yield*/, createAndSetNewCartCookie(domainId)];
195
196
  case 1:
196
197
  _a.sent();
197
198
  return [2 /*return*/];
@@ -457,7 +458,7 @@ function updateCartValues(cartJson) {
457
458
  dispatch(sliceCart.actions.fetchCartSuccess(cartJson));
458
459
  dispatch(initCartShipmentSlice(cartJson));
459
460
  }
460
- function getCart(cartIdAndToken) {
461
+ function getCart(domainId, cartIdAndToken) {
461
462
  var cartSettingsInvalid = sliceCart.actions.cartSettingsInvalid;
462
463
  var id = Number(cartIdAndToken[0]);
463
464
  if (cartIdAndToken[1]) {
@@ -479,7 +480,7 @@ function getCart(cartIdAndToken) {
479
480
  }
480
481
  })
481
482
  .catch(function (e) {
482
- createAndSetNewCartCookie();
483
+ createAndSetNewCartCookie(domainId);
483
484
  });
484
485
  }
485
486
  export function getMerchiCart(domainId) {
@@ -491,10 +492,10 @@ export function getMerchiCart(domainId) {
491
492
  case 1:
492
493
  cartIdAndToken = _a.sent();
493
494
  if (cartIdAndToken) {
494
- getCart(cartIdAndToken);
495
+ getCart(domainId, cartIdAndToken);
495
496
  }
496
497
  else {
497
- createAndSetNewCartCookie();
498
+ createAndSetNewCartCookie(domainId);
498
499
  }
499
500
  return [2 /*return*/];
500
501
  }
@@ -528,11 +529,13 @@ export function getMerchiCartValues() {
528
529
  }
529
530
  export function doCartComplete() {
530
531
  return __awaiter(this, void 0, void 0, function () {
532
+ var domainId;
531
533
  return __generator(this, function (_a) {
532
534
  switch (_a.label) {
533
535
  case 0:
536
+ domainId = getStore().stateCart.domainId;
534
537
  dispatch(sliceCartPayment.actions.doCardComplete());
535
- return [4 /*yield*/, cartAndCookie().then(function () { return location.reload(); })];
538
+ return [4 /*yield*/, cartAndCookie(domainId).then(function () { return location.reload(); })];
536
539
  case 1:
537
540
  _a.sent();
538
541
  return [2 /*return*/];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "merchi_cart",
3
- "version": "0.0.3-a",
3
+ "version": "0.0.3-b",
4
4
  "description": "Merchi's cart",
5
5
  "main": "lib/index.js",
6
6
  "module": "src/index.tsx",