merchi_cart 0.0.3-a → 0.0.3-c

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,12 @@ export function getMerchiCart(domainId) {
491
492
  case 1:
492
493
  cartIdAndToken = _a.sent();
493
494
  if (cartIdAndToken) {
494
- getCart(cartIdAndToken);
495
+ console.log('try get', domainId);
496
+ getCart(domainId, cartIdAndToken);
495
497
  }
496
498
  else {
497
- createAndSetNewCartCookie();
499
+ console.log('try create', domainId);
500
+ createAndSetNewCartCookie(domainId);
498
501
  }
499
502
  return [2 /*return*/];
500
503
  }
@@ -528,11 +531,13 @@ export function getMerchiCartValues() {
528
531
  }
529
532
  export function doCartComplete() {
530
533
  return __awaiter(this, void 0, void 0, function () {
534
+ var domainId;
531
535
  return __generator(this, function (_a) {
532
536
  switch (_a.label) {
533
537
  case 0:
538
+ domainId = getStore().stateCart.domainId;
534
539
  dispatch(sliceCartPayment.actions.doCardComplete());
535
- return [4 /*yield*/, cartAndCookie().then(function () { return location.reload(); })];
540
+ return [4 /*yield*/, cartAndCookie(domainId).then(function () { return location.reload(); })];
536
541
  case 1:
537
542
  _a.sent();
538
543
  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-c",
4
4
  "description": "Merchi's cart",
5
5
  "main": "lib/index.js",
6
6
  "module": "src/index.tsx",