@nuskin/ns-shop 7.0.5-cx1-13272.11 → 7.0.5-cx1-13272.13

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.11",
3
+ "version": "7.0.5-cx1-13272.13",
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,6 +1,7 @@
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';
4
5
 
5
6
  export default {
6
7
  init,
@@ -26,6 +27,8 @@ const ACTIVE_EVENT_TTL = ONE_MINUTE * 14;
26
27
  const INITIALIZING = 'initializing';
27
28
  const EXTERNAL_INITIALIZING = 'initializing-external';
28
29
 
30
+ let isGuest = false;
31
+
29
32
  // Contains a map of all event tickets that are stored in localStorage.
30
33
  let eventTicketInfoMap;
31
34
 
@@ -528,7 +531,7 @@ async function _getRemoteTicket(eventTicketInfo) {
528
531
  response = await axios({
529
532
  method: method,
530
533
  url: `${_getAwsUrl(eventName, ticketId)}${seParams}`,
531
- headers: _getHeaders(),
534
+ headers: _getHeaders(method === 'GET' ? true : false),
532
535
  timeout: 7000
533
536
  });
534
537
 
@@ -643,11 +646,14 @@ function _getAwsUrl(eventName, ticketId) {
643
646
  * @returns {{Accept: string, "Content-Type": string, client_id: *}}
644
647
  * @private
645
648
  */
646
- function _getHeaders() {
649
+ function _getHeaders(noCache = false) {
647
650
  return {
648
651
  'Accept': 'application/json',
649
652
  'Content-Type': 'application/json',
650
- 'client_id': RunConfigService.getRunConfig().clientId
653
+ 'client_id': RunConfigService.getRunConfig().clientId,
654
+ ...(noCache && {'Cache-Control': 'no-cache'}),
655
+ ...(noCache && {'Pragma': 'no-cache'}),
656
+ ...(noCache && {'Expires': '0'})
651
657
  };
652
658
  }
653
659
 
@@ -655,7 +661,7 @@ async function _getActiveEvents() {
655
661
  let response = await axios({
656
662
  method: 'GET',
657
663
  url: `${_getAwsUrl()}?activeWithin=${ACTIVE_EVENT_WITHIN}`,
658
- headers: _getHeaders()
664
+ headers: _getHeaders(true)
659
665
  });
660
666
  return response.data.salesEventResponse
661
667
  }
@@ -736,7 +742,7 @@ async function _loadMarketEventConfig(force, country=undefined) {
736
742
  const response = await axios({
737
743
  method: 'GET',
738
744
  url: `${_getAwsUrl()}`,
739
- headers: _getHeaders()
745
+ headers: _getHeaders(true)
740
746
  });
741
747
  const salesEvents = response.data.salesEventResponse || [];
742
748
  mktEventConfigMap = {};
@@ -785,7 +791,7 @@ async function _checkForMissingTicket(eventName) {
785
791
  }
786
792
 
787
793
  function myAlert(msg) {
788
- if (window.ReactNativeWebView) {
794
+ if (isGuest) {
789
795
  alert(msg);
790
796
  }
791
797
  }
@@ -832,7 +838,7 @@ async function _initializePolling() {
832
838
  if (window.location.pathname === '/static/checkout/checkout.html') {
833
839
  // check for missing tickets. Only perform on checkout s
834
840
  const activeEvents = await _getActiveEvents();
835
- myAlert(`Active Event check, ${activeEventMap}`);
841
+ myAlert(`Active Event check, ${JSON.stringify(activeEventMap)}`);
836
842
 
837
843
  for (const eventInfo of activeEvents) {
838
844
  await _checkForMissingTicket(eventInfo.eventName);
@@ -1038,7 +1044,6 @@ async function initActiveEvents(country = undefined) {
1038
1044
 
1039
1045
  // If there are event tickets then initialize polling
1040
1046
  // if (Object.keys(eventTicketInfoMap).length > 0 && !country) {
1041
- // Test
1042
1047
  await _initializePolling();
1043
1048
  // }
1044
1049
  _removeWaitCheck(INITIALIZING);
@@ -1117,6 +1122,8 @@ const isSubset = (array1, array2) => {
1117
1122
  const csConfigCallback = async (configs) => {
1118
1123
  if (configs != null && isSubset(configs, neededConfigMaps)) {
1119
1124
  events.unsubscribe(events.global.CS_CONFIG_SET, csConfigCallback);
1125
+ isGuest = CheckoutModeService.isGuestCheckout();
1126
+ if (isGuest) alert(`isGuest ${isGuest}`)
1120
1127
  _init(false).then(() => console.log('salesEventService initialized'));
1121
1128
  }
1122
1129
  }