@nuskin/product-components 3.17.1 → 3.17.2

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/docs/CHANGELOG.md CHANGED
@@ -1 +1 @@
1
- ## [3.17.1](https://code.tls.nuskin.io/ns-am/ux/product-components/compare/v3.17.0...v3.17.1) (2024-06-11)
1
+ ## [3.17.2](https://code.tls.nuskin.io/ns-am/ux/product-components/compare/v3.17.1...v3.17.2) (2024-06-17)
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "bomFormat": "CycloneDX",
3
3
  "specVersion": "1.4",
4
- "serialNumber": "urn:uuid:3c48d34c-022f-42f4-bd1b-b2227ef69b90",
4
+ "serialNumber": "urn:uuid:d791f546-6b5a-47e2-b278-d5d586e7caee",
5
5
  "version": 1,
6
6
  "metadata": {
7
- "timestamp": "2024-06-11T10:52:35Z",
7
+ "timestamp": "2024-06-17T16:53:01Z",
8
8
  "tools": [
9
9
  {
10
10
  "vendor": "GitLab",
@@ -21,12 +21,10 @@ import {
21
21
  AdrService,
22
22
  FavoritesService,
23
23
  ProductStatus,
24
- QualificationService as OldQualificationService,
25
24
  Product as ShopProduct,
26
25
  EquinoxCartService
27
26
  } from "@nuskin/ns-shop";
28
- import { default as NewQualificationService } from "@nuskin/exclusive-offer-sdk";
29
- import { retrieveTogglesBasedOnEnvironment } from "@nuskin/ns-feature-flags";
27
+ import QualificationService from "@nuskin/exclusive-offer-sdk";
30
28
  import webLoyalty from "@nuskin/ns-loyalty-web";
31
29
  import { getProp, getFullUrl } from "@nuskin/ns-common-lib";
32
30
  import { PriceType } from "@nuskin/ns-product-lib";
@@ -38,31 +36,6 @@ const PENDING_FAVORITE = "pendingFavorite";
38
36
  const KEY_BREADCRUMB_BACK = "breadcrumbBack";
39
37
  const BUNDLE = "BUNDLE";
40
38
 
41
- let flagsPromise = null;
42
- let featureFlags = false;
43
- const checkFlag = async flag => {
44
- if (!featureFlags && !flagsPromise) {
45
- flagsPromise = retrieveTogglesBasedOnEnvironment().then(
46
- flagsFromServer => (featureFlags = flagsFromServer)
47
- );
48
- }
49
-
50
- if (!featureFlags) {
51
- await flagsPromise;
52
- }
53
-
54
- return featureFlags.has(flag);
55
- };
56
-
57
- const getQualificationService = async () => {
58
- const equinoxMarket = (await getConfiguration(["Equinox_Markets"]))
59
- .Equinox_Markets;
60
- return equinoxMarket.active ||
61
- (await checkFlag("cx15_use_new_exclusive_offer_api"))
62
- ? NewQualificationService
63
- : OldQualificationService;
64
- };
65
-
66
39
  /**
67
40
  * NsProductMixin
68
41
  *
@@ -672,25 +645,32 @@ const NsProductMixin = {
672
645
  if (this.product) {
673
646
  // WARNING: There's a instanceof check on CartService.getAddToCartQty for the ns-shop Product, previously different
674
647
  const shopProduct = new ShopProduct(this.product);
675
- // check if a user is qualified to purchase the product
676
- CartService.getAddToCartQty(shopProduct)
677
- .then(productQuantity => {
678
- // WARNING: this.product is volatile here. re-check is using this.product.
679
- this.maxQuantity = Math.min(
680
- shopProduct.maxQuantity,
681
- shopProduct.availableQuantity,
682
- productQuantity
683
- );
684
- })
685
- .catch(error => {
686
- this.maxQuantity = 0;
687
- console.error("Failed to retrieve add to cart quantity.", error);
688
- })
689
- .finally(() => {
690
- this.setStatus();
691
- this.checkedQualifications = true;
692
- this.emitAvailability();
693
- });
648
+
649
+ getConfiguration(["Equinox_Markets"]).then(({ Equinox_Markets }) => {
650
+ const { active } = Equinox_Markets;
651
+
652
+ const cartService = active ? EquinoxCartService : CartService;
653
+ // check if a user is qualified to purchase the product
654
+ cartService
655
+ .getAddToCartQty(shopProduct)
656
+ .then(productQuantity => {
657
+ // WARNING: this.product is volatile here. re-check is using this.product.
658
+ this.maxQuantity = Math.min(
659
+ shopProduct.maxQuantity,
660
+ shopProduct.availableQuantity,
661
+ productQuantity
662
+ );
663
+ })
664
+ .catch(error => {
665
+ this.maxQuantity = 0;
666
+ console.error("Failed to retrieve add to cart quantity.", error);
667
+ })
668
+ .finally(() => {
669
+ this.setStatus();
670
+ this.checkedQualifications = true;
671
+ this.emitAvailability();
672
+ });
673
+ });
694
674
  }
695
675
  },
696
676
 
@@ -755,9 +735,9 @@ const NsProductMixin = {
755
735
  this.exclusiveOfferMessage = "";
756
736
  if (this.isExclusive) {
757
737
  if (this.isLoggedIn) {
758
- const productQualification = await (
759
- await getQualificationService()
760
- ).getQualification(this.activeSku);
738
+ const productQualification = await QualificationService.getQualification(
739
+ this.activeSku
740
+ );
761
741
 
762
742
  let cartQuantity = 0;
763
743
 
@@ -787,10 +767,10 @@ const NsProductMixin = {
787
767
  cartQuantity = (cartItem || {}).qty || 0;
788
768
  } else {
789
769
  const cartData =
790
- (await (
791
- await getQualificationService()
792
- ).convertCartDataToBaseSkus(CartService.getItemData(), true)) ||
793
- {};
770
+ (await QualificationService.convertCartDataToBaseSkus(
771
+ CartService.getItemData(),
772
+ true
773
+ )) || {};
794
774
  const cartItem = cartData[this.baseSku] || {};
795
775
  cartQuantity = cartItem.qty || 0;
796
776
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/product-components",
3
- "version": "3.17.1",
3
+ "version": "3.17.2",
4
4
  "description": "Nu Skin Product Components",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -200,40 +200,11 @@
200
200
  </template>
201
201
 
202
202
  <script>
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";
203
+ import { CartService } from "@nuskin/ns-shop";
204
+ import QualificationService from "@nuskin/exclusive-offer-sdk";
209
205
  import NsProductMixin from "../mixins/NsProductMixin";
210
206
  import "@nuskin/ns-core-styles/src/dist/main.css";
211
207
 
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
-
237
208
  export default {
238
209
  name: "NsProductMixinPreview",
239
210
  filters: {
@@ -407,9 +378,9 @@ export default {
407
378
  async mounted() {
408
379
  if (this.isExclusive) {
409
380
  if (this.isLoggedIn) {
410
- this.productQualification = await (
411
- await getQualificationService()
412
- ).getQualification(this.activeSku);
381
+ this.productQualification = await QualificationService.getQualification(
382
+ this.activeSku
383
+ );
413
384
 
414
385
  this.cartItem = await CartService.getFirstItemBySku(this.activeSku, {
415
386
  cartOrderItems: true