thm-p3-configurator 0.0.305 → 0.0.307
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/__components__/internal/InternalCustomerDetailsForm.js +160 -242
- package/dist/src/shared/__constants__/cartTable.js +5 -2
- package/dist/src/shared/__containers__/ProductsCartOverview.js +42 -3
- package/dist/src/shared/__containers__/internal/InternalAppointmentForm.js +193 -436
- package/dist/src/shared/__containers__/internal/InternalExtraPriceForm.js +141 -0
- package/dist/src/shared/__containers__/internal/InternalQuotationForm.js +143 -186
- package/dist/src/shared/__context__/OrderSessionContext.js +24 -0
- package/dist/src/shared/__helpers__/cartTable.js +46 -7
- package/package.json +1 -1
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/es.parse-float.js");
|
|
4
|
+
require("core-js/modules/es.regexp.exec.js");
|
|
5
|
+
require("core-js/modules/es.regexp.to-string.js");
|
|
6
|
+
require("core-js/modules/es.string.replace.js");
|
|
7
|
+
require("core-js/modules/es.weak-map.js");
|
|
8
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
9
|
+
require("core-js/modules/es.weak-map.js");
|
|
10
|
+
Object.defineProperty(exports, "__esModule", {
|
|
11
|
+
value: true
|
|
12
|
+
});
|
|
13
|
+
exports.default = void 0;
|
|
14
|
+
require("core-js/modules/es.parse-float.js");
|
|
15
|
+
require("core-js/modules/es.regexp.exec.js");
|
|
16
|
+
require("core-js/modules/es.regexp.to-string.js");
|
|
17
|
+
require("core-js/modules/es.string.replace.js");
|
|
18
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
19
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
20
|
+
var _LinkButton = _interopRequireDefault(require("../../__components__/Buttons/LinkButton"));
|
|
21
|
+
var _PrimaryButton = _interopRequireDefault(require("../../__components__/Buttons/PrimaryButton"));
|
|
22
|
+
var _TextInput = _interopRequireDefault(require("../../__components__/Form/TextInput"));
|
|
23
|
+
var _OrderSessionContext = require("../../__context__/OrderSessionContext");
|
|
24
|
+
var _helpers__ = require("../../__helpers__");
|
|
25
|
+
function _interopRequireDefault(e) {
|
|
26
|
+
return e && e.__esModule ? e : {
|
|
27
|
+
default: e
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function _getRequireWildcardCache(e) {
|
|
31
|
+
if ("function" != typeof WeakMap) return null;
|
|
32
|
+
var r = new WeakMap(),
|
|
33
|
+
t = new WeakMap();
|
|
34
|
+
return (_getRequireWildcardCache = function _getRequireWildcardCache(e) {
|
|
35
|
+
return e ? t : r;
|
|
36
|
+
})(e);
|
|
37
|
+
}
|
|
38
|
+
function _interopRequireWildcard(e, r) {
|
|
39
|
+
if (!r && e && e.__esModule) return e;
|
|
40
|
+
if (null === e || "object" != typeof e && "function" != typeof e) return {
|
|
41
|
+
default: e
|
|
42
|
+
};
|
|
43
|
+
var t = _getRequireWildcardCache(r);
|
|
44
|
+
if (t && t.has(e)) return t.get(e);
|
|
45
|
+
var n = {
|
|
46
|
+
__proto__: null
|
|
47
|
+
},
|
|
48
|
+
a = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
49
|
+
for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
|
|
50
|
+
var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
|
|
51
|
+
i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u];
|
|
52
|
+
}
|
|
53
|
+
return n.default = e, t && t.set(e, n), n;
|
|
54
|
+
}
|
|
55
|
+
const InternalExtraPriceForm = () => {
|
|
56
|
+
const [{
|
|
57
|
+
extraPriceAmount,
|
|
58
|
+
extraPriceDescription
|
|
59
|
+
}, dispatch] = (0, _OrderSessionContext.useOrderSession)();
|
|
60
|
+
const [amount, setAmount] = (0, _react.useState)(extraPriceAmount || '');
|
|
61
|
+
const [description, setDescription] = (0, _react.useState)(extraPriceDescription || '');
|
|
62
|
+
(0, _react.useEffect)(() => {
|
|
63
|
+
setAmount(extraPriceAmount || '');
|
|
64
|
+
setDescription(extraPriceDescription || '');
|
|
65
|
+
}, [extraPriceAmount, extraPriceDescription]);
|
|
66
|
+
const handleAmountChange = value => {
|
|
67
|
+
// Allow positive and negative numbers
|
|
68
|
+
const sanitized = value === null || value === void 0 ? void 0 : value.toString().replace(/[^0-9.-]/g, '');
|
|
69
|
+
setAmount(sanitized);
|
|
70
|
+
};
|
|
71
|
+
const handleDescriptionChange = value => {
|
|
72
|
+
setDescription(value);
|
|
73
|
+
};
|
|
74
|
+
const handleSubmit = () => {
|
|
75
|
+
const parsedAmount = parseFloat(amount);
|
|
76
|
+
if (isNaN(parsedAmount)) return;
|
|
77
|
+
dispatch({
|
|
78
|
+
type: _OrderSessionContext.orderSessionActions.SET_EXTRA_PRICE,
|
|
79
|
+
payload: {
|
|
80
|
+
amount: parsedAmount,
|
|
81
|
+
description: description || ''
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
const handleClear = () => {
|
|
86
|
+
setAmount('');
|
|
87
|
+
setDescription('');
|
|
88
|
+
dispatch({
|
|
89
|
+
type: _OrderSessionContext.orderSessionActions.CLEAR_EXTRA_PRICE
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
const isApplied = extraPriceAmount !== null && extraPriceAmount !== undefined;
|
|
93
|
+
const canSubmit = amount !== '' && !isNaN(parseFloat(amount));
|
|
94
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
95
|
+
className: (0, _helpers__.withStyle)('mx-1 mt-4')
|
|
96
|
+
}, /*#__PURE__*/_react.default.createElement("h5", {
|
|
97
|
+
className: (0, _helpers__.withStyle)('mb-3')
|
|
98
|
+
}, "Meerprijs:"), /*#__PURE__*/_react.default.createElement("div", {
|
|
99
|
+
className: (0, _helpers__.withStyle)('d-flex flex-column gap-3')
|
|
100
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
101
|
+
className: (0, _helpers__.withStyle)('d-flex gap-3 align-items-end')
|
|
102
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
103
|
+
style: {
|
|
104
|
+
width: '150px'
|
|
105
|
+
}
|
|
106
|
+
}, /*#__PURE__*/_react.default.createElement("label", {
|
|
107
|
+
htmlFor: "extra-price-amount",
|
|
108
|
+
className: (0, _helpers__.withStyle)('form-label mb-1')
|
|
109
|
+
}, "Bedrag"), /*#__PURE__*/_react.default.createElement("input", {
|
|
110
|
+
id: "extra-price-amount",
|
|
111
|
+
name: "extra-price-amount",
|
|
112
|
+
type: "text",
|
|
113
|
+
value: amount,
|
|
114
|
+
onChange: e => handleAmountChange(e.target.value),
|
|
115
|
+
placeholder: "0.00",
|
|
116
|
+
className: (0, _helpers__.withStyle)('form-control')
|
|
117
|
+
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
118
|
+
style: {
|
|
119
|
+
flex: 1
|
|
120
|
+
}
|
|
121
|
+
}, /*#__PURE__*/_react.default.createElement(_TextInput.default, {
|
|
122
|
+
name: "extra-price-description",
|
|
123
|
+
label: "Opmerking",
|
|
124
|
+
placeholder: "Omschrijving meerprijs...",
|
|
125
|
+
value: description,
|
|
126
|
+
onChange: handleDescriptionChange,
|
|
127
|
+
isRequired: false
|
|
128
|
+
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
129
|
+
className: (0, _helpers__.withStyle)('d-flex align-items-end gap-2')
|
|
130
|
+
}, /*#__PURE__*/_react.default.createElement(_PrimaryButton.default, {
|
|
131
|
+
isDisabled: !canSubmit,
|
|
132
|
+
onClick: handleSubmit,
|
|
133
|
+
label: "Toepassen",
|
|
134
|
+
isNarrow: true
|
|
135
|
+
}), /*#__PURE__*/_react.default.createElement(_LinkButton.default, {
|
|
136
|
+
isDisabled: !isApplied,
|
|
137
|
+
onClick: handleClear,
|
|
138
|
+
label: "Verwijderen"
|
|
139
|
+
})))));
|
|
140
|
+
};
|
|
141
|
+
var _default = exports.default = InternalExtraPriceForm;
|
|
@@ -121,6 +121,24 @@ function _toPrimitive(t, r) {
|
|
|
121
121
|
return ("string" === r ? String : Number)(t);
|
|
122
122
|
}
|
|
123
123
|
const licensePlateValidator = new _LicensePlateValidator.default();
|
|
124
|
+
|
|
125
|
+
// Empty customer state template
|
|
126
|
+
const getEmptyCustomerState = () => ({
|
|
127
|
+
firstName: '',
|
|
128
|
+
infix: '',
|
|
129
|
+
lastName: '',
|
|
130
|
+
email: '',
|
|
131
|
+
phoneNumber: '',
|
|
132
|
+
zipCode: '',
|
|
133
|
+
houseNumber: '',
|
|
134
|
+
houseNumberAddition: '',
|
|
135
|
+
streetName: '',
|
|
136
|
+
city: '',
|
|
137
|
+
companyName: '',
|
|
138
|
+
kvkNumber: '',
|
|
139
|
+
vatNumber: '',
|
|
140
|
+
countryId: ''
|
|
141
|
+
});
|
|
124
142
|
const internalQuotationFormSchema = (0, _yup.object)({
|
|
125
143
|
ownershipType: (0, _yup.string)().required(_constants__.FORM_ERROR_MESSAGES.required),
|
|
126
144
|
leaseNumber: (0, _yup.string)().nullable(),
|
|
@@ -162,7 +180,7 @@ const InternalQuotationForm = _ref => {
|
|
|
162
180
|
} = _ref;
|
|
163
181
|
const [{
|
|
164
182
|
vehicle,
|
|
165
|
-
customer,
|
|
183
|
+
customer: contextCustomer,
|
|
166
184
|
licensePlate,
|
|
167
185
|
licensePlateBrandModel,
|
|
168
186
|
model,
|
|
@@ -191,6 +209,97 @@ const InternalQuotationForm = _ref => {
|
|
|
191
209
|
const [errors, setErrors] = (0, _react.useState)({});
|
|
192
210
|
const [companySearchTerm, setCompanySearchTerm] = (0, _react.useState)('');
|
|
193
211
|
const [isCompanyInputFocused, setIsCompanyInputFocused] = (0, _react.useState)(false);
|
|
212
|
+
const [refreshKey, setRefreshKey] = (0, _react.useState)(Date.now());
|
|
213
|
+
|
|
214
|
+
// Track the original ownership type from context
|
|
215
|
+
const [originalOwnershipType] = (0, _react.useState)(() => (vehicle === null || vehicle === void 0 ? void 0 : vehicle.ownershipType) || _constants__.VEHICLE_OWNERSHIP_TYPE.Particulier);
|
|
216
|
+
|
|
217
|
+
// Current active ownership type (local state for tab switching)
|
|
218
|
+
const [activeOwnershipType, setActiveOwnershipType] = (0, _react.useState)(originalOwnershipType);
|
|
219
|
+
|
|
220
|
+
// Separate customer state for each ownership type
|
|
221
|
+
const [customerDataPerType, setCustomerDataPerType] = (0, _react.useState)(() => {
|
|
222
|
+
const emptyState = getEmptyCustomerState();
|
|
223
|
+
const initialCustomerData = {
|
|
224
|
+
firstName: (contextCustomer === null || contextCustomer === void 0 ? void 0 : contextCustomer.firstName) || '',
|
|
225
|
+
infix: (contextCustomer === null || contextCustomer === void 0 ? void 0 : contextCustomer.infix) || '',
|
|
226
|
+
lastName: (contextCustomer === null || contextCustomer === void 0 ? void 0 : contextCustomer.lastName) || '',
|
|
227
|
+
email: (contextCustomer === null || contextCustomer === void 0 ? void 0 : contextCustomer.email) || '',
|
|
228
|
+
phoneNumber: (contextCustomer === null || contextCustomer === void 0 ? void 0 : contextCustomer.phoneNumber) || '',
|
|
229
|
+
zipCode: (contextCustomer === null || contextCustomer === void 0 ? void 0 : contextCustomer.zipCode) || '',
|
|
230
|
+
houseNumber: (contextCustomer === null || contextCustomer === void 0 ? void 0 : contextCustomer.houseNumber) || '',
|
|
231
|
+
houseNumberAddition: (contextCustomer === null || contextCustomer === void 0 ? void 0 : contextCustomer.houseNumberAddition) || '',
|
|
232
|
+
streetName: (contextCustomer === null || contextCustomer === void 0 ? void 0 : contextCustomer.streetName) || '',
|
|
233
|
+
city: (contextCustomer === null || contextCustomer === void 0 ? void 0 : contextCustomer.city) || '',
|
|
234
|
+
companyName: (contextCustomer === null || contextCustomer === void 0 ? void 0 : contextCustomer.companyName) || '',
|
|
235
|
+
kvkNumber: (contextCustomer === null || contextCustomer === void 0 ? void 0 : contextCustomer.kvkNumber) || '',
|
|
236
|
+
vatNumber: (contextCustomer === null || contextCustomer === void 0 ? void 0 : contextCustomer.vatNumber) || '',
|
|
237
|
+
countryId: (contextCustomer === null || contextCustomer === void 0 ? void 0 : contextCustomer.countryId) || ''
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
// Only the original ownership type gets the initial data
|
|
241
|
+
return {
|
|
242
|
+
[_constants__.VEHICLE_OWNERSHIP_TYPE.Particulier]: originalOwnershipType === _constants__.VEHICLE_OWNERSHIP_TYPE.Particulier ? _objectSpread({}, initialCustomerData) : _objectSpread({}, emptyState),
|
|
243
|
+
[_constants__.VEHICLE_OWNERSHIP_TYPE.Zakelijk]: originalOwnershipType === _constants__.VEHICLE_OWNERSHIP_TYPE.Zakelijk ? _objectSpread({}, initialCustomerData) : _objectSpread({}, emptyState),
|
|
244
|
+
[_constants__.VEHICLE_OWNERSHIP_TYPE.Leasemaatschappij]: originalOwnershipType === _constants__.VEHICLE_OWNERSHIP_TYPE.Leasemaatschappij ? _objectSpread({}, initialCustomerData) : _objectSpread({}, emptyState)
|
|
245
|
+
};
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
// Get customer data for the active ownership type
|
|
249
|
+
const customer = customerDataPerType[activeOwnershipType];
|
|
250
|
+
|
|
251
|
+
// Helper to update customer data for the active ownership type
|
|
252
|
+
const updateCustomerField = (0, _react.useCallback)((field, value) => {
|
|
253
|
+
setCustomerDataPerType(prev => _objectSpread(_objectSpread({}, prev), {}, {
|
|
254
|
+
[activeOwnershipType]: _objectSpread(_objectSpread({}, prev[activeOwnershipType]), {}, {
|
|
255
|
+
[field]: value
|
|
256
|
+
})
|
|
257
|
+
}));
|
|
258
|
+
}, [activeOwnershipType]);
|
|
259
|
+
|
|
260
|
+
// Sync active ownership type to context when it changes
|
|
261
|
+
(0, _react.useEffect)(() => {
|
|
262
|
+
if (activeOwnershipType !== (vehicle === null || vehicle === void 0 ? void 0 : vehicle.ownershipType)) {
|
|
263
|
+
dispatch({
|
|
264
|
+
type: _OrderSessionContext.orderSessionActions.SET_VEHICLE_OWNERSHIP_TYPE,
|
|
265
|
+
payload: {
|
|
266
|
+
ownershipType: activeOwnershipType
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
}, [activeOwnershipType, vehicle === null || vehicle === void 0 ? void 0 : vehicle.ownershipType, dispatch]);
|
|
271
|
+
|
|
272
|
+
// Sync customer data to context when it changes (for the active tab)
|
|
273
|
+
(0, _react.useEffect)(() => {
|
|
274
|
+
const currentData = customerDataPerType[activeOwnershipType];
|
|
275
|
+
const actionMap = {
|
|
276
|
+
firstName: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_FIRST_NAME,
|
|
277
|
+
infix: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_INFIX,
|
|
278
|
+
lastName: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_LAST_NAME,
|
|
279
|
+
email: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_EMAIL,
|
|
280
|
+
phoneNumber: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_PHONE_NUMBER,
|
|
281
|
+
zipCode: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_ZIP_CODE,
|
|
282
|
+
houseNumber: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_HOUSE_NUMBER,
|
|
283
|
+
houseNumberAddition: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_HOUSE_NUMBER_ADDITION,
|
|
284
|
+
streetName: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_STREET_NAME,
|
|
285
|
+
city: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_CITY,
|
|
286
|
+
companyName: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_COMPANY_NAME,
|
|
287
|
+
kvkNumber: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_KVK_NUMBER,
|
|
288
|
+
vatNumber: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_VAT_NUMBER,
|
|
289
|
+
countryId: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_COUNTRY_ID
|
|
290
|
+
};
|
|
291
|
+
Object.entries(currentData).forEach(_ref2 => {
|
|
292
|
+
let [field, value] = _ref2;
|
|
293
|
+
if (actionMap[field]) {
|
|
294
|
+
dispatch({
|
|
295
|
+
type: actionMap[field],
|
|
296
|
+
payload: {
|
|
297
|
+
[field]: value
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
}, [activeOwnershipType, customerDataPerType, dispatch]);
|
|
194
303
|
const [_licensePlate, _setLicensePlate] = (0, _react.useState)(licensePlate);
|
|
195
304
|
const isTmg = (0, _useIsTmg.useIsTmg)();
|
|
196
305
|
const {
|
|
@@ -237,7 +346,7 @@ const InternalQuotationForm = _ref => {
|
|
|
237
346
|
isTowCenterBranch,
|
|
238
347
|
searchTerm: companySearchTerm,
|
|
239
348
|
formula,
|
|
240
|
-
ownershipType:
|
|
349
|
+
ownershipType: activeOwnershipType,
|
|
241
350
|
organisationType: branchType
|
|
242
351
|
});
|
|
243
352
|
const countryOptions = (0, _react.useMemo)(() => {
|
|
@@ -308,7 +417,7 @@ const InternalQuotationForm = _ref => {
|
|
|
308
417
|
*/
|
|
309
418
|
const handleSubmit = async () => {
|
|
310
419
|
try {
|
|
311
|
-
var _customer$firstName, _customer$lastName, _customer$phoneNumber, _customer$houseNumber, _customer$houseNumber2, _customer$streetName, _customer$countryId, _customer$city, _customer$email, _customer$note, _customer$zipCode, _customer$companyName,
|
|
420
|
+
var _customer$firstName, _customer$lastName, _customer$phoneNumber, _customer$houseNumber, _customer$houseNumber2, _customer$streetName, _customer$countryId, _customer$city, _customer$email, _customer$note, _customer$zipCode, _customer$companyName, _ref3;
|
|
312
421
|
setErrors(null);
|
|
313
422
|
if (!model) {
|
|
314
423
|
// Note: this does not throw on error.
|
|
@@ -322,7 +431,7 @@ const InternalQuotationForm = _ref => {
|
|
|
322
431
|
}
|
|
323
432
|
|
|
324
433
|
// Validate lease number for lease company vehicles
|
|
325
|
-
if (
|
|
434
|
+
if (activeOwnershipType === _constants__.VEHICLE_OWNERSHIP_TYPE.Leasemaatschappij) {
|
|
326
435
|
if ((!(vehicle !== null && vehicle !== void 0 && vehicle.leaseNumber) || (vehicle === null || vehicle === void 0 ? void 0 : vehicle.leaseNumber) === '') && !(vehicle !== null && vehicle !== void 0 && vehicle.leaseNumberUnknown)) {
|
|
327
436
|
setErrors(prev => _objectSpread(_objectSpread({}, prev), {}, {
|
|
328
437
|
leaseNumber: _constants__.FORM_ERROR_MESSAGES.leaseNumber || 'Goedkeuringsnummer is verplicht of geef aan dat het onbekend is'
|
|
@@ -365,7 +474,7 @@ const InternalQuotationForm = _ref => {
|
|
|
365
474
|
})),
|
|
366
475
|
chassisNumber: chassisNumber !== null && chassisNumber !== void 0 ? chassisNumber : undefined,
|
|
367
476
|
channel,
|
|
368
|
-
licensePlate: (
|
|
477
|
+
licensePlate: (_ref3 = licensePlate || _licensePlate) === null || _ref3 === void 0 ? void 0 : _ref3.replace(/-/g, ''),
|
|
369
478
|
model,
|
|
370
479
|
answers: (0, _helpers__.removeNullishProps)({
|
|
371
480
|
duration: durationAnswer,
|
|
@@ -425,79 +534,11 @@ const InternalQuotationForm = _ref => {
|
|
|
425
534
|
input.value = '';
|
|
426
535
|
});
|
|
427
536
|
|
|
428
|
-
//
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
setClearSuccess(false);
|
|
434
|
-
}, 2000);
|
|
435
|
-
dispatch({
|
|
436
|
-
type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_FIRST_NAME,
|
|
437
|
-
payload: {
|
|
438
|
-
firstName: ''
|
|
439
|
-
}
|
|
440
|
-
});
|
|
441
|
-
dispatch({
|
|
442
|
-
type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_INFIX,
|
|
443
|
-
payload: {
|
|
444
|
-
infix: ''
|
|
445
|
-
}
|
|
446
|
-
});
|
|
447
|
-
dispatch({
|
|
448
|
-
type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_LAST_NAME,
|
|
449
|
-
payload: {
|
|
450
|
-
lastName: ''
|
|
451
|
-
}
|
|
452
|
-
});
|
|
453
|
-
dispatch({
|
|
454
|
-
type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_EMAIL,
|
|
455
|
-
payload: {
|
|
456
|
-
email: ''
|
|
457
|
-
}
|
|
458
|
-
});
|
|
459
|
-
dispatch({
|
|
460
|
-
type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_PHONE_NUMBER,
|
|
461
|
-
payload: {
|
|
462
|
-
phoneNumber: ''
|
|
463
|
-
}
|
|
464
|
-
});
|
|
465
|
-
dispatch({
|
|
466
|
-
type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_ZIP_CODE,
|
|
467
|
-
payload: {
|
|
468
|
-
zipCode: ''
|
|
469
|
-
}
|
|
470
|
-
});
|
|
471
|
-
dispatch({
|
|
472
|
-
type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_HOUSE_NUMBER,
|
|
473
|
-
payload: {
|
|
474
|
-
houseNumber: ''
|
|
475
|
-
}
|
|
476
|
-
});
|
|
477
|
-
dispatch({
|
|
478
|
-
type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_HOUSE_NUMBER_ADDITION,
|
|
479
|
-
payload: {
|
|
480
|
-
houseNumberAddition: ''
|
|
481
|
-
}
|
|
482
|
-
});
|
|
483
|
-
dispatch({
|
|
484
|
-
type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_STREET_NAME,
|
|
485
|
-
payload: {
|
|
486
|
-
streetName: ''
|
|
487
|
-
}
|
|
488
|
-
});
|
|
489
|
-
dispatch({
|
|
490
|
-
type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_CITY,
|
|
491
|
-
payload: {
|
|
492
|
-
city: ''
|
|
493
|
-
}
|
|
494
|
-
});
|
|
495
|
-
dispatch({
|
|
496
|
-
type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_COMPANY_NAME,
|
|
497
|
-
payload: {
|
|
498
|
-
companyName: ''
|
|
499
|
-
}
|
|
500
|
-
});
|
|
537
|
+
// Clear all customer fields in the local state for the active ownership type
|
|
538
|
+
const emptyState = getEmptyCustomerState();
|
|
539
|
+
setCustomerDataPerType(prev => _objectSpread(_objectSpread({}, prev), {}, {
|
|
540
|
+
[activeOwnershipType]: emptyState
|
|
541
|
+
}));
|
|
501
542
|
};
|
|
502
543
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
503
544
|
className: (0, _helpers__.withStyle)('row gx-5 mt-3 mt-lg-5')
|
|
@@ -526,12 +567,12 @@ const InternalQuotationForm = _ref => {
|
|
|
526
567
|
placeholder: "Maak een keuze",
|
|
527
568
|
errorMessage: (errors === null || errors === void 0 ? void 0 : errors['channelId']) || (errors === null || errors === void 0 ? void 0 : errors['channelType']),
|
|
528
569
|
initialValue: initialChannel,
|
|
529
|
-
onChange:
|
|
570
|
+
onChange: _ref4 => {
|
|
530
571
|
var _value$kanaalType;
|
|
531
572
|
let {
|
|
532
573
|
label,
|
|
533
574
|
value
|
|
534
|
-
} =
|
|
575
|
+
} = _ref4;
|
|
535
576
|
return dispatch({
|
|
536
577
|
type: _OrderSessionContext.orderSessionActions.SET_MARKETING_CHANNEL,
|
|
537
578
|
payload: {
|
|
@@ -546,14 +587,10 @@ const InternalQuotationForm = _ref => {
|
|
|
546
587
|
name: "ownershipType",
|
|
547
588
|
form: "quotation",
|
|
548
589
|
label: "Type:",
|
|
549
|
-
initialValue:
|
|
590
|
+
initialValue: activeOwnershipType,
|
|
550
591
|
onChange: val => {
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
payload: {
|
|
554
|
-
ownershipType: val
|
|
555
|
-
}
|
|
556
|
-
});
|
|
592
|
+
// Switch to the new ownership type - each type maintains its own separate state
|
|
593
|
+
setActiveOwnershipType(val);
|
|
557
594
|
},
|
|
558
595
|
options: Object.values(_constants__.VEHICLE_OWNERSHIP_TYPE),
|
|
559
596
|
isRequired: true,
|
|
@@ -562,7 +599,7 @@ const InternalQuotationForm = _ref => {
|
|
|
562
599
|
className: (0, _helpers__.withStyle)('my-2')
|
|
563
600
|
}, "Persoonlijke gegevens"), /*#__PURE__*/_react.default.createElement("div", {
|
|
564
601
|
className: (0, _helpers__.withStyle)('col-12 mb-2')
|
|
565
|
-
},
|
|
602
|
+
}, activeOwnershipType === _constants__.VEHICLE_OWNERSHIP_TYPE.Zakelijk && /*#__PURE__*/_react.default.createElement("div", {
|
|
566
603
|
className: (0, _helpers__.withStyle)('company-search-container position-relative mb-3')
|
|
567
604
|
}, /*#__PURE__*/_react.default.createElement(_TextInput.default, {
|
|
568
605
|
placeholder: "Placeholderbedrijf",
|
|
@@ -579,12 +616,7 @@ const InternalQuotationForm = _ref => {
|
|
|
579
616
|
name: "companyName",
|
|
580
617
|
onChange: value => {
|
|
581
618
|
// Update company name in state
|
|
582
|
-
|
|
583
|
-
type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_COMPANY_NAME,
|
|
584
|
-
payload: {
|
|
585
|
-
companyName: value
|
|
586
|
-
}
|
|
587
|
-
});
|
|
619
|
+
updateCustomerField('companyName', value);
|
|
588
620
|
|
|
589
621
|
// Also update search term if value is different
|
|
590
622
|
if (value !== companySearchTerm) {
|
|
@@ -630,77 +662,32 @@ const InternalQuotationForm = _ref => {
|
|
|
630
662
|
onMouseDown: e => {
|
|
631
663
|
var _branch$vatNumber, _branch$kvkNumber;
|
|
632
664
|
e.preventDefault();
|
|
633
|
-
|
|
634
|
-
type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_COMPANY_NAME,
|
|
635
|
-
payload: {
|
|
636
|
-
companyName: branch.name
|
|
637
|
-
}
|
|
638
|
-
});
|
|
665
|
+
updateCustomerField('companyName', branch.name);
|
|
639
666
|
if (branch.postalCode) {
|
|
640
|
-
|
|
641
|
-
type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_ZIP_CODE,
|
|
642
|
-
payload: {
|
|
643
|
-
zipCode: branch.postalCode
|
|
644
|
-
}
|
|
645
|
-
});
|
|
667
|
+
updateCustomerField('zipCode', branch.postalCode);
|
|
646
668
|
}
|
|
647
669
|
if (branch.street) {
|
|
648
|
-
|
|
649
|
-
type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_STREET_NAME,
|
|
650
|
-
payload: {
|
|
651
|
-
streetName: branch.street
|
|
652
|
-
}
|
|
653
|
-
});
|
|
670
|
+
updateCustomerField('streetName', branch.street);
|
|
654
671
|
}
|
|
655
672
|
if (branch.city) {
|
|
656
|
-
|
|
657
|
-
type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_CITY,
|
|
658
|
-
payload: {
|
|
659
|
-
city: branch.city
|
|
660
|
-
}
|
|
661
|
-
});
|
|
673
|
+
updateCustomerField('city', branch.city);
|
|
662
674
|
}
|
|
663
675
|
if (branch.street2) {
|
|
664
|
-
|
|
665
|
-
type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_HOUSE_NUMBER,
|
|
666
|
-
payload: {
|
|
667
|
-
houseNumber: branch.street2
|
|
668
|
-
}
|
|
669
|
-
});
|
|
676
|
+
updateCustomerField('houseNumber', branch.street2);
|
|
670
677
|
}
|
|
671
678
|
const vatNumber = (_branch$vatNumber = branch.vatNumber) !== null && _branch$vatNumber !== void 0 ? _branch$vatNumber : branch.btwNummer;
|
|
672
679
|
if (vatNumber) {
|
|
673
|
-
|
|
674
|
-
type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_VAT_NUMBER,
|
|
675
|
-
payload: {
|
|
676
|
-
vatNumber
|
|
677
|
-
}
|
|
678
|
-
});
|
|
680
|
+
updateCustomerField('vatNumber', vatNumber);
|
|
679
681
|
}
|
|
680
682
|
const kvkNumber = (_branch$kvkNumber = branch.kvkNumber) !== null && _branch$kvkNumber !== void 0 ? _branch$kvkNumber : branch.kvkNummer;
|
|
681
683
|
if (kvkNumber) {
|
|
682
|
-
|
|
683
|
-
type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_KVK_NUMBER,
|
|
684
|
-
payload: {
|
|
685
|
-
kvkNumber
|
|
686
|
-
}
|
|
687
|
-
});
|
|
684
|
+
updateCustomerField('kvkNumber', kvkNumber);
|
|
688
685
|
}
|
|
689
686
|
if (branch.huisnummerToevoeging) {
|
|
690
|
-
|
|
691
|
-
type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_HOUSE_NUMBER_ADDITION,
|
|
692
|
-
payload: {
|
|
693
|
-
houseNumberAddition: branch.huisnummerToevoeging
|
|
694
|
-
}
|
|
695
|
-
});
|
|
687
|
+
updateCustomerField('houseNumberAddition', branch.huisnummerToevoeging);
|
|
696
688
|
}
|
|
697
689
|
if (branch.country && branch.country.entityId) {
|
|
698
|
-
|
|
699
|
-
type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_COUNTRY_ID,
|
|
700
|
-
payload: {
|
|
701
|
-
countryId: branch.country.entityId
|
|
702
|
-
}
|
|
703
|
-
});
|
|
690
|
+
updateCustomerField('countryId', branch.country.entityId);
|
|
704
691
|
setRefreshKey(Date.now());
|
|
705
692
|
}
|
|
706
693
|
setCompanySearchTerm('');
|
|
@@ -710,12 +697,7 @@ const InternalQuotationForm = _ref => {
|
|
|
710
697
|
placeholder: "",
|
|
711
698
|
value: customer.firstName,
|
|
712
699
|
name: "firstName",
|
|
713
|
-
onChange: value =>
|
|
714
|
-
type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_FIRST_NAME,
|
|
715
|
-
payload: {
|
|
716
|
-
firstName: value
|
|
717
|
-
}
|
|
718
|
-
}),
|
|
700
|
+
onChange: value => updateCustomerField('firstName', value),
|
|
719
701
|
isRequired: true,
|
|
720
702
|
form: "quotation",
|
|
721
703
|
label: "Voornaam:",
|
|
@@ -724,12 +706,7 @@ const InternalQuotationForm = _ref => {
|
|
|
724
706
|
placeholder: "",
|
|
725
707
|
value: customer.infix,
|
|
726
708
|
name: "infix",
|
|
727
|
-
onChange: value =>
|
|
728
|
-
type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_INFIX,
|
|
729
|
-
payload: {
|
|
730
|
-
infix: value
|
|
731
|
-
}
|
|
732
|
-
}),
|
|
709
|
+
onChange: value => updateCustomerField('infix', value),
|
|
733
710
|
isRequired: false,
|
|
734
711
|
form: "quotation",
|
|
735
712
|
label: "Tussenvoegsel:",
|
|
@@ -738,12 +715,7 @@ const InternalQuotationForm = _ref => {
|
|
|
738
715
|
placeholder: "",
|
|
739
716
|
value: customer.lastName,
|
|
740
717
|
name: "lastName",
|
|
741
|
-
onChange: value =>
|
|
742
|
-
type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_LAST_NAME,
|
|
743
|
-
payload: {
|
|
744
|
-
lastName: value
|
|
745
|
-
}
|
|
746
|
-
}),
|
|
718
|
+
onChange: value => updateCustomerField('lastName', value),
|
|
747
719
|
isRequired: true,
|
|
748
720
|
form: "quotation",
|
|
749
721
|
label: "Achternaam:",
|
|
@@ -752,17 +724,12 @@ const InternalQuotationForm = _ref => {
|
|
|
752
724
|
placeholder: "",
|
|
753
725
|
value: customer.email,
|
|
754
726
|
name: "email",
|
|
755
|
-
onChange: value =>
|
|
756
|
-
type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_EMAIL,
|
|
757
|
-
payload: {
|
|
758
|
-
email: value
|
|
759
|
-
}
|
|
760
|
-
}),
|
|
727
|
+
onChange: value => updateCustomerField('email', value),
|
|
761
728
|
isRequired: true,
|
|
762
729
|
form: "quotation",
|
|
763
730
|
label: "E-mailadres:",
|
|
764
731
|
errorMessage: errors === null || errors === void 0 ? void 0 : errors['email']
|
|
765
|
-
}),
|
|
732
|
+
}), activeOwnershipType === _constants__.VEHICLE_OWNERSHIP_TYPE.Leasemaatschappij && /*#__PURE__*/_react.default.createElement("div", {
|
|
766
733
|
className: (0, _helpers__.withStyle)('company-search-container position-relative mt-2 mb-2')
|
|
767
734
|
}, /*#__PURE__*/_react.default.createElement(_TextInput.default, {
|
|
768
735
|
placeholder: "Zoek leasemaatschappijen...",
|
|
@@ -770,12 +737,7 @@ const InternalQuotationForm = _ref => {
|
|
|
770
737
|
name: "companyName",
|
|
771
738
|
onChange: value => {
|
|
772
739
|
// Update company name in state
|
|
773
|
-
|
|
774
|
-
type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_COMPANY_NAME,
|
|
775
|
-
payload: {
|
|
776
|
-
companyName: value
|
|
777
|
-
}
|
|
778
|
-
});
|
|
740
|
+
updateCustomerField('companyName', value);
|
|
779
741
|
|
|
780
742
|
// Also update search term if value is different
|
|
781
743
|
if (value !== companySearchTerm) {
|
|
@@ -835,12 +797,7 @@ const InternalQuotationForm = _ref => {
|
|
|
835
797
|
placeholder: "",
|
|
836
798
|
value: customer.phoneNumber,
|
|
837
799
|
name: "phoneNumber",
|
|
838
|
-
onChange: value =>
|
|
839
|
-
type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_PHONE_NUMBER,
|
|
840
|
-
payload: {
|
|
841
|
-
phoneNumber: value
|
|
842
|
-
}
|
|
843
|
-
}),
|
|
800
|
+
onChange: value => updateCustomerField('phoneNumber', value),
|
|
844
801
|
isRequired: true,
|
|
845
802
|
form: "quotation",
|
|
846
803
|
label: "Telefoonnummer:",
|
|
@@ -853,7 +810,7 @@ const InternalQuotationForm = _ref => {
|
|
|
853
810
|
className: (0, _helpers__.withStyle)('modal-title col-12 mb-2')
|
|
854
811
|
}, "Gegevens van de auto ", /*#__PURE__*/_react.default.createElement("br", null)), /*#__PURE__*/_react.default.createElement("div", {
|
|
855
812
|
className: (0, _helpers__.withStyle)('col-12')
|
|
856
|
-
},
|
|
813
|
+
}, activeOwnershipType === _constants__.VEHICLE_OWNERSHIP_TYPE.Leasemaatschappij && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_TextInput.default, {
|
|
857
814
|
placeholder: "",
|
|
858
815
|
value: vehicle === null || vehicle === void 0 ? void 0 : vehicle.leaseNumber,
|
|
859
816
|
name: "leaseNumber",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
require("core-js/modules/es.symbol.description.js");
|
|
3
4
|
require("core-js/modules/es.json.stringify.js");
|
|
4
5
|
require("core-js/modules/es.weak-map.js");
|
|
5
6
|
require("core-js/modules/esnext.iterator.constructor.js");
|
|
@@ -14,6 +15,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
14
15
|
value: true
|
|
15
16
|
});
|
|
16
17
|
exports.useOrderSession = exports.orderSessionActions = exports.OrderSessionController = void 0;
|
|
18
|
+
require("core-js/modules/es.symbol.description.js");
|
|
17
19
|
require("core-js/modules/es.json.stringify.js");
|
|
18
20
|
require("core-js/modules/esnext.iterator.constructor.js");
|
|
19
21
|
require("core-js/modules/esnext.iterator.filter.js");
|
|
@@ -147,6 +149,8 @@ const INITIAL_ORDER_SESSION_STATE = {
|
|
|
147
149
|
},
|
|
148
150
|
discountAmount: null,
|
|
149
151
|
discountPercentage: null,
|
|
152
|
+
extraPriceAmount: null,
|
|
153
|
+
extraPriceDescription: null,
|
|
150
154
|
channel: {
|
|
151
155
|
channelId: null,
|
|
152
156
|
channelType: null
|
|
@@ -244,6 +248,8 @@ const orderSessionActions = exports.orderSessionActions = {
|
|
|
244
248
|
SET_DISCOUNT_AMOUNT: 'SET_DISCOUNT_AMOUNT',
|
|
245
249
|
SET_DISCOUNT_PERCENTAGE: 'SET_DISCOUNT_PERCENTAGE',
|
|
246
250
|
CLEAR_DISCOUNT: 'CLEAR_DISCOUNT',
|
|
251
|
+
SET_EXTRA_PRICE: 'SET_EXTRA_PRICE',
|
|
252
|
+
CLEAR_EXTRA_PRICE: 'CLEAR_EXTRA_PRICE',
|
|
247
253
|
SET_VEHICLE_CHASSIS_NUMBER: 'SET_VEHICLE_CHASSIS_NUMBER',
|
|
248
254
|
SET_FRANCHISE_NAME: 'SET_FRANCHISE_NAME',
|
|
249
255
|
SET_PRICE_CALCULATION_DATE: 'SET_PRICE_CALCULATION_DATE',
|
|
@@ -1039,6 +1045,24 @@ const orderSessionReducer = (state, action) => {
|
|
|
1039
1045
|
discountAmount: null
|
|
1040
1046
|
});
|
|
1041
1047
|
}
|
|
1048
|
+
case orderSessionActions.SET_EXTRA_PRICE:
|
|
1049
|
+
{
|
|
1050
|
+
const {
|
|
1051
|
+
amount,
|
|
1052
|
+
description
|
|
1053
|
+
} = action.payload;
|
|
1054
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
1055
|
+
extraPriceAmount: amount,
|
|
1056
|
+
extraPriceDescription: description
|
|
1057
|
+
});
|
|
1058
|
+
}
|
|
1059
|
+
case orderSessionActions.CLEAR_EXTRA_PRICE:
|
|
1060
|
+
{
|
|
1061
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
1062
|
+
extraPriceAmount: null,
|
|
1063
|
+
extraPriceDescription: null
|
|
1064
|
+
});
|
|
1065
|
+
}
|
|
1042
1066
|
case orderSessionActions.SET_FRANCHISE_NAME:
|
|
1043
1067
|
{
|
|
1044
1068
|
const {
|