thm-p3-configurator 0.0.448 → 0.0.451
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/__containers__/internal/InternalBranchSelectorModal.js +10 -21
- package/dist/src/shared/__helpers__/__tests__/singleOrderBranchSelector.test.js +36 -0
- package/dist/src/shared/__helpers__/singleOrderBranchSelector.js +38 -2
- package/dist/src/shared/__pages__/internal/InternalSingleOrderPage.js +12 -3
- package/package.json +1 -1
|
@@ -4,7 +4,6 @@ require("core-js/modules/es.array.includes.js");
|
|
|
4
4
|
require("core-js/modules/es.string.includes.js");
|
|
5
5
|
require("core-js/modules/es.weak-map.js");
|
|
6
6
|
require("core-js/modules/esnext.iterator.constructor.js");
|
|
7
|
-
require("core-js/modules/esnext.iterator.filter.js");
|
|
8
7
|
require("core-js/modules/esnext.iterator.find.js");
|
|
9
8
|
require("core-js/modules/esnext.iterator.for-each.js");
|
|
10
9
|
require("core-js/modules/esnext.iterator.map.js");
|
|
@@ -18,7 +17,6 @@ exports.default = void 0;
|
|
|
18
17
|
require("core-js/modules/es.array.includes.js");
|
|
19
18
|
require("core-js/modules/es.string.includes.js");
|
|
20
19
|
require("core-js/modules/esnext.iterator.constructor.js");
|
|
21
|
-
require("core-js/modules/esnext.iterator.filter.js");
|
|
22
20
|
require("core-js/modules/esnext.iterator.find.js");
|
|
23
21
|
require("core-js/modules/esnext.iterator.for-each.js");
|
|
24
22
|
require("core-js/modules/esnext.iterator.map.js");
|
|
@@ -258,23 +256,14 @@ const SingleOrderModalContent = _ref6 => {
|
|
|
258
256
|
branchTypeId: singleOrderBranchType
|
|
259
257
|
};
|
|
260
258
|
}, [dispatch, normalizedFormula, setSelectedBranchId, singleOrderBranchType]);
|
|
261
|
-
const filteredBranches = _react.default.useMemo(() => {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
return singleOrderBranches.filter(branch => {
|
|
266
|
-
var _ref7, _branch$formulaCode, _branch$formule;
|
|
267
|
-
const branchFormula = (0, _constants__.getConfiguratorFormulaCode)((_ref7 = (_branch$formulaCode = branch === null || branch === void 0 ? void 0 : branch.formulaCode) !== null && _branch$formulaCode !== void 0 ? _branch$formulaCode : branch === null || branch === void 0 || (_branch$formule = branch.formule) === null || _branch$formule === void 0 ? void 0 : _branch$formule.code) !== null && _ref7 !== void 0 ? _ref7 : branch === null || branch === void 0 ? void 0 : branch.formule);
|
|
268
|
-
if ((0, _constants__.isThcFamilyFormula)(normalizedFormula)) {
|
|
269
|
-
return (0, _constants__.isThcFamilyFormula)(branchFormula);
|
|
270
|
-
}
|
|
271
|
-
return branchFormula === normalizedFormula;
|
|
272
|
-
});
|
|
273
|
-
}, [singleOrderBranches, normalizedFormula]);
|
|
259
|
+
const filteredBranches = _react.default.useMemo(() => (0, _singleOrderBranchSelector.getVisibleSingleOrderBranches)({
|
|
260
|
+
branches: singleOrderBranches,
|
|
261
|
+
formula: normalizedFormula
|
|
262
|
+
}), [singleOrderBranches, normalizedFormula]);
|
|
274
263
|
const branchIdWithFormulaCode = new Map();
|
|
275
264
|
filteredBranches === null || filteredBranches === void 0 || filteredBranches.forEach(branch => {
|
|
276
|
-
var _getConfiguratorFormu,
|
|
277
|
-
branchIdWithFormulaCode.set(branch === null || branch === void 0 ? void 0 : branch.entityId, (_getConfiguratorFormu = (0, _constants__.getConfiguratorFormulaCode)((
|
|
265
|
+
var _getConfiguratorFormu, _ref7, _branch$formulaCode, _branch$formule;
|
|
266
|
+
branchIdWithFormulaCode.set(branch === null || branch === void 0 ? void 0 : branch.entityId, (_getConfiguratorFormu = (0, _constants__.getConfiguratorFormulaCode)((_ref7 = (_branch$formulaCode = branch === null || branch === void 0 ? void 0 : branch.formulaCode) !== null && _branch$formulaCode !== void 0 ? _branch$formulaCode : branch === null || branch === void 0 || (_branch$formule = branch.formule) === null || _branch$formule === void 0 ? void 0 : _branch$formule.code) !== null && _ref7 !== void 0 ? _ref7 : branch === null || branch === void 0 ? void 0 : branch.formule)) !== null && _getConfiguratorFormu !== void 0 ? _getConfiguratorFormu : normalizedFormula);
|
|
278
267
|
});
|
|
279
268
|
const branchOptions = filteredBranches === null || filteredBranches === void 0 ? void 0 : filteredBranches.map(branch => ({
|
|
280
269
|
label: (0, _singleOrderBranchSelector.getSingleOrderBranchOptionLabel)(branch),
|
|
@@ -292,10 +281,10 @@ const SingleOrderModalContent = _ref6 => {
|
|
|
292
281
|
noOptionsMessage: "Geen opties beschikbaar",
|
|
293
282
|
placeholder: "Maak een keuze",
|
|
294
283
|
initialValue: singleOrderBranchType,
|
|
295
|
-
onChange:
|
|
284
|
+
onChange: _ref8 => {
|
|
296
285
|
let {
|
|
297
286
|
value
|
|
298
|
-
} =
|
|
287
|
+
} = _ref8;
|
|
299
288
|
setSingleOrderBranchType(value);
|
|
300
289
|
setSelectedBranchId(undefined);
|
|
301
290
|
setLocalBranchId(undefined);
|
|
@@ -309,11 +298,11 @@ const SingleOrderModalContent = _ref6 => {
|
|
|
309
298
|
noOptionsMessage: "Geen opties beschikbaar",
|
|
310
299
|
placeholder: "Maak een keuze",
|
|
311
300
|
initialValue: selectedBranchId,
|
|
312
|
-
onChange:
|
|
301
|
+
onChange: _ref9 => {
|
|
313
302
|
let {
|
|
314
303
|
label,
|
|
315
304
|
value
|
|
316
|
-
} =
|
|
305
|
+
} = _ref9;
|
|
317
306
|
setSelectedBranchId(value);
|
|
318
307
|
setLocalBranchId(value);
|
|
319
308
|
const formulaCode = branchIdWithFormulaCode.get(value);
|
|
@@ -61,4 +61,40 @@ describe('single-order branch selector helpers', () => {
|
|
|
61
61
|
name: 'Voorbeeld B.V.'
|
|
62
62
|
})).toBe('Rotterdam - Voorbeeld B.V.');
|
|
63
63
|
});
|
|
64
|
+
it('opens the vehicle picker only after a vestiging is chosen', () => {
|
|
65
|
+
expect((0, _singleOrderBranchSelector.shouldOpenSingleOrderVehicleSelector)({
|
|
66
|
+
selectedBranch: null,
|
|
67
|
+
isLoadingBranchById: false,
|
|
68
|
+
licensePlate: null,
|
|
69
|
+
model: null,
|
|
70
|
+
hasActiveFilters: false,
|
|
71
|
+
hasUserDismissedModal: false,
|
|
72
|
+
orderJustCompleted: false,
|
|
73
|
+
showProductOverview: true
|
|
74
|
+
})).toBe(false);
|
|
75
|
+
expect((0, _singleOrderBranchSelector.shouldOpenSingleOrderVehicleSelector)({
|
|
76
|
+
selectedBranch: 'branch-id',
|
|
77
|
+
isLoadingBranchById: false,
|
|
78
|
+
licensePlate: null,
|
|
79
|
+
model: null,
|
|
80
|
+
hasActiveFilters: false,
|
|
81
|
+
hasUserDismissedModal: false,
|
|
82
|
+
orderJustCompleted: false,
|
|
83
|
+
showProductOverview: true
|
|
84
|
+
})).toBe(true);
|
|
85
|
+
});
|
|
86
|
+
it('keeps webshop organizations even when formule is empty', () => {
|
|
87
|
+
const webshopBranches = [{
|
|
88
|
+
entityId: '1',
|
|
89
|
+
name: 'Van Mossel Opel Terneuzen'
|
|
90
|
+
}, {
|
|
91
|
+
entityId: '2',
|
|
92
|
+
name: 'Andere webshop',
|
|
93
|
+
formulaCode: 'TOW'
|
|
94
|
+
}];
|
|
95
|
+
expect((0, _singleOrderBranchSelector.getVisibleSingleOrderBranches)({
|
|
96
|
+
branches: webshopBranches,
|
|
97
|
+
formula: _constants__.CONFIGURATOR_FORMULAS.THL
|
|
98
|
+
})).toEqual(webshopBranches);
|
|
99
|
+
});
|
|
64
100
|
});
|
|
@@ -5,7 +5,7 @@ require("core-js/modules/esnext.iterator.filter.js");
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.shouldShowSingleOrderBranchTypeSelector = exports.shouldResetSingleOrderBranchSelection = exports.shouldResetDismissedBranchSelectorState = exports.shouldOpenSingleOrderCustomerSelector = exports.getSingleOrderBranchTypeId = exports.getSingleOrderBranchOptionLabel = void 0;
|
|
8
|
+
exports.shouldShowSingleOrderBranchTypeSelector = exports.shouldResetSingleOrderBranchSelection = exports.shouldResetDismissedBranchSelectorState = exports.shouldOpenSingleOrderVehicleSelector = exports.shouldOpenSingleOrderCustomerSelector = exports.getVisibleSingleOrderBranches = exports.getSingleOrderBranchTypeId = exports.getSingleOrderBranchOptionLabel = void 0;
|
|
9
9
|
require("core-js/modules/esnext.iterator.constructor.js");
|
|
10
10
|
require("core-js/modules/esnext.iterator.filter.js");
|
|
11
11
|
var _constants__ = require("../__constants__");
|
|
@@ -66,4 +66,40 @@ exports.shouldResetSingleOrderBranchSelection = shouldResetSingleOrderBranchSele
|
|
|
66
66
|
const getSingleOrderBranchOptionLabel = exports.getSingleOrderBranchOptionLabel = function getSingleOrderBranchOptionLabel() {
|
|
67
67
|
let branch = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
68
68
|
return [branch.naamVestiging, branch.name].filter(Boolean).join(' - ');
|
|
69
|
-
};
|
|
69
|
+
};
|
|
70
|
+
const shouldOpenSingleOrderVehicleSelector = _ref6 => {
|
|
71
|
+
let {
|
|
72
|
+
selectedBranch,
|
|
73
|
+
isLoadingBranchById,
|
|
74
|
+
licensePlate,
|
|
75
|
+
model,
|
|
76
|
+
hasActiveFilters,
|
|
77
|
+
hasUserDismissedModal,
|
|
78
|
+
orderJustCompleted,
|
|
79
|
+
showProductOverview
|
|
80
|
+
} = _ref6;
|
|
81
|
+
return Boolean(showProductOverview && selectedBranch && !isLoadingBranchById && !licensePlate && !model && !hasActiveFilters && !hasUserDismissedModal && !orderJustCompleted);
|
|
82
|
+
};
|
|
83
|
+
exports.shouldOpenSingleOrderVehicleSelector = shouldOpenSingleOrderVehicleSelector;
|
|
84
|
+
const getVisibleSingleOrderBranches = _ref7 => {
|
|
85
|
+
let {
|
|
86
|
+
branches,
|
|
87
|
+
formula
|
|
88
|
+
} = _ref7;
|
|
89
|
+
if (!branches || (0, _constants__.isLooseOrderOnlyFormula)(formula)) {
|
|
90
|
+
return branches;
|
|
91
|
+
}
|
|
92
|
+
const normalizedFormula = (0, _constants__.getConfiguratorFormulaCode)(formula);
|
|
93
|
+
if (normalizedFormula === _constants__.CONFIGURATOR_FORMULAS.TMG) {
|
|
94
|
+
return branches;
|
|
95
|
+
}
|
|
96
|
+
return branches.filter(branch => {
|
|
97
|
+
var _ref8, _branch$formulaCode, _branch$formule;
|
|
98
|
+
const branchFormula = (0, _constants__.getConfiguratorFormulaCode)((_ref8 = (_branch$formulaCode = branch === null || branch === void 0 ? void 0 : branch.formulaCode) !== null && _branch$formulaCode !== void 0 ? _branch$formulaCode : branch === null || branch === void 0 || (_branch$formule = branch.formule) === null || _branch$formule === void 0 ? void 0 : _branch$formule.code) !== null && _ref8 !== void 0 ? _ref8 : branch === null || branch === void 0 ? void 0 : branch.formule);
|
|
99
|
+
if ((0, _constants__.isThcFamilyFormula)(normalizedFormula)) {
|
|
100
|
+
return (0, _constants__.isThcFamilyFormula)(branchFormula);
|
|
101
|
+
}
|
|
102
|
+
return branchFormula === normalizedFormula;
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
exports.getVisibleSingleOrderBranches = getVisibleSingleOrderBranches;
|
|
@@ -36,6 +36,7 @@ var _VehicleData = _interopRequireDefault(require("../../__containers__/VehicleD
|
|
|
36
36
|
var _FormulaContext = require("../../__context__/FormulaContext");
|
|
37
37
|
var _OrderSessionContext = require("../../__context__/OrderSessionContext");
|
|
38
38
|
var _helpers__ = require("../../__helpers__");
|
|
39
|
+
var _singleOrderBranchSelector = require("../../__helpers__/singleOrderBranchSelector");
|
|
39
40
|
var _singleOrderArticles = require("../../__helpers__/singleOrderArticles");
|
|
40
41
|
var _singleOrderWebshop = require("../../__helpers__/singleOrderWebshop");
|
|
41
42
|
var _singleOrderVehicleReceipt = require("../../__helpers__/singleOrderVehicleReceipt");
|
|
@@ -207,8 +208,16 @@ const InternalSingleOrderPage = () => {
|
|
|
207
208
|
|
|
208
209
|
// Don't open modal if order was just successfully created
|
|
209
210
|
const orderJustCompleted = isCreateSingleOrderSuccess || isCreateShopifyOrderSuccess;
|
|
210
|
-
|
|
211
|
-
|
|
211
|
+
if ((0, _singleOrderBranchSelector.shouldOpenSingleOrderVehicleSelector)({
|
|
212
|
+
selectedBranch,
|
|
213
|
+
isLoadingBranchById,
|
|
214
|
+
licensePlate,
|
|
215
|
+
model,
|
|
216
|
+
hasActiveFilters,
|
|
217
|
+
hasUserDismissedModal,
|
|
218
|
+
orderJustCompleted,
|
|
219
|
+
showProductOverview
|
|
220
|
+
})) {
|
|
212
221
|
setIsDirectSelectorModalOpen(true);
|
|
213
222
|
} else {
|
|
214
223
|
// Close modal if filters become active or we're on details page
|
|
@@ -216,7 +225,7 @@ const InternalSingleOrderPage = () => {
|
|
|
216
225
|
setIsDirectSelectorModalOpen(false);
|
|
217
226
|
}
|
|
218
227
|
}
|
|
219
|
-
}, [selectedBranch,
|
|
228
|
+
}, [selectedBranch, licensePlate, model, filters, isLoadingBranchById, isDirectSelectorModalOpen, hasUserDismissedModal, isCreateSingleOrderSuccess, isCreateShopifyOrderSuccess, showProductOverview]);
|
|
220
229
|
const resetOrderSession = (0, _react.useCallback)(() => {
|
|
221
230
|
dispatch({
|
|
222
231
|
type: _OrderSessionContext.orderSessionActions.RESET_SINGLE_ORDER
|