thm-p3-configurator 0.0.385 → 0.0.387
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.
|
@@ -9,7 +9,7 @@ describe('queryKeyFactory', () => {
|
|
|
9
9
|
internal: true
|
|
10
10
|
};
|
|
11
11
|
});
|
|
12
|
-
it('normalizes
|
|
12
|
+
it('normalizes incoming year fields into buildYear without mutating input', () => {
|
|
13
13
|
const params = {
|
|
14
14
|
buildYear: '2024',
|
|
15
15
|
formula: 'THC',
|
|
@@ -19,7 +19,7 @@ describe('queryKeyFactory', () => {
|
|
|
19
19
|
};
|
|
20
20
|
const normalized = (0, _queryKeyFactory.normalizeOrderParams)(params);
|
|
21
21
|
expect(normalized).toEqual({
|
|
22
|
-
|
|
22
|
+
buildYear: '2024',
|
|
23
23
|
formula: 'THC',
|
|
24
24
|
skipFilters: false,
|
|
25
25
|
discountAmount: 0,
|
|
@@ -33,6 +33,15 @@ describe('queryKeyFactory', () => {
|
|
|
33
33
|
priceCalculationDate: '2026-03-09'
|
|
34
34
|
});
|
|
35
35
|
});
|
|
36
|
+
it('maps legacy constructionYear into buildYear', () => {
|
|
37
|
+
expect((0, _queryKeyFactory.normalizeOrderParams)({
|
|
38
|
+
formula: 'THC',
|
|
39
|
+
constructionYear: '02/2020 tot heden'
|
|
40
|
+
})).toEqual({
|
|
41
|
+
formula: 'THC',
|
|
42
|
+
buildYear: '02/2020 tot heden'
|
|
43
|
+
});
|
|
44
|
+
});
|
|
36
45
|
it('drops priceCalculationDate for external mode', () => {
|
|
37
46
|
global.APP_CONFIG = {
|
|
38
47
|
internal: false
|
|
@@ -61,7 +70,7 @@ describe('queryKeyFactory', () => {
|
|
|
61
70
|
cart: '[]',
|
|
62
71
|
buildYear: '2024'
|
|
63
72
|
});
|
|
64
|
-
expect(first).toBe('licensePlate=12AB34&formula=THC&
|
|
73
|
+
expect(first).toBe('licensePlate=12AB34&formula=THC&buildYear=2024&durationAnswer=Lang&extraPriceAmount=10&cart=%5B%5D');
|
|
65
74
|
expect(second).toBe(first);
|
|
66
75
|
});
|
|
67
76
|
it('preserves legacy getOrder request semantics by omitting falsy values', () => {
|
|
@@ -69,7 +69,7 @@ function _toPrimitive(t, r) {
|
|
|
69
69
|
}
|
|
70
70
|
return ("string" === r ? String : Number)(t);
|
|
71
71
|
}
|
|
72
|
-
const ORDER_PARAM_PRIORITY = ['licensePlate', 'model', 'formula', '
|
|
72
|
+
const ORDER_PARAM_PRIORITY = ['licensePlate', 'model', 'formula', 'buildYear', 'durationAnswer', 'executionAnswer1', 'executionAnswer2', 'selectBoardComputerUpdate', 'branchId', 'skipFilters', 'discountCode', 'discountAmount', 'discountPercentage', 'montageRate', 'extraPriceAmount', 'priceCalculationDate', 'cart'];
|
|
73
73
|
const removeNullishEntries = function removeNullishEntries() {
|
|
74
74
|
let value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
75
75
|
return Object.fromEntries(Object.entries(value).filter(_ref => {
|
|
@@ -94,10 +94,10 @@ const sortObjectKeys = function sortObjectKeys() {
|
|
|
94
94
|
const normalizeOrderParams = exports.normalizeOrderParams = function normalizeOrderParams() {
|
|
95
95
|
let orderParameters = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
96
96
|
const normalizedParams = removeNullishEntries(_objectSpread({}, orderParameters));
|
|
97
|
-
if (normalizedParams.buildYear != null) {
|
|
98
|
-
normalizedParams.
|
|
99
|
-
delete normalizedParams.buildYear;
|
|
97
|
+
if (normalizedParams.buildYear == null && normalizedParams.constructionYear != null) {
|
|
98
|
+
normalizedParams.buildYear = normalizedParams.constructionYear;
|
|
100
99
|
}
|
|
100
|
+
delete normalizedParams.constructionYear;
|
|
101
101
|
if (normalizedParams.selectBoardComputerUpdate === false || normalizedParams.selectBoardComputerUpdate === 'false') {
|
|
102
102
|
delete normalizedParams.selectBoardComputerUpdate;
|
|
103
103
|
}
|
|
@@ -1372,6 +1372,7 @@ const initializeOrderSession = function initializeOrderSession() {
|
|
|
1372
1372
|
return cachedSession;
|
|
1373
1373
|
};
|
|
1374
1374
|
const AuthSessionRuntimeSync = _ref => {
|
|
1375
|
+
var _branch$entityId;
|
|
1375
1376
|
let {
|
|
1376
1377
|
authMode = 'internal'
|
|
1377
1378
|
} = _ref;
|
|
@@ -1388,25 +1389,25 @@ const AuthSessionRuntimeSync = _ref => {
|
|
|
1388
1389
|
const lastSyncedContextRef = (0, _react.useRef)(null);
|
|
1389
1390
|
const authRuntime = (0, _AuthRuntimeContext.useAuthRuntime)();
|
|
1390
1391
|
const isExternalAuthMode = authMode === 'external';
|
|
1392
|
+
const sessionBranchId = (_branch$entityId = branch === null || branch === void 0 ? void 0 : branch.entityId) !== null && _branch$entityId !== void 0 ? _branch$entityId : null;
|
|
1393
|
+
const authHeaderBranchId = isExternalAuthMode ? sessionBranchId : selectedBranch !== null && selectedBranch !== void 0 ? selectedBranch : sessionBranchId;
|
|
1391
1394
|
(0, _react.useLayoutEffect)(() => {
|
|
1392
|
-
var _ref2;
|
|
1393
1395
|
if (!APP_CONFIG.internal || !initialized) {
|
|
1394
1396
|
if (APP_CONFIG.internal) {
|
|
1395
1397
|
authRuntime.setSessionContextReady(false);
|
|
1396
1398
|
}
|
|
1397
1399
|
return;
|
|
1398
1400
|
}
|
|
1399
|
-
authRuntime.setActiveBranchId(
|
|
1400
|
-
}, [authRuntime, initialized,
|
|
1401
|
+
authRuntime.setActiveBranchId(authHeaderBranchId);
|
|
1402
|
+
}, [authRuntime, initialized, authHeaderBranchId]);
|
|
1401
1403
|
(0, _react.useEffect)(() => {
|
|
1402
|
-
var _ref3;
|
|
1403
1404
|
if (!APP_CONFIG.internal || !initialized) {
|
|
1404
1405
|
if (APP_CONFIG.internal) {
|
|
1405
1406
|
authRuntime.setSessionContextReady(false);
|
|
1406
1407
|
}
|
|
1407
1408
|
return;
|
|
1408
1409
|
}
|
|
1409
|
-
const branchId =
|
|
1410
|
+
const branchId = authHeaderBranchId;
|
|
1410
1411
|
if (!authenticated || !branchId || !formula) {
|
|
1411
1412
|
lastSyncedContextRef.current = null;
|
|
1412
1413
|
authRuntime.setSessionContextReady(false);
|
|
@@ -1445,16 +1446,16 @@ const AuthSessionRuntimeSync = _ref => {
|
|
|
1445
1446
|
return () => {
|
|
1446
1447
|
isCancelled = true;
|
|
1447
1448
|
};
|
|
1448
|
-
}, [authRuntime, authenticated, initialized,
|
|
1449
|
+
}, [authRuntime, authenticated, initialized, authHeaderBranchId, formula, module, isExternalAuthMode]);
|
|
1449
1450
|
return null;
|
|
1450
1451
|
};
|
|
1451
|
-
const OrderSessionController =
|
|
1452
|
+
const OrderSessionController = _ref2 => {
|
|
1452
1453
|
let {
|
|
1453
1454
|
children,
|
|
1454
1455
|
authMode = 'internal',
|
|
1455
1456
|
externalAuthSession = null,
|
|
1456
1457
|
externalAuthRuntime = null
|
|
1457
|
-
} =
|
|
1458
|
+
} = _ref2;
|
|
1458
1459
|
const isSingleOrderPage = (0, _useIsSingleOrder.default)();
|
|
1459
1460
|
const isExternalAuthMode = authMode === 'external' || Boolean(externalAuthSession);
|
|
1460
1461
|
const runtimeMode = isExternalAuthMode ? 'external' : 'internal';
|