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.
@@ -9,7 +9,6 @@ require("core-js/modules/esnext.iterator.for-each.js");
9
9
  require("core-js/modules/esnext.iterator.map.js");
10
10
  require("core-js/modules/web.dom-collections.iterator.js");
11
11
  require("core-js/modules/es.weak-map.js");
12
- require("core-js/modules/esnext.iterator.for-each.js");
13
12
  Object.defineProperty(exports, "__esModule", {
14
13
  value: true
15
14
  });
@@ -18,6 +17,7 @@ require("core-js/modules/es.promise.js");
18
17
  require("core-js/modules/esnext.iterator.constructor.js");
19
18
  require("core-js/modules/esnext.iterator.filter.js");
20
19
  require("core-js/modules/esnext.iterator.find.js");
20
+ require("core-js/modules/esnext.iterator.for-each.js");
21
21
  require("core-js/modules/esnext.iterator.map.js");
22
22
  require("core-js/modules/web.dom-collections.iterator.js");
23
23
  var _react = _interopRequireWildcard(require("react"));
@@ -112,6 +112,23 @@ function _toPrimitive(t, r) {
112
112
  }
113
113
  return ("string" === r ? String : Number)(t);
114
114
  }
115
+ // Empty customer state template
116
+ const getEmptyCustomerState = () => ({
117
+ firstName: '',
118
+ infix: '',
119
+ lastName: '',
120
+ email: '',
121
+ phoneNumber: '',
122
+ zipCode: '',
123
+ houseNumber: '',
124
+ houseNumberAddition: '',
125
+ streetName: '',
126
+ city: '',
127
+ companyName: '',
128
+ kvkNumber: '',
129
+ vatNumber: '',
130
+ countryId: ''
131
+ });
115
132
  const customerDetailsFormSchema = (0, _yup.object)({
116
133
  singleOrderOwnershipType: (0, _yup.string)().nullable(),
117
134
  firstName: (0, _yup.string)().nullable(),
@@ -150,7 +167,7 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
150
167
  form = 'customer-details'
151
168
  } = _ref;
152
169
  const [{
153
- customer,
170
+ customer: contextCustomer,
154
171
  channel,
155
172
  selectedBranch,
156
173
  appointment,
@@ -162,7 +179,6 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
162
179
  afhalenInWinkel,
163
180
  singleOrderFormulaCode
164
181
  }, dispatch] = (0, _OrderSessionContext.useOrderSession)();
165
- console;
166
182
  const {
167
183
  branchById
168
184
  } = (0, _queries.useBranchByIdOrWidgetId)(selectedBranch);
@@ -188,6 +204,97 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
188
204
  const [isCompanyInputFocused, setIsCompanyInputFocused] = (0, _react.useState)(false);
189
205
  const [addressLookupLoading, setAddressLookupLoading] = (0, _react.useState)(false);
190
206
  const [addressLookupTimeoutId, setAddressLookupTimeoutId] = (0, _react.useState)(null);
207
+
208
+ // Track the original ownership type from context
209
+ const [originalOwnershipType] = (0, _react.useState)(() => (vehicle === null || vehicle === void 0 ? void 0 : vehicle.singleOrderOwnershipType) || _constants__.VEHICLE_SINGLE_ORDER_OWNERSHIP_TYPE.Empty);
210
+
211
+ // Current active ownership type (local state for tab switching)
212
+ const [activeOwnershipType, setActiveOwnershipType] = (0, _react.useState)(originalOwnershipType);
213
+
214
+ // Separate customer state for each ownership type
215
+ const [customerDataPerType, setCustomerDataPerType] = (0, _react.useState)(() => {
216
+ const emptyState = getEmptyCustomerState();
217
+ const initialCustomerData = {
218
+ firstName: (contextCustomer === null || contextCustomer === void 0 ? void 0 : contextCustomer.firstName) || '',
219
+ infix: (contextCustomer === null || contextCustomer === void 0 ? void 0 : contextCustomer.infix) || '',
220
+ lastName: (contextCustomer === null || contextCustomer === void 0 ? void 0 : contextCustomer.lastName) || '',
221
+ email: (contextCustomer === null || contextCustomer === void 0 ? void 0 : contextCustomer.email) || '',
222
+ phoneNumber: (contextCustomer === null || contextCustomer === void 0 ? void 0 : contextCustomer.phoneNumber) || '',
223
+ zipCode: (contextCustomer === null || contextCustomer === void 0 ? void 0 : contextCustomer.zipCode) || '',
224
+ houseNumber: (contextCustomer === null || contextCustomer === void 0 ? void 0 : contextCustomer.houseNumber) || '',
225
+ houseNumberAddition: (contextCustomer === null || contextCustomer === void 0 ? void 0 : contextCustomer.houseNumberAddition) || '',
226
+ streetName: (contextCustomer === null || contextCustomer === void 0 ? void 0 : contextCustomer.streetName) || '',
227
+ city: (contextCustomer === null || contextCustomer === void 0 ? void 0 : contextCustomer.city) || '',
228
+ companyName: (contextCustomer === null || contextCustomer === void 0 ? void 0 : contextCustomer.companyName) || '',
229
+ kvkNumber: (contextCustomer === null || contextCustomer === void 0 ? void 0 : contextCustomer.kvkNumber) || '',
230
+ vatNumber: (contextCustomer === null || contextCustomer === void 0 ? void 0 : contextCustomer.vatNumber) || '',
231
+ countryId: (contextCustomer === null || contextCustomer === void 0 ? void 0 : contextCustomer.countryId) || ''
232
+ };
233
+
234
+ // Only the original ownership type gets the initial data
235
+ return {
236
+ [_constants__.VEHICLE_SINGLE_ORDER_OWNERSHIP_TYPE.Empty]: originalOwnershipType === _constants__.VEHICLE_SINGLE_ORDER_OWNERSHIP_TYPE.Empty ? _objectSpread({}, initialCustomerData) : _objectSpread({}, emptyState),
237
+ [_constants__.VEHICLE_SINGLE_ORDER_OWNERSHIP_TYPE.Particulier]: originalOwnershipType === _constants__.VEHICLE_SINGLE_ORDER_OWNERSHIP_TYPE.Particulier ? _objectSpread({}, initialCustomerData) : _objectSpread({}, emptyState),
238
+ [_constants__.VEHICLE_SINGLE_ORDER_OWNERSHIP_TYPE.Zakelijk]: originalOwnershipType === _constants__.VEHICLE_SINGLE_ORDER_OWNERSHIP_TYPE.Zakelijk ? _objectSpread({}, initialCustomerData) : _objectSpread({}, emptyState)
239
+ };
240
+ });
241
+
242
+ // Get customer data for the active ownership type
243
+ const customer = customerDataPerType[activeOwnershipType] || getEmptyCustomerState();
244
+
245
+ // Helper to update customer data for the active ownership type
246
+ const updateCustomerField = (0, _react.useCallback)((field, value) => {
247
+ setCustomerDataPerType(prev => _objectSpread(_objectSpread({}, prev), {}, {
248
+ [activeOwnershipType]: _objectSpread(_objectSpread({}, prev[activeOwnershipType]), {}, {
249
+ [field]: value
250
+ })
251
+ }));
252
+ }, [activeOwnershipType]);
253
+
254
+ // Sync active ownership type to context when it changes
255
+ (0, _react.useEffect)(() => {
256
+ if (activeOwnershipType !== (vehicle === null || vehicle === void 0 ? void 0 : vehicle.singleOrderOwnershipType)) {
257
+ dispatch({
258
+ type: _OrderSessionContext.orderSessionActions.SET_VEHICLE_SINGLE_ORDER_OWNERSHIP_TYPE,
259
+ payload: {
260
+ singleOrderOwnershipType: activeOwnershipType
261
+ }
262
+ });
263
+ }
264
+ }, [activeOwnershipType, vehicle === null || vehicle === void 0 ? void 0 : vehicle.singleOrderOwnershipType, dispatch]);
265
+
266
+ // Sync customer data to context when it changes (for the active tab)
267
+ (0, _react.useEffect)(() => {
268
+ const currentData = customerDataPerType[activeOwnershipType];
269
+ if (!currentData) return;
270
+ const actionMap = {
271
+ firstName: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_FIRST_NAME,
272
+ infix: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_INFIX,
273
+ lastName: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_LAST_NAME,
274
+ email: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_EMAIL,
275
+ phoneNumber: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_PHONE_NUMBER,
276
+ zipCode: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_ZIP_CODE,
277
+ houseNumber: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_HOUSE_NUMBER,
278
+ houseNumberAddition: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_HOUSE_NUMBER_ADDITION,
279
+ streetName: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_STREET_NAME,
280
+ city: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_CITY,
281
+ companyName: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_COMPANY_NAME,
282
+ kvkNumber: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_KVK_NUMBER,
283
+ vatNumber: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_VAT_NUMBER,
284
+ countryId: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_COUNTRY_ID
285
+ };
286
+ Object.entries(currentData).forEach(_ref2 => {
287
+ let [field, value] = _ref2;
288
+ if (actionMap[field]) {
289
+ dispatch({
290
+ type: actionMap[field],
291
+ payload: {
292
+ [field]: value
293
+ }
294
+ });
295
+ }
296
+ });
297
+ }, [activeOwnershipType, customerDataPerType, dispatch]);
191
298
  const addressLookupService = new _AddressLookupService.default();
192
299
  const branchType = branchTypes === null || branchTypes === void 0 || (_branchTypes$byId$aut = branchTypes.byId[authSession === null || authSession === void 0 || (_authSession$branch = authSession.branch) === null || _authSession$branch === void 0 || (_authSession$branch = _authSession$branch.organisatietype) === null || _authSession$branch === void 0 ? void 0 : _authSession$branch[0]]) === null || _branchTypes$byId$aut === void 0 ? void 0 : _branchTypes$byId$aut.title;
193
300
  const {
@@ -202,22 +309,17 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
202
309
  isTowCenterBranch,
203
310
  searchTerm: companySearchTerm,
204
311
  formula,
205
- ownershipType: vehicle === null || vehicle === void 0 ? void 0 : vehicle.singleOrderOwnershipType,
312
+ ownershipType: activeOwnershipType,
206
313
  organisationType: branchType
207
314
  });
