thm-p3-configurator 0.0.385 → 0.0.388
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__/__tests__/queryKeyFactory.test.js +12 -3
- package/dist/src/shared/__api__/queryKeyFactory.js +4 -4
- package/dist/src/shared/__containers__/internal/InternalBranchSelectorModal.js +36 -1
- package/dist/src/shared/__context__/OrderSessionContext.js +17 -12
- package/dist/src/shared/__helpers__/singleOrderBranchSelector.js +14 -0
- package/dist/src/shared/__hooks__/useIsSingleOrder.js +1 -4
- package/package.json +1 -1
|
@@ -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
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
require("core-js/modules/es.array.includes.js");
|
|
4
|
+
require("core-js/modules/es.string.includes.js");
|
|
3
5
|
require("core-js/modules/es.weak-map.js");
|
|
4
6
|
require("core-js/modules/esnext.iterator.constructor.js");
|
|
5
7
|
require("core-js/modules/esnext.iterator.filter.js");
|
|
@@ -13,6 +15,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
13
15
|
value: true
|
|
14
16
|
});
|
|
15
17
|
exports.default = void 0;
|
|
18
|
+
require("core-js/modules/es.array.includes.js");
|
|
19
|
+
require("core-js/modules/es.string.includes.js");
|
|
16
20
|
require("core-js/modules/esnext.iterator.constructor.js");
|
|
17
21
|
require("core-js/modules/esnext.iterator.filter.js");
|
|
18
22
|
require("core-js/modules/esnext.iterator.find.js");
|
|
@@ -29,9 +33,11 @@ var _constants__ = require("../../__constants__");
|
|
|
29
33
|
var _FormulaContext = require("../../__context__/FormulaContext");
|
|
30
34
|
var _OrderSessionContext = require("../../__context__/OrderSessionContext");
|
|
31
35
|
var _helpers__ = require("../../__helpers__");
|
|
36
|
+
var _singleOrderBranchSelector = require("../../__helpers__/singleOrderBranchSelector");
|
|
32
37
|
var _useIsSingleOrder = _interopRequireDefault(require("../../__hooks__/useIsSingleOrder"));
|
|
33
38
|
var _useIsTmg = require("../../__hooks__/useIsTmg");
|
|
34
39
|
var _OrderTypeSelectorModal = _interopRequireWildcard(require("./OrderTypeSelectorModal"));
|
|
40
|
+
var _reactRouterDom = require("react-router-dom");
|
|
35
41
|
function _interopRequireDefault(e) {
|
|
36
42
|
return e && e.__esModule ? e : {
|
|
37
43
|
default: e
|
|
@@ -297,6 +303,7 @@ const SingleOrderModalContent = _ref6 => {
|
|
|
297
303
|
}));
|
|
298
304
|
};
|
|
299
305
|
const InternalBranchSelectorModal = () => {
|
|
306
|
+
const location = (0, _reactRouterDom.useLocation)();
|
|
300
307
|
const {
|
|
301
308
|
branchTypes,
|
|
302
309
|
isLoadingBranchTypes
|
|
@@ -315,8 +322,11 @@ const InternalBranchSelectorModal = () => {
|
|
|
315
322
|
existingDossierId,
|
|
316
323
|
orderType,
|
|
317
324
|
licensePlate,
|
|
318
|
-
model
|
|
325
|
+
model,
|
|
326
|
+
singleOrderFlowRevision
|
|
319
327
|
}, dispatch] = (0, _OrderSessionContext.useOrderSession)();
|
|
328
|
+
const previousSelectedBranchRef = (0, _react.useRef)(selectedBranch);
|
|
329
|
+
const previousLocationKeyRef = (0, _react.useRef)(location.key);
|
|
320
330
|
const {
|
|
321
331
|
myBranches,
|
|
322
332
|
isLoadingMyBranches
|
|
@@ -348,6 +358,31 @@ const InternalBranchSelectorModal = () => {
|
|
|
348
358
|
branchTypes
|
|
349
359
|
});
|
|
350
360
|
}, [selectedBranch, branchById, isTMGOrganization, branchTypes, dispatch]);
|
|
361
|
+
(0, _react.useEffect)(() => {
|
|
362
|
+
if ((0, _singleOrderBranchSelector.shouldResetDismissedBranchSelectorState)({
|
|
363
|
+
previousSelectedBranch: previousSelectedBranchRef.current,
|
|
364
|
+
selectedBranch
|
|
365
|
+
})) {
|
|
366
|
+
setIsDismissed(false);
|
|
367
|
+
_setSelectedBranchId(undefined);
|
|
368
|
+
}
|
|
369
|
+
previousSelectedBranchRef.current = selectedBranch;
|
|
370
|
+
}, [selectedBranch]);
|
|
371
|
+
(0, _react.useEffect)(() => {
|
|
372
|
+
const isSingleOrderPath = location.pathname.includes('configurator/single-order') || location.pathname.includes('configurator/losse-order');
|
|
373
|
+
const didLocationEntryChange = previousLocationKeyRef.current !== location.key;
|
|
374
|
+
if (isSingleOrderPath && didLocationEntryChange) {
|
|
375
|
+
setIsDismissed(false);
|
|
376
|
+
_setSelectedBranchId(undefined);
|
|
377
|
+
}
|
|
378
|
+
previousLocationKeyRef.current = location.key;
|
|
379
|
+
}, [location.key, location.pathname]);
|
|
380
|
+
(0, _react.useEffect)(() => {
|
|
381
|
+
if (isSingleOrderPage && !selectedBranch) {
|
|
382
|
+
setIsDismissed(false);
|
|
383
|
+
_setSelectedBranchId(undefined);
|
|
384
|
+
}
|
|
385
|
+
}, [singleOrderFlowRevision, isSingleOrderPage, selectedBranch]);
|
|
351
386
|
const handlePrimaryButtonClicked = () => {
|
|
352
387
|
dispatch({
|
|
353
388
|
type: _OrderSessionContext.orderSessionActions.SET_SELECTED_BRANCH,
|
|
@@ -204,7 +204,8 @@ const INITIAL_ORDER_SESSION_STATE = {
|
|
|
204
204
|
isTowCenterBranch: false,
|
|
205
205
|
anderAfleveradres: false,
|
|
206
206
|
afhalenInWinkel: false,
|
|
207
|
-
hasGoedkeuringsnummerActivity: false
|
|
207
|
+
hasGoedkeuringsnummerActivity: false,
|
|
208
|
+
singleOrderFlowRevision: 0
|
|
208
209
|
};
|
|
209
210
|
const orderSessionActions = exports.orderSessionActions = {
|
|
210
211
|
INITIALIZE_NEW_ORDER: 'INITIALIZE_NEW_ORDER',
|
|
@@ -334,13 +335,15 @@ const orderSessionReducer = (state, action) => {
|
|
|
334
335
|
selectedBoardComputer: null,
|
|
335
336
|
isBoardComputerDeselected: false,
|
|
336
337
|
singleOrderCart: singleOrderCart || INITIAL_ORDER_SESSION_STATE.singleOrderCart,
|
|
337
|
-
discountCode: discountCode || INITIAL_ORDER_SESSION_STATE.discountCode
|
|
338
|
+
discountCode: discountCode || INITIAL_ORDER_SESSION_STATE.discountCode,
|
|
339
|
+
singleOrderFlowRevision: state.singleOrderFlowRevision + 1
|
|
338
340
|
});
|
|
339
341
|
}
|
|
340
342
|
return _objectSpread(_objectSpread({}, INITIAL_ORDER_SESSION_STATE), {}, {
|
|
341
343
|
selectedBranch: branchId || INITIAL_ORDER_SESSION_STATE.selectedBranch,
|
|
342
344
|
discountCode: discountCode || INITIAL_ORDER_SESSION_STATE.discountCode,
|
|
343
|
-
singleOrderCart: singleOrderCart || INITIAL_ORDER_SESSION_STATE.singleOrderCart
|
|
345
|
+
singleOrderCart: singleOrderCart || INITIAL_ORDER_SESSION_STATE.singleOrderCart,
|
|
346
|
+
singleOrderFlowRevision: state.singleOrderFlowRevision + 1
|
|
344
347
|
});
|
|
345
348
|
}
|
|
346
349
|
case orderSessionActions.INITIALIZE_EXISTING_ORDER:
|
|
@@ -376,7 +379,8 @@ const orderSessionReducer = (state, action) => {
|
|
|
376
379
|
window.sessionStorage.removeItem(_constants__.PRIVATE_SINGLE_ORDER_SESSION_KEY);
|
|
377
380
|
return _objectSpread(_objectSpread({}, INITIAL_ORDER_SESSION_STATE), {}, {
|
|
378
381
|
selectedBranch: null,
|
|
379
|
-
singleOrderCart: []
|
|
382
|
+
singleOrderCart: [],
|
|
383
|
+
singleOrderFlowRevision: state.singleOrderFlowRevision + 1
|
|
380
384
|
});
|
|
381
385
|
}
|
|
382
386
|
case orderSessionActions.EMPTY_SINGLE_ORDER_CART:
|
|
@@ -1372,6 +1376,7 @@ const initializeOrderSession = function initializeOrderSession() {
|
|
|
1372
1376
|
return cachedSession;
|
|
1373
1377
|
};
|
|
1374
1378
|
const AuthSessionRuntimeSync = _ref => {
|
|
1379
|
+
var _branch$entityId;
|
|
1375
1380
|
let {
|
|
1376
1381
|
authMode = 'internal'
|
|
1377
1382
|
} = _ref;
|
|
@@ -1388,25 +1393,25 @@ const AuthSessionRuntimeSync = _ref => {
|
|
|
1388
1393
|
const lastSyncedContextRef = (0, _react.useRef)(null);
|
|
1389
1394
|
const authRuntime = (0, _AuthRuntimeContext.useAuthRuntime)();
|
|
1390
1395
|
const isExternalAuthMode = authMode === 'external';
|
|
1396
|
+
const sessionBranchId = (_branch$entityId = branch === null || branch === void 0 ? void 0 : branch.entityId) !== null && _branch$entityId !== void 0 ? _branch$entityId : null;
|
|
1397
|
+
const authHeaderBranchId = isExternalAuthMode ? sessionBranchId : selectedBranch !== null && selectedBranch !== void 0 ? selectedBranch : sessionBranchId;
|
|
1391
1398
|
(0, _react.useLayoutEffect)(() => {
|
|
1392
|
-
var _ref2;
|
|
1393
1399
|
if (!APP_CONFIG.internal || !initialized) {
|
|
1394
1400
|
if (APP_CONFIG.internal) {
|
|
1395
1401
|
authRuntime.setSessionContextReady(false);
|
|
1396
1402
|
}
|
|
1397
1403
|
return;
|
|
1398
1404
|
}
|
|
1399
|
-
authRuntime.setActiveBranchId(
|
|
1400
|
-
}, [authRuntime, initialized,
|
|
1405
|
+
authRuntime.setActiveBranchId(authHeaderBranchId);
|
|
1406
|
+
}, [authRuntime, initialized, authHeaderBranchId]);
|
|
1401
1407
|
(0, _react.useEffect)(() => {
|
|
1402
|
-
var _ref3;
|
|
1403
1408
|
if (!APP_CONFIG.internal || !initialized) {
|
|
1404
1409
|
if (APP_CONFIG.internal) {
|
|
1405
1410
|
authRuntime.setSessionContextReady(false);
|
|
1406
1411
|
}
|
|
1407
1412
|
return;
|
|
1408
1413
|
}
|
|
1409
|
-
const branchId =
|
|
1414
|
+
const branchId = authHeaderBranchId;
|
|
1410
1415
|
if (!authenticated || !branchId || !formula) {
|
|
1411
1416
|
lastSyncedContextRef.current = null;
|
|
1412
1417
|
authRuntime.setSessionContextReady(false);
|
|
@@ -1445,16 +1450,16 @@ const AuthSessionRuntimeSync = _ref => {
|
|
|
1445
1450
|
return () => {
|
|
1446
1451
|
isCancelled = true;
|
|
1447
1452
|
};
|
|
1448
|
-
}, [authRuntime, authenticated, initialized,
|
|
1453
|
+
}, [authRuntime, authenticated, initialized, authHeaderBranchId, formula, module, isExternalAuthMode]);
|
|
1449
1454
|
return null;
|
|
1450
1455
|
};
|
|
1451
|
-
const OrderSessionController =
|
|
1456
|
+
const OrderSessionController = _ref2 => {
|
|
1452
1457
|
let {
|
|
1453
1458
|
children,
|
|
1454
1459
|
authMode = 'internal',
|
|
1455
1460
|
externalAuthSession = null,
|
|
1456
1461
|
externalAuthRuntime = null
|
|
1457
|
-
} =
|
|
1462
|
+
} = _ref2;
|
|
1458
1463
|
const isSingleOrderPage = (0, _useIsSingleOrder.default)();
|
|
1459
1464
|
const isExternalAuthMode = authMode === 'external' || Boolean(externalAuthSession);
|
|
1460
1465
|
const runtimeMode = isExternalAuthMode ? 'external' : 'internal';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.shouldResetDismissedBranchSelectorState = void 0;
|
|
7
|
+
const shouldResetDismissedBranchSelectorState = _ref => {
|
|
8
|
+
let {
|
|
9
|
+
previousSelectedBranch,
|
|
10
|
+
selectedBranch
|
|
11
|
+
} = _ref;
|
|
12
|
+
return Boolean(previousSelectedBranch) && !selectedBranch;
|
|
13
|
+
};
|
|
14
|
+
exports.shouldResetDismissedBranchSelectorState = shouldResetDismissedBranchSelectorState;
|
|
@@ -8,11 +8,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.useIsSingleOrder = exports.default = void 0;
|
|
9
9
|
require("core-js/modules/es.array.includes.js");
|
|
10
10
|
require("core-js/modules/es.string.includes.js");
|
|
11
|
-
var _react = require("react");
|
|
12
11
|
const useIsSingleOrder = () => {
|
|
13
|
-
return (
|
|
14
|
-
return typeof window !== 'undefined' && (window.location.pathname.includes('configurator/single-order') || window.location.pathname.includes('configurator/losse-order'));
|
|
15
|
-
}, []);
|
|
12
|
+
return typeof window !== 'undefined' && (window.location.pathname.includes('configurator/single-order') || window.location.pathname.includes('configurator/losse-order'));
|
|
16
13
|
};
|
|
17
14
|
exports.useIsSingleOrder = useIsSingleOrder;
|
|
18
15
|
var _default = exports.default = useIsSingleOrder;
|