@nuskin/ns-shop 7.0.5-cx1-13272.19 → 7.0.5

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-shop",
3
- "version": "7.0.5-cx1-13272.19",
3
+ "version": "7.0.5",
4
4
  "description": "The description that will amaze and astound your audience when they read it",
5
5
  "main": "src/shop.js",
6
6
  "scripts": {
@@ -1,7 +1,6 @@
1
1
  import {RunConfigService, UrlService, events, storage} from '@nuskin/ns-util';
2
2
  import axios from 'axios';
3
3
  import { UserService } from '@nuskin/ns-account';
4
- // import CheckoutModeService from './checkout/checkoutModeService';
5
4
 
6
5
  export default {
7
6
  init,
@@ -27,8 +26,6 @@ const ACTIVE_EVENT_TTL = ONE_MINUTE * 14;
27
26
  const INITIALIZING = 'initializing';
28
27
  const EXTERNAL_INITIALIZING = 'initializing-external';
29
28
 
30
- // let isGuest = false;
31
-
32
29
  // Contains a map of all event tickets that are stored in localStorage.
33
30
  let eventTicketInfoMap;
34
31
 
@@ -73,7 +70,6 @@ events.subscribe(events.salesevent.INIT_EVENT_TICKET, async (eventName, refresh
73
70
 
74
71
  if (eventName && await _initData()) {
75
72
  if (mktEventConfigMap[eventName]) {
76
- // myAlert(`events.salesevent.INIT_EVENT_TICKET, ${eventName}`);
77
73
  _initEventTicketInfo(eventName, refresh)
78
74
  .catch((err) => {
79
75
  console.error(`Error initializing event ticket for ${eventName}.`, err)
@@ -230,7 +226,6 @@ async function _initEventTicketInfo(eventName, refreshTicket = false) {
230
226
  if (!eventTicketInfo.ticket || refreshTicket) {
231
227
  initInfo.refreshTime = Date.now();
232
228
  await _getRemoteTicket(eventTicketInfo);
233
- // myAlert(`_initEventTicketInfo, ${JSON.stringify(eventTicketInfo)}`);
234
229
  useServerWaitTime = true;
235
230
  }
236
231
  _marketStatusCheck(eventTicketInfo);
@@ -428,7 +423,6 @@ function _getLocalStorageTickets() {
428
423
 
429
424
  Object.keys(localStorage).forEach(lsKey => {
430
425
  if (lsKey.endsWith('-event-ticket')) {
431
- // myAlert(`localStorage ticket, ${lsKey}`);
432
426
  let ticket = getStorageItem(lsKey);
433
427
 
434
428
  if (ticket && ticket.eventName && ticket.ticketId && ticket.status && mktEventConfigMap[ticket.eventName]) {
@@ -786,21 +780,11 @@ function getStorageItem(key) {
786
780
  }
787
781
 
788
782
  async function _checkForMissingTicket(eventName) {
789
- // myAlert(`_checkForMissingTicket1, ${eventName}`);
790
- // myAlert(`_checkForMissingTicket2, ${JSON.stringify(mktEventConfigMap[eventName])}`);
791
- // myAlert(`_checkForMissingTicket3, ${JSON.stringify(eventTicketInfoMap[eventName])}`);
792
783
  if (mktEventConfigMap[eventName] && !eventTicketInfoMap[eventName]) {
793
- // myAlert(`missing ticket for ${eventName}`)
794
784
  await _initEventTicketInfo(eventName);
795
785
  }
796
786
  }
797
787
 
798
- // function myAlert(msg) {
799
- // if (isGuest) {
800
- // alert(msg);
801
- // }
802
- // }
803
-
804
788
  /**
805
789
  * This initializes an interval timer which checks to see if the browser (computer)
806
790
  * went to sleep. It's intention is to update the wait timer if it has.
@@ -836,10 +820,11 @@ async function _initializePolling() {
836
820
  _checkStatus(eventTicketInfo, false);
837
821
  });
838
822
 
839
- if (window.location.pathname === '/static/checkout/checkout.html') {
840
- // check for missing tickets. Only perform on checkout s
823
+ if (window.location.pathname === '/static/checkout/checkout.html' ||
824
+ window.location.pathname === '/static/cart/cart.html'
825
+ ) {
826
+ // check for missing tickets. Only perform on checkout screen
841
827
  const activeEvents = await _getActiveEvents();
842
- // myAlert(`Active Event check, ${JSON.stringify(activeEvents.map(ae => ae.eventName))}`);
843
828
 
844
829
  for (const eventInfo of activeEvents) {
845
830
  await _checkForMissingTicket(eventInfo.eventName);
@@ -971,7 +956,7 @@ function _removeWaitCheck(value) {
971
956
  */
972
957
  async function _loadAwsActiveEvents(country) {
973
958
  let activeEventsName = `${ACTIVE_EVENTS}-${country? country: RunConfigService.getRunConfig().country}`,
974
- storageObj = null, // getStorageItem(activeEventsName),
959
+ storageObj = null,
975
960
  ttl = storageObj ? storageObj.ttl - Date.now() : ACTIVE_EVENT_TTL,
976
961
  eventInfos = {},
977
962
  ok = true;
@@ -983,14 +968,11 @@ async function _loadAwsActiveEvents(country) {
983
968
  * @param eventNames
984
969
  */
985
970
  let addEvents = (eventNames) => {
986
- // myAlert(`addEvents1 ${JSON.stringify(eventNames)}`)
987
971
  eventNames.forEach(_eventName => {
988
972
  let eventName = _eventName.eventName || _eventName;
989
973
 
990
- // myAlert(`addEvents2 ${JSON.stringify(mktEventConfigMap[eventName])}`)
991
974
  if (mktEventConfigMap[eventName]) {
992
975
  eventInfos[eventName] = _createEventTicketInfo(eventName);
993
- // myAlert(`addEvents3 ${JSON.stringify(eventInfos)}`)
994
976
  }
995
977
  });
996
978
  };
@@ -1000,7 +982,6 @@ async function _loadAwsActiveEvents(country) {
1000
982
  storageObj = {events: []};
1001
983
  storage.setItem(activeEventsName, storageObj, {ttl: 250}); // to prevent multiple calls.
1002
984
  try {
1003
- // myAlert(`_loadAwsActiveEvents - no storageObj`)
1004
985
  addEvents(await _getActiveEvents());
1005
986
  } catch (e) {
1006
987
  // an error occurred with the call, clear active events
@@ -1042,27 +1023,19 @@ async function initActiveEvents(country = undefined) {
1042
1023
  }
1043
1024
  })
1044
1025
 
1045
- // myAlert(`initActiveEvents0, ${JSON.stringify(awsEvents)}`)
1046
- // myAlert(`initActiveEvents1, ${JSON.stringify(eventTicketInfoMap)}`)
1047
1026
  eventTicketInfoMap = Object.assign({}, awsEvents, eventTicketInfoMap);
1048
- // myAlert(`initActiveEvents2, ${JSON.stringify(eventTicketInfoMap)}`)
1049
1027
  Object.keys(eventTicketInfoMap).forEach(eventName => {
1050
1028
  if (mktEventConfigMap[eventName] && eventTicketInfoMap[eventName].eventName) {
1051
- // myAlert(`initActiveEvents, ${JSON.stringify(eventTicketInfoMap[eventName])}`)
1052
1029
  promises.push(_initEventTicketInfo(eventName));
1053
1030
  }
1054
1031
  });
1055
1032
  }
1056
1033
 
1057
1034
  return Promise.all(promises).then(async () => {
1058
- // myAlert(`Initial Events, ${[Object.keys(activeEventMap)]}`);
1059
1035
 
1060
1036
  events.setValue(events.salesevent.INITIAL_ACTIVE_EVENTS, [Object.keys(activeEventMap)]);
1061
1037
 
1062
- // If there are event tickets then initialize polling
1063
- // if (Object.keys(eventTicketInfoMap).length > 0 && !country) {
1064
1038
  await _initializePolling();
1065
- // }
1066
1039
  _removeWaitCheck(INITIALIZING);
1067
1040
  });
1068
1041
  }
@@ -1118,13 +1091,7 @@ async function _init(force = true) {
1118
1091
  * If there are, make sure polling is happening, otherwise, stop polling.
1119
1092
  */
1120
1093
  events.subscribe(events.salesevent.ACTIVE_EVENTS, (/*activeEvents*/) => {
1121
- // if (eventTicketInfoMap) {
1122
- // if (Object.keys(eventTicketInfoMap).length > 0) {
1123
1094
  _initializePolling().then(() => console.log('Polling initialized'));
1124
- // } else {
1125
- // _clearPollingInterval();
1126
- // }
1127
- // }
1128
1095
  });
1129
1096
 
1130
1097
  // persistentCartService needs to wait until the following configMaps are loaded
@@ -1139,7 +1106,6 @@ const isSubset = (array1, array2) => {
1139
1106
  const csConfigCallback = async (configs) => {
1140
1107
  if (configs != null && isSubset(configs, neededConfigMaps)) {
1141
1108
  events.unsubscribe(events.global.CS_CONFIG_SET, csConfigCallback);
1142
- // isGuest = CheckoutModeService.isGuestCheckout();
1143
1109
  _init(false).then(() => console.log('salesEventService initialized'));
1144
1110
  }
1145
1111
  }