208
315
  (0, _react.useEffect)(() => {
209
316
  if (!(customer !== null && customer !== void 0 && customer.countryId) && countryOptions !== null && countryOptions !== void 0 && countryOptions.length) {
210
317
  const defaultCountry = countryOptions.find(option => option.label === 'NEDERLAND');
211
318
  if (defaultCountry) {
212
- dispatch({
213
- type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_COUNTRY_ID,
214
- payload: {
215
- countryId: defaultCountry.value
216
- }
217
- });
319
+ updateCustomerField('countryId', defaultCountry.value);
218
320
  }
219
321
  }
220
- }, [customer === null || customer === void 0 ? void 0 : customer.countryId, countryOptions, dispatch]);
322
+ }, [customer === null || customer === void 0 ? void 0 : customer.countryId, countryOptions, updateCustomerField]);
221
323
 
222
324
  /**
223
325
  * @description Auto-set Partner Portal channel for non-TMG users
@@ -262,13 +364,8 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
262
364
  }
263
365
  });
264
366
  // Set default ownership type to Particulier if not already set
265
- if (!(vehicle !== null && vehicle !== void 0 && vehicle.singleOrderOwnershipType) || (vehicle === null || vehicle === void 0 ? void 0 : vehicle.singleOrderOwnershipType) === _constants__.VEHICLE_SINGLE_ORDER_OWNERSHIP_TYPE.Empty) {
266
- dispatch({
267
- type: _OrderSessionContext.orderSessionActions.SET_VEHICLE_SINGLE_ORDER_OWNERSHIP_TYPE,
268
- payload: {
269
- singleOrderOwnershipType: _constants__.VEHICLE_SINGLE_ORDER_OWNERSHIP_TYPE.Particulier
270
- }
271
- });
367
+ if (!activeOwnershipType || activeOwnershipType === _constants__.VEHICLE_SINGLE_ORDER_OWNERSHIP_TYPE.Empty) {
368
+ setActiveOwnershipType(_constants__.VEHICLE_SINGLE_ORDER_OWNERSHIP_TYPE.Particulier);
272
369
  }
273
370
  } else {
274
371
  dispatch({
@@ -284,7 +381,7 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
284
381
  }
285
382
  });
286
383
  }
287
- }, [isTmg, isTowCenterBranch, dispatch, vehicle === null || vehicle === void 0 ? void 0 : vehicle.singleOrderOwnershipType]);
384
+ }, [isTmg, isTowCenterBranch, dispatch, activeOwnershipType]);
288
385
  const initialChannel = (0, _react.useMemo)(() => {
289
386
  if (!(channel !== null && channel !== void 0 && channel.channelId) || !(marketingChannels !== null && marketingChannels !== void 0 && marketingChannels.length)) return null;
290
387
  const selectedChannel = marketingChannels === null || marketingChannels === void 0 ? void 0 : marketingChannels.find(marketingC => (marketingC === null || marketingC === void 0 ? void 0 : marketingC.entityId) === (channel === null || channel === void 0 ? void 0 : channel.channelId));
@@ -295,77 +392,27 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
295
392
  }, [channel, marketingChannels]);
296
393
  const handleAutofillButtonClicked = () => {
297
394
  var _branchById$kvkNumber, _branchById$vatNumber, _branchById$country;
298
- dispatch({
299
- type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_COMPANY_NAME,
300
- payload: {
301
- companyName: branchById === null || branchById === void 0 ? void 0 : branchById.name
302
- }
303
- });
304
- dispatch({
305
- type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_ZIP_CODE,
306
- payload: {
307
- zipCode: branchById === null || branchById === void 0 ? void 0 : branchById.postalCode
308
- }
309
- });
310
- dispatch({
311
- type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_STREET_NAME,
312
- payload: {
313
- streetName: branchById === null || branchById === void 0 ? void 0 : branchById.street
314
- }
315
- });
316
- dispatch({
317
- type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_CITY,
318
- payload: {
319
- city: branchById === null || branchById === void 0 ? void 0 : branchById.city
320
- }
321
- });
322
- dispatch({
323
- type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_HOUSE_NUMBER,
324
- payload: {
325
- houseNumber: branchById === null || branchById === void 0 ? void 0 : branchById.street2
326
- }
327
- });
395
+ updateCustomerField('companyName', (branchById === null || branchById === void 0 ? void 0 : branchById.name) || '');
396
+ updateCustomerField('zipCode', (branchById === null || branchById === void 0 ? void 0 : branchById.postalCode) || '');
397
+ updateCustomerField('streetName', (branchById === null || branchById === void 0 ? void 0 : branchById.street) || '');
398
+ updateCustomerField('city', (branchById === null || branchById === void 0 ? void 0 : branchById.city) || '');
399
+ updateCustomerField('houseNumber', (branchById === null || branchById === void 0 ? void 0 : branchById.street2) || '');
328
400
  const kvkNumber = (_branchById$kvkNumber = branchById === null || branchById === void 0 ? void 0 : branchById.kvkNumber) !== null && _branchById$kvkNumber !== void 0 ? _branchById$kvkNumber : branchById === null || branchById === void 0 ? void 0 : branchById.kvkNummer;
329
401
  if (kvkNumber) {
330
- dispatch({
331
- type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_KVK_NUMBER,
332
- payload: {
333
- kvkNumber
334
- }
335
- });
402
+ updateCustomerField('kvkNumber', kvkNumber);
336
403
  }
337
404
  const vatNumber = (_branchById$vatNumber = branchById === null || branchById === void 0 ? void 0 : branchById.vatNumber) !== null && _branchById$vatNumber !== void 0 ? _branchById$vatNumber : branchById === null || branchById === void 0 ? void 0 : branchById.btwNummer;
338
405
  if (vatNumber) {
339
- dispatch({
340
- type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_VAT_NUMBER,
341
- payload: {
342
- vatNumber
343
- }
344
- });
406
+ updateCustomerField('vatNumber', vatNumber);
345
407
  }
346
408
  if (branchById !== null && branchById !== void 0 && branchById.email) {
347
- dispatch({
348
- type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_EMAIL,
349
- payload: {
350
- email: branchById.email
351
- }
352
- });
409
+ updateCustomerField('email', branchById.email);
353
410
  }
354
411
  if (branchById !== null && branchById !== void 0 && branchById.phone) {
355
- dispatch({
356
- type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_PHONE_NUMBER,
357
- payload: {
358
- phoneNumber: branchById.phone
359
- }
360
- });
412
+ updateCustomerField('phoneNumber', branchById.phone);
361
413
  }
362
414
  if (branchById !== null && branchById !== void 0 && (_branchById$country = branchById.country) !== null && _branchById$country !== void 0 && _branchById$country.entityId) {
363
- dispatch({
364
- type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_COUNTRY_ID,
365
- payload: {
366
- countryId: branchById.country.entityId
367
- }
368
- });
415
+ updateCustomerField('countryId', branchById.country.entityId);
369
416
  }
370
417
  };
371
418
 
@@ -379,18 +426,8 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
379
426
  const addressInfo = await addressLookupService.lookup(postcode, houseNumber);
380
427
  if (addressInfo && addressInfo.street && addressInfo.city) {
381
428
  // Auto-fill street and city fields
382
- dispatch({
383
- type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_STREET_NAME,
384
- payload: {
385
- streetName: addressInfo.street
386
- }
387
- });
388
- dispatch({
389
- type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_CITY,
390
- payload: {
391
- city: addressInfo.city
392
- }
393
- });
429
+ updateCustomerField('streetName', addressInfo.street);
430
+ updateCustomerField('city', addressInfo.city);
394
431
  }
395
432
  } catch (error) {
396
433
  console.error('Address lookup failed:', error);
@@ -464,7 +501,7 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
464
501
  validationSchema = validationSchema.shape(requiredFields);
465
502
  }
466
503
  await validationSchema.validate(_objectSpread(_objectSpread({}, customer), {}, {
467
- singleOrderOwnershipType: (vehicle === null || vehicle === void 0 ? void 0 : vehicle.singleOrderOwnershipType) || '',
504
+ singleOrderOwnershipType: activeOwnershipType || '',
468
505
  channelType: (channel === null || channel === void 0 ? void 0 : channel.channelType) || '',
469
506
  channelId: (channel === null || channel === void 0 ? void 0 : channel.channelId) || ''
470
507
  }), {
@@ -514,12 +551,12 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
514
551
  placeholder: "Maak een keuze",
515
552
  errorMessage: (errors === null || errors === void 0 ? void 0 : errors['channelType']) || (errors === null || errors === void 0 ? void 0 : errors['channelId']),
516
553
  initialValue: initialChannel,
517
- onChange: _ref2 => {
554
+ onChange: _ref3 => {
518
555
  var _value$kanaalType;
519
556
  let {
520
557
  label,
521
558
  value
522
- } = _ref2;
559
+ } = _ref3;
523
560
  return dispatch({
524
561
  type: _OrderSessionContext.orderSessionActions.SET_MARKETING_CHANNEL,
525
562
  payload: {
@@ -533,14 +570,10 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
533
570
  })), /*#__PURE__*/_react.default.createElement(_RadioButtons.default, {
534
571
  name: "singleOrderOwnershipType",
535
572
  label: "Type:",
536
- initialValue: (vehicle === null || vehicle === void 0 ? void 0 : vehicle.singleOrderOwnershipType) || (isTmg || isTowCenterBranch ? _constants__.VEHICLE_SINGLE_ORDER_OWNERSHIP_TYPE.Particulier : _constants__.VEHICLE_SINGLE_ORDER_OWNERSHIP_TYPE.Empty),
573
+ initialValue: activeOwnershipType || (isTmg || isTowCenterBranch ? _constants__.VEHICLE_SINGLE_ORDER_OWNERSHIP_TYPE.Particulier : _constants__.VEHICLE_SINGLE_ORDER_OWNERSHIP_TYPE.Empty),
537
574
  onChange: val => {
538
- dispatch({
539
- type: _OrderSessionContext.orderSessionActions.SET_VEHICLE_SINGLE_ORDER_OWNERSHIP_TYPE,
540
- payload: {
541
- singleOrderOwnershipType: val
542
- }
543
- });
575
+ // Switch to the new ownership type - each type maintains its own separate state
576
+ setActiveOwnershipType(val);
544
577
  },
545
578
  options: isTmg || isTowCenterBranch ? Object.values(_constants__.VEHICLE_SINGLE_ORDER_OWNERSHIP_TYPE).filter(option => option !== _constants__.VEHICLE_SINGLE_ORDER_OWNERSHIP_TYPE.Empty) : Object.values(_constants__.VEHICLE_SINGLE_ORDER_OWNERSHIP_TYPE),
546
579
  isRequired: isTmg || isTowCenterBranch,
@@ -579,12 +612,7 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
579
612
  placeholder: "",
580
613
  initialValue: customer.firstName,
581
614
  name: "firstName",
582
- onChange: value => dispatch({
583
- type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_FIRST_NAME,
584
- payload: {
585
- firstName: value
586
- }
587
- }),
615
+ onChange: value => updateCustomerField('firstName', value),
588
616
  isRequired: webshop || anderAfleveradres,
589
617
  form: form,
590
618
  label: "Voornaam:",
@@ -593,12 +621,7 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
593
621
  placeholder: "",
594
622
  initialValue: customer.infix,
595
623
  name: "infix",
596
- onChange: value => dispatch({
597
- type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_INFIX,
598
- payload: {
599
- infix: value
600
- }
601
- }),
624
+ onChange: value => updateCustomerField('infix', value),
602
625
  isRequired: false,
603
626
  form: form,
604
627
  label: "Tussenvoegsel:",
@@ -607,12 +630,7 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
607
630
  placeholder: "",
608
631
  initialValue: customer.lastName,
609
632
  name: "lastName",
610
- onChange: value => dispatch({
611
- type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_LAST_NAME,
612
- payload: {
613
- lastName: value
614
- }
615
- }),
633
+ onChange: value => updateCustomerField('lastName', value),
616
634
  isRequired: webshop || anderAfleveradres,
617
635
  form: form,
618
636
  label: "Achternaam:",
@@ -621,12 +639,7 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
621
639
  placeholder: "",
622
640
  initialValue: customer.email,
623
641
  name: "email",
624
- onChange: value => dispatch({
625
- type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_EMAIL,
626
- payload: {
627
- email: value
628
- }
629
- }),
642
+ onChange: value => updateCustomerField('email', value),
630
643
  isRequired: webshop,
631
644
  form: form,
632
645
  label: "E-mailadres:",
@@ -635,19 +648,14 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
635
648
  placeholder: "",
636
649
  initialValue: customer.phoneNumber,
637
650
  name: "phoneNumber",
638
- onChange: value => dispatch({
639
- type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_PHONE_NUMBER,
640
- payload: {
641
- phoneNumber: value
642
- }
643
- }),
651
+ onChange: value => updateCustomerField('phoneNumber', value),
644
652
  form: form,
645
653
  isRequired: webshop,
646
654
  label: "Telefoonnummer:",
647
655
  errorMessage: errors === null || errors === void 0 ? void 0 : errors['phoneNumber']
648
656
  })), /*#__PURE__*/_react.default.createElement("div", {
649
657
  className: (0, _helpers__.withStyle)('col-12 mt-2 col-md-6')
650
- }, (vehicle === null || vehicle === void 0 ? void 0 : vehicle.singleOrderOwnershipType) === _constants__.VEHICLE_SINGLE_ORDER_OWNERSHIP_TYPE.Zakelijk ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("h6", {
658
+ }, activeOwnershipType === _constants__.VEHICLE_SINGLE_ORDER_OWNERSHIP_TYPE.Zakelijk ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("h6", {
651
659
  className: (0, _helpers__.withStyle)('modal-title mb-2')
652
660
  }, "Gegevens bedrijf"), /*#__PURE__*/_react.default.createElement("div", {
653
661
  className: (0, _helpers__.withStyle)('company-search-container position-relative mb-3')
@@ -665,12 +673,7 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
665
673
  initialValue: customer.companyName,
666
674
  name: "companyName",
667
675
  onChange: value => {
668
- dispatch({
669
- type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_COMPANY_NAME,
670
- payload: {
671
- companyName: value
672
- }
673
- });
676
+ updateCustomerField('companyName', value);
674
677
  if (value !== companySearchTerm) {
675
678
  setCompanySearchTerm(value);
676
679
  setIsCompanyInputFocused(true);
@@ -712,77 +715,32 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
712
715
  onMouseDown: e => {
713
716
  var _branch$vatNumber, _branch$kvkNumber;
714
717
  e.preventDefault();
715
- dispatch({
716
- type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_COMPANY_NAME,
717
- payload: {
718
- companyName: branch.name
719
- }
720
- });
718
+ updateCustomerField('companyName', branch.name);
721
719
  if (branch.postalCode) {
722
- dispatch({
723
- type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_ZIP_CODE,
724
- payload: {
725
- zipCode: branch.postalCode
726
- }
727
- });
720
+ updateCustomerField('zipCode', branch.postalCode);
728
721
  }
729
722
  if (branch.street) {
730
- dispatch({
731
- type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_STREET_NAME,
732
- payload: {
733
- streetName: branch.street
734
- }
735
- });
723
+ updateCustomerField('streetName', branch.street);
736
724
  }
737
725
  if (branch.city) {
738
- dispatch({
739
- type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_CITY,
740
- payload: {
741
- city: branch.city
742
- }
743
- });
726
+ updateCustomerField('city', branch.city);
744
727
  }
745
728
  if (branch.street2) {
746
- dispatch({
747
- type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_HOUSE_NUMBER,
748
- payload: {
749
- houseNumber: branch.street2
750
- }
751
- });
729
+ updateCustomerField('houseNumber', branch.street2);
752
730
  }
753
731
  const vatNumber = (_branch$vatNumber = branch.vatNumber) !== null && _branch$vatNumber !== void 0 ? _branch$vatNumber : branch.btwNummer;
754
732
  if (vatNumber) {
755
- dispatch({
756
- type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_VAT_NUMBER,
757
- payload: {
758
- vatNumber
759
- }
760
- });
733
+ updateCustomerField('vatNumber', vatNumber);
761
734
  }
762
735
  const kvkNumber = (_branch$kvkNumber = branch.kvkNumber) !== null && _branch$kvkNumber !== void 0 ? _branch$kvkNumber : branch.kvkNummer;
763
736
  if (kvkNumber) {
764
- dispatch({
765
- type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_KVK_NUMBER,
766
- payload: {
767
- kvkNumber
768
- }
769
- });
737
+ updateCustomerField('kvkNumber', kvkNumber);
770
738
  }
771
739
  if (branch.huisnummerToevoeging) {
772
- dispatch({
773
- type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_HOUSE_NUMBER_ADDITION,
774
- payload: {
775
- houseNumberAddition: branch.huisnummerToevoeging
776
- }
777
- });
740
+ updateCustomerField('houseNumberAddition', branch.huisnummerToevoeging);
778
741
  }
779
742
  if (branch.country && branch.country.entityId) {
780
- dispatch({
781
- type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_COUNTRY_ID,
782
- payload: {
783
- countryId: branch.country.entityId
784
- }
785
- });
743
+ updateCustomerField('countryId', branch.country.entityId);
786
744
  }
787
745
  setCompanySearchTerm('');
788
746
  setIsCompanyInputFocused(false);
@@ -791,12 +749,7 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
791
749
  placeholder: "",
792
750
  initialValue: customer.kvkNumber,
793
751
  name: "kvkNumber",
794
- onChange: value => dispatch({
795
- type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_KVK_NUMBER,
796
- payload: {
797
- kvkNumber: value
798
- }
799
- }),
752
+ onChange: value => updateCustomerField('kvkNumber', value),
800
753
  isRequired: false,
801
754
  form: form,
802
755
  label: "KVK-nummer:",
@@ -805,12 +758,7 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
805
758
  placeholder: "",
806
759
  initialValue: customer.vatNumber,
807
760
  name: "vatNumber",
808
- onChange: value => dispatch({
809
- type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_VAT_NUMBER,
810
- payload: {
811
- vatNumber: value
812
- }
813
- }),
761
+ onChange: value => updateCustomerField('vatNumber', value),
814
762
  isRequired: false,
815
763
  form: form,
816
764
  label: "BTW-nummer:",
@@ -820,12 +768,7 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
820
768
  initialValue: customer.zipCode,
821
769
  name: "zipCode",
822
770
  onChange: value => {
823
- dispatch({
824
- type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_ZIP_CODE,
825
- payload: {
826
- zipCode: value
827
- }
828
- });
771
+ updateCustomerField('zipCode', value);
829
772
  // Trigger address lookup if house number is also available
830
773
  if (customer.houseNumber) {
831
774
  handleAddressLookup(value, customer.houseNumber);
@@ -840,12 +783,7 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
840
783
  initialValue: customer.houseNumber,
841
784
  name: "houseNumber",
842
785
  onChange: value => {
843
- dispatch({
844
- type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_HOUSE_NUMBER,
845
- payload: {
846
- houseNumber: value
847
- }
848
- });
786
+ updateCustomerField('houseNumber', value);
849
787
  // Trigger address lookup if postcode is also available
850
788
  if (customer.zipCode) {
851
789
  handleAddressLookup(customer.zipCode, value);
@@ -859,12 +797,7 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
859
797
  placeholder: "",
860
798
  initialValue: customer.houseNumberAddition,
861
799
  name: "houseNumberAddition",
862
- onChange: value => dispatch({
863
- type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_HOUSE_NUMBER_ADDITION,
864
- payload: {
865
- houseNumberAddition: value
866
- }
867
- }),
800
+ onChange: value => updateCustomerField('houseNumberAddition', value),
868
801
  isRequired: false,
869
802
  form: form,
870
803
  label: "Huisnummer toevoeging:",
@@ -873,12 +806,7 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
873
806
  placeholder: addressLookupLoading ? 'Adres wordt opgezocht...' : '',
874
807
  initialValue: customer.streetName,
875
808
  name: "streetName",
876
- onChange: value => dispatch({
877
- type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_STREET_NAME,
878
- payload: {
879
- streetName: value
880
- }
881
- }),
809
+ onChange: value => updateCustomerField('streetName', value),
882
810
  isRequired: anderAfleveradres,
883
811
  form: form,
884
812
  label: "Straat:".concat(addressLookupLoading ? ' (wordt opgezocht...)' : ''),
@@ -887,12 +815,7 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
887
815
  placeholder: addressLookupLoading ? 'Stad wordt opgezocht...' : '',
888
816
  initialValue: customer.city,
889
817
  name: "city",
890
- onChange: value => dispatch({
891
- type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_CITY,
892
- payload: {
893
- city: value
894
- }
895
- }),
818
+ onChange: value => updateCustomerField('city', value),
896
819
  isRequired: anderAfleveradres,
897
820
  form: form,
898
821
  label: "Stad:".concat(addressLookupLoading ? ' (wordt opgezocht...)' : ''),
@@ -907,16 +830,11 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
907
830
  placeholder: "Selecteer een land",
908
831
  errorMessage: errors === null || errors === void 0 ? void 0 : errors['countryId'],
909
832
  initialValue: (countryOptions === null || countryOptions === void 0 ? void 0 : countryOptions.find(option => option.value === (customer === null || customer === void 0 ? void 0 : customer.countryId))) || null,
910
- onChange: _ref3 => {
833
+ onChange: _ref4 => {
911
834
  let {
912
835
  value
913
- } = _ref3;
914
- return dispatch({
915
- type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_COUNTRY_ID,
916
- payload: {
917
- countryId: value
918
- }
919
- });
836
+ } = _ref4;
837
+ return updateCustomerField('countryId', value);
920
838
  }
921
839
  }))))), !webshop && /*#__PURE__*/_react.default.createElement("div", {
922
840
  className: (0, _helpers__.withStyle)('col-12')
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.VAT_RATE = exports.MARKET_CORRECTION_ARTICLE_NUMBER = exports.CART_TABLE_PRICE_CELL_CLASS = exports.CART_TABLE_DISPLAY_MODES = exports.CART_TABLE_BOLD_END_CLASS = void 0;
6
+ exports.VAT_RATE = exports.MARKET_CORRECTION_ARTICLE_NUMBER = exports.EXTRA_PRICE_ARTICLE_NUMBER = exports.CART_TABLE_PRICE_CELL_CLASS = exports.CART_TABLE_DISPLAY_MODES = exports.CART_TABLE_BOLD_END_CLASS = void 0;
7
7
  /**
8
8
  * Display modes for the cart table:
9
9
  * - DEFAULT: No purchase prices shown (7 columns)
@@ -26,4 +26,7 @@ const CART_TABLE_BOLD_END_CLASS = exports.CART_TABLE_BOLD_END_CLASS = 'fw-bold t
26
26
  const VAT_RATE = exports.VAT_RATE = 1.21;
27
27
 
28
28
  /** Market correction article number */
29
- const MARKET_CORRECTION_ARTICLE_NUMBER = exports.MARKET_CORRECTION_ARTICLE_NUMBER = 'MC';
29
+ const MARKET_CORRECTION_ARTICLE_NUMBER = exports.MARKET_CORRECTION_ARTICLE_NUMBER = 'MC';
30
+
31
+ /** Extra price (Meerprijs) article number */
32
+ const EXTRA_PRICE_ARTICLE_NUMBER = exports.EXTRA_PRICE_ARTICLE_NUMBER = 'MEERPRIJS';