thm-p3-configurator 0.0.405 → 0.0.407
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/public/assets/images/tm-logo-old.png +0 -0
- package/dist/public/assets/images/tm-logo.png +0 -0
- package/dist/src/shared/__api__/__tests__/queryKeyFactory.test.js +1 -1
- package/dist/src/shared/__api__/queries.js +10 -1
- package/dist/src/shared/__api__/queryKeyFactory.js +1 -1
- package/dist/src/shared/__components__/Form/DatePickerInput.js +5 -1
- package/dist/src/shared/__components__/Form/TimePickerInput.js +122 -12
- package/dist/src/shared/__components__/internal/InternalCustomerDetailsForm.js +52 -28
- package/dist/src/shared/__constants__/__tests__/index.test.js +7 -7
- package/dist/src/shared/__constants__/index.js +24 -7
- package/dist/src/shared/__containers__/ProductsCartOverview.js +3 -1
- package/dist/src/shared/__containers__/internal/InternalAppointmentForm.js +123 -60
- package/dist/src/shared/__containers__/internal/InternalQuotationForm.js +2 -8
- package/dist/src/shared/__context__/OrderSessionContext.js +3 -1
- package/dist/src/shared/__helpers__/countryOptions.js +42 -0
- package/dist/src/shared/__helpers__/dossier.js +14 -1
- package/dist/src/shared/__helpers__/openingHours.js +211 -0
- package/dist/src/shared/__hooks__/usePricingFormula.js +30 -0
- package/dist/src/shared/__pages__/internal/InternalSessionEditPage.js +12 -6
- package/package.json +1 -1
|
Binary file
|
|
Binary file
|
|
@@ -90,7 +90,7 @@ describe('queryKeyFactory', () => {
|
|
|
90
90
|
});
|
|
91
91
|
it('includes formula in brands and build-years keys', () => {
|
|
92
92
|
expect((0, _queryKeyFactory.getBrandsQueryKey)('TMG')).toEqual(['brands', 'TMG']);
|
|
93
|
-
expect((0, _queryKeyFactory.getBrandsQueryKey)('
|
|
93
|
+
expect((0, _queryKeyFactory.getBrandsQueryKey)('TBE')).toEqual(['brands', 'TBE']);
|
|
94
94
|
expect((0, _queryKeyFactory.getBuildYearsQueryKey)({
|
|
95
95
|
brand: 'Volvo',
|
|
96
96
|
formula: 'TMG'
|
|
@@ -38,6 +38,7 @@ var _constants__ = require("../__constants__");
|
|
|
38
38
|
var _AuthSessionContext = require("../__context__/AuthSessionContext");
|
|
39
39
|
var _FormulaContext = require("../__context__/FormulaContext");
|
|
40
40
|
var _OrderSessionContext = require("../__context__/OrderSessionContext");
|
|
41
|
+
var _usePricingFormula = require("../__hooks__/usePricingFormula");
|
|
41
42
|
var _helpers__ = require("../__helpers__");
|
|
42
43
|
var _singleOrderArticles = require("../__helpers__/singleOrderArticles");
|
|
43
44
|
var _singleOrderCartArticles = require("../__helpers__/singleOrderCartArticles");
|
|
@@ -534,7 +535,15 @@ const useSingleOrderCart = () => {
|
|
|
534
535
|
exports.useSingleOrderCart = useSingleOrderCart;
|
|
535
536
|
const useOrderDataQuery = exports.useOrderDataQuery = function useOrderDataQuery() {
|
|
536
537
|
let orderParameters = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
537
|
-
const
|
|
538
|
+
const [{
|
|
539
|
+
existingDossierId
|
|
540
|
+
}] = (0, _OrderSessionContext.useOrderSession)();
|
|
541
|
+
const pricingFormula = (0, _usePricingFormula.usePricingFormula)();
|
|
542
|
+
const normalizedOrderParams = (0, _queryKeyFactory.normalizeOrderParams)(_objectSpread(_objectSpread({}, orderParameters), {}, {
|
|
543
|
+
formula: pricingFormula
|
|
544
|
+
}, existingDossierId ? {
|
|
545
|
+
existingDossierEntityId: existingDossierId
|
|
546
|
+
} : {}));
|
|
538
547
|
const {
|
|
539
548
|
licensePlate,
|
|
540
549
|
model
|
|
@@ -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', 'buildYear', 'durationAnswer', 'executionAnswer1', 'executionAnswer2', 'selectBoardComputerUpdate', 'branchId', 'skipFilters', 'discountCode', 'discountAmount', 'discountPercentage', 'montageRate', 'extraPriceAmount', 'priceCalculationDate', 'cart'];
|
|
72
|
+
const ORDER_PARAM_PRIORITY = ['licensePlate', 'model', 'formula', 'buildYear', 'durationAnswer', 'executionAnswer1', 'executionAnswer2', 'selectBoardComputerUpdate', 'branchId', 'existingDossierEntityId', '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 => {
|
|
@@ -54,7 +54,9 @@ const DatePickerInput = _ref => {
|
|
|
54
54
|
label,
|
|
55
55
|
errorMessage,
|
|
56
56
|
minDate = new Date(),
|
|
57
|
-
maxDate
|
|
57
|
+
maxDate,
|
|
58
|
+
filterDate,
|
|
59
|
+
includeDates
|
|
58
60
|
} = _ref;
|
|
59
61
|
const [value, setValue] = (0, _react.useState)(null);
|
|
60
62
|
const [isTouched, setIsTouched] = (0, _react.useState)(false);
|
|
@@ -112,6 +114,8 @@ const DatePickerInput = _ref => {
|
|
|
112
114
|
},
|
|
113
115
|
minDate: minDate,
|
|
114
116
|
maxDate: maxDate,
|
|
117
|
+
filterDate: filterDate,
|
|
118
|
+
includeDates: includeDates,
|
|
115
119
|
locale: "nl",
|
|
116
120
|
onFocus: handleFocus,
|
|
117
121
|
onChange: date => handleChange(date),
|
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
require("core-js/modules/es.weak-map.js");
|
|
4
|
+
require("core-js/modules/esnext.iterator.constructor.js");
|
|
5
|
+
require("core-js/modules/esnext.iterator.filter.js");
|
|
6
|
+
require("core-js/modules/esnext.iterator.for-each.js");
|
|
4
7
|
require("core-js/modules/web.dom-collections.iterator.js");
|
|
5
8
|
require("core-js/modules/es.weak-map.js");
|
|
9
|
+
require("core-js/modules/esnext.iterator.constructor.js");
|
|
10
|
+
require("core-js/modules/esnext.iterator.filter.js");
|
|
11
|
+
require("core-js/modules/esnext.iterator.for-each.js");
|
|
6
12
|
Object.defineProperty(exports, "__esModule", {
|
|
7
13
|
value: true
|
|
8
14
|
});
|
|
9
15
|
exports.default = void 0;
|
|
10
16
|
require("core-js/modules/web.dom-collections.iterator.js");
|
|
11
17
|
var _nl = _interopRequireDefault(require("date-fns/locale/nl"));
|
|
18
|
+
var _dateFns = require("date-fns");
|
|
12
19
|
var _setHours = _interopRequireDefault(require("date-fns/setHours"));
|
|
13
20
|
var _setMinutes = _interopRequireDefault(require("date-fns/setMinutes"));
|
|
14
21
|
var _moment = _interopRequireDefault(require("moment"));
|
|
15
22
|
var _react = _interopRequireWildcard(require("react"));
|
|
16
23
|
var _reactDatepicker = _interopRequireWildcard(require("react-datepicker"));
|
|
24
|
+
var _openingHours = require("../../__helpers__/openingHours");
|
|
17
25
|
var _helpers__ = require("../../__helpers__");
|
|
18
26
|
var _ErrorMessage = _interopRequireDefault(require("./ErrorMessage"));
|
|
19
27
|
function _getRequireWildcardCache(e) {
|
|
@@ -46,30 +54,127 @@ function _interopRequireDefault(e) {
|
|
|
46
54
|
default: e
|
|
47
55
|
};
|
|
48
56
|
}
|
|
57
|
+
function ownKeys(e, r) {
|
|
58
|
+
var t = Object.keys(e);
|
|
59
|
+
if (Object.getOwnPropertySymbols) {
|
|
60
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
61
|
+
r && (o = o.filter(function (r) {
|
|
62
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
63
|
+
})), t.push.apply(t, o);
|
|
64
|
+
}
|
|
65
|
+
return t;
|
|
66
|
+
}
|
|
67
|
+
function _objectSpread(e) {
|
|
68
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
69
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
70
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
|
|
71
|
+
_defineProperty(e, r, t[r]);
|
|
72
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
|
73
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
return e;
|
|
77
|
+
}
|
|
78
|
+
function _defineProperty(e, r, t) {
|
|
79
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
80
|
+
value: t,
|
|
81
|
+
enumerable: !0,
|
|
82
|
+
configurable: !0,
|
|
83
|
+
writable: !0
|
|
84
|
+
}) : e[r] = t, e;
|
|
85
|
+
}
|
|
86
|
+
function _toPropertyKey(t) {
|
|
87
|
+
var i = _toPrimitive(t, "string");
|
|
88
|
+
return "symbol" == typeof i ? i : i + "";
|
|
89
|
+
}
|
|
90
|
+
function _toPrimitive(t, r) {
|
|
91
|
+
if ("object" != typeof t || !t) return t;
|
|
92
|
+
var e = t[Symbol.toPrimitive];
|
|
93
|
+
if (void 0 !== e) {
|
|
94
|
+
var i = e.call(t, r || "default");
|
|
95
|
+
if ("object" != typeof i) return i;
|
|
96
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
97
|
+
}
|
|
98
|
+
return ("string" === r ? String : Number)(t);
|
|
99
|
+
}
|
|
49
100
|
(0, _reactDatepicker.registerLocale)('nl', _nl.default);
|
|
101
|
+
const getTimeInMinutes = date => {
|
|
102
|
+
if (!date) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
const value = new Date(date);
|
|
106
|
+
return value.getHours() * 60 + value.getMinutes();
|
|
107
|
+
};
|
|
50
108
|
const TimePickerInput = _ref => {
|
|
109
|
+
var _openToDate$getTime, _openToDate$getTime2, _resolvedOpenToDate$g, _resolvedOpenToDate$g2, _minTime$getTime, _minTime$getTime2, _maxTime$getTime, _maxTime$getTime2;
|
|
51
110
|
let {
|
|
52
111
|
initialValue,
|
|
112
|
+
value: controlledValue,
|
|
53
113
|
onChange,
|
|
54
114
|
name,
|
|
55
115
|
isRequired,
|
|
56
116
|
label,
|
|
57
117
|
isStrict = false,
|
|
118
|
+
isDisabled = false,
|
|
119
|
+
minTime: minTimeProp = null,
|
|
120
|
+
maxTime: maxTimeProp = null,
|
|
121
|
+
openToDate = null,
|
|
58
122
|
errorMessage
|
|
59
123
|
} = _ref;
|
|
60
|
-
const
|
|
124
|
+
const isControlled = controlledValue !== undefined;
|
|
125
|
+
const [internalValue, setInternalValue] = (0, _react.useState)(null);
|
|
61
126
|
const [isTouched, setIsTouched] = (0, _react.useState)(false);
|
|
127
|
+
const strictMinTime = isStrict ? (0, _setHours.default)((0, _setMinutes.default)(new Date(), 0), 6) : null;
|
|
128
|
+
const strictMaxTime = isStrict ? (0, _setHours.default)((0, _setMinutes.default)(new Date(), 0), 20) : null;
|
|
129
|
+
const minTime = minTimeProp !== null && minTimeProp !== void 0 ? minTimeProp : strictMinTime;
|
|
130
|
+
const maxTime = maxTimeProp !== null && maxTimeProp !== void 0 ? maxTimeProp : strictMaxTime;
|
|
131
|
+
const resolvedOpenToDate = (0, _react.useMemo)(() => openToDate ? new Date(openToDate) : null, [(_openToDate$getTime = openToDate === null || openToDate === void 0 || (_openToDate$getTime2 = openToDate.getTime) === null || _openToDate$getTime2 === void 0 ? void 0 : _openToDate$getTime2.call(openToDate)) !== null && _openToDate$getTime !== void 0 ? _openToDate$getTime : openToDate]);
|
|
132
|
+
const pickerMinDate = (0, _react.useMemo)(() => resolvedOpenToDate ? (0, _dateFns.startOfDay)(resolvedOpenToDate) : (0, _dateFns.startOfDay)(new Date()), [(_resolvedOpenToDate$g = resolvedOpenToDate === null || resolvedOpenToDate === void 0 || (_resolvedOpenToDate$g2 = resolvedOpenToDate.getTime) === null || _resolvedOpenToDate$g2 === void 0 ? void 0 : _resolvedOpenToDate$g2.call(resolvedOpenToDate)) !== null && _resolvedOpenToDate$g !== void 0 ? _resolvedOpenToDate$g : resolvedOpenToDate]);
|
|
133
|
+
const selectedValue = isControlled ? controlledValue !== null && controlledValue !== void 0 ? controlledValue : null : internalValue;
|
|
134
|
+
const initialTimestamp = initialValue instanceof Date ? initialValue.getTime() : initialValue ? new Date(initialValue).getTime() : null;
|
|
62
135
|
(0, _react.useEffect)(() => {
|
|
63
|
-
if (
|
|
64
|
-
|
|
136
|
+
if (isControlled) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
if (initialTimestamp && (0, _moment.default)(initialTimestamp).isValid()) {
|
|
140
|
+
setInternalValue(new Date(initialTimestamp));
|
|
141
|
+
return;
|
|
65
142
|
}
|
|
66
|
-
|
|
143
|
+
setInternalValue(null);
|
|
144
|
+
}, [isControlled, initialTimestamp]);
|
|
145
|
+
const filterTime = (0, _react.useCallback)(time => {
|
|
146
|
+
if (!minTime && !maxTime) {
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
const selectedMinutes = getTimeInMinutes(time);
|
|
150
|
+
if (selectedMinutes == null) {
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
const minMinutes = getTimeInMinutes(minTime);
|
|
154
|
+
if (minMinutes != null && selectedMinutes < minMinutes) {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
const maxMinutes = getTimeInMinutes(maxTime);
|
|
158
|
+
if (maxMinutes != null && selectedMinutes > maxMinutes) {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
return true;
|
|
162
|
+
}, [(_minTime$getTime = minTime === null || minTime === void 0 || (_minTime$getTime2 = minTime.getTime) === null || _minTime$getTime2 === void 0 ? void 0 : _minTime$getTime2.call(minTime)) !== null && _minTime$getTime !== void 0 ? _minTime$getTime : minTime, (_maxTime$getTime = maxTime === null || maxTime === void 0 || (_maxTime$getTime2 = maxTime.getTime) === null || _maxTime$getTime2 === void 0 ? void 0 : _maxTime$getTime2.call(maxTime)) !== null && _maxTime$getTime !== void 0 ? _maxTime$getTime : maxTime]);
|
|
67
163
|
const handleFocus = () => {
|
|
164
|
+
if (isDisabled) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
68
167
|
setIsTouched(true);
|
|
69
168
|
};
|
|
70
169
|
const handleChange = date => {
|
|
71
|
-
|
|
72
|
-
|
|
170
|
+
if (isDisabled) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
const nextValue = date && resolvedOpenToDate ? (0, _openingHours.copyTimeToDate)(date, resolvedOpenToDate) : date;
|
|
174
|
+
if (!isControlled) {
|
|
175
|
+
setInternalValue(nextValue);
|
|
176
|
+
}
|
|
177
|
+
onChange(nextValue);
|
|
73
178
|
};
|
|
74
179
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
75
180
|
className: (0, _helpers__.withStyle)('form-group')
|
|
@@ -80,10 +185,14 @@ const TimePickerInput = _ref => {
|
|
|
80
185
|
className: isTouched && errorMessage ? (0, _helpers__.withStyle)('is-invalid') : ''
|
|
81
186
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
82
187
|
className: (0, _helpers__.withStyle)('form-group__icon-field'),
|
|
83
|
-
style: {
|
|
188
|
+
style: _objectSpread({
|
|
84
189
|
position: 'relative',
|
|
85
190
|
width: '100%'
|
|
86
|
-
}
|
|
191
|
+
}, isDisabled ? {
|
|
192
|
+
pointerEvents: 'none',
|
|
193
|
+
opacity: 0.65,
|
|
194
|
+
cursor: 'not-allowed'
|
|
195
|
+
} : {})
|
|
87
196
|
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
88
197
|
className: "fal fa-clock",
|
|
89
198
|
"aria-hidden": "true",
|
|
@@ -107,13 +216,14 @@ const TimePickerInput = _ref => {
|
|
|
107
216
|
timeCaption: name,
|
|
108
217
|
id: name,
|
|
109
218
|
name: name,
|
|
110
|
-
|
|
219
|
+
disabled: isDisabled,
|
|
220
|
+
selected: selectedValue,
|
|
111
221
|
onKeyDown: e => {
|
|
112
222
|
e.preventDefault();
|
|
113
223
|
},
|
|
114
|
-
minDate:
|
|
115
|
-
|
|
116
|
-
|
|
224
|
+
minDate: pickerMinDate,
|
|
225
|
+
openToDate: resolvedOpenToDate !== null && resolvedOpenToDate !== void 0 ? resolvedOpenToDate : undefined,
|
|
226
|
+
filterTime: minTime || maxTime ? filterTime : undefined,
|
|
117
227
|
locale: "nl",
|
|
118
228
|
onFocus: handleFocus,
|
|
119
229
|
wrapperClassName: (0, _helpers__.withStyle)('react-datepicker-wrapper'),
|
|
@@ -32,7 +32,9 @@ var _queries = require("../../__api__/queries");
|
|
|
32
32
|
var _constants__ = require("../../__constants__");
|
|
33
33
|
var _AuthSessionContext = require("../../__context__/AuthSessionContext");
|
|
34
34
|
var _OrderSessionContext = require("../../__context__/OrderSessionContext");
|
|
35
|
+
var _openingHours = require("../../__helpers__/openingHours");
|
|
35
36
|
var _helpers__ = require("../../__helpers__");
|
|
37
|
+
var _countryOptions = require("../../__helpers__/countryOptions");
|
|
36
38
|
var _useIsTmg = require("../../__hooks__/useIsTmg");
|
|
37
39
|
var _AddressLookupService = _interopRequireDefault(require("../../__services__/AddressLookupService"));
|
|
38
40
|
var _LinkButton = _interopRequireDefault(require("../Buttons/LinkButton"));
|
|
@@ -160,7 +162,7 @@ const customerDetailsFormSchema = (0, _yup.object)({
|
|
|
160
162
|
})
|
|
161
163
|
});
|
|
162
164
|
const InternalCustomerDetailsForm = (_ref, ref) => {
|
|
163
|
-
var _customer$vatNumber, _customer$kvkNumber, _branchTypes$byId$aut, _authSession$branch, _authSession$branch2;
|
|
165
|
+
var _appointment$time$get, _appointment$time, _appointment$time$get2, _appointment$date$get, _appointment$date, _appointment$date$get2, _customer$vatNumber, _customer$kvkNumber, _branchTypes$byId$aut, _authSession$branch, _authSession$branch2, _ref5, _appointment$date$get3, _appointment$date2, _appointment$date2$ge;
|
|
164
166
|
let {
|
|
165
167
|
errors = {},
|
|
166
168
|
onValidationError,
|
|
@@ -187,14 +189,13 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
|
|
|
187
189
|
countries,
|
|
188
190
|
isLoadingCountries
|
|
189
191
|
} = (0, _queries.useCountriesQuery)();
|
|
190
|
-
const countryOptions = (0, _react.useMemo)(() =>
|
|
191
|
-
|
|
192
|
-
if (!(
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
}, [countries]);
|
|
192
|
+
const countryOptions = (0, _react.useMemo)(() => (0, _countryOptions.buildCountryDropdownOptions)(countries === null || countries === void 0 ? void 0 : countries.results), [countries]);
|
|
193
|
+
const appointmentTimeValue = (0, _react.useMemo)(() => {
|
|
194
|
+
if (!(appointment !== null && appointment !== void 0 && appointment.time) || !(appointment !== null && appointment !== void 0 && appointment.date)) {
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
return (0, _openingHours.copyTimeToDate)(new Date(appointment.time), new Date(appointment.date));
|
|
198
|
+
}, [(_appointment$time$get = appointment === null || appointment === void 0 || (_appointment$time = appointment.time) === null || _appointment$time === void 0 || (_appointment$time$get2 = _appointment$time.getTime) === null || _appointment$time$get2 === void 0 ? void 0 : _appointment$time$get2.call(_appointment$time)) !== null && _appointment$time$get !== void 0 ? _appointment$time$get : appointment === null || appointment === void 0 ? void 0 : appointment.time, (_appointment$date$get = appointment === null || appointment === void 0 || (_appointment$date = appointment.date) === null || _appointment$date === void 0 || (_appointment$date$get2 = _appointment$date.getTime) === null || _appointment$date$get2 === void 0 ? void 0 : _appointment$date$get2.call(_appointment$date)) !== null && _appointment$date$get !== void 0 ? _appointment$date$get : appointment === null || appointment === void 0 ? void 0 : appointment.date]);
|
|
198
199
|
const authSession = (0, _AuthSessionContext.useAuthSession)();
|
|
199
200
|
const isTmg = (0, _useIsTmg.useIsTmg)();
|
|
200
201
|
const [companySearchTerm, setCompanySearchTerm] = (0, _react.useState)('');
|
|
@@ -263,10 +264,15 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
|
|
|
263
264
|
const needsCustomerDeliveryIdentity = isDirectDeliveryEnabled;
|
|
264
265
|
const isNetherlandsSelected = (0, _react.useMemo)(() => {
|
|
265
266
|
if (!(selectedCountry !== null && selectedCountry !== void 0 && selectedCountry.label)) return false;
|
|
266
|
-
return selectedCountry.label.toUpperCase() ===
|
|
267
|
+
return selectedCountry.label.toUpperCase() === _constants__.COUNTRY_NAMES.NETHERLANDS;
|
|
268
|
+
}, [selectedCountry === null || selectedCountry === void 0 ? void 0 : selectedCountry.label]);
|
|
269
|
+
const isBelgiumSelected = (0, _react.useMemo)(() => {
|
|
270
|
+
if (!(selectedCountry !== null && selectedCountry !== void 0 && selectedCountry.label)) return false;
|
|
271
|
+
const normalizedCountryLabel = selectedCountry.label.trim().toUpperCase();
|
|
272
|
+
return normalizedCountryLabel === _constants__.COUNTRY_NAMES.BELGIUM || normalizedCountryLabel === _constants__.COUNTRY_NAMES.BELGIUM_FALLBACK;
|
|
267
273
|
}, [selectedCountry === null || selectedCountry === void 0 ? void 0 : selectedCountry.label]);
|
|
268
|
-
const shouldRequireKvkNumber = needsCustomerDeliveryIdentity && isBusinessOwnership && (isNetherlandsSelected || !(customer !== null && customer !== void 0 && (_customer$vatNumber = customer.vatNumber) !== null && _customer$vatNumber !== void 0 && _customer$vatNumber.trim()));
|
|
269
|
-
const shouldRequireVatNumber = needsCustomerDeliveryIdentity && isBusinessOwnership && !isNetherlandsSelected && !(customer !== null && customer !== void 0 && (_customer$kvkNumber = customer.kvkNumber) !== null && _customer$kvkNumber !== void 0 && _customer$kvkNumber.trim());
|
|
274
|
+
const shouldRequireKvkNumber = needsCustomerDeliveryIdentity && isBusinessOwnership && (isNetherlandsSelected || !isNetherlandsSelected && !isBelgiumSelected && !(customer !== null && customer !== void 0 && (_customer$vatNumber = customer.vatNumber) !== null && _customer$vatNumber !== void 0 && _customer$vatNumber.trim()));
|
|
275
|
+
const shouldRequireVatNumber = needsCustomerDeliveryIdentity && isBusinessOwnership && (isBelgiumSelected || !isNetherlandsSelected && !isBelgiumSelected && !(customer !== null && customer !== void 0 && (_customer$kvkNumber = customer.kvkNumber) !== null && _customer$kvkNumber !== void 0 && _customer$kvkNumber.trim()));
|
|
270
276
|
|
|
271
277
|
// Helper to update customer data for the active ownership type
|
|
272
278
|
const updateCustomerField = (0, _react.useCallback)((field, value) => {
|
|
@@ -341,13 +347,15 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
|
|
|
341
347
|
enabled: isBusinessOwnership
|
|
342
348
|
});
|
|
343
349
|
(0, _react.useEffect)(() => {
|
|
344
|
-
if (
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
350
|
+
if (customer !== null && customer !== void 0 && customer.countryId || !(countryOptions !== null && countryOptions !== void 0 && countryOptions.length)) {
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
const inferredCountry = (0, _helpers__.getCountryOptionForPostalCode)(customer === null || customer === void 0 ? void 0 : customer.zipCode, countryOptions);
|
|
354
|
+
const defaultCountry = inferredCountry || countryOptions.find(option => option.label === 'NEDERLAND');
|
|
355
|
+
if (defaultCountry) {
|
|
356
|
+
updateCustomerField('countryId', defaultCountry.value);
|
|
349
357
|
}
|
|
350
|
-
}, [customer === null || customer === void 0 ? void 0 : customer.countryId, countryOptions, updateCustomerField]);
|
|
358
|
+
}, [customer === null || customer === void 0 ? void 0 : customer.countryId, customer === null || customer === void 0 ? void 0 : customer.zipCode, countryOptions, updateCustomerField]);
|
|
351
359
|
(0, _react.useEffect)(() => {
|
|
352
360
|
if (checkboxAvailability.shouldForceDirectDelivery && !Boolean(anderAfleveradres)) {
|
|
353
361
|
dispatch({
|
|
@@ -526,7 +534,13 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
|
|
|
526
534
|
});
|
|
527
535
|
return false;
|
|
528
536
|
}
|
|
529
|
-
if (
|
|
537
|
+
if (isBelgiumSelected && !hasVatNumber) {
|
|
538
|
+
onValidationError === null || onValidationError === void 0 || onValidationError({
|
|
539
|
+
vatNumber: 'BTW-nummer is verplicht voor zakelijke dossiers in België'
|
|
540
|
+
});
|
|
541
|
+
return false;
|
|
542
|
+
}
|
|
543
|
+
if (!isNetherlandsSelected && !isBelgiumSelected && !hasKvkNumber && !hasVatNumber) {
|
|
530
544
|
onValidationError === null || onValidationError === void 0 || onValidationError({
|
|
531
545
|
kvkNumber: 'Vul een KVK- of BTW-nummer in',
|
|
532
546
|
vatNumber: 'Vul een KVK- of BTW-nummer in'
|
|
@@ -958,25 +972,35 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
|
|
|
958
972
|
}, "Gegevens voor de afspraak", /*#__PURE__*/_react.default.createElement("br", null)), /*#__PURE__*/_react.default.createElement("div", {
|
|
959
973
|
className: (0, _helpers__.withStyle)('col-12 col-md-6')
|
|
960
974
|
}, /*#__PURE__*/_react.default.createElement(_DatePickerInput.default, {
|
|
961
|
-
onChange: value =>
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
975
|
+
onChange: value => {
|
|
976
|
+
dispatch({
|
|
977
|
+
type: _OrderSessionContext.orderSessionActions.SET_APPOINTMENT_DATE,
|
|
978
|
+
payload: {
|
|
979
|
+
date: value
|
|
980
|
+
}
|
|
981
|
+
});
|
|
982
|
+
dispatch({
|
|
983
|
+
type: _OrderSessionContext.orderSessionActions.SET_APPOINTMENT_TIME,
|
|
984
|
+
payload: {
|
|
985
|
+
time: null
|
|
986
|
+
}
|
|
987
|
+
});
|
|
988
|
+
},
|
|
967
989
|
name: 'Datum',
|
|
968
990
|
label: "Datum",
|
|
969
991
|
initialValue: appointment !== null && appointment !== void 0 && appointment.date ? new Date(appointment === null || appointment === void 0 ? void 0 : appointment.date) : null,
|
|
970
992
|
isStrict: false,
|
|
971
993
|
errorMessage: errors === null || errors === void 0 ? void 0 : errors['date']
|
|
972
994
|
}), /*#__PURE__*/_react.default.createElement(_TimePickerInput.default, {
|
|
973
|
-
|
|
995
|
+
key: "appointment-time-".concat((_ref5 = (_appointment$date$get3 = appointment === null || appointment === void 0 || (_appointment$date2 = appointment.date) === null || _appointment$date2 === void 0 || (_appointment$date2$ge = _appointment$date2.getTime) === null || _appointment$date2$ge === void 0 ? void 0 : _appointment$date2$ge.call(_appointment$date2)) !== null && _appointment$date$get3 !== void 0 ? _appointment$date$get3 : appointment === null || appointment === void 0 ? void 0 : appointment.date) !== null && _ref5 !== void 0 ? _ref5 : 'none'),
|
|
996
|
+
value: appointmentTimeValue,
|
|
997
|
+
onChange: time => dispatch({
|
|
974
998
|
type: _OrderSessionContext.orderSessionActions.SET_APPOINTMENT_TIME,
|
|
975
999
|
payload: {
|
|
976
|
-
time
|
|
1000
|
+
time
|
|
977
1001
|
}
|
|
978
1002
|
}),
|
|
979
|
-
|
|
1003
|
+
openToDate: appointment !== null && appointment !== void 0 && appointment.date ? new Date(appointment.date) : null,
|
|
980
1004
|
name: 'Tijd',
|
|
981
1005
|
label: "Tijd",
|
|
982
1006
|
isStrict: false,
|
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
var _index = require("../index");
|
|
4
4
|
describe('__constants__/formula helpers', () => {
|
|
5
|
-
it('keeps
|
|
6
|
-
expect((0, _index.mapBranchFormulaToConfiguratorFormula)('
|
|
7
|
-
expect((0, _index.mapBranchFormulaToConfiguratorFormula)('Trekhaakcentrum Business')).toBe(_index.CONFIGURATOR_FORMULAS.
|
|
5
|
+
it('keeps TBE exact when normalizing branch formulas', () => {
|
|
6
|
+
expect((0, _index.mapBranchFormulaToConfiguratorFormula)('TBE')).toBe(_index.CONFIGURATOR_FORMULAS.TBE);
|
|
7
|
+
expect((0, _index.mapBranchFormulaToConfiguratorFormula)('Trekhaakcentrum Business')).toBe(_index.CONFIGURATOR_FORMULAS.TBE);
|
|
8
8
|
});
|
|
9
9
|
it('normalizes known formula titles and codes without collapsing unknown codes', () => {
|
|
10
10
|
expect((0, _index.getConfiguratorFormulaCode)('Trekhaakcentrum')).toBe(_index.CONFIGURATOR_FORMULAS.THC);
|
|
11
11
|
expect((0, _index.getConfiguratorFormulaCode)('TowMotive')).toBe(_index.CONFIGURATOR_FORMULAS.TOW);
|
|
12
|
-
expect((0, _index.getConfiguratorFormulaCode)('
|
|
12
|
+
expect((0, _index.getConfiguratorFormulaCode)('tbe')).toBe(_index.CONFIGURATOR_FORMULAS.TBE);
|
|
13
13
|
expect((0, _index.getConfiguratorFormulaCode)('abc')).toBe('ABC');
|
|
14
14
|
});
|
|
15
|
-
it('treats
|
|
15
|
+
it('treats TBE as THC-family for theme decisions only', () => {
|
|
16
16
|
expect((0, _index.isThcFamilyFormula)(_index.CONFIGURATOR_FORMULAS.THC)).toBe(true);
|
|
17
|
-
expect((0, _index.isThcFamilyFormula)(_index.CONFIGURATOR_FORMULAS.
|
|
18
|
-
expect((0, _index.getThemeFormulaForConfiguratorFormula)(_index.CONFIGURATOR_FORMULAS.
|
|
17
|
+
expect((0, _index.isThcFamilyFormula)(_index.CONFIGURATOR_FORMULAS.TBE)).toBe(true);
|
|
18
|
+
expect((0, _index.getThemeFormulaForConfiguratorFormula)(_index.CONFIGURATOR_FORMULAS.TBE)).toBe(_index.CONFIGURATOR_FORMULAS.THC);
|
|
19
19
|
});
|
|
20
20
|
});
|
|
@@ -6,7 +6,7 @@ require("core-js/modules/es.string.trim.js");
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", {
|
|
7
7
|
value: true
|
|
8
8
|
});
|
|
9
|
-
exports.mapBranchFormulaToConfiguratorFormula = exports.isThcFamilyFormula = exports.getThemeFormulaForConfiguratorFormula = exports.getConfiguratorFormulaCode = exports.VESTIGING_TYPE_ID = exports.VEHICLE_SINGLE_ORDER_OWNERSHIP_TYPE = exports.VEHICLE_OWNERSHIP_TYPE = exports.VEHICLE_CODING_SUBGROUP_NAME = exports.USER_GEOLOCATION_KEY = exports.TOWMOTIVE_ORGANIZATION_TYPE = exports.TMG_ORGANIZATION_TYPE = exports.StockStatus = exports.STATUS_ASSESSMENT = exports.PRODUCT_CATEGORIES = exports.PRIVATE_SINGLE_ORDER_SESSION_KEY = exports.PARTNER_PORTAL_PAGE_TITLES_BY_THEME = exports.PARTNER_PORTAL_CHANNEL_TITLE = exports.ORDER_SESSION_KEY = exports.NO_PRODUCTS_CONTACT_DETAILS_BY_FORMULA = exports.NAVIGATION_STEPS_INTERNAL = exports.NAVIGATION_STEPS_EXTERNAL = exports.NAVIGATION_BUTTONS = exports.MOUSE_EXIT_INTENT_THROTTLE = exports.MOUSE_EXIT_INTENT_OFFSET = exports.LOCATION_TYPE = exports.LOCATION_CHANGE_BUTTON_LABEL = exports.LOCALE = exports.LEASE_TYPE_ID = exports.FORM_ERROR_MESSAGES = exports.EXECUTION_HELP_CONTACT_DETAILS_BY_FORMULA = exports.DOSSIER_TYPES = exports.DISCOUNT_TYPES = exports.DEFAULT_MAP_LONGITUDE = exports.DEFAULT_MAP_LATITUDE = exports.DEFAULT_ARTICLE_BRAND = exports.DAY_NAMES = exports.CONFIGURATOR_FORMULAS = exports.BRANCH_THEME_BY_FORMULA = exports.BRANCH_FORMULAS = exports.BOARD_COMPUTER_DISABLED_KEY = exports.ApiStockStatus = exports.AUTH_SESSION_KEY = exports.ARTICLE_SPECS_TRANSLATIONS = exports.ARTICLES_SYSTEM_FIELDS = exports.API_ERROR_CODES = exports.ALL_EXPERIMENTS = exports.ACTIVE_VARIANTS = void 0;
|
|
9
|
+
exports.normalizeFormulaForOrderApi = exports.mapBranchFormulaToConfiguratorFormula = exports.isThcFamilyFormula = exports.getThemeFormulaForConfiguratorFormula = exports.getConfiguratorFormulaCode = exports.VESTIGING_TYPE_ID = exports.VEHICLE_SINGLE_ORDER_OWNERSHIP_TYPE = exports.VEHICLE_OWNERSHIP_TYPE = exports.VEHICLE_CODING_SUBGROUP_NAME = exports.USER_GEOLOCATION_KEY = exports.TOWMOTIVE_ORGANIZATION_TYPE = exports.TMG_ORGANIZATION_TYPE = exports.StockStatus = exports.STATUS_ASSESSMENT = exports.PRODUCT_CATEGORIES = exports.PRIVATE_SINGLE_ORDER_SESSION_KEY = exports.PARTNER_PORTAL_PAGE_TITLES_BY_THEME = exports.PARTNER_PORTAL_CHANNEL_TITLE = exports.ORDER_SESSION_KEY = exports.NO_PRODUCTS_CONTACT_DETAILS_BY_FORMULA = exports.NAVIGATION_STEPS_INTERNAL = exports.NAVIGATION_STEPS_EXTERNAL = exports.NAVIGATION_BUTTONS = exports.MOUSE_EXIT_INTENT_THROTTLE = exports.MOUSE_EXIT_INTENT_OFFSET = exports.LOCATION_TYPE = exports.LOCATION_CHANGE_BUTTON_LABEL = exports.LOCALE = exports.LEASE_TYPE_ID = exports.FORM_ERROR_MESSAGES = exports.EXECUTION_HELP_CONTACT_DETAILS_BY_FORMULA = exports.DOSSIER_TYPES = exports.DISCOUNT_TYPES = exports.DEFAULT_MAP_LONGITUDE = exports.DEFAULT_MAP_LATITUDE = exports.DEFAULT_ARTICLE_BRAND = exports.DAY_NAMES = exports.COUNTRY_NAMES = exports.CONFIGURATOR_FORMULAS = exports.BRANCH_THEME_BY_FORMULA = exports.BRANCH_FORMULAS = exports.BOARD_COMPUTER_DISABLED_KEY = exports.ApiStockStatus = exports.AUTH_SESSION_KEY = exports.ARTICLE_SPECS_TRANSLATIONS = exports.ARTICLES_SYSTEM_FIELDS = exports.API_ERROR_CODES = exports.ALL_EXPERIMENTS = exports.ACTIVE_VARIANTS = void 0;
|
|
10
10
|
require("core-js/modules/es.array.includes.js");
|
|
11
11
|
require("core-js/modules/es.string.includes.js");
|
|
12
12
|
require("core-js/modules/es.string.trim.js");
|
|
@@ -27,6 +27,11 @@ const FORM_ERROR_MESSAGES = exports.FORM_ERROR_MESSAGES = {
|
|
|
27
27
|
licensePlateMin: 'Kenteken moet minimaal 6 characters bevatten',
|
|
28
28
|
licensePlateMax: 'Kenteken mag maximaal 8 characters bevatten'
|
|
29
29
|
};
|
|
30
|
+
const COUNTRY_NAMES = exports.COUNTRY_NAMES = {
|
|
31
|
+
NETHERLANDS: 'NEDERLAND',
|
|
32
|
+
BELGIUM: 'BELGIË',
|
|
33
|
+
BELGIUM_FALLBACK: 'BELGIE'
|
|
34
|
+
};
|
|
30
35
|
const BRANCH_FORMULAS = exports.BRANCH_FORMULAS = {
|
|
31
36
|
Trekhaakcentrum: 'Trekhaakcentrum',
|
|
32
37
|
TowMotiveGroup: 'TowMotive Group',
|
|
@@ -228,7 +233,7 @@ const ApiStockStatus = exports.ApiStockStatus = {
|
|
|
228
233
|
const CONFIGURATOR_FORMULAS = exports.CONFIGURATOR_FORMULAS = {
|
|
229
234
|
THM: 'THM',
|
|
230
235
|
THC: 'THC',
|
|
231
|
-
|
|
236
|
+
TBE: 'TBE',
|
|
232
237
|
TMG: 'TMG',
|
|
233
238
|
TOW: 'TOW',
|
|
234
239
|
TM: 'TOW',
|
|
@@ -250,6 +255,18 @@ const normalizeFormulaInput = formula => {
|
|
|
250
255
|
const normalizedFormula = formula.trim();
|
|
251
256
|
return normalizedFormula.length > 0 ? normalizedFormula : null;
|
|
252
257
|
};
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Hyper order/pricing APIs expect TM instead of THM for non-dossier flows.
|
|
261
|
+
*/
|
|
262
|
+
const normalizeFormulaForOrderApi = formula => {
|
|
263
|
+
const normalizedFormula = getConfiguratorFormulaCode(formula);
|
|
264
|
+
if (!normalizedFormula) {
|
|
265
|
+
return normalizedFormula;
|
|
266
|
+
}
|
|
267
|
+
return normalizedFormula === CONFIGURATOR_FORMULAS.THM ? CONFIGURATOR_FORMULAS.TM : normalizedFormula;
|
|
268
|
+
};
|
|
269
|
+
exports.normalizeFormulaForOrderApi = normalizeFormulaForOrderApi;
|
|
253
270
|
const getConfiguratorFormulaCode = formula => {
|
|
254
271
|
const normalizedFormula = normalizeFormulaInput(formula);
|
|
255
272
|
if (!normalizedFormula) {
|
|
@@ -267,10 +284,10 @@ const getConfiguratorFormulaCode = formula => {
|
|
|
267
284
|
case 'thc':
|
|
268
285
|
case 'trekhaakcentrum':
|
|
269
286
|
return CONFIGURATOR_FORMULAS.THC;
|
|
270
|
-
case '
|
|
287
|
+
case 'tbe':
|
|
271
288
|
case 'trekhaakcentrum belgie':
|
|
272
289
|
case 'trekhaakcentrum business':
|
|
273
|
-
return CONFIGURATOR_FORMULAS.
|
|
290
|
+
return CONFIGURATOR_FORMULAS.TBE;
|
|
274
291
|
case 'thm':
|
|
275
292
|
case 'trekhaakmontage':
|
|
276
293
|
return CONFIGURATOR_FORMULAS.THM;
|
|
@@ -281,7 +298,7 @@ const getConfiguratorFormulaCode = formula => {
|
|
|
281
298
|
exports.getConfiguratorFormulaCode = getConfiguratorFormulaCode;
|
|
282
299
|
const isThcFamilyFormula = formula => {
|
|
283
300
|
const normalizedFormula = getConfiguratorFormulaCode(formula);
|
|
284
|
-
return normalizedFormula === CONFIGURATOR_FORMULAS.THC || normalizedFormula === CONFIGURATOR_FORMULAS.
|
|
301
|
+
return normalizedFormula === CONFIGURATOR_FORMULAS.THC || normalizedFormula === CONFIGURATOR_FORMULAS.TBE;
|
|
285
302
|
};
|
|
286
303
|
exports.isThcFamilyFormula = isThcFamilyFormula;
|
|
287
304
|
const getThemeFormulaForConfiguratorFormula = formula => {
|
|
@@ -307,7 +324,7 @@ const NO_PRODUCTS_CONTACT_DETAILS_BY_FORMULA = exports.NO_PRODUCTS_CONTACT_DETAI
|
|
|
307
324
|
companyName: 'Trekhaakcentrum',
|
|
308
325
|
logoAltText: 'Trekhaakcentrum Logo'
|
|
309
326
|
},
|
|
310
|
-
[CONFIGURATOR_FORMULAS.
|
|
327
|
+
[CONFIGURATOR_FORMULAS.TBE]: {
|
|
311
328
|
email: 'order@trekhaakcentrum.nl',
|
|
312
329
|
phoneDisplay: '+31 162 - 490 910',
|
|
313
330
|
phoneHref: 'tel:+31162490910',
|
|
@@ -345,7 +362,7 @@ const EXECUTION_HELP_CONTACT_DETAILS_BY_FORMULA = exports.EXECUTION_HELP_CONTACT
|
|
|
345
362
|
phoneDisplay: '+31 85 202 0660',
|
|
346
363
|
phoneHref: 'tel:+31852020660'
|
|
347
364
|
},
|
|
348
|
-
[CONFIGURATOR_FORMULAS.
|
|
365
|
+
[CONFIGURATOR_FORMULAS.TBE]: {
|
|
349
366
|
phoneDisplay: '+31 85 202 0660',
|
|
350
367
|
phoneHref: 'tel:+31852020660'
|
|
351
368
|
}
|
|
@@ -612,11 +612,13 @@ const ProductCartTable = () => {
|
|
|
612
612
|
var _p$priceInfo14;
|
|
613
613
|
return t + Number((p === null || p === void 0 || (_p$priceInfo14 = p.priceInfo) === null || _p$priceInfo14 === void 0 ? void 0 : _p$priceInfo14.salesPrice) || 0);
|
|
614
614
|
}, 0) : 0;
|
|
615
|
+
const apiMontageSubtotalIncl = (totals === null || totals === void 0 ? void 0 : totals.subtotalMontageInclVat) != null ? Number(totals.subtotalMontageInclVat) : null;
|
|
616
|
+
const mainSubtotalIncl = !isToggled && apiMontageSubtotalIncl !== null && Number.isFinite(apiMontageSubtotalIncl) ? apiMontageSubtotalIncl : mainInclVat + montageInclVat;
|
|
615
617
|
return {
|
|
616
618
|
main: {
|
|
617
619
|
purchase: mainPurchase,
|
|
618
620
|
margin: mainMargin,
|
|
619
|
-
inclVat:
|
|
621
|
+
inclVat: mainSubtotalIncl,
|
|
620
622
|
exclVat: mainExclVat + montageExclVat + marketCorrectionExclVat,
|
|
621
623
|
tmg: {
|
|
622
624
|
catalog: tmgCatalog,
|