thm-p3-configurator 0.0.397 → 0.0.398
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.
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
require("core-js/modules/es.symbol.description.js");
|
|
4
|
+
require("core-js/modules/es.array.includes.js");
|
|
4
5
|
require("core-js/modules/es.array.sort.js");
|
|
5
6
|
require("core-js/modules/es.json.stringify.js");
|
|
6
7
|
require("core-js/modules/es.object.from-entries.js");
|
|
7
8
|
require("core-js/modules/es.promise.js");
|
|
8
9
|
require("core-js/modules/es.regexp.to-string.js");
|
|
10
|
+
require("core-js/modules/es.string.includes.js");
|
|
9
11
|
require("core-js/modules/esnext.iterator.constructor.js");
|
|
10
12
|
require("core-js/modules/esnext.iterator.filter.js");
|
|
11
|
-
require("core-js/modules/esnext.iterator.find.js");
|
|
12
13
|
require("core-js/modules/esnext.iterator.for-each.js");
|
|
13
14
|
require("core-js/modules/esnext.iterator.map.js");
|
|
14
15
|
require("core-js/modules/web.dom-collections.iterator.js");
|
|
@@ -18,14 +19,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
18
19
|
});
|
|
19
20
|
exports.useSingleOrderCart = exports.useSingleOrderBranchesQuery = exports.useSingleOrderBranchTypes = exports.useSingleOrderArticles = exports.useQuestionsQuery = exports.useProductsQuery = exports.useProductFieldLabels = exports.usePrivateDossierByTypeAndIdQuery = exports.usePartBrands = exports.useOrderDataQuery = exports.useMyBranches = exports.useModelsQuery = exports.useMarketingChannels = exports.useCountriesQuery = exports.useConfiguratorLocationsQuery = exports.useBusinessBranches = exports.useBuildYearsQuery = exports.useBrandsQuery = exports.useBranchesQuery = exports.useBranchesByType = exports.useBranchTypes = exports.useBranchByIdOrWidgetId = exports.useArticleTypes = exports.useArticleSubGroups = exports.useArticleGroups = exports.useActiveDiscounts = void 0;
|
|
20
21
|
require("core-js/modules/es.symbol.description.js");
|
|
22
|
+
require("core-js/modules/es.array.includes.js");
|
|
21
23
|
require("core-js/modules/es.array.sort.js");
|
|
22
24
|
require("core-js/modules/es.json.stringify.js");
|
|
23
25
|
require("core-js/modules/es.object.from-entries.js");
|
|
24
26
|
require("core-js/modules/es.promise.js");
|
|
25
27
|
require("core-js/modules/es.regexp.to-string.js");
|
|
28
|
+
require("core-js/modules/es.string.includes.js");
|
|
26
29
|
require("core-js/modules/esnext.iterator.constructor.js");
|
|
27
30
|
require("core-js/modules/esnext.iterator.filter.js");
|
|
28
|
-
require("core-js/modules/esnext.iterator.find.js");
|
|
29
31
|
require("core-js/modules/esnext.iterator.for-each.js");
|
|
30
32
|
require("core-js/modules/esnext.iterator.map.js");
|
|
31
33
|
require("core-js/modules/web.dom-collections.iterator.js");
|
|
@@ -308,7 +310,9 @@ const useSingleOrderArticles = exports.useSingleOrderArticles = function useSing
|
|
|
308
310
|
totalArticles: 0
|
|
309
311
|
};
|
|
310
312
|
}
|
|
311
|
-
const currentArticles = await (0, _singleOrderArticles.enrichArticlesWithBrandsAndPrices)(articles, branchId || null, branchId ? singleOrderFormula : singleOrderFormula || 'THL'
|
|
313
|
+
const currentArticles = await (0, _singleOrderArticles.enrichArticlesWithBrandsAndPrices)(articles, branchId || null, branchId ? singleOrderFormula : singleOrderFormula || 'THL', {
|
|
314
|
+
useArticleNumberForPricing: true
|
|
315
|
+
});
|
|
312
316
|
const pricedArticles = currentArticles.filter(article => {
|
|
313
317
|
const {
|
|
314
318
|
priceExclVat,
|
|
@@ -392,23 +396,33 @@ const useSingleOrderCart = () => {
|
|
|
392
396
|
})).toString();
|
|
393
397
|
const cartQuery = (0, _reactQuery.useQuery)(['singleOrderCart', cartOrderQuery, webshop], {
|
|
394
398
|
queryFn: async () => {
|
|
395
|
-
var
|
|
399
|
+
var _articleResponse$arti2;
|
|
400
|
+
const emptyTotals = {
|
|
401
|
+
totalQuantity: 0,
|
|
402
|
+
totalBtw: 0,
|
|
403
|
+
totalExclVat: 0,
|
|
404
|
+
totalInclVat: 0
|
|
405
|
+
};
|
|
396
406
|
if (!singleOrderCart.length) {
|
|
397
407
|
return {
|
|
398
408
|
articles: [],
|
|
399
|
-
totals:
|
|
409
|
+
totals: emptyTotals,
|
|
410
|
+
validationError: null
|
|
400
411
|
};
|
|
401
412
|
}
|
|
402
413
|
|
|
403
414
|
// If webshop is selected, use Shopify prices directly without API call
|
|
404
415
|
if (webshop) {
|
|
405
|
-
var
|
|
406
|
-
const
|
|
407
|
-
const
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
const
|
|
416
|
+
var _articleResponse$arti;
|
|
417
|
+
const articleResponse = await (0, _singleOrderArticles.fetchArticlesByArticleNumbers)(singleOrderCart.map(article => article.articleNumber), null, false, null, singleOrderFormula);
|
|
418
|
+
const articleLookup = Object.fromEntries(((_articleResponse$arti = articleResponse === null || articleResponse === void 0 ? void 0 : articleResponse.articles) !== null && _articleResponse$arti !== void 0 ? _articleResponse$arti : []).map(article => [article.articleNumber, article]));
|
|
419
|
+
const articlesWithPrice = singleOrderCart.map(cartItem => {
|
|
420
|
+
var _articleLookup$cartIt, _article$name, _cartItem$brandNumber;
|
|
421
|
+
const article = (_articleLookup$cartIt = articleLookup[cartItem.articleNumber]) !== null && _articleLookup$cartIt !== void 0 ? _articleLookup$cartIt : {};
|
|
422
|
+
const totals = cartTotalsLookup[cartItem.articleNumber];
|
|
411
423
|
return _objectSpread(_objectSpread({}, article), {}, {
|
|
424
|
+
articleNumber: cartItem.articleNumber,
|
|
425
|
+
name: (_article$name = article === null || article === void 0 ? void 0 : article.name) !== null && _article$name !== void 0 ? _article$name : cartItem.articleNumber,
|
|
412
426
|
price: cartItem !== null && cartItem !== void 0 && cartItem.productPriceInclVat ? Math.round(Number(cartItem === null || cartItem === void 0 ? void 0 : cartItem.productPriceInclVat) * 100) / 100 : 0,
|
|
413
427
|
quantity: Number(cartItem === null || cartItem === void 0 ? void 0 : cartItem.quantity),
|
|
414
428
|
// Add the calculated totals using Shopify prices
|
|
@@ -429,25 +443,47 @@ const useSingleOrderCart = () => {
|
|
|
429
443
|
totalBtw: Math.round(totalBtw * 100) / 100,
|
|
430
444
|
totalExclVat: Math.round(totalExclVat * 100) / 100,
|
|
431
445
|
totalInclVat: Math.round(totalInclVat * 100) / 100
|
|
432
|
-
}
|
|
446
|
+
},
|
|
447
|
+
validationError: null
|
|
433
448
|
};
|
|
434
449
|
}
|
|
435
450
|
|
|
436
|
-
// Original logic for non-webshop orders
|
|
437
|
-
|
|
438
|
-
|
|
451
|
+
// Original logic for non-webshop orders.
|
|
452
|
+
// If Hyper rejects a cart with ARTICLES_NOT_FOUND (404), keep rendering
|
|
453
|
+
// from the local session cart instead of breaking the entire cart query.
|
|
454
|
+
let cart = [];
|
|
455
|
+
let validationError = null;
|
|
456
|
+
try {
|
|
457
|
+
var _orderResults$data$ca, _orderResults$data;
|
|
458
|
+
const orderResults = await _authenticatedProxyApi.authenticatedProxyApi.getOrder(cartOrderQuery).then(res => res.data);
|
|
459
|
+
cart = (_orderResults$data$ca = orderResults === null || orderResults === void 0 || (_orderResults$data = orderResults.data) === null || _orderResults$data === void 0 ? void 0 : _orderResults$data.cart) !== null && _orderResults$data$ca !== void 0 ? _orderResults$data$ca : [];
|
|
460
|
+
} catch (error) {
|
|
461
|
+
var _error$response, _error$response2, _error$response3;
|
|
462
|
+
const isCartOrderLookup = cartOrderQuery.includes('cart=');
|
|
463
|
+
const isArticlesNotFoundError = (error === null || error === void 0 || (_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.status) === 404 && (error === null || error === void 0 || (_error$response2 = error.response) === null || _error$response2 === void 0 || (_error$response2 = _error$response2.data) === null || _error$response2 === void 0 ? void 0 : _error$response2.code) === 'ARTICLES_NOT_FOUND';
|
|
464
|
+
const isGenericNotFoundError = (error === null || error === void 0 || (_error$response3 = error.response) === null || _error$response3 === void 0 ? void 0 : _error$response3.status) === 404;
|
|
465
|
+
if (!isCartOrderLookup || !isArticlesNotFoundError && !isGenericNotFoundError) {
|
|
466
|
+
throw error;
|
|
467
|
+
}
|
|
468
|
+
cart = apiCart;
|
|
469
|
+
validationError = 'Een of meer artikelen in de winkelwagen zijn momenteel niet bestelbaar voor deze formule.';
|
|
470
|
+
}
|
|
471
|
+
if (!cart.length) {
|
|
439
472
|
return {
|
|
440
|
-
|
|
473
|
+
articles: [],
|
|
474
|
+
totals: emptyTotals,
|
|
475
|
+
validationError
|
|
441
476
|
};
|
|
442
477
|
}
|
|
443
|
-
const
|
|
444
|
-
const
|
|
445
|
-
const
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
const
|
|
449
|
-
const totals = cartTotalsLookup[article.articleNumber];
|
|
478
|
+
const articleResponse = await (0, _singleOrderArticles.fetchArticlesByArticleNumbers)(cart.map(article => article.articleNumber), null, false, null, singleOrderFormula);
|
|
479
|
+
const articleLookup = Object.fromEntries(((_articleResponse$arti2 = articleResponse === null || articleResponse === void 0 ? void 0 : articleResponse.articles) !== null && _articleResponse$arti2 !== void 0 ? _articleResponse$arti2 : []).map(article => [article.articleNumber, article]));
|
|
480
|
+
const articlesWithPrice = cart.map(cartItem => {
|
|
481
|
+
var _articleLookup$cartIt2, _article$name2, _cartItem$brandNumber2;
|
|
482
|
+
const article = (_articleLookup$cartIt2 = articleLookup[cartItem.articleNumber]) !== null && _articleLookup$cartIt2 !== void 0 ? _articleLookup$cartIt2 : {};
|
|
483
|
+
const totals = cartTotalsLookup[cartItem.articleNumber];
|
|
450
484
|
return _objectSpread(_objectSpread({}, article), {}, {
|
|
485
|
+
articleNumber: cartItem.articleNumber,
|
|
486
|
+
name: (_article$name2 = article === null || article === void 0 ? void 0 : article.name) !== null && _article$name2 !== void 0 ? _article$name2 : cartItem.articleNumber,
|
|
451
487
|
price: cartItem !== null && cartItem !== void 0 && cartItem.consumerTotal ? Math.round(Number(cartItem === null || cartItem === void 0 ? void 0 : cartItem.consumerTotal) * 100) / 100 : 0,
|
|
452
488
|
quantity: Number(cartItem === null || cartItem === void 0 ? void 0 : cartItem.quantity),
|
|
453
489
|
// Add the calculated totals
|
|
@@ -468,7 +504,8 @@ const useSingleOrderCart = () => {
|
|
|
468
504
|
totalBtw: Math.round(totalBtw * 100) / 100,
|
|
469
505
|
totalExclVat: Math.round(totalExclVat * 100) / 100,
|
|
470
506
|
totalInclVat: Math.round(totalInclVat * 100) / 100
|
|
471
|
-
}
|
|
507
|
+
},
|
|
508
|
+
validationError
|
|
472
509
|
};
|
|
473
510
|
}
|
|
474
511
|
});
|
|
@@ -12,6 +12,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
12
12
|
var _queries = require("../../__api__/queries");
|
|
13
13
|
var _LinkButton = _interopRequireDefault(require("../../__components__/Buttons/LinkButton"));
|
|
14
14
|
var _PrimaryButton = _interopRequireDefault(require("../../__components__/Buttons/PrimaryButton"));
|
|
15
|
+
var _DangerAlert = _interopRequireDefault(require("../../__components__/DangerAlert"));
|
|
15
16
|
var _ExpandableCard = _interopRequireDefault(require("../../__components__/Cards/ExpandableCard"));
|
|
16
17
|
var _SingleOrderCartCard = _interopRequireDefault(require("../../__components__/SingleOrderCartCard"));
|
|
17
18
|
var _helpers__ = require("../../__helpers__");
|
|
@@ -29,7 +30,7 @@ const EmptyState = _ref => {
|
|
|
29
30
|
}, message));
|
|
30
31
|
};
|
|
31
32
|
const InternalSingleOrderCart = _ref2 => {
|
|
32
|
-
var _cart$articles, _cart$totals$totalExc, _cart$totals, _cart$totals$totalBtw, _cart$totals2, _cart$totals$totalInc, _cart$totals3;
|
|
33
|
+
var _cart$validationError, _cart$articles, _cart$totals$totalExc, _cart$totals, _cart$totals$totalBtw, _cart$totals2, _cart$totals$totalInc, _cart$totals3;
|
|
33
34
|
let {
|
|
34
35
|
handleQuantityChange,
|
|
35
36
|
removeFromCart: _removeFromCart,
|
|
@@ -43,6 +44,7 @@ const InternalSingleOrderCart = _ref2 => {
|
|
|
43
44
|
cart,
|
|
44
45
|
isLoadingCart
|
|
45
46
|
} = (0, _queries.useSingleOrderCart)();
|
|
47
|
+
const cartValidationError = (_cart$validationError = cart === null || cart === void 0 ? void 0 : cart.validationError) !== null && _cart$validationError !== void 0 ? _cart$validationError : null;
|
|
46
48
|
const confirmButtonClicked = () => {
|
|
47
49
|
if (showProductOverview) {
|
|
48
50
|
toggleOverview();
|
|
@@ -89,8 +91,11 @@ const InternalSingleOrderCart = _ref2 => {
|
|
|
89
91
|
}, /*#__PURE__*/_react.default.createElement(_LinkButton.default, {
|
|
90
92
|
label: "Bestelling herstarten",
|
|
91
93
|
onClick: () => resetOrderSession()
|
|
94
|
+
}), cartValidationError && /*#__PURE__*/_react.default.createElement(_DangerAlert.default, {
|
|
95
|
+
className: "mx-2 mb-0",
|
|
96
|
+
message: "".concat(cartValidationError, " Pas de artikelen aan voordat je kunt bevestigen.")
|
|
92
97
|
}), /*#__PURE__*/_react.default.createElement(_PrimaryButton.default, {
|
|
93
|
-
isDisabled: disabledCreateOrder,
|
|
98
|
+
isDisabled: disabledCreateOrder || Boolean(cartValidationError),
|
|
94
99
|
label: !showProductOverview ? 'Bevestigen' : 'Bestellen',
|
|
95
100
|
onClick: confirmButtonClicked
|
|
96
101
|
})));
|