thm-p3-configurator 0.0.417 → 0.0.418
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/dist/src/shared/__api__/mutations.js +7 -3
- package/dist/src/shared/__components__/SingleOrderProductCard.js +6 -2
- package/dist/src/shared/__containers__/AppointmentForm.js +13 -11
- package/dist/src/shared/__containers__/ExitIntentModal.js +26 -15
- package/dist/src/shared/__containers__/QuotationForm.js +13 -11
- package/dist/src/shared/__containers__/internal/InternalSingleOrderProductOverview.js +5 -1
- package/dist/src/shared/__helpers__/__tests__/product.test.js +33 -7
- package/dist/src/shared/__helpers__/product.js +25 -22
- package/dist/src/shared/__helpers__/prospectTracking.js +39 -0
- package/package.json +1 -1
|
@@ -107,7 +107,8 @@ const useCreateQuotationMutation = () => {
|
|
|
107
107
|
discount,
|
|
108
108
|
vehicle,
|
|
109
109
|
skipFilters,
|
|
110
|
-
isExitIntent = false
|
|
110
|
+
isExitIntent = false,
|
|
111
|
+
prospectId
|
|
111
112
|
} = _ref;
|
|
112
113
|
return _publicProxyApi.publicProxyApi.postQuotation({
|
|
113
114
|
isExitIntent,
|
|
@@ -122,7 +123,8 @@ const useCreateQuotationMutation = () => {
|
|
|
122
123
|
skipFilters,
|
|
123
124
|
selectBoardComputerUpdate: selectBoardComputerUpdate,
|
|
124
125
|
customer: customer,
|
|
125
|
-
branchId
|
|
126
|
+
branchId,
|
|
127
|
+
prospectId
|
|
126
128
|
});
|
|
127
129
|
});
|
|
128
130
|
return {
|
|
@@ -144,6 +146,7 @@ const useCreateAppointmentRequestMutation = () => {
|
|
|
144
146
|
licensePlate,
|
|
145
147
|
model,
|
|
146
148
|
constructionYear,
|
|
149
|
+
prospectId,
|
|
147
150
|
answers,
|
|
148
151
|
cart,
|
|
149
152
|
selectBoardComputerUpdate,
|
|
@@ -166,7 +169,8 @@ const useCreateAppointmentRequestMutation = () => {
|
|
|
166
169
|
customer,
|
|
167
170
|
branchId,
|
|
168
171
|
discount,
|
|
169
|
-
vehicle
|
|
172
|
+
vehicle,
|
|
173
|
+
prospectId
|
|
170
174
|
});
|
|
171
175
|
}, {});
|
|
172
176
|
return {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
require("core-js/modules/es.number.to-fixed.js");
|
|
3
4
|
require("core-js/modules/es.promise.js");
|
|
4
5
|
require("core-js/modules/es.string.trim.js");
|
|
5
6
|
require("core-js/modules/es.weak-map.js");
|
|
@@ -16,6 +17,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
16
17
|
value: true
|
|
17
18
|
});
|
|
18
19
|
exports.default = void 0;
|
|
20
|
+
require("core-js/modules/es.number.to-fixed.js");
|
|
19
21
|
require("core-js/modules/es.promise.js");
|
|
20
22
|
require("core-js/modules/es.string.trim.js");
|
|
21
23
|
require("core-js/modules/esnext.iterator.constructor.js");
|
|
@@ -218,6 +220,8 @@ const SingleOrderProductCard = _ref4 => {
|
|
|
218
220
|
productTitle,
|
|
219
221
|
productPrice,
|
|
220
222
|
productPriceInclVat,
|
|
223
|
+
locationPriceExclVat = null,
|
|
224
|
+
consumerPriceExclVat = null,
|
|
221
225
|
productBrandNumber,
|
|
222
226
|
productSpecifications,
|
|
223
227
|
quantity = 0,
|
|
@@ -315,8 +319,8 @@ const SingleOrderProductCard = _ref4 => {
|
|
|
315
319
|
}, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("h5", {
|
|
316
320
|
className: (0, _helpers__.withStyle)('card-title mb-3')
|
|
317
321
|
}, productTitle, /*#__PURE__*/_react.default.createElement("span", {
|
|
318
|
-
className: (0, _helpers__.withStyle)('ms-2')
|
|
319
|
-
}, "\u20AC",
|
|
322
|
+
className: (0, _helpers__.withStyle)('ms-2 d-flex flex-column align-items-end')
|
|
323
|
+
}, locationPriceExclVat != null && /*#__PURE__*/_react.default.createElement("span", null, "Vestigingprijs excl BTW: \u20AC", locationPriceExclVat.toFixed(2)), consumerPriceExclVat != null && /*#__PURE__*/_react.default.createElement("small", null, "Consumentenprijs excl BTW: \u20AC", consumerPriceExclVat.toFixed(2)))), /*#__PURE__*/_react.default.createElement("div", {
|
|
320
324
|
className: (0, _helpers__.withStyle)(isModelArticle ? 'd-flex justify-content-between' : '')
|
|
321
325
|
}, (productSubgroup || articleNumber || preferredPart) && /*#__PURE__*/_react.default.createElement(ProductCategories, {
|
|
322
326
|
brandName: brandName,
|
|
@@ -40,6 +40,7 @@ var _constants__ = require("../__constants__");
|
|
|
40
40
|
var _FormulaContext = require("../__context__/FormulaContext");
|
|
41
41
|
var _OrderSessionContext = require("../__context__/OrderSessionContext");
|
|
42
42
|
var _helpers__ = require("../__helpers__");
|
|
43
|
+
var _prospectTracking = require("../__helpers__/prospectTracking");
|
|
43
44
|
var _Datalayer = require("../__services__/Datalayer");
|
|
44
45
|
var _product = require("../__helpers__/product");
|
|
45
46
|
var _useDebouncedPush = _interopRequireDefault(require("../__hooks__/useDebouncedPush"));
|
|
@@ -164,6 +165,8 @@ const AppointmentForm = () => {
|
|
|
164
165
|
}, dispatch] = (0, _OrderSessionContext.useOrderSession)();
|
|
165
166
|
const [errors, setErrors] = (0, _react.useState)({});
|
|
166
167
|
const [isTermsAccepted, setIsTermsAccepted] = (0, _react.useState)(false);
|
|
168
|
+
const hasTrackedValidSubmitRef = (0, _react.useRef)(false);
|
|
169
|
+
const prospectIdRef = (0, _react.useRef)(null);
|
|
167
170
|
const trackInput = (0, _useDebouncedPush.default)();
|
|
168
171
|
const APPOINTMENT_REQUEST_ERROR_FALLBACK = 'Er is een fout opgetreden bij het maken van de afspraak, probeer het opnieuw.';
|
|
169
172
|
const {
|
|
@@ -194,7 +197,10 @@ const AppointmentForm = () => {
|
|
|
194
197
|
strict: false,
|
|
195
198
|
abortEarly: false
|
|
196
199
|
});
|
|
200
|
+
const prospectId = (0, _prospectTracking.createProspectId)();
|
|
201
|
+
prospectIdRef.current = prospectId;
|
|
197
202
|
const appointmentRequestPayload = (0, _helpers__.removeNullishProps)({
|
|
203
|
+
prospectId,
|
|
198
204
|
licensePlate: licensePlate === null || licensePlate === void 0 ? void 0 : licensePlate.replace(/-/g, ''),
|
|
199
205
|
model,
|
|
200
206
|
constructionYear: buildYear !== null && buildYear !== void 0 ? buildYear : undefined,
|
|
@@ -233,17 +239,6 @@ const AppointmentForm = () => {
|
|
|
233
239
|
})
|
|
234
240
|
});
|
|
235
241
|
await createAppointmentRequest(appointmentRequestPayload);
|
|
236
|
-
(0, _Datalayer.pushToDataLayer)({
|
|
237
|
-
event: 'form',
|
|
238
|
-
component: 'afspraak',
|
|
239
|
-
element: 'button',
|
|
240
|
-
action: 'submit',
|
|
241
|
-
action_value: 'valid'
|
|
242
|
-
});
|
|
243
|
-
(0, _Datalayer.pushToDataLayer)({
|
|
244
|
-
event: 'form_submit',
|
|
245
|
-
form_name: 'config_afspraak'
|
|
246
|
-
});
|
|
247
242
|
} catch (ex) {
|
|
248
243
|
(0, _Datalayer.pushToDataLayer)({
|
|
249
244
|
event: 'form',
|
|
@@ -262,6 +257,13 @@ const AppointmentForm = () => {
|
|
|
262
257
|
}
|
|
263
258
|
};
|
|
264
259
|
if (isCreateAppointmentRequestSuccess) {
|
|
260
|
+
if (!hasTrackedValidSubmitRef.current) {
|
|
261
|
+
hasTrackedValidSubmitRef.current = true;
|
|
262
|
+
(0, _prospectTracking.pushProspectCreated)({
|
|
263
|
+
formName: 'afspraak',
|
|
264
|
+
prospectId: prospectIdRef.current
|
|
265
|
+
});
|
|
266
|
+
}
|
|
265
267
|
return /*#__PURE__*/_react.default.createElement(_reactRouter.Redirect, {
|
|
266
268
|
to: {
|
|
267
269
|
pathname: "/configurator/gegevens/bedankt",
|
|
@@ -37,6 +37,7 @@ var _Datalayer = require("../__services__/Datalayer");
|
|
|
37
37
|
var _product = require("../__helpers__/product");
|
|
38
38
|
var _ui = require("../__helpers__/ui");
|
|
39
39
|
var _useIsTowmotive = require("../__hooks__/useIsTowmotive");
|
|
40
|
+
var _prospectTracking = require("../__helpers__/prospectTracking");
|
|
40
41
|
function _interopRequireDefault(e) {
|
|
41
42
|
return e && e.__esModule ? e : {
|
|
42
43
|
default: e
|
|
@@ -125,6 +126,7 @@ const ExitIntentModal = () => {
|
|
|
125
126
|
const [errors, setErrors] = (0, _react.useState)(null);
|
|
126
127
|
const hasTrackedOpenRef = (0, _react.useRef)(false);
|
|
127
128
|
const hasTrackedValidSubmitRef = (0, _react.useRef)(false);
|
|
129
|
+
const prospectIdRef = (0, _react.useRef)(null);
|
|
128
130
|
const inputDebounceRefs = (0, _react.useRef)({
|
|
129
131
|
email: null,
|
|
130
132
|
phoneNumber: null
|
|
@@ -143,7 +145,6 @@ const ExitIntentModal = () => {
|
|
|
143
145
|
discountCode,
|
|
144
146
|
executionAnswer1,
|
|
145
147
|
executionAnswer2,
|
|
146
|
-
priceCalculationDate,
|
|
147
148
|
selectedDiscountedProducts = [],
|
|
148
149
|
selectedExtras,
|
|
149
150
|
vehicleCodingDiscountPercentage,
|
|
@@ -154,6 +155,27 @@ const ExitIntentModal = () => {
|
|
|
154
155
|
(0, _react.useEffect)(() => {
|
|
155
156
|
(0, _ui.scrollToFirstErrorMessage)();
|
|
156
157
|
}, [errors]);
|
|
158
|
+
(0, _react.useEffect)(() => {
|
|
159
|
+
if (!isCreateQuotationSuccess || hasTrackedValidSubmitRef.current) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
hasTrackedValidSubmitRef.current = true;
|
|
163
|
+
(0, _Datalayer.pushToDataLayer)({
|
|
164
|
+
event: 'form',
|
|
165
|
+
component: 'exit_intent',
|
|
166
|
+
element: 'button',
|
|
167
|
+
action: 'submit',
|
|
168
|
+
action_value: 'valid'
|
|
169
|
+
});
|
|
170
|
+
(0, _prospectTracking.pushProspectCreated)({
|
|
171
|
+
formName: 'offerte',
|
|
172
|
+
prospectId: prospectIdRef.current
|
|
173
|
+
});
|
|
174
|
+
(0, _Datalayer.pushToDataLayer)({
|
|
175
|
+
event: 'form_submit',
|
|
176
|
+
form_name: 'config_exitintent'
|
|
177
|
+
});
|
|
178
|
+
}, [isCreateQuotationSuccess]);
|
|
157
179
|
const handleMouseLeave = event => {
|
|
158
180
|
if (document.cookie.includes('exitIntentModalShown=true')) {
|
|
159
181
|
return;
|
|
@@ -210,7 +232,10 @@ const ExitIntentModal = () => {
|
|
|
210
232
|
strict: false,
|
|
211
233
|
abortEarly: false
|
|
212
234
|
});
|
|
235
|
+
const prospectId = (0, _prospectTracking.createProspectId)();
|
|
236
|
+
prospectIdRef.current = prospectId;
|
|
213
237
|
await createQuotation((0, _helpers__.removeNullishProps)({
|
|
238
|
+
prospectId,
|
|
214
239
|
isExitIntent: true,
|
|
215
240
|
licensePlate,
|
|
216
241
|
model,
|
|
@@ -242,20 +267,6 @@ const ExitIntentModal = () => {
|
|
|
242
267
|
vehicleCodingDiscountPercentage
|
|
243
268
|
})
|
|
244
269
|
}));
|
|
245
|
-
(0, _Datalayer.pushToDataLayer)({
|
|
246
|
-
event: 'form',
|
|
247
|
-
component: 'exit_intent',
|
|
248
|
-
element: 'button',
|
|
249
|
-
action: 'submit',
|
|
250
|
-
action_value: 'valid'
|
|
251
|
-
});
|
|
252
|
-
if (!hasTrackedValidSubmitRef.current) {
|
|
253
|
-
hasTrackedValidSubmitRef.current = true;
|
|
254
|
-
(0, _Datalayer.pushToDataLayer)({
|
|
255
|
-
event: 'form_submit',
|
|
256
|
-
form_name: 'config_exitintent'
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
270
|
} catch (ex) {
|
|
260
271
|
(0, _Datalayer.pushToDataLayer)({
|
|
261
272
|
event: 'form',
|
|
@@ -32,6 +32,7 @@ var _constants__ = require("../__constants__");
|
|
|
32
32
|
var _FormulaContext = require("../__context__/FormulaContext");
|
|
33
33
|
var _OrderSessionContext = require("../__context__/OrderSessionContext");
|
|
34
34
|
var _helpers__ = require("../__helpers__");
|
|
35
|
+
var _prospectTracking = require("../__helpers__/prospectTracking");
|
|
35
36
|
var _Datalayer = require("../__services__/Datalayer");
|
|
36
37
|
var _useDebouncedPush = _interopRequireDefault(require("../__hooks__/useDebouncedPush"));
|
|
37
38
|
var _product = require("../__helpers__/product");
|
|
@@ -155,6 +156,8 @@ const QuotationForm = () => {
|
|
|
155
156
|
}, dispatch] = (0, _OrderSessionContext.useOrderSession)();
|
|
156
157
|
const [errors, setErrors] = (0, _react.useState)({});
|
|
157
158
|
const [isTermsAccepted, setIsTermsAccepted] = (0, _react.useState)(false);
|
|
159
|
+
const hasTrackedValidSubmitRef = (0, _react.useRef)(false);
|
|
160
|
+
const prospectIdRef = (0, _react.useRef)(null);
|
|
158
161
|
const trackInput = (0, _useDebouncedPush.default)();
|
|
159
162
|
const {
|
|
160
163
|
createQuotation,
|
|
@@ -184,18 +187,10 @@ const QuotationForm = () => {
|
|
|
184
187
|
strict: false,
|
|
185
188
|
abortEarly: false
|
|
186
189
|
});
|
|
187
|
-
(0,
|
|
188
|
-
|
|
189
|
-
component: 'offerte',
|
|
190
|
-
element: 'button',
|
|
191
|
-
action: 'submit',
|
|
192
|
-
action_value: 'valid'
|
|
193
|
-
});
|
|
194
|
-
(0, _Datalayer.pushToDataLayer)({
|
|
195
|
-
event: 'form_submit',
|
|
196
|
-
form_name: 'config_offerte'
|
|
197
|
-
});
|
|
190
|
+
const prospectId = (0, _prospectTracking.createProspectId)();
|
|
191
|
+
prospectIdRef.current = prospectId;
|
|
198
192
|
await createQuotation((0, _helpers__.removeNullishProps)({
|
|
193
|
+
prospectId,
|
|
199
194
|
isExitIntent: false,
|
|
200
195
|
licensePlate,
|
|
201
196
|
model,
|
|
@@ -245,6 +240,13 @@ const QuotationForm = () => {
|
|
|
245
240
|
}
|
|
246
241
|
};
|
|
247
242
|
if (isCreateQuotationSuccess) {
|
|
243
|
+
if (!hasTrackedValidSubmitRef.current) {
|
|
244
|
+
hasTrackedValidSubmitRef.current = true;
|
|
245
|
+
(0, _prospectTracking.pushProspectCreated)({
|
|
246
|
+
formName: 'offerte',
|
|
247
|
+
prospectId: prospectIdRef.current
|
|
248
|
+
});
|
|
249
|
+
}
|
|
248
250
|
return /*#__PURE__*/_react.default.createElement(_reactRouter.Redirect, {
|
|
249
251
|
to: {
|
|
250
252
|
pathname: "/configurator/offerte/bedankt",
|
|
@@ -133,7 +133,9 @@ const InternalSingleOrderProductOverview = _ref => {
|
|
|
133
133
|
var _article$consumerPric, _article$consumerPric2, _article$consumerPric3, _cart$find$quantity, _cart$find;
|
|
134
134
|
const {
|
|
135
135
|
priceExclVat,
|
|
136
|
-
priceInclVat
|
|
136
|
+
priceInclVat,
|
|
137
|
+
locationPriceExclVat,
|
|
138
|
+
consumerPriceExclVat
|
|
137
139
|
} = (0, _product.resolveSingleOrderArticlePrices)(article);
|
|
138
140
|
// Hide stock for webshops (online orders)
|
|
139
141
|
const stockQuantity = orderSession.webshop ? 0 : (_article$consumerPric = article === null || article === void 0 || (_article$consumerPric2 = article.consumerPrices) === null || _article$consumerPric2 === void 0 || (_article$consumerPric2 = _article$consumerPric2.stock) === null || _article$consumerPric2 === void 0 ? void 0 : _article$consumerPric2.quantity) !== null && _article$consumerPric !== void 0 ? _article$consumerPric : 0;
|
|
@@ -174,6 +176,8 @@ const InternalSingleOrderProductOverview = _ref => {
|
|
|
174
176
|
productTitle: article.name,
|
|
175
177
|
productPrice: priceExclVat.toFixed(2),
|
|
176
178
|
productPriceInclVat: priceInclVat.toFixed(2),
|
|
179
|
+
locationPriceExclVat: locationPriceExclVat,
|
|
180
|
+
consumerPriceExclVat: consumerPriceExclVat,
|
|
177
181
|
productBrandNumber: article.brand,
|
|
178
182
|
productSubgroup: article === null || article === void 0 ? void 0 : article.subgroup,
|
|
179
183
|
isWebshop: !!orderSession.webshop
|
|
@@ -18,7 +18,9 @@ describe('product helpers', () => {
|
|
|
18
18
|
}
|
|
19
19
|
})).toEqual({
|
|
20
20
|
priceExclVat: 129.95,
|
|
21
|
-
priceInclVat: 157.24
|
|
21
|
+
priceInclVat: 157.24,
|
|
22
|
+
locationPriceExclVat: null,
|
|
23
|
+
consumerPriceExclVat: 129.95
|
|
22
24
|
});
|
|
23
25
|
expect((0, _product.resolveSingleOrderArticlePrices)({
|
|
24
26
|
locationPrices: {
|
|
@@ -31,7 +33,9 @@ describe('product helpers', () => {
|
|
|
31
33
|
}
|
|
32
34
|
})).toEqual({
|
|
33
35
|
priceExclVat: 129.95,
|
|
34
|
-
priceInclVat: 157.24
|
|
36
|
+
priceInclVat: 157.24,
|
|
37
|
+
locationPriceExclVat: null,
|
|
38
|
+
consumerPriceExclVat: 129.95
|
|
35
39
|
});
|
|
36
40
|
expect((0, _product.resolveSingleOrderArticlePrices)({
|
|
37
41
|
locationPrices: {
|
|
@@ -44,14 +48,36 @@ describe('product helpers', () => {
|
|
|
44
48
|
}
|
|
45
49
|
})).toEqual({
|
|
46
50
|
priceExclVat: 50,
|
|
47
|
-
priceInclVat: 60.5
|
|
51
|
+
priceInclVat: 60.5,
|
|
52
|
+
locationPriceExclVat: 50,
|
|
53
|
+
consumerPriceExclVat: 129.95
|
|
48
54
|
});
|
|
49
55
|
});
|
|
50
|
-
it('
|
|
51
|
-
|
|
56
|
+
it('returns zero totals and null per-audience prices when no prices are present', () => {
|
|
57
|
+
expect((0, _product.resolveSingleOrderArticlePrices)({
|
|
52
58
|
price: 189
|
|
59
|
+
})).toEqual({
|
|
60
|
+
priceExclVat: 0,
|
|
61
|
+
priceInclVat: 0,
|
|
62
|
+
locationPriceExclVat: null,
|
|
63
|
+
consumerPriceExclVat: null
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
it('treats non-numeric price values as absent', () => {
|
|
67
|
+
expect((0, _product.resolveSingleOrderArticlePrices)({
|
|
68
|
+
locationPrices: {
|
|
69
|
+
priceExclVat: 'n/a',
|
|
70
|
+
priceInclVat: 'n/a'
|
|
71
|
+
},
|
|
72
|
+
consumerPrices: {
|
|
73
|
+
priceExclVat: '129.95',
|
|
74
|
+
priceInclVat: '157.24'
|
|
75
|
+
}
|
|
76
|
+
})).toEqual({
|
|
77
|
+
priceExclVat: 129.95,
|
|
78
|
+
priceInclVat: 157.24,
|
|
79
|
+
locationPriceExclVat: null,
|
|
80
|
+
consumerPriceExclVat: 129.95
|
|
53
81
|
});
|
|
54
|
-
expect(result.priceInclVat).toBe(189);
|
|
55
|
-
expect(result.priceExclVat).toBeCloseTo(156.2, 2);
|
|
56
82
|
});
|
|
57
83
|
});
|
|
@@ -108,34 +108,37 @@ const shouldRequestUnfilteredProductsForCart = exports.shouldRequestUnfilteredPr
|
|
|
108
108
|
let cart = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
109
109
|
return Array.isArray(cart) && cart.some(lineItem => (lineItem === null || lineItem === void 0 ? void 0 : lineItem.articleNumber) != null);
|
|
110
110
|
};
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
|
|
111
|
+
const toFiniteNumber = value => {
|
|
112
|
+
if (value === null || value === undefined || value === '') {
|
|
113
|
+
return null;
|
|
114
114
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
continue;
|
|
118
|
-
}
|
|
119
|
-
const numberValue = Number(value);
|
|
120
|
-
if (Number.isFinite(numberValue)) {
|
|
121
|
-
return numberValue;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
return 0;
|
|
115
|
+
const numberValue = Number(value);
|
|
116
|
+
return Number.isFinite(numberValue) ? numberValue : null;
|
|
125
117
|
};
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* @description Resolves single-order article prices.
|
|
121
|
+
* Returns both the merged price (location, falling back to consumer, used
|
|
122
|
+
* for cart/quantity totals) and the raw per-audience exclVat prices (used
|
|
123
|
+
* to display them separately in the UI).
|
|
124
|
+
*/
|
|
126
125
|
const resolveSingleOrderArticlePrices = exports.resolveSingleOrderArticlePrices = function resolveSingleOrderArticlePrices() {
|
|
127
|
-
var _article$locationPric, _article$consumerPric, _article$locationPric2, _article$consumerPric2;
|
|
126
|
+
var _article$locationPric, _article$consumerPric, _ref3, _ref4, _toFiniteNumber, _article$locationPric2, _article$consumerPric2;
|
|
128
127
|
let article = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
128
|
+
const locationPriceExclVat = toFiniteNumber(article === null || article === void 0 || (_article$locationPric = article.locationPrices) === null || _article$locationPric === void 0 ? void 0 : _article$locationPric.priceExclVat);
|
|
129
|
+
const consumerPriceExclVat = toFiniteNumber(article === null || article === void 0 || (_article$consumerPric = article.consumerPrices) === null || _article$consumerPric === void 0 ? void 0 : _article$consumerPric.priceExclVat);
|
|
129
130
|
return {
|
|
130
|
-
priceExclVat:
|
|
131
|
-
priceInclVat:
|
|
131
|
+
priceExclVat: (_ref3 = locationPriceExclVat !== null && locationPriceExclVat !== void 0 ? locationPriceExclVat : consumerPriceExclVat) !== null && _ref3 !== void 0 ? _ref3 : 0,
|
|
132
|
+
priceInclVat: (_ref4 = (_toFiniteNumber = toFiniteNumber(article === null || article === void 0 || (_article$locationPric2 = article.locationPrices) === null || _article$locationPric2 === void 0 ? void 0 : _article$locationPric2.priceInclVat)) !== null && _toFiniteNumber !== void 0 ? _toFiniteNumber : toFiniteNumber(article === null || article === void 0 || (_article$consumerPric2 = article.consumerPrices) === null || _article$consumerPric2 === void 0 ? void 0 : _article$consumerPric2.priceInclVat)) !== null && _ref4 !== void 0 ? _ref4 : 0,
|
|
133
|
+
locationPriceExclVat,
|
|
134
|
+
consumerPriceExclVat
|
|
132
135
|
};
|
|
133
136
|
};
|
|
134
137
|
|
|
135
138
|
/**
|
|
136
139
|
* @description Builds the cart input including optional TowMotive vehicle coding discount
|
|
137
140
|
*/
|
|
138
|
-
const buildCartInput =
|
|
141
|
+
const buildCartInput = _ref5 => {
|
|
139
142
|
let {
|
|
140
143
|
selectedCableset,
|
|
141
144
|
selectedCombiset,
|
|
@@ -147,7 +150,7 @@ const buildCartInput = _ref3 => {
|
|
|
147
150
|
vehicleCodingDiscountPercentage = null,
|
|
148
151
|
consumerDiscounts = {},
|
|
149
152
|
touchedConsumerDiscounts = {}
|
|
150
|
-
} =
|
|
153
|
+
} = _ref5;
|
|
151
154
|
// Only send consumerDiscountPercentage when the user has explicitly set a value.
|
|
152
155
|
// null = user cleared the field → omit entirely so backend applies its defaults.
|
|
153
156
|
// 0 = user typed 0 → send it explicitly.
|
|
@@ -173,8 +176,8 @@ const buildCartInput = _ref3 => {
|
|
|
173
176
|
quantity: 1
|
|
174
177
|
}, isTowmotiveFormula && vehicleCodingDiscountPercentage !== null && vehicleCodingDiscountPercentage !== undefined ? {
|
|
175
178
|
consumerDiscountPercentage: vehicleCodingDiscountPercentage
|
|
176
|
-
} : discountField(selectedBoardComputer))] : []), ...Object.entries(selectedExtras).map(
|
|
177
|
-
let [extraArticleNumber, extraQuantity] =
|
|
179
|
+
} : discountField(selectedBoardComputer))] : []), ...Object.entries(selectedExtras).map(_ref6 => {
|
|
180
|
+
let [extraArticleNumber, extraQuantity] = _ref6;
|
|
178
181
|
return _objectSpread({
|
|
179
182
|
articleNumber: extraArticleNumber,
|
|
180
183
|
quantity: extraQuantity
|
|
@@ -186,12 +189,12 @@ const buildCartInput = _ref3 => {
|
|
|
186
189
|
* @description Checks if a product is recommended, by checking if it both a towbar and is detachable
|
|
187
190
|
*/
|
|
188
191
|
exports.buildCartInput = buildCartInput;
|
|
189
|
-
const checkIfTowbarIsRecommended =
|
|
192
|
+
const checkIfTowbarIsRecommended = _ref7 => {
|
|
190
193
|
var _product$subgroupName;
|
|
191
194
|
let {
|
|
192
195
|
product,
|
|
193
196
|
category
|
|
194
|
-
} =
|
|
197
|
+
} = _ref7;
|
|
195
198
|
return category === _constants__.PRODUCT_CATEGORIES.TOWBAR && ((product === null || product === void 0 ? void 0 : product.subgroupName.toLowerCase().includes('afneembaar')) || (product === null || product === void 0 || (_product$subgroupName = product.subgroupName) === null || _product$subgroupName === void 0 ? void 0 : _product$subgroupName.toLowerCase().includes('afneembare')));
|
|
196
199
|
};
|
|
197
200
|
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/es.regexp.exec.js");
|
|
4
|
+
require("core-js/modules/es.regexp.to-string.js");
|
|
5
|
+
require("core-js/modules/es.string.replace.js");
|
|
6
|
+
Object.defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
exports.pushProspectCreated = exports.createProspectId = void 0;
|
|
10
|
+
require("core-js/modules/es.regexp.exec.js");
|
|
11
|
+
require("core-js/modules/es.regexp.to-string.js");
|
|
12
|
+
require("core-js/modules/es.string.replace.js");
|
|
13
|
+
var _Datalayer = require("../__services__/Datalayer");
|
|
14
|
+
const createProspectId = () => {
|
|
15
|
+
if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {
|
|
16
|
+
return crypto.randomUUID();
|
|
17
|
+
}
|
|
18
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, char => {
|
|
19
|
+
const random = Math.random() * 16 | 0;
|
|
20
|
+
const value = char === 'x' ? random : random & 0x3 | 0x8;
|
|
21
|
+
return value.toString(16);
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
exports.createProspectId = createProspectId;
|
|
25
|
+
const pushProspectCreated = _ref => {
|
|
26
|
+
let {
|
|
27
|
+
formName,
|
|
28
|
+
prospectId
|
|
29
|
+
} = _ref;
|
|
30
|
+
if (!formName || !prospectId) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
(0, _Datalayer.pushToDataLayer)({
|
|
34
|
+
event: 'prospect_created',
|
|
35
|
+
form_name: formName,
|
|
36
|
+
prospect_id: prospectId
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
exports.pushProspectCreated = pushProspectCreated;
|