@nuskin/ns-util 3.101.0 → 3.102.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-util",
3
- "version": "3.101.0",
3
+ "version": "3.102.0",
4
4
  "baseURL": "/",
5
5
  "main": "src/util.js",
6
6
  "scripts": {
@@ -10,7 +10,8 @@ const CONTEXT_WHITELIST = [
10
10
  /shopper-account\./, // guest signup
11
11
  /\/personal-offer\./, // personal offer
12
12
  /\/static\//, // all static apps
13
- /\/exclusive-offer\./ // leader preview
13
+ /\/exclusive-offer\./, // leader preview
14
+ /\/catalog\// // catalog/PDP3
14
15
  ];
15
16
  /**
16
17
  *
@@ -1,3 +1,4 @@
1
+ import ConfigService from './configurationService';
1
2
  import storage from "./storage.js";
2
3
 
3
4
  /**
@@ -32,8 +33,38 @@ var publicMethods = {
32
33
  isStorefront: function () {
33
34
  var storefront = publicMethods.getStoreFrontSponsor();
34
35
  return storefront !== null && storefront !== undefined;
36
+ },
37
+ getDisplayName: async function ({source, userId, getAccountInfo} = {}) {
38
+ let name;
39
+
40
+ try {
41
+ if (!source) {
42
+ const marketConfig = ConfigService.getMarketConfig();
43
+ source = marketConfig && marketConfig.storefront ? marketConfig.storefront.userDisplayNameSrc : '';
44
+ }
45
+
46
+ switch (source) {
47
+ case 'accountservice':
48
+ {
49
+ if (userId) {
50
+ const accountInfo = await getAccountInfo(userId);
51
+ if (accountInfo) name = accountInfo.preferredName;
52
+ }
53
+
54
+ break;
55
+ }
56
+ }
57
+ } catch (ex) {
58
+ console.error(ex);
59
+ }
60
+
61
+ if (!name) {
62
+ const sponsor = publicMethods.getStoreFrontSponsor();
63
+ if (sponsor) name = sponsor.displayName;
64
+ }
65
+
66
+ return name;
35
67
  }
36
68
  };
37
69
 
38
70
  export default publicMethods;
39
-