thm-p3-configurator 0.0.409 → 0.0.411

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.
@@ -427,7 +427,8 @@ const useCreatePrivateAppointmentMutation = () => {
427
427
  zakelijkContactPersoonNaam,
428
428
  zakelijkContactTelefoonnummer,
429
429
  zakeiljkContactFactuuradres,
430
- zakelijkContactEMailadres
430
+ zakelijkContactEMailadres,
431
+ orderProcessingNote = undefined
431
432
  } = _ref7;
432
433
  const _ref8 = customer || {},
433
434
  {
@@ -435,7 +436,7 @@ const useCreatePrivateAppointmentMutation = () => {
435
436
  } = _ref8,
436
437
  restCustomer = _objectWithoutProperties(_ref8, _excluded2);
437
438
  const apiMontageRate = (0, _montageRate.toApiMontageRate)(montageRate);
438
- const response = await _authenticatedProxyApi.authenticatedProxyApi.postAppointment({
439
+ const response = await _authenticatedProxyApi.authenticatedProxyApi.postAppointment(_objectSpread({
439
440
  appointment,
440
441
  model,
441
442
  constructionYear,
@@ -462,7 +463,9 @@ const useCreatePrivateAppointmentMutation = () => {
462
463
  zakelijkContactTelefoonnummer,
463
464
  zakeiljkContactFactuuradres,
464
465
  zakelijkContactEMailadres
465
- });
466
+ }, orderProcessingNote ? {
467
+ orderProcessingNote
468
+ } : {}));
466
469
  const entityId = (_response$data = response.data) === null || _response$data === void 0 || (_response$data = _response$data.data) === null || _response$data === void 0 ? void 0 : _response$data.entityId;
467
470
  if (linkToExistingCustomerId && entityId) {
468
471
  await _authenticatedProxyApi.authenticatedProxyApi.putDossierById({
@@ -513,6 +513,18 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
513
513
 
514
514
  setAddressLookupTimeoutId(newTimeoutId);
515
515
  };
516
+ const handlePostalCodeChange = value => {
517
+ updateCustomerField('zipCode', value);
518
+ const inferredCountry = (0, _helpers__.getCountryOptionForPostalCode)(value, countryOptions);
519
+ if (inferredCountry && inferredCountry.value !== (customer === null || customer === void 0 ? void 0 : customer.countryId)) {
520
+ updateCustomerField('countryId', inferredCountry.value);
521
+ }
522
+
523
+ // Trigger address lookup if house number is also available
524
+ if (customer.houseNumber) {
525
+ handleAddressLookup(value, customer.houseNumber);
526
+ }
527
+ };
516
528
 
517
529
  // Cleanup timeout on unmount
518
530
  (0, _react.useEffect)(() => {
@@ -857,13 +869,7 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
857
869
  placeholder: "",
858
870
  value: customer.zipCode,
859
871
  name: "zipCode",
860
- onChange: value => {
861
- updateCustomerField('zipCode', value);
862
- // Trigger address lookup if house number is also available
863
- if (customer.houseNumber) {
864
- handleAddressLookup(value, customer.houseNumber);
865
- }
866
- },
872
+ onChange: handlePostalCodeChange,
867
873
  isRequired: isDirectDeliveryEnabled,
868
874
  key: "zipCode-".concat(refreshKey),
869
875
  form: form,
@@ -916,6 +922,7 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
916
922
  label: "Stad:".concat(addressLookupLoading ? ' (wordt opgezocht...)' : ''),
917
923
  errorMessage: errors === null || errors === void 0 ? void 0 : errors['city']
918
924
  }), /*#__PURE__*/_react.default.createElement(_DropdownInput.default, {
925
+ key: "country-".concat((customer === null || customer === void 0 ? void 0 : customer.countryId) || 'default'),
919
926
  options: countryOptions,
920
927
  name: "country",
921
928
  label: "Land:",
@@ -2,6 +2,10 @@
2
2
 
3
3
  var _index = require("../index");
4
4
  describe('__constants__/formula helpers', () => {
5
+ const originalAppConfig = global.APP_CONFIG;
6
+ afterEach(() => {
7
+ global.APP_CONFIG = originalAppConfig;
8
+ });
5
9
  it('keeps TBE exact when normalizing branch formulas', () => {
6
10
  expect((0, _index.mapBranchFormulaToConfiguratorFormula)('TBE')).toBe(_index.CONFIGURATOR_FORMULAS.TBE);
7
11
  expect((0, _index.mapBranchFormulaToConfiguratorFormula)('Trekhaakcentrum Business')).toBe(_index.CONFIGURATOR_FORMULAS.TBE);
@@ -17,4 +21,18 @@ describe('__constants__/formula helpers', () => {
17
21
  expect((0, _index.isThcFamilyFormula)(_index.CONFIGURATOR_FORMULAS.TBE)).toBe(true);
18
22
  expect((0, _index.getThemeFormulaForConfiguratorFormula)(_index.CONFIGURATOR_FORMULAS.TBE)).toBe(_index.CONFIGURATOR_FORMULAS.THC);
19
23
  });
24
+ it('keeps THM for standalone order/pricing requests', () => {
25
+ global.APP_CONFIG = {
26
+ internal: false
27
+ };
28
+ expect((0, _index.normalizeFormulaForOrderApi)(_index.CONFIGURATOR_FORMULAS.THM)).toBe(_index.CONFIGURATOR_FORMULAS.THM);
29
+ expect((0, _index.normalizeFormulaForOrderApi)('trekhaakmontage')).toBe(_index.CONFIGURATOR_FORMULAS.THM);
30
+ });
31
+ it('maps THM to TOW for internal order/pricing requests', () => {
32
+ global.APP_CONFIG = {
33
+ internal: true
34
+ };
35
+ expect((0, _index.normalizeFormulaForOrderApi)(_index.CONFIGURATOR_FORMULAS.THM)).toBe(_index.CONFIGURATOR_FORMULAS.TOW);
36
+ expect((0, _index.normalizeFormulaForOrderApi)(_index.CONFIGURATOR_FORMULAS.THC)).toBe(_index.CONFIGURATOR_FORMULAS.THC);
37
+ });
20
38
  });
@@ -257,14 +257,18 @@ const normalizeFormulaInput = formula => {
257
257
  };
258
258
 
259
259
  /**
260
- * Hyper order/pricing APIs expect TM instead of THM for non-dossier flows.
260
+ * Normalizes formula for Hyper order/pricing APIs.
261
+ * Internal (partner portal) flows map THM to TM; standalone sends THM as-is.
261
262
  */
262
263
  const normalizeFormulaForOrderApi = formula => {
263
264
  const normalizedFormula = getConfiguratorFormulaCode(formula);
264
265
  if (!normalizedFormula) {
265
266
  return normalizedFormula;
266
267
  }
267
- return normalizedFormula === CONFIGURATOR_FORMULAS.THM ? CONFIGURATOR_FORMULAS.TM : normalizedFormula;
268
+ if (APP_CONFIG.internal && normalizedFormula === CONFIGURATOR_FORMULAS.THM) {
269
+ return CONFIGURATOR_FORMULAS.TM;
270
+ }
271
+ return normalizedFormula;
268
272
  };
269
273
  exports.normalizeFormulaForOrderApi = normalizeFormulaForOrderApi;
270
274
  const getConfiguratorFormulaCode = formula => {
@@ -355,16 +359,13 @@ const NO_PRODUCTS_CONTACT_DETAILS_BY_FORMULA = exports.NO_PRODUCTS_CONTACT_DETAI
355
359
  };
356
360
  const EXECUTION_HELP_CONTACT_DETAILS_BY_FORMULA = exports.EXECUTION_HELP_CONTACT_DETAILS_BY_FORMULA = {
357
361
  [CONFIGURATOR_FORMULAS.THM]: {
358
- phoneDisplay: '+31 85 000 4122',
359
- phoneHref: 'tel:+31850004122'
362
+ helpUrl: 'https://www.trekhaakmontage.nl/uitvoering-niet-bekend'
360
363
  },
361
364
  [CONFIGURATOR_FORMULAS.THC]: {
362
- phoneDisplay: '+31 85 202 0660',
363
- phoneHref: 'tel:+31852020660'
365
+ helpUrl: 'https://www.trekhaakcentrum.nl/uitvoering-niet-bekend'
364
366
  },
365
367
  [CONFIGURATOR_FORMULAS.TBE]: {
366
- phoneDisplay: '+31 85 202 0660',
367
- phoneHref: 'tel:+31852020660'
368
+ helpUrl: 'https://www.trekhaakcentrum.nl/uitvoering-niet-bekend'
368
369
  }
369
370
  };
370
371
  const LOCATION_CHANGE_BUTTON_LABEL = exports.LOCATION_CHANGE_BUTTON_LABEL = 'Wijzig de locatie';
@@ -422,8 +422,8 @@ const QuestionsForm = _ref => {
422
422
  });
423
423
  }
424
424
  };
425
- const hasExecutionQuestion = initialOptions.execution1.length > 0 || initialOptions.execution2.length > 0;
426
- const executionHelpContactDetails = !APP_CONFIG.internal && hasExecutionQuestion ? _constants__.EXECUTION_HELP_CONTACT_DETAILS_BY_FORMULA[formula] : null;
425
+ const shouldShowExecutionHelp = initialOptions.duration.length > 0 || initialOptions.execution1.length > 0 || initialOptions.execution2.length > 0;
426
+ const executionHelpContactDetails = !APP_CONFIG.internal && shouldShowExecutionHelp ? _constants__.EXECUTION_HELP_CONTACT_DETAILS_BY_FORMULA[formula] : null;
427
427
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("p", null, "We hebben nog een aantal vragen (max 4) voordat we de juiste trekhaak voor jouw auto kunnen adviseren."), /*#__PURE__*/_react.default.createElement("div", {
428
428
  className: (0, _helpers__.withStyle)('my-2')
429
429
  }, initialOptions.duration.length > 0 && /*#__PURE__*/_react.default.createElement(_RadioInput.default, {
@@ -447,13 +447,18 @@ const QuestionsForm = _ref => {
447
447
  initialValue: isFilter ? filterAnswers.executionAnswer2 : executionAnswer2,
448
448
  options: initialOptions.execution2,
449
449
  isRequired: true
450
- }), executionHelpContactDetails && /*#__PURE__*/_react.default.createElement("p", {
451
- className: (0, _helpers__.withStyle)('small text-muted mt-3 mb-0')
452
- }, "Weet u niet wat voor uitvoering uw auto is? Neem dan contact op met", ' ', /*#__PURE__*/_react.default.createElement("a", {
453
- href: executionHelpContactDetails.phoneHref,
454
- className: (0, _helpers__.withStyle)('text-nowrap')
455
- }, executionHelpContactDetails.phoneDisplay), ".")), /*#__PURE__*/_react.default.createElement("div", {
456
- className: (0, _helpers__.withStyle)('row align-items-center justify-content-end mt-2')
450
+ }), (executionHelpContactDetails === null || executionHelpContactDetails === void 0 ? void 0 : executionHelpContactDetails.helpUrl) && /*#__PURE__*/_react.default.createElement("div", {
451
+ className: (0, _helpers__.withStyle)('text-center mt-3 mb-2')
452
+ }, /*#__PURE__*/_react.default.createElement(_LinkButton.default, {
453
+ type: "button",
454
+ isDisabled: false,
455
+ onClick: () => {
456
+ window.location.href = executionHelpContactDetails.helpUrl;
457
+ },
458
+ label: "Ik weet het niet / ik heb hulp nodig",
459
+ className: formula === _constants__.CONFIGURATOR_FORMULAS.THM ? 'fw-bold' : ''
460
+ }))), /*#__PURE__*/_react.default.createElement("div", {
461
+ className: (0, _helpers__.withStyle)('row align-items-center justify-content-between mt-2')
457
462
  }, /*#__PURE__*/_react.default.createElement("div", {
458
463
  className: (0, _helpers__.withStyle)("col col-sm-auto mt-1")
459
464
  }, /*#__PURE__*/_react.default.createElement("div", {
@@ -272,7 +272,8 @@ const InternalAppointmentForm = _ref => {
272
272
  hasGoedkeuringsnummerActivity,
273
273
  isTowCenterBranch,
274
274
  extraPriceAmount,
275
- extraPriceDescription
275
+ extraPriceDescription,
276
+ orderProcessingNote
276
277
  } = order;
277
278
 
278
279
  // Track the original ownership type from context
@@ -384,6 +385,7 @@ const InternalAppointmentForm = _ref => {
384
385
  }
385
386
  });
386
387
  }, [activeOwnershipType, customerDataPerType, dispatch]);
388
+ const [wantsOrderProcessingNote, setWantsOrderProcessingNote] = (0, _react.useState)(false);
387
389
  const [errors, setErrors] = (0, _react.useState)({});
388
390
  const [_licensePlate, _setLicensePlate] = (0, _react.useState)();
389
391
  const isTmg = (0, _useIsTmg.useIsTmg)();
@@ -707,6 +709,9 @@ const InternalAppointmentForm = _ref => {
707
709
  payload.zakelijkContactTelefoonnummer = activeOwnershipType === _constants__.VEHICLE_OWNERSHIP_TYPE.Zakelijk ? (customer === null || customer === void 0 ? void 0 : customer.zakelijkContactTelefoonnummer) || '' : '';
708
710
  payload.zakeiljkContactFactuuradres = activeOwnershipType === _constants__.VEHICLE_OWNERSHIP_TYPE.Zakelijk ? (customer === null || customer === void 0 ? void 0 : customer.zakeiljkContactFactuuradres) || '' : '';
709
711
  payload.zakelijkContactEMailadres = activeOwnershipType === _constants__.VEHICLE_OWNERSHIP_TYPE.Zakelijk ? (customer === null || customer === void 0 ? void 0 : customer.zakelijkContactEMailadres) || '' : '';
712
+ if (!existingDossierId && appointmentType === _constants__.DOSSIER_TYPES.PlannedAppointment && wantsOrderProcessingNote && orderProcessingNote !== null && orderProcessingNote !== void 0 && orderProcessingNote.trim()) {
713
+ payload.orderProcessingNote = orderProcessingNote.trim();
714
+ }
710
715
  await onSubmit(payload);
711
716
  } catch (ex) {
712
717
  console.error("handleSubmit(): ".concat(ex));
@@ -830,6 +835,18 @@ const InternalAppointmentForm = _ref => {
830
835
 
831
836
  setAddressLookupTimeoutId(newTimeoutId);
832
837
  };
838
+ const handlePostalCodeChange = value => {
839
+ updateCustomerField('zipCode', value);
840
+ const inferredCountry = (0, _helpers__.getCountryOptionForPostalCode)(value, countryOptions);
841
+ if (inferredCountry && inferredCountry.value !== (customer === null || customer === void 0 ? void 0 : customer.countryId)) {
842
+ updateCustomerField('countryId', inferredCountry.value);
843
+ }
844
+
845
+ // Trigger address lookup if house number is also available
846
+ if (customer.houseNumber) {
847
+ handleAddressLookup(value, customer.houseNumber);
848
+ }
849
+ };
833
850
 
834
851
  // Cleanup timeout on unmount
835
852
  (0, _react.useEffect)(() => {
@@ -1220,13 +1237,7 @@ const InternalAppointmentForm = _ref => {
1220
1237
  placeholder: "",
1221
1238
  value: customer.zipCode,
1222
1239
  name: "zipCode",
1223
- onChange: value => {
1224
- updateCustomerField('zipCode', value);
1225
- // Trigger address lookup if house number is also available
1226
- if (customer.houseNumber) {
1227
- handleAddressLookup(value, customer.houseNumber);
1228
- }
1229
- },
1240
+ onChange: handlePostalCodeChange,
1230
1241
  key: "zipCode-".concat(refreshKey),
1231
1242
  isRequired: true,
1232
1243
  label: "Postcode:",
@@ -1324,13 +1335,7 @@ const InternalAppointmentForm = _ref => {
1324
1335
  placeholder: "",
1325
1336
  value: customer.zipCode,
1326
1337
  name: "zipCode",
1327
- onChange: value => {
1328
- updateCustomerField('zipCode', value);
1329
- // Trigger address lookup if house number is also available
1330
- if (customer.houseNumber) {
1331
- handleAddressLookup(value, customer.houseNumber);
1332
- }
1333
- },
1338
+ onChange: handlePostalCodeChange,
1334
1339
  key: "zipCode-".concat(refreshKey),
1335
1340
  isRequired: true,
1336
1341
  label: "Postcode:",
@@ -1407,13 +1412,7 @@ const InternalAppointmentForm = _ref => {
1407
1412
  placeholder: "",
1408
1413
  value: customer.zipCode,
1409
1414
  name: "zipCode",
1410
- onChange: value => {
1411
- updateCustomerField('zipCode', value);
1412
- // Trigger address lookup if house number is also available
1413
- if (customer.houseNumber) {
1414
- handleAddressLookup(value, customer.houseNumber);
1415
- }
1416
- },
1415
+ onChange: handlePostalCodeChange,
1417
1416
  key: "zipCode-".concat(refreshKey),
1418
1417
  isRequired: true,
1419
1418
  label: "Postcode:",
@@ -1648,6 +1647,43 @@ const InternalAppointmentForm = _ref => {
1648
1647
  label: "Eventuele opmerkingen:",
1649
1648
  errorMessage: errors === null || errors === void 0 ? void 0 : errors['note'],
1650
1649
  key: "note-".concat(refreshKey)
1650
+ })), !existingDossierId && /*#__PURE__*/_react.default.createElement("div", {
1651
+ className: (0, _helpers__.withStyle)('col-12')
1652
+ }, /*#__PURE__*/_react.default.createElement(_CheckboxInput.default, {
1653
+ isRequired: false,
1654
+ name: "wantsOrderProcessingNote",
1655
+ initialValue: wantsOrderProcessingNote,
1656
+ onChange: value => {
1657
+ setWantsOrderProcessingNote(value);
1658
+ if (!value) {
1659
+ dispatch({
1660
+ type: _OrderSessionContext.orderSessionActions.SET_ORDER_PROCESSING_NOTE,
1661
+ payload: {
1662
+ orderProcessingNote: ''
1663
+ }
1664
+ });
1665
+ }
1666
+ },
1667
+ form: "appointment",
1668
+ label: "Notitie orderverwerking plaatsen",
1669
+ key: "wantsOrderProcessingNote-".concat(refreshKey)
1670
+ }), /*#__PURE__*/_react.default.createElement("p", {
1671
+ className: (0, _helpers__.withStyle)('text-muted small mb-2')
1672
+ }, "Alleen van toepassing bij het maken van een geplande afspraak. Voorkomt automatische orderverwerking naar XDMS. Dit is geen klantopmerking."), wantsOrderProcessingNote && /*#__PURE__*/_react.default.createElement(_TextAreaInput.default, {
1673
+ placeholder: "",
1674
+ value: orderProcessingNote !== null && orderProcessingNote !== void 0 ? orderProcessingNote : '',
1675
+ name: "orderProcessingNote",
1676
+ onChange: value => dispatch({
1677
+ type: _OrderSessionContext.orderSessionActions.SET_ORDER_PROCESSING_NOTE,
1678
+ payload: {
1679
+ orderProcessingNote: value
1680
+ }
1681
+ }),
1682
+ isRequired: false,
1683
+ form: "appointment",
1684
+ label: "Notitie orderverwerking:",
1685
+ errorMessage: errors === null || errors === void 0 ? void 0 : errors['orderProcessingNote'],
1686
+ key: "orderProcessingNote-".concat(refreshKey)
1651
1687
  }))))), /*#__PURE__*/_react.default.createElement("div", {
1652
1688
  className: (0, _helpers__.withStyle)('col-12 mt-4')
1653
1689
  }, isError && /*#__PURE__*/_react.default.createElement(_ErrorMessage.default, {
@@ -141,6 +141,7 @@ const INITIAL_ORDER_SESSION_STATE = {
141
141
  selectedDiscountedProducts: [],
142
142
  discountsInitialized: false,
143
143
  internalNote: null,
144
+ orderProcessingNote: '',
144
145
  selectedBoardComputer: null,
145
146
  isBoardComputerDeselected: false,
146
147
  selectedBranch: null,
@@ -254,6 +255,7 @@ const orderSessionActions = exports.orderSessionActions = {
254
255
  SET_CUSTOMER_PHONE_NUMBER: 'SET_CUSTOMER_TELEPHONE_NUMBER',
255
256
  SET_CUSTOMER_EMAIL: 'SET_CUSTOMER_EMAIL',
256
257
  SET_CUSTOMER_NOTE: 'SET_CUSTOMER_NOTE',
258
+ SET_ORDER_PROCESSING_NOTE: 'SET_ORDER_PROCESSING_NOTE',
257
259
  SET_INTERNAL_NOTE: 'SET_INTERNAL_NOTE',
258
260
  SET_DISCOUNT_CODE: 'SET_DISCOUNT_CODE',
259
261
  SET_ANWB_DISCOUNT_VALIDATED: 'SET_ANWB_DISCOUNT_VALIDATED',
@@ -728,6 +730,15 @@ const orderSessionReducer = (state, action) => {
728
730
  })
729
731
  });
730
732
  }
733
+ case orderSessionActions.SET_ORDER_PROCESSING_NOTE:
734
+ {
735
+ const {
736
+ orderProcessingNote
737
+ } = action.payload;
738
+ return _objectSpread(_objectSpread({}, state), {}, {
739
+ orderProcessingNote
740
+ });
741
+ }
731
742
  case orderSessionActions.SET_DURATION_ANSWER:
732
743
  {
733
744
  const {
@@ -3,12 +3,14 @@
3
3
  require("core-js/modules/es.array.reduce.js");
4
4
  require("core-js/modules/es.object.from-entries.js");
5
5
  require("core-js/modules/es.regexp.exec.js");
6
+ require("core-js/modules/es.regexp.test.js");
6
7
  require("core-js/modules/es.regexp.to-string.js");
7
8
  require("core-js/modules/es.string.ends-with.js");
8
9
  require("core-js/modules/es.string.replace.js");
9
10
  require("core-js/modules/es.string.trim.js");
10
11
  require("core-js/modules/esnext.iterator.constructor.js");
11
12
  require("core-js/modules/esnext.iterator.filter.js");
13
+ require("core-js/modules/esnext.iterator.find.js");
12
14
  require("core-js/modules/esnext.iterator.for-each.js");
13
15
  require("core-js/modules/esnext.iterator.map.js");
14
16
  require("core-js/modules/esnext.iterator.reduce.js");
@@ -32,21 +34,26 @@ var _exportNames = {
32
34
  truncateAtPipe: true,
33
35
  parseJson: true,
34
36
  isBelgianDomain: true,
37
+ isDutchPostalCode: true,
38
+ isBelgianPostalCode: true,
39
+ getCountryOptionForPostalCode: true,
35
40
  removeNullishProps: true,
36
41
  createSlug: true,
37
42
  getProxyApiErrorMessage: true,
38
43
  formatMontageTime: true
39
44
  };
40
- exports.withStyle = exports.truncateAtPipe = exports.removeNullishProps = exports.reduceYupErrorsToObject = exports.pushToDataLayer = exports.parseJson = exports.parseDateAndTimeToTimestamp = exports.parseArrayToInputOptions = exports.normalizeArray = exports.isBelgianDomain = exports.groupByKey = exports.getProxyApiErrorMessage = exports.getConfiguratorThemeClassByFormula = exports.getConfiguratorThemeClass = exports.getConfiguratorButtonVariant = exports.formatPrice = exports.formatMontageTime = exports.createSlug = void 0;
45
+ exports.withStyle = exports.truncateAtPipe = exports.removeNullishProps = exports.reduceYupErrorsToObject = exports.pushToDataLayer = exports.parseJson = exports.parseDateAndTimeToTimestamp = exports.parseArrayToInputOptions = exports.normalizeArray = exports.isDutchPostalCode = exports.isBelgianPostalCode = exports.isBelgianDomain = exports.groupByKey = exports.getProxyApiErrorMessage = exports.getCountryOptionForPostalCode = exports.getConfiguratorThemeClassByFormula = exports.getConfiguratorThemeClass = exports.getConfiguratorButtonVariant = exports.formatPrice = exports.formatMontageTime = exports.createSlug = void 0;
41
46
  require("core-js/modules/es.array.reduce.js");
42
47
  require("core-js/modules/es.object.from-entries.js");
43
48
  require("core-js/modules/es.regexp.exec.js");
49
+ require("core-js/modules/es.regexp.test.js");
44
50
  require("core-js/modules/es.regexp.to-string.js");
45
51
  require("core-js/modules/es.string.ends-with.js");
46
52
  require("core-js/modules/es.string.replace.js");
47
53
  require("core-js/modules/es.string.trim.js");
48
54
  require("core-js/modules/esnext.iterator.constructor.js");
49
55
  require("core-js/modules/esnext.iterator.filter.js");
56
+ require("core-js/modules/esnext.iterator.find.js");
50
57
  require("core-js/modules/esnext.iterator.map.js");
51
58
  require("core-js/modules/esnext.iterator.reduce.js");
52
59
  require("core-js/modules/web.dom-collections.iterator.js");
@@ -304,11 +311,33 @@ const isBelgianDomain = () => {
304
311
  const hostname = (_window$location = window.location) === null || _window$location === void 0 || (_window$location = _window$location.hostname) === null || _window$location === void 0 ? void 0 : _window$location.toLowerCase();
305
312
  return Boolean(hostname && (hostname === 'be' || hostname.endsWith('.be')));
306
313
  };
314
+ exports.isBelgianDomain = isBelgianDomain;
315
+ const isDutchPostalCode = postalCode => {
316
+ if (!postalCode) return false;
317
+ const cleanedPostalCode = postalCode.replace(/\s/g, '');
318
+ return /^[1-9][0-9]{3}[A-Z]{2}$/i.test(cleanedPostalCode);
319
+ };
320
+ exports.isDutchPostalCode = isDutchPostalCode;
321
+ const isBelgianPostalCode = postalCode => {
322
+ if (!postalCode) return false;
323
+ const cleanedPostalCode = postalCode.replace(/\s/g, '');
324
+ return /^[1-9][0-9]{3}$/.test(cleanedPostalCode);
325
+ };
326
+ exports.isBelgianPostalCode = isBelgianPostalCode;
327
+ const normalizeCountryLabel = function normalizeCountryLabel() {
328
+ let label = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
329
+ return label.normalize('NFD').replace(/[\u0300-\u036f]/g, '').toUpperCase();
330
+ };
331
+ const getCountryOptionForPostalCode = exports.getCountryOptionForPostalCode = function getCountryOptionForPostalCode(postalCode) {
332
+ let countryOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
333
+ const countryName = isDutchPostalCode(postalCode) ? 'NEDERLAND' : isBelgianPostalCode(postalCode) ? 'BELGIE' : null;
334
+ if (!countryName) return null;
335
+ return countryOptions.find(option => normalizeCountryLabel(option === null || option === void 0 ? void 0 : option.label) === countryName) || null;
336
+ };
307
337
 
308
338
  /**
309
339
  * @description Removes nullish properties from a passed object
310
340
  */
311
- exports.isBelgianDomain = isBelgianDomain;
312
341
  const removeNullishProps = exports.removeNullishProps = function removeNullishProps() {
313
342
  let object = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
314
343
  return Object.fromEntries(Object.entries(object).filter(_ref3 => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thm-p3-configurator",
3
- "version": "0.0.409",
3
+ "version": "0.0.411",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "author": "EnoRm.",