thm-p3-configurator 0.0.67 → 0.0.68
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/App.js +8 -9
- package/dist/src/shared/__api__/queries.js +42 -16
- package/dist/src/shared/__components__/ProductTable/ProductTableEditableRow.js +1 -1
- package/dist/src/shared/__components__/ProductTable/ProductTableStaticRow.js +1 -1
- package/dist/src/shared/__containers__/ProductCartSide.js +291 -41
- package/dist/src/shared/__containers__/ProductsCartOverview.js +229 -60
- package/dist/src/shared/__containers__/ProductsOverview.js +18 -10
- package/dist/src/shared/__containers__/internal/InternalAppointmentForm.js +58 -22
- package/dist/src/shared/__containers__/internal/InternalQuotationForm.js +58 -20
- package/dist/src/shared/__context__/OrderSessionContext.js +28 -2
- package/dist/src/shared/__pages__/internal/InternalExtraProductsPage.js +2 -1
- package/dist/src/shared/__style__/components/cart/_cart-table.scss +22 -3
- package/dist/src/shared/__style__/configurator/_configurator-offset.scss +4 -1
- package/package.json +1 -1
package/dist/src/shared/App.js
CHANGED
|
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
value: true
|
|
9
9
|
});
|
|
10
10
|
exports.default = void 0;
|
|
11
|
+
var _TEST_ONLY_INTERNAL_ROUTES = _interopRequireDefault(require("./__pages__/internal/__TEST_ONLY_INTERNAL_ROUTES"));
|
|
11
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
12
13
|
require("react-datepicker/src/stylesheets/datepicker-cssmodules.scss");
|
|
13
14
|
var _reactGtmModule = _interopRequireDefault(require("react-gtm-module"));
|
|
@@ -16,7 +17,6 @@ var _reactQuery = require("react-query");
|
|
|
16
17
|
var _reactRouterDom = require("react-router-dom");
|
|
17
18
|
var _Navbar = _interopRequireDefault(require("./__components__/Navbar"));
|
|
18
19
|
var _constants__ = require("./__constants__");
|
|
19
|
-
var _InternalBranchSelectorModal = _interopRequireDefault(require("./__containers__/internal/InternalBranchSelectorModal"));
|
|
20
20
|
var _SentryWrapper = _interopRequireDefault(require("./__containers__/SentryWrapper"));
|
|
21
21
|
var _StyleWrapper = _interopRequireDefault(require("./__containers__/StyleWrapper"));
|
|
22
22
|
var _ActiveMarkerContext = require("./__context__/ActiveMarkerContext");
|
|
@@ -25,15 +25,9 @@ var _FormulaContext = require("./__context__/FormulaContext");
|
|
|
25
25
|
var _OrderSessionContext = require("./__context__/OrderSessionContext");
|
|
26
26
|
var _cookiebot = require("./__helpers__/cookiebot");
|
|
27
27
|
var _queryClient = _interopRequireDefault(require("./__helpers__/queryClient"));
|
|
28
|
-
var _index = _interopRequireDefault(require("./__pages__/index"));
|
|
29
28
|
var _Experiments = _interopRequireDefault(require("./__services__/Experiments"));
|
|
30
29
|
var _mainExternal = _interopRequireDefault(require("./__style__/main-external.scss"));
|
|
31
30
|
var _main = _interopRequireDefault(require("./__style__/main.scss"));
|
|
32
|
-
function _interopRequireDefault(e) {
|
|
33
|
-
return e && e.__esModule ? e : {
|
|
34
|
-
default: e
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
31
|
function _getRequireWildcardCache(e) {
|
|
38
32
|
if ("function" != typeof WeakMap) return null;
|
|
39
33
|
var r = new WeakMap(),
|
|
@@ -59,6 +53,11 @@ function _interopRequireWildcard(e, r) {
|
|
|
59
53
|
}
|
|
60
54
|
return n.default = e, t && t.set(e, n), n;
|
|
61
55
|
}
|
|
56
|
+
function _interopRequireDefault(e) {
|
|
57
|
+
return e && e.__esModule ? e : {
|
|
58
|
+
default: e
|
|
59
|
+
};
|
|
60
|
+
}
|
|
62
61
|
_reactGtmModule.default.initialize({
|
|
63
62
|
gtmId: APP_CONFIG.googleTagManagerId || 'GTM-TC67SZ4'
|
|
64
63
|
});
|
|
@@ -69,11 +68,11 @@ const App = () => {
|
|
|
69
68
|
(0, _Experiments.default)();
|
|
70
69
|
});
|
|
71
70
|
return /*#__PURE__*/_react.default.createElement(_SentryWrapper.default, null, /*#__PURE__*/_react.default.createElement(_FormulaContext.FormulaController, {
|
|
72
|
-
defaultFormula: _constants__.CONFIGURATOR_FORMULAS.
|
|
71
|
+
defaultFormula: _constants__.CONFIGURATOR_FORMULAS.THC
|
|
73
72
|
}, /*#__PURE__*/_react.default.createElement(_CountryContext.CountryController, {
|
|
74
73
|
defaultCountry: APP_CONFIG.country
|
|
75
74
|
}, /*#__PURE__*/_react.default.createElement(_OrderSessionContext.OrderSessionController, null, /*#__PURE__*/_react.default.createElement(_reactQuery.QueryClientProvider, {
|
|
76
75
|
client: _queryClient.default
|
|
77
|
-
}, /*#__PURE__*/_react.default.createElement(_reactRouterDom.BrowserRouter, null, /*#__PURE__*/_react.default.createElement(_reactHotLoader.AppContainer, null, /*#__PURE__*/_react.default.createElement(_ActiveMarkerContext.ActiveMarkerProvider, null, /*#__PURE__*/_react.default.createElement(_StyleWrapper.default, null, !APP_CONFIG.internal && /*#__PURE__*/_react.default.createElement(_Navbar.default, null), APP_CONFIG.
|
|
76
|
+
}, /*#__PURE__*/_react.default.createElement(_reactRouterDom.BrowserRouter, null, /*#__PURE__*/_react.default.createElement(_reactHotLoader.AppContainer, null, /*#__PURE__*/_react.default.createElement(_ActiveMarkerContext.ActiveMarkerProvider, null, /*#__PURE__*/_react.default.createElement(_StyleWrapper.default, null, !APP_CONFIG.internal && /*#__PURE__*/_react.default.createElement(_Navbar.default, null), APP_CONFIG.nodeEnv === 'development' && APP_CONFIG.internal === true && /*#__PURE__*/_react.default.createElement(_TEST_ONLY_INTERNAL_ROUTES.default, null))))))))));
|
|
78
77
|
};
|
|
79
78
|
var _default = exports.default = App;
|
|
@@ -297,14 +297,10 @@ const useSingleOrderArticles = exports.useSingleOrderArticles = function useSing
|
|
|
297
297
|
*/
|
|
298
298
|
const useSingleOrderCart = () => {
|
|
299
299
|
const [{
|
|
300
|
-
model,
|
|
301
|
-
licensePlate,
|
|
302
300
|
singleOrderCart
|
|
303
301
|
}] = (0, _OrderSessionContext.useOrderSession)();
|
|
304
302
|
const formula = (0, _FormulaContext.useFormula)();
|
|
305
303
|
let cartOrderQuery = new URLSearchParams((0, _helpers__.removeNullishProps)({
|
|
306
|
-
model,
|
|
307
|
-
licensePlate,
|
|
308
304
|
formula,
|
|
309
305
|
isSingle: true,
|
|
310
306
|
cart: JSON.stringify(singleOrderCart)
|
|
@@ -349,22 +345,52 @@ const useSingleOrderCart = () => {
|
|
|
349
345
|
|
|
350
346
|
/**
|
|
351
347
|
* @description Retrieves the products of an order
|
|
348
|
+
* @param {String} branchId - The branch id to apply to the articles
|
|
352
349
|
*/
|
|
353
350
|
exports.useSingleOrderCart = useSingleOrderCart;
|
|
354
351
|
const useProductsQuery = orderParameters => {
|
|
355
352
|
var _productsQuery$data, _productsQuery$data2, _productsQuery$data3, _productsQuery$data4, _productsQuery$data5, _productsQuery$data6, _productsQuery$data7, _productsQuery$data8, _productsQuery$data9, _productsQuery$data$a, _productsQuery$data10, _productsQuery$data$c, _productsQuery$data11, _productsQuery$data$a2, _productsQuery$data12, _productsQuery$data$a3, _productsQuery$data13, _productsQuery$data$a4, _productsQuery$data14, _productsQuery$data15, _productsQuery$data16, _productsQuery$data$a5, _productsQuery$data17, _productsQuery$data$t, _productsQuery$data18;
|
|
356
353
|
const {
|
|
357
354
|
licensePlate,
|
|
358
|
-
model
|
|
355
|
+
model,
|
|
356
|
+
formula
|
|
359
357
|
} = orderParameters;
|
|
360
358
|
const productsSearchParams = new URLSearchParams((0, _helpers__.removeNullishProps)(orderParameters)).toString();
|
|
361
359
|
const productsQuery = (0, _reactQuery.useQuery)(['products', productsSearchParams], {
|
|
362
360
|
enabled: (licensePlate === null || licensePlate === void 0 ? void 0 : licensePlate.length) > 5 || !!(model !== null && model !== void 0 && model.length),
|
|
363
361
|
keepPreviousData: true,
|
|
364
|
-
queryFn:
|
|
365
|
-
var
|
|
366
|
-
|
|
367
|
-
|
|
362
|
+
queryFn: async () => {
|
|
363
|
+
var _response$data, _JSON$parse, _data$articles, _data$articles2, _data$articles3, _data$articles4, _data$articles5, _data$articles6, _data$articles7, _data$articles8, _data$articles9, _data$articles10, _data$articles11;
|
|
364
|
+
const response = await _orderApi.orderApi.getOrder(productsSearchParams);
|
|
365
|
+
const data = (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.data;
|
|
366
|
+
if (!data) return data;
|
|
367
|
+
const authSession = _LocalStorageWorker.lsw.get(_constants__.AUTH_SESSION_KEY);
|
|
368
|
+
const branchId = (_JSON$parse = JSON.parse(authSession)) === null || _JSON$parse === void 0 || (_JSON$parse = _JSON$parse.branch) === null || _JSON$parse === void 0 ? void 0 : _JSON$parse.entityId;
|
|
369
|
+
|
|
370
|
+
// Skip enrichment if no branchId is provided
|
|
371
|
+
if (!branchId) {
|
|
372
|
+
return data;
|
|
373
|
+
}
|
|
374
|
+
// Get all products to enrich
|
|
375
|
+
const allProducts = [...(((_data$articles = data.articles) === null || _data$articles === void 0 ? void 0 : _data$articles.towbars) || []), ...(((_data$articles2 = data.articles) === null || _data$articles2 === void 0 ? void 0 : _data$articles2.cablesets) || []), ...(((_data$articles3 = data.articles) === null || _data$articles3 === void 0 ? void 0 : _data$articles3.combisets) || []), ...((_data$articles4 = data.articles) !== null && _data$articles4 !== void 0 && _data$articles4.boardComputerUpdate ? [(_data$articles5 = data.articles) === null || _data$articles5 === void 0 ? void 0 : _data$articles5.boardComputerUpdate] : []), ...(((_data$articles6 = data.articles) === null || _data$articles6 === void 0 ? void 0 : _data$articles6.extras) || [])];
|
|
376
|
+
|
|
377
|
+
// Enrich all products with brands and prices
|
|
378
|
+
const enrichedProducts = await (0, _singleOrderArticles.enrichArticlesWithBrandsAndPrices)(allProducts, branchId, formula);
|
|
379
|
+
|
|
380
|
+
// Create a lookup map for the enriched products
|
|
381
|
+
const enrichedProductsMap = Object.fromEntries(enrichedProducts.map(product => [product.articleNumber, product]));
|
|
382
|
+
|
|
383
|
+
// Update the products in the response with the enriched data
|
|
384
|
+
return _objectSpread(_objectSpread({}, data), {}, {
|
|
385
|
+
articles: _objectSpread(_objectSpread({}, data.articles), {}, {
|
|
386
|
+
towbars: ((_data$articles7 = data.articles) === null || _data$articles7 === void 0 || (_data$articles7 = _data$articles7.towbars) === null || _data$articles7 === void 0 ? void 0 : _data$articles7.map(product => _objectSpread(_objectSpread({}, product), enrichedProductsMap[product.articleNumber]))) || [],
|
|
387
|
+
cablesets: ((_data$articles8 = data.articles) === null || _data$articles8 === void 0 || (_data$articles8 = _data$articles8.cablesets) === null || _data$articles8 === void 0 ? void 0 : _data$articles8.map(product => _objectSpread(_objectSpread({}, product), enrichedProductsMap[product.articleNumber]))) || [],
|
|
388
|
+
combisets: ((_data$articles9 = data.articles) === null || _data$articles9 === void 0 || (_data$articles9 = _data$articles9.combisets) === null || _data$articles9 === void 0 ? void 0 : _data$articles9.map(product => _objectSpread(_objectSpread({}, product), enrichedProductsMap[product.articleNumber]))) || [],
|
|
389
|
+
boardComputerUpdate: (_data$articles10 = data.articles) !== null && _data$articles10 !== void 0 && _data$articles10.boardComputerUpdate ? _objectSpread(_objectSpread({}, data.articles.boardComputerUpdate), enrichedProductsMap[data.articles.boardComputerUpdate.articleNumber]) : null,
|
|
390
|
+
extras: ((_data$articles11 = data.articles) === null || _data$articles11 === void 0 || (_data$articles11 = _data$articles11.extras) === null || _data$articles11 === void 0 ? void 0 : _data$articles11.map(product => _objectSpread(_objectSpread({}, product), enrichedProductsMap[product.articleNumber]))) || []
|
|
391
|
+
})
|
|
392
|
+
});
|
|
393
|
+
}
|
|
368
394
|
});
|
|
369
395
|
return {
|
|
370
396
|
isLoadingProducts: productsQuery.isLoading,
|
|
@@ -407,14 +433,14 @@ const useQuestionsQuery = questionParams => {
|
|
|
407
433
|
const questionsQuery = (0, _reactQuery.useQuery)(['questions', questionsParamsString], {
|
|
408
434
|
enabled: (licensePlate === null || licensePlate === void 0 ? void 0 : licensePlate.length) > 5 || !!(model !== null && model !== void 0 && model.length),
|
|
409
435
|
queryFn: () => _orderApi.orderApi.getOrder(questionsParamsString).then(res => {
|
|
410
|
-
var _res$data5, _res$data6, _res$data7, _res$data8, _res$data9
|
|
436
|
+
var _res$data4, _res$data5, _res$data6, _res$data7, _res$data8, _res$data9;
|
|
411
437
|
return {
|
|
412
|
-
execution1Answer: res === null || res === void 0 || (_res$
|
|
413
|
-
execution2Answer: res === null || res === void 0 || (_res$
|
|
414
|
-
durationAnswer: res === null || res === void 0 || (_res$
|
|
415
|
-
durationQuestion: (0, _helpers__.parseArrayToInputOptions)(res === null || res === void 0 || (_res$
|
|
416
|
-
execution1AnswerOptions: (0, _helpers__.parseArrayToInputOptions)(res === null || res === void 0 || (_res$
|
|
417
|
-
execution2AnswerOptions: (0, _helpers__.parseArrayToInputOptions)(res === null || res === void 0 || (_res$
|
|
438
|
+
execution1Answer: res === null || res === void 0 || (_res$data4 = res.data) === null || _res$data4 === void 0 || (_res$data4 = _res$data4.data) === null || _res$data4 === void 0 || (_res$data4 = _res$data4.answers) === null || _res$data4 === void 0 ? void 0 : _res$data4.execution1,
|
|
439
|
+
execution2Answer: res === null || res === void 0 || (_res$data5 = res.data) === null || _res$data5 === void 0 || (_res$data5 = _res$data5.data) === null || _res$data5 === void 0 || (_res$data5 = _res$data5.answers) === null || _res$data5 === void 0 ? void 0 : _res$data5.execution2,
|
|
440
|
+
durationAnswer: res === null || res === void 0 || (_res$data6 = res.data) === null || _res$data6 === void 0 || (_res$data6 = _res$data6.data) === null || _res$data6 === void 0 || (_res$data6 = _res$data6.answers) === null || _res$data6 === void 0 ? void 0 : _res$data6.duration,
|
|
441
|
+
durationQuestion: (0, _helpers__.parseArrayToInputOptions)(res === null || res === void 0 || (_res$data7 = res.data) === null || _res$data7 === void 0 || (_res$data7 = _res$data7.data) === null || _res$data7 === void 0 ? void 0 : _res$data7.durationAnswerOptions),
|
|
442
|
+
execution1AnswerOptions: (0, _helpers__.parseArrayToInputOptions)(res === null || res === void 0 || (_res$data8 = res.data) === null || _res$data8 === void 0 || (_res$data8 = _res$data8.data) === null || _res$data8 === void 0 || (_res$data8 = _res$data8.executionAnswerOptions) === null || _res$data8 === void 0 ? void 0 : _res$data8.execution1AnswerOptions),
|
|
443
|
+
execution2AnswerOptions: (0, _helpers__.parseArrayToInputOptions)(res === null || res === void 0 || (_res$data9 = res.data) === null || _res$data9 === void 0 || (_res$data9 = _res$data9.data) === null || _res$data9 === void 0 || (_res$data9 = _res$data9.executionAnswerOptions) === null || _res$data9 === void 0 ? void 0 : _res$data9.execution2AnswerOptions)
|
|
418
444
|
};
|
|
419
445
|
})
|
|
420
446
|
});
|
|
@@ -32,7 +32,7 @@ const ProductTableEditableRow = _ref => {
|
|
|
32
32
|
}, /*#__PURE__*/_react.default.createElement("td", null, /*#__PURE__*/_react.default.createElement("div", {
|
|
33
33
|
className: (0, _helpers__.withStyle)('cart__product row align-items-center justify-content-between')
|
|
34
34
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
35
|
-
className: (0, _helpers__.withStyle)('col-
|
|
35
|
+
className: (0, _helpers__.withStyle)('col-12')
|
|
36
36
|
}, /*#__PURE__*/_react.default.createElement("img", {
|
|
37
37
|
className: (0, _helpers__.withStyle)('img-fluid rounded-1'),
|
|
38
38
|
src: productImage || _logoPrimary.default,
|
|
@@ -27,7 +27,7 @@ const ProductTableStaticRow = _ref => {
|
|
|
27
27
|
}, /*#__PURE__*/_react.default.createElement("td", null, /*#__PURE__*/_react.default.createElement("div", {
|
|
28
28
|
className: (0, _helpers__.withStyle)('cart__product row align-items-center justify-content-between')
|
|
29
29
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
30
|
-
className: (0, _helpers__.withStyle)('col-
|
|
30
|
+
className: (0, _helpers__.withStyle)('col-12')
|
|
31
31
|
}, /*#__PURE__*/_react.default.createElement("img", {
|
|
32
32
|
className: (0, _helpers__.withStyle)('img-fluid rounded-1'),
|
|
33
33
|
src: productImage || _logoPrimary.default,
|
|
@@ -1,106 +1,356 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
require("core-js/modules/es.array.includes.js");
|
|
4
|
+
require("core-js/modules/es.array.reduce.js");
|
|
5
|
+
require("core-js/modules/es.json.stringify.js");
|
|
6
|
+
require("core-js/modules/es.parse-float.js");
|
|
7
|
+
require("core-js/modules/es.regexp.to-string.js");
|
|
8
|
+
require("core-js/modules/es.string.includes.js");
|
|
9
|
+
require("core-js/modules/es.weak-map.js");
|
|
3
10
|
require("core-js/modules/esnext.iterator.constructor.js");
|
|
11
|
+
require("core-js/modules/esnext.iterator.filter.js");
|
|
12
|
+
require("core-js/modules/esnext.iterator.find.js");
|
|
4
13
|
require("core-js/modules/esnext.iterator.map.js");
|
|
14
|
+
require("core-js/modules/esnext.iterator.reduce.js");
|
|
15
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
16
|
+
require("core-js/modules/es.weak-map.js");
|
|
5
17
|
Object.defineProperty(exports, "__esModule", {
|
|
6
18
|
value: true
|
|
7
19
|
});
|
|
8
20
|
exports.default = void 0;
|
|
21
|
+
require("core-js/modules/es.array.includes.js");
|
|
22
|
+
require("core-js/modules/es.array.reduce.js");
|
|
23
|
+
require("core-js/modules/es.json.stringify.js");
|
|
24
|
+
require("core-js/modules/es.parse-float.js");
|
|
25
|
+
require("core-js/modules/es.regexp.to-string.js");
|
|
26
|
+
require("core-js/modules/es.string.includes.js");
|
|
9
27
|
require("core-js/modules/esnext.iterator.constructor.js");
|
|
28
|
+
require("core-js/modules/esnext.iterator.filter.js");
|
|
29
|
+
require("core-js/modules/esnext.iterator.find.js");
|
|
10
30
|
require("core-js/modules/esnext.iterator.map.js");
|
|
11
|
-
|
|
12
|
-
|
|
31
|
+
require("core-js/modules/esnext.iterator.reduce.js");
|
|
32
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
33
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
34
|
+
var _logoPrimary = _interopRequireDefault(require("../../../public/assets/images/logo-primary.png"));
|
|
35
|
+
var _queries = require("../__api__/queries");
|
|
13
36
|
var _TogglableCard = _interopRequireDefault(require("../__components__/Cards/TogglableCard"));
|
|
14
37
|
var _ProductTableEditableRow = _interopRequireDefault(require("../__components__/ProductTable/ProductTableEditableRow"));
|
|
38
|
+
var _ProductTableHead = _interopRequireDefault(require("../__components__/ProductTable/ProductTableHead"));
|
|
15
39
|
var _ProductTableSection = _interopRequireDefault(require("../__components__/ProductTable/ProductTableSection"));
|
|
16
40
|
var _ProductTableSectionTotal = _interopRequireDefault(require("../__components__/ProductTable/ProductTableSectionTotal"));
|
|
17
41
|
var _ProductTableStaticRow = _interopRequireDefault(require("../__components__/ProductTable/ProductTableStaticRow"));
|
|
18
42
|
var _ProductTableTotal = _interopRequireDefault(require("../__components__/ProductTable/ProductTableTotal"));
|
|
43
|
+
var _FullPageSpinner = _interopRequireDefault(require("../__components__/Spinners/FullPageSpinner"));
|
|
44
|
+
var _FormulaContext = require("../__context__/FormulaContext");
|
|
45
|
+
var _OrderSessionContext = require("../__context__/OrderSessionContext");
|
|
19
46
|
var _helpers__ = require("../__helpers__");
|
|
47
|
+
var _image = require("../__helpers__/image");
|
|
48
|
+
var _product = require("../__helpers__/product");
|
|
20
49
|
function _interopRequireDefault(e) {
|
|
21
50
|
return e && e.__esModule ? e : {
|
|
22
51
|
default: e
|
|
23
52
|
};
|
|
24
53
|
}
|
|
54
|
+
function _getRequireWildcardCache(e) {
|
|
55
|
+
if ("function" != typeof WeakMap) return null;
|
|
56
|
+
var r = new WeakMap(),
|
|
57
|
+
t = new WeakMap();
|
|
58
|
+
return (_getRequireWildcardCache = function _getRequireWildcardCache(e) {
|
|
59
|
+
return e ? t : r;
|
|
60
|
+
})(e);
|
|
61
|
+
}
|
|
62
|
+
function _interopRequireWildcard(e, r) {
|
|
63
|
+
if (!r && e && e.__esModule) return e;
|
|
64
|
+
if (null === e || "object" != typeof e && "function" != typeof e) return {
|
|
65
|
+
default: e
|
|
66
|
+
};
|
|
67
|
+
var t = _getRequireWildcardCache(r);
|
|
68
|
+
if (t && t.has(e)) return t.get(e);
|
|
69
|
+
var n = {
|
|
70
|
+
__proto__: null
|
|
71
|
+
},
|
|
72
|
+
a = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
73
|
+
for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
|
|
74
|
+
var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
|
|
75
|
+
i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u];
|
|
76
|
+
}
|
|
77
|
+
return n.default = e, t && t.set(e, n), n;
|
|
78
|
+
}
|
|
25
79
|
const ProductCartSide = () => {
|
|
80
|
+
const formula = (0, _FormulaContext.useFormula)();
|
|
81
|
+
const [isToggled, setIsToggled] = (0, _react.useState)(false);
|
|
82
|
+
const [{
|
|
83
|
+
licensePlate,
|
|
84
|
+
model,
|
|
85
|
+
executionAnswer1,
|
|
86
|
+
executionAnswer2,
|
|
87
|
+
durationAnswer,
|
|
88
|
+
selectedTowbar,
|
|
89
|
+
selectedCableset,
|
|
90
|
+
selectedCombiset,
|
|
91
|
+
selectedBoardComputer,
|
|
92
|
+
selectedExtras,
|
|
93
|
+
discountAmount,
|
|
94
|
+
discountPercentage
|
|
95
|
+
}, dispatch] = (0, _OrderSessionContext.useOrderSession)();
|
|
96
|
+
const cartInput = (0, _product.validateCartInput)([{
|
|
97
|
+
articleNumber: selectedCableset,
|
|
98
|
+
quantity: 1
|
|
99
|
+
}, {
|
|
100
|
+
articleNumber: selectedCombiset,
|
|
101
|
+
quantity: 1
|
|
102
|
+
}, {
|
|
103
|
+
articleNumber: selectedTowbar,
|
|
104
|
+
quantity: 1
|
|
105
|
+
}, ...Object.entries(selectedExtras).map(_ref => {
|
|
106
|
+
let [extraArticleNumber, extraQuantity] = _ref;
|
|
107
|
+
return {
|
|
108
|
+
articleNumber: extraArticleNumber,
|
|
109
|
+
quantity: extraQuantity
|
|
110
|
+
};
|
|
111
|
+
})]);
|
|
26
112
|
const {
|
|
27
|
-
|
|
28
|
-
|
|
113
|
+
cart,
|
|
114
|
+
totals,
|
|
115
|
+
products,
|
|
116
|
+
isLoadingProducts
|
|
117
|
+
} = (0, _queries.useProductsQuery)({
|
|
118
|
+
licensePlate,
|
|
119
|
+
model,
|
|
120
|
+
executionAnswer1,
|
|
121
|
+
executionAnswer2,
|
|
122
|
+
durationAnswer,
|
|
123
|
+
selectBoardComputerUpdate: selectedBoardComputer != null,
|
|
124
|
+
cart: cartInput ? JSON.stringify(cartInput) : undefined,
|
|
125
|
+
formula
|
|
126
|
+
});
|
|
127
|
+
let mainProducts = [];
|
|
128
|
+
let accessoireProducts = [];
|
|
129
|
+
if (products) {
|
|
130
|
+
var _products$Trekhaak, _products$Combiset, _products$Kabelset, _products$Elektronica, _products$Extras;
|
|
131
|
+
const towbar = selectedTowbar && ((_products$Trekhaak = products.Trekhaak) === null || _products$Trekhaak === void 0 ? void 0 : _products$Trekhaak.find(product => product.articleNumber === selectedTowbar)) || null;
|
|
132
|
+
const combiset = selectedCombiset && ((_products$Combiset = products.Combiset) === null || _products$Combiset === void 0 ? void 0 : _products$Combiset.find(product => product.articleNumber === selectedCombiset)) || null;
|
|
133
|
+
const cableset = selectedCableset && ((_products$Kabelset = products.Kabelset) === null || _products$Kabelset === void 0 ? void 0 : _products$Kabelset.find(product => product.articleNumber === selectedCableset)) || null;
|
|
134
|
+
const boardComputer = selectedBoardComputer && ((_products$Elektronica = products['Elektronica boordcomputer updaten']) === null || _products$Elektronica === void 0 ? void 0 : _products$Elektronica.find(product => product.articleNumber === selectedBoardComputer)) || null;
|
|
135
|
+
const extras = Object.keys(selectedExtras);
|
|
136
|
+
mainProducts = [towbar, combiset, cableset, boardComputer].filter(Boolean);
|
|
137
|
+
accessoireProducts = extras.length > 0 && ((_products$Extras = products.Extras) === null || _products$Extras === void 0 ? void 0 : _products$Extras.filter(product => extras.includes(product.articleNumber.toString()))) || [];
|
|
138
|
+
}
|
|
139
|
+
if (isLoadingProducts) {
|
|
140
|
+
return /*#__PURE__*/_react.default.createElement(_FullPageSpinner.default, null);
|
|
141
|
+
}
|
|
142
|
+
const getItemPrice = cartItem => {
|
|
143
|
+
var _product$consumerPric;
|
|
144
|
+
if (!cartItem) return 0;
|
|
145
|
+
|
|
146
|
+
// Find the corresponding product
|
|
147
|
+
const product = [...mainProducts, ...accessoireProducts].find(p => p.articleNumber === cartItem.articleNumber);
|
|
148
|
+
if (isToggled) {
|
|
149
|
+
var _product$locationPric;
|
|
150
|
+
// Use location price from the product's locationPrices (excl. BTW)
|
|
151
|
+
return (product === null || product === void 0 || (_product$locationPric = product.locationPrices) === null || _product$locationPric === void 0 ? void 0 : _product$locationPric.priceExclVat) || 0;
|
|
152
|
+
}
|
|
153
|
+
// Use consumer price from the product's consumerPrices (incl. BTW)
|
|
154
|
+
return (product === null || product === void 0 || (_product$consumerPric = product.consumerPrices) === null || _product$consumerPric === void 0 ? void 0 : _product$consumerPric.priceInclVat) || cartItem.consumerTotal || 0;
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
// Calculate subtotal for products
|
|
158
|
+
const subtotalPriceProducts = (cart === null || cart === void 0 ? void 0 : cart.reduce((acc, item) => {
|
|
159
|
+
if (mainProducts.find(product => product.articleNumber === item.articleNumber)) {
|
|
160
|
+
return acc + parseFloat(getItemPrice(item));
|
|
161
|
+
}
|
|
162
|
+
return acc;
|
|
163
|
+
}, 0)) || 0;
|
|
164
|
+
|
|
165
|
+
// Calculate subtotal for accessories
|
|
166
|
+
const subtotalPriceAccessoires = (cart === null || cart === void 0 ? void 0 : cart.reduce((acc, item) => {
|
|
167
|
+
if (accessoireProducts.find(product => product.articleNumber === item.articleNumber)) {
|
|
168
|
+
return acc + parseFloat(getItemPrice(item));
|
|
169
|
+
}
|
|
170
|
+
return acc;
|
|
171
|
+
}, 0)) || 0;
|
|
172
|
+
|
|
173
|
+
// Calculate total discount
|
|
174
|
+
const calculateTotalDiscount = () => {
|
|
175
|
+
const totalPrice = subtotalPriceProducts + subtotalPriceAccessoires;
|
|
176
|
+
if (discountPercentage) {
|
|
177
|
+
return totalPrice * discountPercentage / 100;
|
|
178
|
+
}
|
|
179
|
+
if (discountAmount) {
|
|
180
|
+
return discountAmount;
|
|
181
|
+
}
|
|
182
|
+
return 0;
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
// Calculate original total
|
|
186
|
+
const calculateOriginalTotal = () => {
|
|
187
|
+
return subtotalPriceProducts + subtotalPriceAccessoires;
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
// Calculate final totals
|
|
191
|
+
const calculateFinalTotals = () => {
|
|
192
|
+
const totalDiscount = calculateTotalDiscount();
|
|
193
|
+
const originalTotal = calculateOriginalTotal();
|
|
194
|
+
|
|
195
|
+
// Calculate the proportion of the discount that applies to the excl. VAT amount
|
|
196
|
+
const discountExclVat = totalDiscount / 1.21; // Remove VAT from discount
|
|
197
|
+
const discountVat = totalDiscount - discountExclVat;
|
|
198
|
+
const baseExclVat = originalTotal / 1.21; // Original price excl VAT
|
|
199
|
+
const baseVat = originalTotal - baseExclVat; // Original VAT amount
|
|
200
|
+
|
|
201
|
+
return {
|
|
202
|
+
exclVat: Math.max(0, baseExclVat - discountExclVat),
|
|
203
|
+
vat: Math.max(0, baseVat - discountVat),
|
|
204
|
+
total: Math.max(0, originalTotal - totalDiscount),
|
|
205
|
+
originalTotal
|
|
206
|
+
};
|
|
207
|
+
};
|
|
29
208
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
30
209
|
className: (0, _helpers__.withStyle)("col-lg mt-3")
|
|
31
210
|
}, /*#__PURE__*/_react.default.createElement(_TogglableCard.default, {
|
|
32
211
|
title: 'Overzicht',
|
|
33
212
|
untoggleButton: "Verberg inkoopprijzen",
|
|
34
213
|
toggleButton: "Toon inkoopprijzen",
|
|
35
|
-
onToggle: toggled =>
|
|
214
|
+
onToggle: toggled => setIsToggled(toggled)
|
|
36
215
|
}, /*#__PURE__*/_react.default.createElement("table", {
|
|
37
216
|
className: (0, _helpers__.withStyle)('cart__table table table-borderless align-middle')
|
|
38
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
217
|
+
}, /*#__PURE__*/_react.default.createElement(_ProductTableHead.default, {
|
|
218
|
+
columns: [{},
|
|
219
|
+
// Image
|
|
220
|
+
{},
|
|
221
|
+
// Title
|
|
222
|
+
{
|
|
223
|
+
text: isToggled ? 'Inkoopprijs (excl. btw)' : 'Verkoop Prijs (incl. btw)',
|
|
224
|
+
className: 'fw-bold text-end'
|
|
225
|
+
}]
|
|
226
|
+
}), /*#__PURE__*/_react.default.createElement("tbody", null, /*#__PURE__*/_react.default.createElement(_ProductTableSection.default, {
|
|
39
227
|
heading: 'Trekhaakmontage'
|
|
40
|
-
},
|
|
41
|
-
|
|
42
|
-
title,
|
|
43
|
-
id,
|
|
44
|
-
image,
|
|
45
|
-
price
|
|
46
|
-
} = _ref;
|
|
228
|
+
}, mainProducts.map(product => {
|
|
229
|
+
var _product$images, _product$images2;
|
|
47
230
|
return /*#__PURE__*/_react.default.createElement(_ProductTableStaticRow.default, {
|
|
48
|
-
key:
|
|
49
|
-
productTitle:
|
|
50
|
-
productImage:
|
|
231
|
+
key: product.articleNumber,
|
|
232
|
+
productTitle: product.name || product.subgroupName,
|
|
233
|
+
productImage: product !== null && product !== void 0 && (_product$images = product.images) !== null && _product$images !== void 0 && _product$images[0] ? (0, _image.getImageFromHyper)({
|
|
234
|
+
imageId: (_product$images2 = product.images) === null || _product$images2 === void 0 ? void 0 : _product$images2[0]
|
|
235
|
+
}) : _logoPrimary.default,
|
|
51
236
|
extraCells: [{}, {
|
|
52
|
-
text: (0, _helpers__.formatPrice)(
|
|
237
|
+
text: (0, _helpers__.formatPrice)(getItemPrice(cart === null || cart === void 0 ? void 0 : cart.find(item => item.articleNumber === product.articleNumber)) || 0),
|
|
53
238
|
className: 'cart__table-purchase-price text-end'
|
|
54
239
|
}]
|
|
55
240
|
});
|
|
56
241
|
}), /*#__PURE__*/_react.default.createElement(_ProductTableSectionTotal.default, {
|
|
57
242
|
isEditable: false,
|
|
58
243
|
extraCells: [{}, {
|
|
59
|
-
text: 'Subtotaal (incl.
|
|
244
|
+
text: isToggled ? 'Subtotaal (excl. btw)' : 'Subtotaal (incl. btw)',
|
|
60
245
|
className: 'fw-bold text-end pb-2'
|
|
61
246
|
}, {
|
|
62
|
-
text: (0, _helpers__.formatPrice)(
|
|
247
|
+
text: (0, _helpers__.formatPrice)(subtotalPriceProducts),
|
|
63
248
|
className: 'fw-bold text-end pb-2'
|
|
64
249
|
}]
|
|
65
|
-
})), /*#__PURE__*/_react.default.createElement(_ProductTableSection.default, {
|
|
250
|
+
})), accessoireProducts.length > 0 && /*#__PURE__*/_react.default.createElement(_ProductTableSection.default, {
|
|
66
251
|
heading: 'Toebehoren'
|
|
67
|
-
},
|
|
68
|
-
|
|
69
|
-
title,
|
|
70
|
-
image,
|
|
71
|
-
price,
|
|
72
|
-
amount
|
|
73
|
-
} = _ref2;
|
|
252
|
+
}, accessoireProducts.map(product => {
|
|
253
|
+
var _product$images3, _product$images4;
|
|
74
254
|
return /*#__PURE__*/_react.default.createElement(_ProductTableEditableRow.default, {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
255
|
+
key: product.articleNumber,
|
|
256
|
+
productTitle: product.name,
|
|
257
|
+
productImage: product !== null && product !== void 0 && (_product$images3 = product.images) !== null && _product$images3 !== void 0 && _product$images3[0] ? (0, _image.getImageFromHyper)({
|
|
258
|
+
imageId: (_product$images4 = product.images) === null || _product$images4 === void 0 ? void 0 : _product$images4[0]
|
|
259
|
+
}) : _logoPrimary.default,
|
|
78
260
|
extraCells: [{}, {
|
|
79
|
-
text: (0, _helpers__.formatPrice)(
|
|
261
|
+
text: (0, _helpers__.formatPrice)(getItemPrice(cart === null || cart === void 0 ? void 0 : cart.find(item => item.articleNumber === product.articleNumber)) || 0),
|
|
80
262
|
className: 'cart__table-purchase-price text-end'
|
|
81
263
|
}],
|
|
82
|
-
productAmount:
|
|
83
|
-
onEdit:
|
|
84
|
-
|
|
264
|
+
productAmount: selectedExtras[product.articleNumber],
|
|
265
|
+
onEdit: value => {
|
|
266
|
+
if (value > 0) {
|
|
267
|
+
dispatch({
|
|
268
|
+
type: _OrderSessionContext.orderSessionActions.UPDATE_EXTRA_QUANTITY,
|
|
269
|
+
payload: {
|
|
270
|
+
id: product.articleNumber,
|
|
271
|
+
quantity: value
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
onRemove: () => dispatch({
|
|
277
|
+
type: _OrderSessionContext.orderSessionActions.REMOVE_EXTRA,
|
|
278
|
+
payload: {
|
|
279
|
+
id: product.articleNumber
|
|
280
|
+
}
|
|
281
|
+
}),
|
|
85
282
|
isDisabled: false
|
|
86
283
|
});
|
|
87
284
|
}), /*#__PURE__*/_react.default.createElement(_ProductTableSectionTotal.default, {
|
|
88
285
|
isEditable: false,
|
|
89
286
|
extraCells: [{}, {
|
|
90
|
-
text: 'Subtotaal (incl.
|
|
287
|
+
text: isToggled ? 'Subtotaal (excl. btw)' : 'Subtotaal (incl. btw)',
|
|
91
288
|
className: 'fw-bold text-end pb-2'
|
|
92
289
|
}, {
|
|
93
|
-
text: (0, _helpers__.formatPrice)(
|
|
290
|
+
text: (0, _helpers__.formatPrice)(subtotalPriceAccessoires),
|
|
94
291
|
className: 'fw-bold text-end pb-2'
|
|
95
292
|
}]
|
|
96
293
|
})), /*#__PURE__*/_react.default.createElement(_ProductTableTotal.default, {
|
|
97
|
-
rows: [[{}, {
|
|
294
|
+
rows: [...(isToggled ? [[{}, {
|
|
295
|
+
text: 'Producten (excl. btw)',
|
|
296
|
+
className: 'text-end pt-2'
|
|
297
|
+
}, {
|
|
298
|
+
text: (0, _helpers__.formatPrice)(calculateFinalTotals().exclVat),
|
|
299
|
+
className: 'text-end pt-2'
|
|
300
|
+
}], [{}, {
|
|
301
|
+
text: 'btw',
|
|
302
|
+
className: 'text-end'
|
|
303
|
+
}, {
|
|
304
|
+
text: (0, _helpers__.formatPrice)(calculateFinalTotals().vat),
|
|
305
|
+
className: 'text-end'
|
|
306
|
+
}], [{}, {
|
|
307
|
+
text: 'Totaal (incl. btw)',
|
|
308
|
+
className: 'fw-bold text-end'
|
|
309
|
+
}, {
|
|
310
|
+
text: (0, _helpers__.formatPrice)(calculateOriginalTotal()),
|
|
311
|
+
className: 'fw-bold text-end'
|
|
312
|
+
}]] : [[{}, {
|
|
98
313
|
text: 'Producten (excl. btw)',
|
|
99
|
-
className: '
|
|
314
|
+
className: 'text-end pt-2'
|
|
315
|
+
}, {
|
|
316
|
+
text: (0, _helpers__.formatPrice)(calculateFinalTotals().exclVat),
|
|
317
|
+
className: 'text-end pt-2'
|
|
318
|
+
}], [{}, {
|
|
319
|
+
text: 'Totaal (incl. btw)',
|
|
320
|
+
className: 'fw-bold text-end'
|
|
321
|
+
}, {
|
|
322
|
+
text: (0, _helpers__.formatPrice)(calculateOriginalTotal()),
|
|
323
|
+
className: 'fw-bold text-end'
|
|
324
|
+
}]])]
|
|
325
|
+
}), (discountAmount || discountPercentage) && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("tr", null, /*#__PURE__*/_react.default.createElement("td", {
|
|
326
|
+
colSpan: "3",
|
|
327
|
+
className: (0, _helpers__.withStyle)('pt-4 pb-2')
|
|
328
|
+
}, /*#__PURE__*/_react.default.createElement("hr", null))), /*#__PURE__*/_react.default.createElement(_ProductTableTotal.default, {
|
|
329
|
+
rows: [[{}, {
|
|
330
|
+
text: discountPercentage ? "Correctie (".concat(discountPercentage, "%)") : 'Correctie',
|
|
331
|
+
className: 'text-end text-success'
|
|
332
|
+
}, {
|
|
333
|
+
text: "-".concat((0, _helpers__.formatPrice)(calculateTotalDiscount())),
|
|
334
|
+
className: 'text-end text-success'
|
|
335
|
+
}], ...(isToggled ? [[{}, {
|
|
336
|
+
text: 'Totaal na correctie (excl. btw)',
|
|
337
|
+
className: 'text-end'
|
|
338
|
+
}, {
|
|
339
|
+
text: (0, _helpers__.formatPrice)(calculateFinalTotals().exclVat),
|
|
340
|
+
className: 'text-end'
|
|
341
|
+
}], [{}, {
|
|
342
|
+
text: 'Correctie btw',
|
|
343
|
+
className: 'text-end'
|
|
344
|
+
}, {
|
|
345
|
+
text: (0, _helpers__.formatPrice)(calculateFinalTotals().vat),
|
|
346
|
+
className: 'text-end'
|
|
347
|
+
}]] : []), [{}, {
|
|
348
|
+
text: 'Totaal na correctie (incl. btw)',
|
|
349
|
+
className: 'fw-bold text-end'
|
|
100
350
|
}, {
|
|
101
|
-
text: (0, _helpers__.formatPrice)(
|
|
102
|
-
className: 'fw-bold text-end
|
|
351
|
+
text: (0, _helpers__.formatPrice)(calculateFinalTotals().total),
|
|
352
|
+
className: 'fw-bold text-end'
|
|
103
353
|
}]]
|
|
104
|
-
})))));
|
|
354
|
+
}))))));
|
|
105
355
|
};
|
|
106
356
|
var _default = exports.default = ProductCartSide;
|