@nuskin/product-components 2.20.2 → 3.0.3
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/CHANGELOG.md +33 -0
- package/components/NsPayPalPayLater.vue +17 -11
- package/components/NsProductCardBase.vue +0 -1
- package/components/NsProductDetail.vue +43 -0
- package/components/NsProductDetailBase.vue +1 -39
- package/components/NsProductList.vue +6 -14
- package/components/NsProductListSortable.vue +8 -22
- package/index.js +2 -0
- package/mixins/NsProductMixin.js +43 -188
- package/package.json +1 -1
- package/services/NsProductDataService.js +1 -5
- package/services/NsProductFeatureFlagsService.js +0 -4
- package/stories/NsProductDetail.stories.js +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,36 @@
|
|
|
1
|
+
## [3.0.3](https://code.tls.nuskin.io/ns-am/ux/product-components/compare/v3.0.2...v3.0.3) (2022-02-09)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Fix
|
|
5
|
+
|
|
6
|
+
* [NsProductDetail] Send analytics whenever title changes (now sent when variant is selected) (#CX12-4270) ([b21973f](https://code.tls.nuskin.io/ns-am/ux/product-components/commit/b21973f36aa13963b2bd3f8a0cfab29e158f13e2)), closes [#CX12-4270](https://code.tls.nuskin.io/ns-am/ux/product-components/issues/CX12-4270)
|
|
7
|
+
* Add cx.config ([d887042](https://code.tls.nuskin.io/ns-am/ux/product-components/commit/d8870428055cb63d24150e3388d12f99e2c91ef5))
|
|
8
|
+
|
|
9
|
+
## [3.0.2](https://code.tls.nuskin.io/ns-am/ux/product-components/compare/v3.0.1...v3.0.2) (2021-09-29)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Fix
|
|
13
|
+
|
|
14
|
+
* updates to paypal pay later component to set buyercountry, other cleanup (#CX12-4269) ([b6be36e](https://code.tls.nuskin.io/ns-am/ux/product-components/commit/b6be36e35cb5e4b2a1b8eec9bd40a16a96c66720)), closes [#CX12-4269](https://code.tls.nuskin.io/ns-am/ux/product-components/issues/CX12-4269)
|
|
15
|
+
|
|
16
|
+
## [3.0.1](https://code.tls.nuskin.io/ns-am/ux/product-components/compare/v3.0.0...v3.0.1) (2021-09-21)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Chore
|
|
20
|
+
|
|
21
|
+
* updated storybook versions (#CX12-3362) ([846083d](https://code.tls.nuskin.io/ns-am/ux/product-components/commit/846083d55b345b31e7f453ed84cd4acb1187825e)), closes [#CX12-3362](https://code.tls.nuskin.io/ns-am/ux/product-components/issues/CX12-3362)
|
|
22
|
+
|
|
23
|
+
### Fix
|
|
24
|
+
|
|
25
|
+
* hide adr price by unsetting when adr type not in supported order types (#CX12-4239) ([bc543cc](https://code.tls.nuskin.io/ns-am/ux/product-components/commit/bc543cc5d11326f11c7dc1ccbef4edea57a126ca)), closes [#CX12-4239](https://code.tls.nuskin.io/ns-am/ux/product-components/issues/CX12-4239)
|
|
26
|
+
|
|
27
|
+
# [3.0.0](https://code.tls.nuskin.io/ns-am/ux/product-components/compare/v2.20.2...v3.0.0) (2021-08-25)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
### Breaking
|
|
31
|
+
|
|
32
|
+
* removed feature flag to toggle useProductData on/off, related code adjustments (#CX12-3362) ([df56364](https://code.tls.nuskin.io/ns-am/ux/product-components/commit/df56364d9f883d87212e0108627a5b5b9f470114)), closes [#CX12-3362](https://code.tls.nuskin.io/ns-am/ux/product-components/issues/CX12-3362)
|
|
33
|
+
|
|
1
34
|
## [2.20.2](https://code.tls.nuskin.io/ns-am/ux/product-components/compare/v2.20.1...v2.20.2) (2021-08-17)
|
|
2
35
|
|
|
3
36
|
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
<div v-if="show" :class="$style.container">
|
|
3
3
|
<div
|
|
4
4
|
data-pp-message
|
|
5
|
+
:data-pp-buyerCountry="runConfig.country"
|
|
5
6
|
:data-pp-amount="amount"
|
|
6
7
|
:data-pp-placement="placement"
|
|
7
8
|
:data-pp-style-text-size="textSize"
|
|
@@ -16,8 +17,6 @@ import Vue from "vue";
|
|
|
16
17
|
import axios from "axios";
|
|
17
18
|
import LoadScript from "vue-plugin-load-script";
|
|
18
19
|
|
|
19
|
-
import { RunConfigService, ConfigService } from "@nuskin/ns-util";
|
|
20
|
-
|
|
21
20
|
Vue.use(LoadScript);
|
|
22
21
|
|
|
23
22
|
export default {
|
|
@@ -48,15 +47,25 @@ export default {
|
|
|
48
47
|
},
|
|
49
48
|
data() {
|
|
50
49
|
return {
|
|
50
|
+
buyerCountry: "",
|
|
51
51
|
payPalClientId: ""
|
|
52
52
|
};
|
|
53
53
|
},
|
|
54
54
|
computed: {
|
|
55
|
+
runConfig() {
|
|
56
|
+
return this.$NsProductAppService.runConfig;
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
marketConfig() {
|
|
60
|
+
return this.$NsProductAppService.marketConfig;
|
|
61
|
+
},
|
|
62
|
+
|
|
55
63
|
payPalComponentsSrc() {
|
|
56
64
|
return `https://www.paypal.com/sdk/js?client-id=${this.payPalClientId}&components=messages`;
|
|
57
65
|
},
|
|
66
|
+
|
|
58
67
|
show() {
|
|
59
|
-
return !!
|
|
68
|
+
return !!this.runConfig && !!this.payPalClientId && !!this.amount;
|
|
60
69
|
}
|
|
61
70
|
},
|
|
62
71
|
watch: {
|
|
@@ -86,12 +95,9 @@ export default {
|
|
|
86
95
|
*/
|
|
87
96
|
async getPayPalClientId() {
|
|
88
97
|
try {
|
|
89
|
-
const
|
|
90
|
-
const marketConfig = ConfigService.getMarketConfig();
|
|
91
|
-
|
|
92
|
-
const lambdaUrl = `${marketConfig.awsUrl}/PaymentPaypal/v1/client-id/${runConfig.country}`;
|
|
98
|
+
const lambdaUrl = `${this.marketConfig.awsUrl}/PaymentPaypal/v1/client-id/${this.runConfig.country}`;
|
|
93
99
|
const lambdaResponse = await axios.get(lambdaUrl, {
|
|
94
|
-
headers: this.getRequestHeaders(
|
|
100
|
+
headers: this.getRequestHeaders()
|
|
95
101
|
});
|
|
96
102
|
const lambdaData = this.processLambdaResponse(lambdaResponse);
|
|
97
103
|
|
|
@@ -122,11 +128,11 @@ export default {
|
|
|
122
128
|
* @returns {{Content-Type: string, client_id: string, client_secret: string}}
|
|
123
129
|
* @private
|
|
124
130
|
*/
|
|
125
|
-
getRequestHeaders(
|
|
131
|
+
getRequestHeaders() {
|
|
126
132
|
return {
|
|
127
133
|
"Content-Type": "application/json",
|
|
128
|
-
client_id: marketConfig.checkout.clientId,
|
|
129
|
-
client_secret: marketConfig.checkout.clientSecret
|
|
134
|
+
client_id: this.marketConfig.checkout.clientId,
|
|
135
|
+
client_secret: this.marketConfig.checkout.clientSecret
|
|
130
136
|
};
|
|
131
137
|
},
|
|
132
138
|
|
|
@@ -79,6 +79,7 @@
|
|
|
79
79
|
<script>
|
|
80
80
|
import NsProductDetailBase from "./NsProductDetailBase.vue";
|
|
81
81
|
import NsProductMixin from "../mixins/NsProductMixin.js";
|
|
82
|
+
import { events } from "@nuskin/ns-util";
|
|
82
83
|
|
|
83
84
|
/**
|
|
84
85
|
* NsProductDetail
|
|
@@ -132,6 +133,48 @@ export default {
|
|
|
132
133
|
loadFirstVariant: true,
|
|
133
134
|
referrer: "productPage"
|
|
134
135
|
};
|
|
136
|
+
},
|
|
137
|
+
watch: {
|
|
138
|
+
title() {
|
|
139
|
+
this.sendAnalytics();
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
methods: {
|
|
143
|
+
sendAnalytics() {
|
|
144
|
+
let tries = 0;
|
|
145
|
+
this.analyticsInterval = setInterval(() => {
|
|
146
|
+
if (window.dataLayer && window.ga && window.ga.loaded) {
|
|
147
|
+
const impression = {
|
|
148
|
+
event: events.shop.PRODUCT_IMPRESSION_DETAIL,
|
|
149
|
+
ecommerce: {
|
|
150
|
+
detail: {
|
|
151
|
+
products: [
|
|
152
|
+
{
|
|
153
|
+
id: this.activeSku,
|
|
154
|
+
name: this.title
|
|
155
|
+
// TODO: uncomment below when these fields are available (contentstack is up)
|
|
156
|
+
// category: this.category,
|
|
157
|
+
// brand: this.brand,
|
|
158
|
+
// variant: this.variant
|
|
159
|
+
}
|
|
160
|
+
]
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
window.dataLayer.push(impression);
|
|
165
|
+
clearInterval(this.analyticsInterval);
|
|
166
|
+
this.analyticsInterval = null;
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
tries += 1;
|
|
171
|
+
|
|
172
|
+
if (tries > 50) {
|
|
173
|
+
clearInterval(this.analyticsInterval);
|
|
174
|
+
this.analyticsInterval = null;
|
|
175
|
+
}
|
|
176
|
+
}, 200);
|
|
177
|
+
}
|
|
135
178
|
}
|
|
136
179
|
};
|
|
137
180
|
</script>
|
|
@@ -364,7 +364,6 @@
|
|
|
364
364
|
|
|
365
365
|
<script>
|
|
366
366
|
import { NsIcon } from "@nuskin/design-components";
|
|
367
|
-
import { events } from "@nuskin/ns-util";
|
|
368
367
|
import NsImage from "./NsImage.vue";
|
|
369
368
|
import NsProductDetailCarousel from "./NsProductDetailCarousel.vue";
|
|
370
369
|
import NsProductVariantSelector from "./NsProductVariantSelector.vue";
|
|
@@ -706,9 +705,7 @@ export default {
|
|
|
706
705
|
}
|
|
707
706
|
}
|
|
708
707
|
},
|
|
709
|
-
mounted() {
|
|
710
|
-
this.sendAnalytics();
|
|
711
|
-
},
|
|
708
|
+
mounted() {},
|
|
712
709
|
destroyed() {
|
|
713
710
|
if (this.analyticsInterval) {
|
|
714
711
|
clearInterval(this.analyticsInterval);
|
|
@@ -906,41 +903,6 @@ export default {
|
|
|
906
903
|
}
|
|
907
904
|
|
|
908
905
|
return data;
|
|
909
|
-
},
|
|
910
|
-
sendAnalytics() {
|
|
911
|
-
let tries = 0;
|
|
912
|
-
this.analyticsInterval = setInterval(() => {
|
|
913
|
-
if (window.dataLayer && window.ga && window.ga.loaded) {
|
|
914
|
-
const impression = {
|
|
915
|
-
event: events.shop.PRODUCT_IMPRESSION_DETAIL,
|
|
916
|
-
ecommerce: {
|
|
917
|
-
detail: {
|
|
918
|
-
products: [
|
|
919
|
-
{
|
|
920
|
-
id: this.sku,
|
|
921
|
-
name: this.title
|
|
922
|
-
// TODO: uncomment below when these fields are available (contentstack is up)
|
|
923
|
-
// category: this.category,
|
|
924
|
-
// brand: this.brand,
|
|
925
|
-
// variant: this.variant
|
|
926
|
-
}
|
|
927
|
-
]
|
|
928
|
-
}
|
|
929
|
-
}
|
|
930
|
-
};
|
|
931
|
-
window.dataLayer.push(impression);
|
|
932
|
-
clearInterval(this.analyticsInterval);
|
|
933
|
-
this.analyticsInterval = null;
|
|
934
|
-
return;
|
|
935
|
-
}
|
|
936
|
-
|
|
937
|
-
tries += 1;
|
|
938
|
-
|
|
939
|
-
if (tries > 50) {
|
|
940
|
-
clearInterval(this.analyticsInterval);
|
|
941
|
-
this.analyticsInterval = null;
|
|
942
|
-
}
|
|
943
|
-
}, 200);
|
|
944
906
|
}
|
|
945
907
|
}
|
|
946
908
|
};
|
|
@@ -145,17 +145,11 @@ export default {
|
|
|
145
145
|
displayedSkus() {
|
|
146
146
|
return this.showSpinner ? this.limitedSkusFrozen : this.limitedSkus;
|
|
147
147
|
},
|
|
148
|
-
useProductData() {
|
|
149
|
-
return this.$NsProductFeatureFlagsService.useProductData;
|
|
150
|
-
},
|
|
151
148
|
showSpinner() {
|
|
152
|
-
return (
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
batch =>
|
|
156
|
-
!["success", "failed"].includes(batch.status) &&
|
|
157
|
-
batch.skus.some(batchSku => this.limitedSkus.includes(batchSku))
|
|
158
|
-
)
|
|
149
|
+
return this.$NsProductDataService.batches.some(
|
|
150
|
+
batch =>
|
|
151
|
+
!["success", "failed"].includes(batch.status) &&
|
|
152
|
+
batch.skus.some(batchSku => this.limitedSkus.includes(batchSku))
|
|
159
153
|
);
|
|
160
154
|
},
|
|
161
155
|
showLoadMore() {
|
|
@@ -170,7 +164,7 @@ export default {
|
|
|
170
164
|
limitedSkus: {
|
|
171
165
|
immediate: true,
|
|
172
166
|
handler(skus) {
|
|
173
|
-
if (
|
|
167
|
+
if (!this.$NsProductDataService.check(skus)) {
|
|
174
168
|
this.$NsProductDataService.queue(skus);
|
|
175
169
|
}
|
|
176
170
|
}
|
|
@@ -184,9 +178,7 @@ export default {
|
|
|
184
178
|
this.$emit("product-update", product);
|
|
185
179
|
},
|
|
186
180
|
loadMoreSkus(event) {
|
|
187
|
-
|
|
188
|
-
this.limitedSkusFrozen = this.limitedSkus;
|
|
189
|
-
}
|
|
181
|
+
this.limitedSkusFrozen = this.limitedSkus;
|
|
190
182
|
|
|
191
183
|
event.target.blur();
|
|
192
184
|
this.skusLimit += this.skusPerLoad;
|
|
@@ -155,12 +155,8 @@ export default {
|
|
|
155
155
|
return option.id !== "bestMatch" || !!this.skuSearchScores;
|
|
156
156
|
});
|
|
157
157
|
},
|
|
158
|
-
useProductData() {
|
|
159
|
-
return this.$NsProductFeatureFlagsService.useProductData;
|
|
160
|
-
},
|
|
161
158
|
showSpinnerOnFirstLoad() {
|
|
162
159
|
return (
|
|
163
|
-
this.useProductData &&
|
|
164
160
|
this.sortedSkus.length <= this.skusPerLoad &&
|
|
165
161
|
this.$NsProductDataService.batches.some(
|
|
166
162
|
batch =>
|
|
@@ -170,15 +166,10 @@ export default {
|
|
|
170
166
|
);
|
|
171
167
|
},
|
|
172
168
|
productCount() {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
return productsFound.length;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
// without all the product data loaded, unknown how many skus are valid until they are loaded
|
|
181
|
-
return this.sortedSkus.length;
|
|
169
|
+
const productsFound = this.$NsProductDataService.findProducts(
|
|
170
|
+
this.sortedSkus
|
|
171
|
+
);
|
|
172
|
+
return productsFound.length;
|
|
182
173
|
},
|
|
183
174
|
productCountLabel() {
|
|
184
175
|
return this.productsLabel.replace(PRODUCT_COUNT, this.productCount);
|
|
@@ -262,10 +253,7 @@ export default {
|
|
|
262
253
|
},
|
|
263
254
|
|
|
264
255
|
sortSelect(value) {
|
|
265
|
-
if (
|
|
266
|
-
this.useProductData &&
|
|
267
|
-
!this.$NsProductDataService.check(this.localSkus)
|
|
268
|
-
) {
|
|
256
|
+
if (!this.$NsProductDataService.check(this.localSkus)) {
|
|
269
257
|
this.$NsProductDataService.queue(this.localSkus);
|
|
270
258
|
}
|
|
271
259
|
|
|
@@ -289,11 +277,9 @@ export default {
|
|
|
289
277
|
const sort = sortOption.sort;
|
|
290
278
|
const order = sortOption.order;
|
|
291
279
|
|
|
292
|
-
const products = this
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
.reduce((a, p) => ({ ...a, [p.sku]: p }), {})
|
|
296
|
-
: this.products;
|
|
280
|
+
const products = this.$NsProductDataService
|
|
281
|
+
.findProducts(this.localSkus, false)
|
|
282
|
+
.reduce((a, p) => ({ ...a, [p.sku]: p }), {});
|
|
297
283
|
|
|
298
284
|
const sortedSkus = [...this.localSkus].sort((x, y) => {
|
|
299
285
|
//make sure to get sku
|
package/index.js
CHANGED
|
@@ -23,6 +23,7 @@ import NsProductDataService from "./services/NsProductDataService";
|
|
|
23
23
|
|
|
24
24
|
import NsProductMixin from "./mixins/NsProductMixin.js";
|
|
25
25
|
|
|
26
|
+
import NsPayPalPayLater from "./components/NsPayPalPayLater.vue";
|
|
26
27
|
import NsProductCardBase from "./components/NsProductCardBase.vue";
|
|
27
28
|
import NsProductCard from "./components/NsProductCard.vue";
|
|
28
29
|
import NsProductDetailBase from "./components/NsProductDetailBase.vue";
|
|
@@ -41,6 +42,7 @@ export {
|
|
|
41
42
|
// Mixins
|
|
42
43
|
NsProductMixin,
|
|
43
44
|
// Components
|
|
45
|
+
NsPayPalPayLater,
|
|
44
46
|
NsProductCardBase,
|
|
45
47
|
NsProductCard,
|
|
46
48
|
NsProductDetailBase,
|
package/mixins/NsProductMixin.js
CHANGED
|
@@ -9,9 +9,7 @@ import {
|
|
|
9
9
|
UrlService
|
|
10
10
|
} from "@nuskin/ns-util";
|
|
11
11
|
import {
|
|
12
|
-
ProductService,
|
|
13
12
|
CartService,
|
|
14
|
-
OrderType,
|
|
15
13
|
AdrService,
|
|
16
14
|
FavoritesService,
|
|
17
15
|
ProductStatus,
|
|
@@ -19,8 +17,8 @@ import {
|
|
|
19
17
|
Product as ShopProduct
|
|
20
18
|
} from "@nuskin/ns-shop";
|
|
21
19
|
import webLoyalty from "@nuskin/ns-loyalty-web";
|
|
22
|
-
import { getProp
|
|
23
|
-
import {
|
|
20
|
+
import { getProp } from "@nuskin/ns-common-lib";
|
|
21
|
+
import { PriceType } from "@nuskin/ns-product-lib";
|
|
24
22
|
|
|
25
23
|
//const PRODUCT_SMALL_VARIANT = "product-card.selected-variant";
|
|
26
24
|
const PENDING_FAVORITE = "pendingFavorite";
|
|
@@ -148,7 +146,6 @@ const NsProductMixin = {
|
|
|
148
146
|
*/
|
|
149
147
|
isFavorite: false,
|
|
150
148
|
isSale: false,
|
|
151
|
-
isStatusSet: false,
|
|
152
149
|
/**
|
|
153
150
|
* Exclusive offer text determined by user logged in and status.
|
|
154
151
|
*/
|
|
@@ -180,10 +177,6 @@ const NsProductMixin = {
|
|
|
180
177
|
* Active poduct data
|
|
181
178
|
*/
|
|
182
179
|
product: undefined,
|
|
183
|
-
/**
|
|
184
|
-
* Determines if Product Status has been handled for the active sku
|
|
185
|
-
*/
|
|
186
|
-
productStatusResults: [],
|
|
187
180
|
/**
|
|
188
181
|
* Quantity of product selected
|
|
189
182
|
*/
|
|
@@ -204,7 +197,6 @@ const NsProductMixin = {
|
|
|
204
197
|
variants: [],
|
|
205
198
|
|
|
206
199
|
featureFlags: this.$NsProductFeatureFlagsService.featureFlags,
|
|
207
|
-
useProductData: this.$NsProductFeatureFlagsService.useProductData,
|
|
208
200
|
|
|
209
201
|
activeSalesEvents: []
|
|
210
202
|
};
|
|
@@ -273,12 +265,28 @@ const NsProductMixin = {
|
|
|
273
265
|
showPriceLabels() {
|
|
274
266
|
return this.marketConfig.showPriceLabels;
|
|
275
267
|
},
|
|
268
|
+
orderTypes() {
|
|
269
|
+
return (this.product || {}).orderTypes || {};
|
|
270
|
+
},
|
|
271
|
+
hasOrderTypeOrder() {
|
|
272
|
+
// !!this.orderTypes[OrderType.ORDER] doesn't work with change detection
|
|
273
|
+
return !!this.orderTypes.order;
|
|
274
|
+
},
|
|
275
|
+
hasOrderTypeAdr() {
|
|
276
|
+
// !!this.orderTypes[OrderType.ADR] doesn't work with change detection
|
|
277
|
+
return !!this.orderTypes.adr;
|
|
278
|
+
},
|
|
279
|
+
/**
|
|
280
|
+
* Show ADR pricing (if not the same) and add to cart, not to be confused with showAdrPrice (used to force the ADR Price to show even if same)
|
|
281
|
+
*/
|
|
282
|
+
showAdr() {
|
|
283
|
+
return !this.hideAdr && this.hasOrderTypeAdr;
|
|
284
|
+
},
|
|
285
|
+
/**
|
|
286
|
+
* Show ADR pricing and add to cart instead of standard pricing
|
|
287
|
+
*/
|
|
276
288
|
showAdrOnly() {
|
|
277
|
-
return
|
|
278
|
-
(this.adrHasPriority && ((this.product || {}).orderTypes || {}).adr) ||
|
|
279
|
-
(((this.product || {}).orderTypes || {}).adr &&
|
|
280
|
-
!((this.product || {}).orderTypes || {}).order)
|
|
281
|
-
);
|
|
289
|
+
return this.showAdr && (this.adrHasPriority || !this.hasOrderTypeOrder);
|
|
282
290
|
}
|
|
283
291
|
},
|
|
284
292
|
watch: {
|
|
@@ -295,11 +303,6 @@ const NsProductMixin = {
|
|
|
295
303
|
},
|
|
296
304
|
hideAdrOverride() {
|
|
297
305
|
this.setHideAdr();
|
|
298
|
-
},
|
|
299
|
-
useProductData(newValue, oldValue) {
|
|
300
|
-
if (newValue !== oldValue) {
|
|
301
|
-
this.refreshProductData(this.activeSku);
|
|
302
|
-
}
|
|
303
306
|
}
|
|
304
307
|
},
|
|
305
308
|
async mounted() {
|
|
@@ -332,12 +335,9 @@ const NsProductMixin = {
|
|
|
332
335
|
}
|
|
333
336
|
|
|
334
337
|
this.resetProductData(sku);
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
} else {
|
|
339
|
-
await this.refreshProductDataManually(sku);
|
|
340
|
-
}
|
|
338
|
+
|
|
339
|
+
this.activeSku = sku;
|
|
340
|
+
this.setFromProductData(sku);
|
|
341
341
|
},
|
|
342
342
|
|
|
343
343
|
setFromProductData(sku, product) {
|
|
@@ -369,8 +369,6 @@ const NsProductMixin = {
|
|
|
369
369
|
this.product = product;
|
|
370
370
|
}
|
|
371
371
|
|
|
372
|
-
this.isStatusSet = true;
|
|
373
|
-
|
|
374
372
|
this.appendTranslations({
|
|
375
373
|
variantType: product.variantType,
|
|
376
374
|
variantDropdownLabel: product.variantDropdownLabel,
|
|
@@ -380,74 +378,6 @@ const NsProductMixin = {
|
|
|
380
378
|
this.setActiveProduct();
|
|
381
379
|
},
|
|
382
380
|
|
|
383
|
-
async refreshProductDataManually(sku) {
|
|
384
|
-
try {
|
|
385
|
-
ProductService.getProductData(sku)
|
|
386
|
-
.then(productData => {
|
|
387
|
-
if (isNullOrEmpty(productData)) {
|
|
388
|
-
return;
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
let product = new Product({ sku: sku });
|
|
392
|
-
product.setProductData(productData);
|
|
393
|
-
|
|
394
|
-
if (product.isVariant()) {
|
|
395
|
-
this.activeSku = sku;
|
|
396
|
-
this.refreshProductDataManually(product.baseSku);
|
|
397
|
-
return;
|
|
398
|
-
} else if (product.isBase()) {
|
|
399
|
-
this.baseSku = sku;
|
|
400
|
-
this.variants = product.getVariantsList();
|
|
401
|
-
this.baseProduct = product;
|
|
402
|
-
|
|
403
|
-
if (
|
|
404
|
-
this.activeSku === sku &&
|
|
405
|
-
this.loadFirstVariant &&
|
|
406
|
-
this.variants.length > 0
|
|
407
|
-
) {
|
|
408
|
-
this.activeSku = this.variants[0].sku;
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
for (const variant of this.variants) {
|
|
412
|
-
events.publish(
|
|
413
|
-
events.shop.ADD_SKU_PRODUCT_STATUS_QUEUE,
|
|
414
|
-
variant.sku
|
|
415
|
-
);
|
|
416
|
-
}
|
|
417
|
-
} else {
|
|
418
|
-
this.activeSku = sku;
|
|
419
|
-
this.variants = [];
|
|
420
|
-
this.product = product;
|
|
421
|
-
events.publish(
|
|
422
|
-
events.shop.ADD_SKU_PRODUCT_STATUS_QUEUE,
|
|
423
|
-
this.activeSku
|
|
424
|
-
);
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
this.appendTranslations({
|
|
428
|
-
variantType: product.variantType,
|
|
429
|
-
variantDropdownLabel: product.variantDropdownLabel,
|
|
430
|
-
variantDropdownPlaceholder: product.variantDropdownPlaceholder
|
|
431
|
-
});
|
|
432
|
-
|
|
433
|
-
this.setActiveProduct();
|
|
434
|
-
})
|
|
435
|
-
.catch(error => {
|
|
436
|
-
this.disable();
|
|
437
|
-
console.error(
|
|
438
|
-
`Failed to retrieve product data. Sku: ${sku}, Error: `,
|
|
439
|
-
error
|
|
440
|
-
);
|
|
441
|
-
});
|
|
442
|
-
} catch (error) {
|
|
443
|
-
this.disable();
|
|
444
|
-
console.error(
|
|
445
|
-
`Failed to retrieve product data manually. Sku: ${sku}, Error: `,
|
|
446
|
-
error
|
|
447
|
-
);
|
|
448
|
-
}
|
|
449
|
-
},
|
|
450
|
-
|
|
451
381
|
async setLoyalty() {
|
|
452
382
|
this.hideLoyalty =
|
|
453
383
|
PersonalOfferStorageService.isPersonalOffer() ||
|
|
@@ -590,10 +520,6 @@ const NsProductMixin = {
|
|
|
590
520
|
},
|
|
591
521
|
|
|
592
522
|
handleProductChanged(product) {
|
|
593
|
-
if (!this.useProductData) {
|
|
594
|
-
return;
|
|
595
|
-
}
|
|
596
|
-
|
|
597
523
|
const baseProductChanged =
|
|
598
524
|
product.isBase() &&
|
|
599
525
|
(this.baseSku === product.sku ||
|
|
@@ -641,11 +567,7 @@ const NsProductMixin = {
|
|
|
641
567
|
this.statusMessage = "";
|
|
642
568
|
this.statusMessageKey = "";
|
|
643
569
|
|
|
644
|
-
if (
|
|
645
|
-
!this.product ||
|
|
646
|
-
this.isBaseSku ||
|
|
647
|
-
(!this.useProductData && !this.isStatusSet)
|
|
648
|
-
) {
|
|
570
|
+
if (!this.product || this.isBaseSku) {
|
|
649
571
|
this.disable();
|
|
650
572
|
return;
|
|
651
573
|
}
|
|
@@ -764,7 +686,9 @@ const NsProductMixin = {
|
|
|
764
686
|
this.adrPriceType = this.isWholesale
|
|
765
687
|
? PriceType.WADW
|
|
766
688
|
: this.getAdrPriceType();
|
|
767
|
-
this.adrPrice = this.
|
|
689
|
+
this.adrPrice = this.showAdr
|
|
690
|
+
? this.product.getPricing(this.adrPriceType)
|
|
691
|
+
: "";
|
|
768
692
|
|
|
769
693
|
// check if sales event
|
|
770
694
|
this.eventName = this.product.eventName;
|
|
@@ -894,7 +818,7 @@ const NsProductMixin = {
|
|
|
894
818
|
* Adds product to cart
|
|
895
819
|
*/
|
|
896
820
|
handleAddToCart() {
|
|
897
|
-
if (!this.disableAddToCart
|
|
821
|
+
if (!this.disableAddToCart) {
|
|
898
822
|
window.sessionStorage.setItem("nstoast-allowed", "true");
|
|
899
823
|
|
|
900
824
|
let countryCode = CartService.getCartProperty("cntryCd") || "";
|
|
@@ -905,9 +829,7 @@ const NsProductMixin = {
|
|
|
905
829
|
qty: this.selectedQuantity,
|
|
906
830
|
userId: this.userId,
|
|
907
831
|
cntryCd: countryCode,
|
|
908
|
-
adr:
|
|
909
|
-
!!this.product.orderTypes[OrderType.ADR] &&
|
|
910
|
-
!this.product.orderTypes[OrderType.ORDER],
|
|
832
|
+
adr: this.showAdrOnly,
|
|
911
833
|
referrer: this.referrer,
|
|
912
834
|
domain: window.location.hostname
|
|
913
835
|
};
|
|
@@ -930,7 +852,7 @@ const NsProductMixin = {
|
|
|
930
852
|
* Adds product to subscription order
|
|
931
853
|
*/
|
|
932
854
|
handleAddToAdr() {
|
|
933
|
-
if (!this.disableAddToAdr
|
|
855
|
+
if (!this.disableAddToAdr) {
|
|
934
856
|
let options = {
|
|
935
857
|
sku: this.activeSku,
|
|
936
858
|
qty: this.selectedQuantity,
|
|
@@ -1036,9 +958,8 @@ const NsProductMixin = {
|
|
|
1036
958
|
},
|
|
1037
959
|
|
|
1038
960
|
checkAddToCartAndAdr() {
|
|
1039
|
-
|
|
1040
|
-
this.
|
|
1041
|
-
this.disableAddToAdr = this.hideAdr || !this.product.orderTypes.adr;
|
|
961
|
+
this.disableAddToCart = this.showAdrOnly || !this.hasOrderTypeOrder;
|
|
962
|
+
this.disableAddToAdr = !this.showAdr;
|
|
1042
963
|
},
|
|
1043
964
|
|
|
1044
965
|
/**
|
|
@@ -1056,80 +977,17 @@ const NsProductMixin = {
|
|
|
1056
977
|
* Handle product status events
|
|
1057
978
|
*/
|
|
1058
979
|
handleProductStatus(results) {
|
|
1059
|
-
|
|
1060
|
-
this.$NsProductDataService.handleProductStatus(results);
|
|
1061
|
-
return;
|
|
1062
|
-
}
|
|
1063
|
-
|
|
1064
|
-
if (!this.product || this.useProductData) {
|
|
1065
|
-
return;
|
|
1066
|
-
}
|
|
1067
|
-
|
|
1068
|
-
results.forEach(async productStatusResult => {
|
|
1069
|
-
if (this.isBaseSku || this.isVariantSku) {
|
|
1070
|
-
const variant = this.variants.find(
|
|
1071
|
-
variantProduct => variantProduct.sku === productStatusResult.SKU
|
|
1072
|
-
);
|
|
1073
|
-
if (variant) {
|
|
1074
|
-
this.mergeProductStatusData(variant, productStatusResult);
|
|
1075
|
-
}
|
|
1076
|
-
|
|
1077
|
-
this.setBaseSkuPriceRange();
|
|
1078
|
-
} else if (this.activeSku === productStatusResult.SKU) {
|
|
1079
|
-
this.mergeProductStatusData(this.product, productStatusResult);
|
|
1080
|
-
}
|
|
1081
|
-
|
|
1082
|
-
this.setProductPricing();
|
|
1083
|
-
|
|
1084
|
-
if (this.product && this.activeSku === productStatusResult.SKU) {
|
|
1085
|
-
this.product.setMarketAttributes(productStatusResult);
|
|
1086
|
-
this.setProductAvailability();
|
|
1087
|
-
this.isStatusSet = true;
|
|
1088
|
-
}
|
|
1089
|
-
});
|
|
1090
|
-
},
|
|
1091
|
-
|
|
1092
|
-
mergeProductStatusData(product, productStatus) {
|
|
1093
|
-
if (productStatus) {
|
|
1094
|
-
productStatus.SKU = product.sku;
|
|
1095
|
-
|
|
1096
|
-
product.availableQuantity = productStatus.availableQuantity;
|
|
1097
|
-
product.addPricingFromStatus(productStatus, this.getPriceType());
|
|
1098
|
-
product.setMarketAttributes(productStatus);
|
|
1099
|
-
|
|
1100
|
-
this.marketAttributes = productStatus.marketAttributes || {};
|
|
1101
|
-
|
|
1102
|
-
if (this.activeSku === product.SKU) {
|
|
1103
|
-
this.setProductAvailability();
|
|
1104
|
-
this.isStatusSet = true;
|
|
1105
|
-
}
|
|
1106
|
-
|
|
1107
|
-
this.productStatusResults.push(productStatus);
|
|
1108
|
-
}
|
|
980
|
+
this.$NsProductDataService.handleProductStatus(results);
|
|
1109
981
|
},
|
|
1110
982
|
|
|
1111
983
|
setBaseSkuPriceRange() {
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
)
|
|
1120
|
-
))
|
|
1121
|
-
) {
|
|
1122
|
-
// We have to use getProp() instead of variantProduct.getPricing
|
|
1123
|
-
// because that was returning an array of undefined prices
|
|
1124
|
-
const variantPrices = this.variants.map(variantProduct =>
|
|
1125
|
-
getProp(variantProduct.priceMap, this.getPriceType(), 0)
|
|
1126
|
-
);
|
|
1127
|
-
this.minPrice = Math.min(...variantPrices).toString();
|
|
1128
|
-
this.maxPrice = Math.max(...variantPrices).toString();
|
|
1129
|
-
|
|
1130
|
-
// when loading a base sku first, we set status as true for all variants
|
|
1131
|
-
this.isStatusSet = true;
|
|
1132
|
-
}
|
|
984
|
+
// We have to use getProp() instead of variantProduct.getPricing
|
|
985
|
+
// because that was returning an array of undefined prices
|
|
986
|
+
const variantPrices = this.variants.map(variantProduct =>
|
|
987
|
+
getProp(variantProduct.priceMap, this.getPriceType(), 0)
|
|
988
|
+
);
|
|
989
|
+
this.minPrice = Math.min(...variantPrices).toString();
|
|
990
|
+
this.maxPrice = Math.max(...variantPrices).toString();
|
|
1133
991
|
},
|
|
1134
992
|
|
|
1135
993
|
setUser() {
|
|
@@ -1151,7 +1009,6 @@ const NsProductMixin = {
|
|
|
1151
1009
|
|
|
1152
1010
|
handleFeatureFlagsChanged() {
|
|
1153
1011
|
this.featureFlags = this.$NsProductFeatureFlagsService.featureFlags;
|
|
1154
|
-
this.useProductData = this.$NsProductFeatureFlagsService.useProductData;
|
|
1155
1012
|
this.setProductPricingAndAvailability();
|
|
1156
1013
|
},
|
|
1157
1014
|
|
|
@@ -1349,8 +1206,6 @@ const NsProductMixin = {
|
|
|
1349
1206
|
this.variants = [];
|
|
1350
1207
|
|
|
1351
1208
|
this.checkedQualifications = false;
|
|
1352
|
-
this.productStatusResults = [];
|
|
1353
|
-
this.isStatusSet = false;
|
|
1354
1209
|
|
|
1355
1210
|
this.marketAttributes = {};
|
|
1356
1211
|
},
|
package/package.json
CHANGED
|
@@ -83,11 +83,7 @@ if (!NsProductDataService) {
|
|
|
83
83
|
* @param {string[]} skus
|
|
84
84
|
*/
|
|
85
85
|
skus(skus) {
|
|
86
|
-
if (
|
|
87
|
-
this.pause ||
|
|
88
|
-
!this.$NsProductFeatureFlagsService.useProductData ||
|
|
89
|
-
!skus.length
|
|
90
|
-
) {
|
|
86
|
+
if (this.pause || !skus.length) {
|
|
91
87
|
return;
|
|
92
88
|
}
|
|
93
89
|
this.createBatchesForSkus(skus);
|
|
@@ -14,7 +14,6 @@ if (!NsProductFeatureFlagsService) {
|
|
|
14
14
|
data() {
|
|
15
15
|
return {
|
|
16
16
|
featureFlags: {},
|
|
17
|
-
useProductData: false,
|
|
18
17
|
loading: true
|
|
19
18
|
};
|
|
20
19
|
},
|
|
@@ -66,9 +65,6 @@ if (!NsProductFeatureFlagsService) {
|
|
|
66
65
|
{}
|
|
67
66
|
);
|
|
68
67
|
this.featureFlags = featureFlags;
|
|
69
|
-
this.useProductData = !!this.featureFlags[
|
|
70
|
-
"cx12-2118-product-data-lambda"
|
|
71
|
-
];
|
|
72
68
|
|
|
73
69
|
// we need to set loading before the emit, but after data is changed
|
|
74
70
|
this.loading = false;
|
|
@@ -61,12 +61,12 @@ const Template = (args, { argTypes }) => ({
|
|
|
61
61
|
|
|
62
62
|
export const Simple = Template.bind({});
|
|
63
63
|
Simple.args = {
|
|
64
|
-
sku: "
|
|
64
|
+
sku: "01003610"
|
|
65
65
|
};
|
|
66
66
|
Simple.parameters = {
|
|
67
67
|
docs: {
|
|
68
68
|
source: {
|
|
69
|
-
code: `<NsProductDetail sku="
|
|
69
|
+
code: `<NsProductDetail sku="01003610" />`
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
};
|