@nuskin/ns-shop 6.5.0 → 6.6.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 +1 -1
- package/src/cart/cartService.js +29 -2
package/package.json
CHANGED
package/src/cart/cartService.js
CHANGED
|
@@ -14,6 +14,7 @@ import webLoyalty from '@nuskin/ns-loyalty-web';
|
|
|
14
14
|
import axios from 'axios';
|
|
15
15
|
import { getCachedConfigField, getCachedConfiguration, getConfiguration } from '@nuskin/configuration-sdk';
|
|
16
16
|
import equinoxCartService from './equinoxCartService';
|
|
17
|
+
import {retrieveTogglesBasedOnEnvironment} from '@nuskin/ns-feature-flags';
|
|
17
18
|
|
|
18
19
|
export default {
|
|
19
20
|
goToCartPage,
|
|
@@ -90,9 +91,35 @@ const awaitForConfig = async () => {
|
|
|
90
91
|
await getConfiguration(['Cart', 'Checkout']);
|
|
91
92
|
};
|
|
92
93
|
|
|
94
|
+
let flagsPromise = null
|
|
95
|
+
let featureFlags = false
|
|
96
|
+
const checkFlag = async (flag) => {
|
|
97
|
+
if (!featureFlags && !flagsPromise) {
|
|
98
|
+
flagsPromise = retrieveTogglesBasedOnEnvironment().then(flagsFromServer => featureFlags = flagsFromServer)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (!featureFlags) {
|
|
102
|
+
await flagsPromise
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return featureFlags.has(flag)
|
|
106
|
+
}
|
|
107
|
+
checkFlag()
|
|
108
|
+
|
|
93
109
|
const getQualificationService = async () => {
|
|
94
|
-
|
|
95
|
-
|
|
110
|
+
try {
|
|
111
|
+
const [
|
|
112
|
+
flagSet,
|
|
113
|
+
configEnabled
|
|
114
|
+
] = await Promise.all([
|
|
115
|
+
checkFlag('cx15_use_new_exclusive_offer_api'),
|
|
116
|
+
getConfiguration(['Equinox_Markets']).then(configuration => configuration.Equinox_Markets.active)
|
|
117
|
+
])
|
|
118
|
+
return flagSet || configEnabled ? NewQualificationService : OldQualificationService;
|
|
119
|
+
} catch (e) {
|
|
120
|
+
console.error('error retrieving configuration. Defaulting to Legacy exclusive offer service', e)
|
|
121
|
+
return OldQualificationService
|
|
122
|
+
}
|
|
96
123
|
}
|
|
97
124
|
|
|
98
125
|
/**
|