@nuskin/product-components 3.3.8 → 3.3.9

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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [3.3.9](https://code.tls.nuskin.io/ns-am/ux/product-components/compare/v3.3.8...v3.3.9) (2023-04-10)
2
+
3
+
4
+ ### Fix
5
+
6
+ * fixes to get exclusive offer working (#CX15-6971) ([2333571](https://code.tls.nuskin.io/ns-am/ux/product-components/commit/23335712d88116f3238536b0a53b8a270a5d11e4)), closes [#CX15-6971](https://code.tls.nuskin.io/ns-am/ux/product-components/issues/CX15-6971)
7
+
1
8
  ## [3.3.8](https://code.tls.nuskin.io/ns-am/ux/product-components/compare/v3.3.7...v3.3.8) (2023-04-06)
2
9
 
3
10
 
@@ -17,10 +17,11 @@ import {
17
17
  AdrService,
18
18
  FavoritesService,
19
19
  ProductStatus,
20
- QualificationService,
20
+ QualificationService as OldQualificationService,
21
21
  Product as ShopProduct,
22
22
  EquinoxCartService
23
23
  } from "@nuskin/ns-shop";
24
+ import { default as NewQualificationService } from "@nuskin/exclusive-offer-sdk";
24
25
  import webLoyalty from "@nuskin/ns-loyalty-web";
25
26
  import { getProp, getFullUrl } from "@nuskin/ns-common-lib";
26
27
  import { PriceType } from "@nuskin/ns-product-lib";
@@ -30,6 +31,31 @@ import { waitForConfig } from "../services/configHelper";
30
31
  const PENDING_FAVORITE = "pendingFavorite";
31
32
  const KEY_BREADCRUMB_BACK = "breadcrumbBack";
32
33
 
34
+ let equinoxMarket = {
35
+ promise: getConfiguration(["Equinox_Markets"]).then(config => {
36
+ equinoxMarket = {
37
+ value:
38
+ config && config.Equinox_Markets
39
+ ? !!config.Equinox_Markets.active
40
+ : false,
41
+ promise: null,
42
+ loaded: true
43
+ };
44
+ }),
45
+ loaded: false,
46
+ value: undefined
47
+ };
48
+
49
+ const getQualificationService = async () => {
50
+ if (!equinoxMarket.loaded) {
51
+ await equinoxMarket.promise;
52
+ }
53
+ if (equinoxMarket.value) {
54
+ return NewQualificationService;
55
+ }
56
+ return OldQualificationService;
57
+ };
58
+
33
59
  /**
34
60
  * NsProductMixin
35
61
  *
@@ -573,7 +599,9 @@ const NsProductMixin = {
573
599
  (this.baseSku === product.sku ||
574
600
  product.variantSkus().includes(this.activeSku));
575
601
  const productChanged =
576
- !baseProductChanged && this.activeSku === product.sku;
602
+ !baseProductChanged &&
603
+ (this.activeSku === product.sku ||
604
+ this.activeSku === product.equinoxProductId);
577
605
  if (baseProductChanged || productChanged) {
578
606
  this.setFromProductData(this.activeSku, product);
579
607
  }
@@ -669,9 +697,9 @@ const NsProductMixin = {
669
697
  this.exclusiveOfferMessage = "";
670
698
  if (this.isExclusive) {
671
699
  if (this.isLoggedIn) {
672
- const productQualification = await QualificationService.getQualification(
673
- this.activeSku
674
- );
700
+ const productQualification = await (
701
+ await getQualificationService()
702
+ ).getQualification(this.activeSku);
675
703
 
676
704
  let cartQuantity;
677
705
  if (!this.baseSku) {
@@ -684,10 +712,10 @@ const NsProductMixin = {
684
712
  cartQuantity = (cartItem || {}).qty || 0;
685
713
  } else {
686
714
  const cartData =
687
- (await QualificationService.convertCartDataToBaseSkus(
688
- CartService.getItemData(),
689
- true
690
- )) || {};
715
+ (await (
716
+ await getQualificationService()
717
+ ).convertCartDataToBaseSkus(CartService.getItemData(), true)) ||
718
+ {};
691
719
  const cartItem = cartData[this.baseSku] || {};
692
720
  cartQuantity = cartItem.qty || 0;
693
721
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/product-components",
3
- "version": "3.3.8",
3
+ "version": "3.3.9",
4
4
  "description": "Nu Skin Product Components",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -42,6 +42,7 @@
42
42
  "fibers": "^4.0.1"
43
43
  },
44
44
  "peerDependencies": {
45
+ "@nuskin/exclusive-offer-sdk": "1.x",
45
46
  "@nuskin/ns-account": "5.x",
46
47
  "@nuskin/ns-checkout-common": "3.x",
47
48
  "@nuskin/ns-feature-flags": "1.x",
@@ -198,7 +198,10 @@ if (!NsProductDataService) {
198
198
  continue;
199
199
  }
200
200
  const product = this.products.find(
201
- p => p.sku === sku || p.variantSkus().includes(sku)
201
+ p =>
202
+ p.sku === sku ||
203
+ p.variantSkus().includes(sku) ||
204
+ p.equinoxProductId === sku
202
205
  );
203
206
  if (product) {
204
207
  if (product.sku === sku || top) {
@@ -200,10 +200,40 @@
200
200
  </template>
201
201
 
202
202
  <script>
203
- import { QualificationService, CartService } from "@nuskin/ns-shop";
204
-
203
+ import {
204
+ QualificationService as OldQualificationService,
205
+ CartService
206
+ } from "@nuskin/ns-shop";
207
+ import { getConfiguration } from "@nuskin/configuration-sdk";
208
+ import { default as NewQualificationService } from "@nuskin/exclusive-offer-sdk";
205
209
  import NsProductMixin from "../mixins/NsProductMixin";
206
210
  import "@nuskin/ns-core-styles/src/dist/main.css";
211
+
212
+ let equinoxMarket = {
213
+ promise: getConfiguration(["Equinox_Markets"]).then(config => {
214
+ equinoxMarket = {
215
+ value:
216
+ config && config.Equinox_Markets
217
+ ? !!config.Equinox_Markets.active
218
+ : false,
219
+ promise: null,
220
+ loaded: true
221
+ };
222
+ }),
223
+ loaded: false,
224
+ value: undefined
225
+ };
226
+
227
+ const getQualificationService = async () => {
228
+ if (!equinoxMarket.loaded) {
229
+ await equinoxMarket.promise;
230
+ }
231
+ if (equinoxMarket.value) {
232
+ return NewQualificationService;
233
+ }
234
+ return OldQualificationService;
235
+ };
236
+
207
237
  export default {
208
238
  name: "NsProductMixinPreview",
209
239
  filters: {
@@ -377,9 +407,9 @@ export default {
377
407
  async mounted() {
378
408
  if (this.isExclusive) {
379
409
  if (this.isLoggedIn) {
380
- this.productQualification = await QualificationService.getQualification(
381
- this.activeSku
382
- );
410
+ this.productQualification = await (
411
+ await getQualificationService()
412
+ ).getQualification(this.activeSku);
383
413
 
384
414
  this.cartItem = await CartService.getFirstItemBySku(this.activeSku, {
385
415
  cartOrderItems: true