thm-p3-configurator 0.0.404 → 0.0.405

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.
@@ -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)('TBE')).toEqual(['brands', 'TBE']);
93
+ expect((0, _queryKeyFactory.getBrandsQueryKey)('THCB')).toEqual(['brands', 'THCB']);
94
94
  expect((0, _queryKeyFactory.getBuildYearsQueryKey)({
95
95
  brand: 'Volvo',
96
96
  formula: 'TMG'
@@ -33,7 +33,6 @@ var _constants__ = require("../../__constants__");
33
33
  var _AuthSessionContext = require("../../__context__/AuthSessionContext");
34
34
  var _OrderSessionContext = require("../../__context__/OrderSessionContext");
35
35
  var _helpers__ = require("../../__helpers__");
36
- var _countryOptions = require("../../__helpers__/countryOptions");
37
36
  var _useIsTmg = require("../../__hooks__/useIsTmg");
38
37
  var _AddressLookupService = _interopRequireDefault(require("../../__services__/AddressLookupService"));
39
38
  var _LinkButton = _interopRequireDefault(require("../Buttons/LinkButton"));
@@ -188,7 +187,14 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
188
187
  countries,
189
188
  isLoadingCountries
190
189
  } = (0, _queries.useCountriesQuery)();
191
- const countryOptions = (0, _react.useMemo)(() => (0, _countryOptions.buildCountryDropdownOptions)(countries === null || countries === void 0 ? void 0 : countries.results), [countries]);
190
+ const countryOptions = (0, _react.useMemo)(() => {
191
+ var _countries$results;
192
+ if (!(countries !== null && countries !== void 0 && (_countries$results = countries.results) !== null && _countries$results !== void 0 && _countries$results.length)) return [];
193
+ return countries.results.map(country => ({
194
+ label: country.title,
195
+ value: country.entityId
196
+ }));
197
+ }, [countries]);
192
198
  const authSession = (0, _AuthSessionContext.useAuthSession)();
193
199
  const isTmg = (0, _useIsTmg.useIsTmg)();
194
200
  const [companySearchTerm, setCompanySearchTerm] = (0, _react.useState)('');
@@ -257,15 +263,10 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
257
263
  const needsCustomerDeliveryIdentity = isDirectDeliveryEnabled;
258
264
  const isNetherlandsSelected = (0, _react.useMemo)(() => {
259
265
  if (!(selectedCountry !== null && selectedCountry !== void 0 && selectedCountry.label)) return false;
260
- return selectedCountry.label.toUpperCase() === _constants__.COUNTRY_NAMES.NETHERLANDS;
261
- }, [selectedCountry === null || selectedCountry === void 0 ? void 0 : selectedCountry.label]);
262
- const isBelgiumSelected = (0, _react.useMemo)(() => {
263
- if (!(selectedCountry !== null && selectedCountry !== void 0 && selectedCountry.label)) return false;
264
- const normalizedCountryLabel = selectedCountry.label.trim().toUpperCase();
265
- return normalizedCountryLabel === _constants__.COUNTRY_NAMES.BELGIUM || normalizedCountryLabel === _constants__.COUNTRY_NAMES.BELGIUM_FALLBACK;
266
+ return selectedCountry.label.toUpperCase() === 'NEDERLAND';
266
267
  }, [selectedCountry === null || selectedCountry === void 0 ? void 0 : selectedCountry.label]);
267
- const shouldRequireKvkNumber = needsCustomerDeliveryIdentity && isBusinessOwnership && (isNetherlandsSelected || !isNetherlandsSelected && !isBelgiumSelected && !(customer !== null && customer !== void 0 && (_customer$vatNumber = customer.vatNumber) !== null && _customer$vatNumber !== void 0 && _customer$vatNumber.trim()));
268
- const shouldRequireVatNumber = needsCustomerDeliveryIdentity && isBusinessOwnership && (isBelgiumSelected || !isNetherlandsSelected && !isBelgiumSelected && !(customer !== null && customer !== void 0 && (_customer$kvkNumber = customer.kvkNumber) !== null && _customer$kvkNumber !== void 0 && _customer$kvkNumber.trim()));
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());
269
270
 
270
271
  // Helper to update customer data for the active ownership type
271
272
  const updateCustomerField = (0, _react.useCallback)((field, value) => {
@@ -504,18 +505,6 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
504
505
 
505
506
  setAddressLookupTimeoutId(newTimeoutId);
506
507
  };
507
- const handlePostalCodeChange = value => {
508
- updateCustomerField('zipCode', value);
509
- const inferredCountry = (0, _helpers__.getCountryOptionForPostalCode)(value, countryOptions);
510
- if (inferredCountry && inferredCountry.value !== (customer === null || customer === void 0 ? void 0 : customer.countryId)) {
511
- updateCustomerField('countryId', inferredCountry.value);
512
- }
513
-
514
- // Trigger address lookup if house number is also available
515
- if (customer.houseNumber) {
516
- handleAddressLookup(value, customer.houseNumber);
517
- }
518
- };
519
508
 
520
509
  // Cleanup timeout on unmount
521
510
  (0, _react.useEffect)(() => {
@@ -537,13 +526,7 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
537
526
  });
538
527
  return false;
539
528
  }
540
- if (isBelgiumSelected && !hasVatNumber) {
541
- onValidationError === null || onValidationError === void 0 || onValidationError({
542
- vatNumber: 'BTW-nummer is verplicht voor zakelijke dossiers in België'
543
- });
544
- return false;
545
- }
546
- if (!isNetherlandsSelected && !isBelgiumSelected && !hasKvkNumber && !hasVatNumber) {
529
+ if (!isNetherlandsSelected && !hasKvkNumber && !hasVatNumber) {
547
530
  onValidationError === null || onValidationError === void 0 || onValidationError({
548
531
  kvkNumber: 'Vul een KVK- of BTW-nummer in',
549
532
  vatNumber: 'Vul een KVK- of BTW-nummer in'
@@ -860,7 +843,13 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
860
843
  placeholder: "",
861
844
  value: customer.zipCode,
862
845
  name: "zipCode",
863
- onChange: handlePostalCodeChange,
846
+ onChange: value => {
847
+ updateCustomerField('zipCode', value);
848
+ // Trigger address lookup if house number is also available
849
+ if (customer.houseNumber) {
850
+ handleAddressLookup(value, customer.houseNumber);
851
+ }
852
+ },
864
853
  isRequired: isDirectDeliveryEnabled,
865
854
  key: "zipCode-".concat(refreshKey),
866
855
  form: form,
@@ -913,7 +902,6 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
913
902
  label: "Stad:".concat(addressLookupLoading ? ' (wordt opgezocht...)' : ''),
914
903
  errorMessage: errors === null || errors === void 0 ? void 0 : errors['city']
915
904
  }), /*#__PURE__*/_react.default.createElement(_DropdownInput.default, {
916
- key: "country-".concat((customer === null || customer === void 0 ? void 0 : customer.countryId) || 'default'),
917
905
  options: countryOptions,
918
906
  name: "country",
919
907
  label: "Land:",
@@ -2,19 +2,19 @@
2
2
 
3
3
  var _index = require("../index");
4
4
  describe('__constants__/formula helpers', () => {
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);
5
+ it('keeps THCB exact when normalizing branch formulas', () => {
6
+ expect((0, _index.mapBranchFormulaToConfiguratorFormula)('THCB')).toBe(_index.CONFIGURATOR_FORMULAS.THCB);
7
+ expect((0, _index.mapBranchFormulaToConfiguratorFormula)('Trekhaakcentrum Business')).toBe(_index.CONFIGURATOR_FORMULAS.THCB);
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)('tbe')).toBe(_index.CONFIGURATOR_FORMULAS.TBE);
12
+ expect((0, _index.getConfiguratorFormulaCode)('thcb')).toBe(_index.CONFIGURATOR_FORMULAS.THCB);
13
13
  expect((0, _index.getConfiguratorFormulaCode)('abc')).toBe('ABC');
14
14
  });
15
- it('treats TBE as THC-family for theme decisions only', () => {
15
+ it('treats THCB 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.TBE)).toBe(true);
18
- expect((0, _index.getThemeFormulaForConfiguratorFormula)(_index.CONFIGURATOR_FORMULAS.TBE)).toBe(_index.CONFIGURATOR_FORMULAS.THC);
17
+ expect((0, _index.isThcFamilyFormula)(_index.CONFIGURATOR_FORMULAS.THCB)).toBe(true);
18
+ expect((0, _index.getThemeFormulaForConfiguratorFormula)(_index.CONFIGURATOR_FORMULAS.THCB)).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.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;
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;
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,11 +27,6 @@ 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
- };
35
30
  const BRANCH_FORMULAS = exports.BRANCH_FORMULAS = {
36
31
  Trekhaakcentrum: 'Trekhaakcentrum',
37
32
  TowMotiveGroup: 'TowMotive Group',
@@ -233,7 +228,7 @@ const ApiStockStatus = exports.ApiStockStatus = {
233
228
  const CONFIGURATOR_FORMULAS = exports.CONFIGURATOR_FORMULAS = {
234
229
  THM: 'THM',
235
230
  THC: 'THC',
236
- TBE: 'TBE',
231
+ THCB: 'THCB',
237
232
  TMG: 'TMG',
238
233
  TOW: 'TOW',
239
234
  TM: 'TOW',
@@ -272,10 +267,10 @@ const getConfiguratorFormulaCode = formula => {
272
267
  case 'thc':
273
268
  case 'trekhaakcentrum':
274
269
  return CONFIGURATOR_FORMULAS.THC;
275
- case 'tbe':
270
+ case 'thcb':
276
271
  case 'trekhaakcentrum belgie':
277
272
  case 'trekhaakcentrum business':
278
- return CONFIGURATOR_FORMULAS.TBE;
273
+ return CONFIGURATOR_FORMULAS.THCB;
279
274
  case 'thm':
280
275
  case 'trekhaakmontage':
281
276
  return CONFIGURATOR_FORMULAS.THM;
@@ -286,7 +281,7 @@ const getConfiguratorFormulaCode = formula => {
286
281
  exports.getConfiguratorFormulaCode = getConfiguratorFormulaCode;
287
282
  const isThcFamilyFormula = formula => {
288
283
  const normalizedFormula = getConfiguratorFormulaCode(formula);
289
- return normalizedFormula === CONFIGURATOR_FORMULAS.THC || normalizedFormula === CONFIGURATOR_FORMULAS.TBE;
284
+ return normalizedFormula === CONFIGURATOR_FORMULAS.THC || normalizedFormula === CONFIGURATOR_FORMULAS.THCB;
290
285
  };
291
286
  exports.isThcFamilyFormula = isThcFamilyFormula;
292
287
  const getThemeFormulaForConfiguratorFormula = formula => {
@@ -312,7 +307,7 @@ const NO_PRODUCTS_CONTACT_DETAILS_BY_FORMULA = exports.NO_PRODUCTS_CONTACT_DETAI
312
307
  companyName: 'Trekhaakcentrum',
313
308
  logoAltText: 'Trekhaakcentrum Logo'
314
309
  },
315
- [CONFIGURATOR_FORMULAS.TBE]: {
310
+ [CONFIGURATOR_FORMULAS.THCB]: {
316
311
  email: 'order@trekhaakcentrum.nl',
317
312
  phoneDisplay: '+31 162 - 490 910',
318
313
  phoneHref: 'tel:+31162490910',
@@ -350,7 +345,7 @@ const EXECUTION_HELP_CONTACT_DETAILS_BY_FORMULA = exports.EXECUTION_HELP_CONTACT
350
345
  phoneDisplay: '+31 85 202 0660',
351
346
  phoneHref: 'tel:+31852020660'
352
347
  },
353
- [CONFIGURATOR_FORMULAS.TBE]: {
348
+ [CONFIGURATOR_FORMULAS.THCB]: {
354
349
  phoneDisplay: '+31 85 202 0660',
355
350
  phoneHref: 'tel:+31852020660'
356
351
  }
@@ -612,13 +612,11 @@ 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;
617
615
  return {
618
616
  main: {
619
617
  purchase: mainPurchase,
620
618
  margin: mainMargin,
621
- inclVat: mainSubtotalIncl,
619
+ inclVat: mainInclVat + montageInclVat,
622
620
  exclVat: mainExclVat + montageExclVat + marketCorrectionExclVat,
623
621
  tmg: {
624
622
  catalog: tmgCatalog,
@@ -51,7 +51,6 @@ var _AuthSessionContext = require("../../__context__/AuthSessionContext");
51
51
  var _FormulaContext = require("../../__context__/FormulaContext");
52
52
  var _OrderSessionContext = require("../../__context__/OrderSessionContext");
53
53
  var _helpers__ = require("../../__helpers__");
54
- var _countryOptions = require("../../__helpers__/countryOptions");
55
54
  var _product = require("../../__helpers__/product");
56
55
  var _ui = require("../../__helpers__/ui");
57
56
  var _useIsTmg = require("../../__hooks__/useIsTmg");
@@ -157,7 +156,6 @@ const internalAppointmentFormSchema = (0, _yup.object)({
157
156
  houseNumberAddition: (0, _yup.string)().nullable(),
158
157
  streetName: (0, _yup.string)().required(_constants__.FORM_ERROR_MESSAGES.required),
159
158
  city: (0, _yup.string)().required(_constants__.FORM_ERROR_MESSAGES.required),
160
- countryId: (0, _yup.string)().required(_constants__.FORM_ERROR_MESSAGES.required),
161
159
  date: (0, _yup.string)().nullable(),
162
160
  time: (0, _yup.string)().nullable(),
163
161
  customerAgreed: (0, _yup.boolean)().required(_constants__.FORM_ERROR_MESSAGES.required).isTrue(_constants__.FORM_ERROR_MESSAGES.required),
@@ -219,7 +217,7 @@ const getBranchCity = function getBranchCity() {
219
217
  return (branch === null || branch === void 0 ? void 0 : branch.city) || (branch === null || branch === void 0 ? void 0 : branch.gemeente) || '';
220
218
  };
221
219
  const InternalAppointmentForm = _ref => {
222
- var _branchTypes$byId$aut, _authSession$branch, _customer$vatNumber, _customer$kvkNumber, _authSession$branch2, _contextCustomer$note2;
220
+ var _branchTypes$byId$aut, _authSession$branch, _authSession$branch2, _contextCustomer$note2;
223
221
  let {
224
222
  onSubmit = payload => {},
225
223
  isError = false,
@@ -395,7 +393,14 @@ const InternalAppointmentForm = _ref => {
395
393
  countries,
396
394
  isLoadingCountries
397
395
  } = (0, _queries.useCountriesQuery)();
398
- const countryOptions = (0, _react.useMemo)(() => (0, _countryOptions.buildCountryDropdownOptions)(countries === null || countries === void 0 ? void 0 : countries.results), [countries]);
396
+ const countryOptions = (0, _react.useMemo)(() => {
397
+ var _countries$results;
398
+ if (!(countries !== null && countries !== void 0 && (_countries$results = countries.results) !== null && _countries$results !== void 0 && _countries$results.length)) return [];
399
+ return countries.results.map(country => ({
400
+ label: country.title,
401
+ value: country.entityId
402
+ }));
403
+ }, [countries]);
399
404
  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;
400
405
  const {
401
406
  marketingChannels,
@@ -438,23 +443,23 @@ const InternalAppointmentForm = _ref => {
438
443
  if (!(customer !== null && customer !== void 0 && customer.countryId) && countryOptions !== null && countryOptions !== void 0 && countryOptions.length) {
439
444
  const defaultCountry = countryOptions.find(option => option.label === 'NEDERLAND');
440
445
  if (defaultCountry) {
441
- updateCustomerField('countryId', defaultCountry.value);
446
+ dispatch({
447
+ type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_COUNTRY_ID,
448
+ payload: {
449
+ countryId: defaultCountry.value
450
+ }
451
+ });
442
452
  }
443
453
  }
444
- }, [customer === null || customer === void 0 ? void 0 : customer.countryId, countryOptions, updateCustomerField]);
454
+ }, [customer === null || customer === void 0 ? void 0 : customer.countryId, countryOptions, dispatch]);
445
455
  const isBusinessOwnership = activeOwnershipType === _constants__.VEHICLE_OWNERSHIP_TYPE.Zakelijk;
446
456
  const isLeaseOwnership = activeOwnershipType === _constants__.VEHICLE_OWNERSHIP_TYPE.Leasemaatschappij;
447
457
  const isNetherlandsSelected = (0, _react.useMemo)(() => {
448
458
  if (!(selectedCountry !== null && selectedCountry !== void 0 && selectedCountry.label)) return false;
449
- return selectedCountry.label.toUpperCase() === _constants__.COUNTRY_NAMES.NETHERLANDS;
459
+ return selectedCountry.label.toUpperCase() === 'NEDERLAND';
450
460
  }, [selectedCountry === null || selectedCountry === void 0 ? void 0 : selectedCountry.label]);
451
- const isBelgiumSelected = (0, _react.useMemo)(() => {
452
- if (!(selectedCountry !== null && selectedCountry !== void 0 && selectedCountry.label)) return false;
453
- const normalizedCountryLabel = selectedCountry.label.trim().toUpperCase();
454
- return normalizedCountryLabel === _constants__.COUNTRY_NAMES.BELGIUM || normalizedCountryLabel === _constants__.COUNTRY_NAMES.BELGIUM_FALLBACK;
455
- }, [selectedCountry === null || selectedCountry === void 0 ? void 0 : selectedCountry.label]);
456
- const shouldRequireKvkNumber = isBusinessOwnership && (isNetherlandsSelected || !isNetherlandsSelected && !isBelgiumSelected && !(customer !== null && customer !== void 0 && (_customer$vatNumber = customer.vatNumber) !== null && _customer$vatNumber !== void 0 && _customer$vatNumber.trim()));
457
- const shouldRequireVatNumber = isBusinessOwnership && (isBelgiumSelected || !isNetherlandsSelected && !isBelgiumSelected && !(customer !== null && customer !== void 0 && (_customer$kvkNumber = customer.kvkNumber) !== null && _customer$kvkNumber !== void 0 && _customer$kvkNumber.trim()));
461
+ const shouldRequireKvkNumber = isBusinessOwnership && (isNetherlandsSelected || !isNetherlandsSelected && !(customer !== null && customer !== void 0 && customer.vatNumber));
462
+ const shouldRequireVatNumber = isBusinessOwnership && !isNetherlandsSelected && !(customer !== null && customer !== void 0 && customer.kvkNumber);
458
463
  const {
459
464
  branchById
460
465
  } = (0, _queries.useBranchByIdOrWidgetId)(selectedBranch);
@@ -497,7 +502,7 @@ const InternalAppointmentForm = _ref => {
497
502
  const handleSubmit = async function handleSubmit() {
498
503
  let appointmentType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _constants__.DOSSIER_TYPES.PlannedAppointment;
499
504
  try {
500
- var _customer$kvkNumber2, _customer$vatNumber2, _customer$firstName, _customer$lastName, _customer$phoneNumber, _customer$houseNumber, _customer$houseNumber2, _customer$streetName, _customer$countryId, _customer$city, _customer$email, _ref3, _contextCustomer$anwb, _contextCustomer$note, _customer$zipCode, _customer$companyName, _customer$kvkNumber3, _customer$vatNumber3, _ref4, _vehicle$leaseNumber, _vehicle$leaseNumberU, _customer$companyName2, _customer$kvkNumber4, _customer$vatNumber4;
505
+ var _customer$kvkNumber, _customer$vatNumber, _customer$firstName, _customer$lastName, _customer$phoneNumber, _customer$houseNumber, _customer$houseNumber2, _customer$streetName, _customer$countryId, _customer$city, _customer$email, _ref3, _contextCustomer$anwb, _contextCustomer$note, _customer$zipCode, _customer$companyName, _customer$kvkNumber2, _customer$vatNumber2, _ref4, _vehicle$leaseNumber, _vehicle$leaseNumberU, _customer$companyName2, _customer$kvkNumber3, _customer$vatNumber3;
501
506
  setErrors({});
502
507
  if (!model) {
503
508
  // Note: this does not throw on error.
@@ -519,8 +524,8 @@ const InternalAppointmentForm = _ref => {
519
524
  return;
520
525
  }
521
526
  }
522
- const hasKvkNumber = !!(customer !== null && customer !== void 0 && (_customer$kvkNumber2 = customer.kvkNumber) !== null && _customer$kvkNumber2 !== void 0 && _customer$kvkNumber2.trim());
523
- const hasVatNumber = !!(customer !== null && customer !== void 0 && (_customer$vatNumber2 = customer.vatNumber) !== null && _customer$vatNumber2 !== void 0 && _customer$vatNumber2.trim());
527
+ const hasKvkNumber = !!(customer !== null && customer !== void 0 && (_customer$kvkNumber = customer.kvkNumber) !== null && _customer$kvkNumber !== void 0 && _customer$kvkNumber.trim());
528
+ const hasVatNumber = !!(customer !== null && customer !== void 0 && (_customer$vatNumber = customer.vatNumber) !== null && _customer$vatNumber !== void 0 && _customer$vatNumber.trim());
524
529
  if (isBusinessOwnership) {
525
530
  if (isNetherlandsSelected && !hasKvkNumber) {
526
531
  setErrors({
@@ -528,13 +533,7 @@ const InternalAppointmentForm = _ref => {
528
533
  });
529
534
  return;
530
535
  }
531
- if (isBelgiumSelected && !hasVatNumber) {
532
- setErrors({
533
- vatNumber: 'BTW-nummer is verplicht voor zakelijke dossiers in België'
534
- });
535
- return;
536
- }
537
- if (!isNetherlandsSelected && !isBelgiumSelected && !hasKvkNumber && !hasVatNumber) {
536
+ if (!isNetherlandsSelected && !hasKvkNumber && !hasVatNumber) {
538
537
  setErrors({
539
538
  kvkNumber: 'Vul een KVK- of BTW-nummer in',
540
539
  vatNumber: 'Vul een KVK- of BTW-nummer in'
@@ -578,8 +577,8 @@ const InternalAppointmentForm = _ref => {
578
577
  note: (_contextCustomer$note = contextCustomer === null || contextCustomer === void 0 ? void 0 : contextCustomer.note) !== null && _contextCustomer$note !== void 0 ? _contextCustomer$note : undefined,
579
578
  zipCode: (_customer$zipCode = customer === null || customer === void 0 ? void 0 : customer.zipCode) !== null && _customer$zipCode !== void 0 ? _customer$zipCode : undefined,
580
579
  companyName: activeOwnershipType !== _constants__.VEHICLE_OWNERSHIP_TYPE.Leasemaatschappij ? (_customer$companyName = customer === null || customer === void 0 ? void 0 : customer.companyName) !== null && _customer$companyName !== void 0 ? _customer$companyName : undefined : undefined,
581
- kvkNumber: (_customer$kvkNumber3 = customer === null || customer === void 0 ? void 0 : customer.kvkNumber) !== null && _customer$kvkNumber3 !== void 0 ? _customer$kvkNumber3 : undefined,
582
- vatNumber: (_customer$vatNumber3 = customer === null || customer === void 0 ? void 0 : customer.vatNumber) !== null && _customer$vatNumber3 !== void 0 ? _customer$vatNumber3 : undefined
580
+ kvkNumber: (_customer$kvkNumber2 = customer === null || customer === void 0 ? void 0 : customer.kvkNumber) !== null && _customer$kvkNumber2 !== void 0 ? _customer$kvkNumber2 : undefined,
581
+ vatNumber: (_customer$vatNumber2 = customer === null || customer === void 0 ? void 0 : customer.vatNumber) !== null && _customer$vatNumber2 !== void 0 ? _customer$vatNumber2 : undefined
583
582
  })),
584
583
  customerAgreed,
585
584
  appointment,
@@ -631,8 +630,8 @@ const InternalAppointmentForm = _ref => {
631
630
  });
632
631
  payload.customer = _objectSpread(_objectSpread({}, payload.customer || {}), {}, {
633
632
  companyName: activeOwnershipType === _constants__.VEHICLE_OWNERSHIP_TYPE.Zakelijk ? (_customer$companyName2 = customer === null || customer === void 0 ? void 0 : customer.companyName) !== null && _customer$companyName2 !== void 0 ? _customer$companyName2 : '' : '',
634
- kvkNumber: activeOwnershipType === _constants__.VEHICLE_OWNERSHIP_TYPE.Zakelijk ? (_customer$kvkNumber4 = customer === null || customer === void 0 ? void 0 : customer.kvkNumber) !== null && _customer$kvkNumber4 !== void 0 ? _customer$kvkNumber4 : '' : '',
635
- vatNumber: activeOwnershipType === _constants__.VEHICLE_OWNERSHIP_TYPE.Zakelijk ? (_customer$vatNumber4 = customer === null || customer === void 0 ? void 0 : customer.vatNumber) !== null && _customer$vatNumber4 !== void 0 ? _customer$vatNumber4 : '' : ''
633
+ kvkNumber: activeOwnershipType === _constants__.VEHICLE_OWNERSHIP_TYPE.Zakelijk ? (_customer$kvkNumber3 = customer === null || customer === void 0 ? void 0 : customer.kvkNumber) !== null && _customer$kvkNumber3 !== void 0 ? _customer$kvkNumber3 : '' : '',
634
+ vatNumber: activeOwnershipType === _constants__.VEHICLE_OWNERSHIP_TYPE.Zakelijk ? (_customer$vatNumber3 = customer === null || customer === void 0 ? void 0 : customer.vatNumber) !== null && _customer$vatNumber3 !== void 0 ? _customer$vatNumber3 : '' : ''
636
635
  });
637
636
  if (existingDossierId && appointmentType === _constants__.DOSSIER_TYPES.PlannedAppointment && typeof invoicePaymentByLeaseCompany === 'boolean') {
638
637
  payload.invoicePaymentByLeaseCompany = activeOwnershipType === _constants__.VEHICLE_OWNERSHIP_TYPE.Leasemaatschappij ? invoicePaymentByLeaseCompany : false;
@@ -772,18 +771,6 @@ const InternalAppointmentForm = _ref => {
772
771
 
773
772
  setAddressLookupTimeoutId(newTimeoutId);
774
773
  };
775
- const handlePostalCodeChange = value => {
776
- updateCustomerField('zipCode', value);
777
- const inferredCountry = (0, _helpers__.getCountryOptionForPostalCode)(value, countryOptions);
778
- if (inferredCountry && inferredCountry.value !== (customer === null || customer === void 0 ? void 0 : customer.countryId)) {
779
- updateCustomerField('countryId', inferredCountry.value);
780
- }
781
-
782
- // Trigger address lookup if house number is also available
783
- if (customer.houseNumber) {
784
- handleAddressLookup(value, customer.houseNumber);
785
- }
786
- };
787
774
 
788
775
  // Cleanup timeout on unmount
789
776
  (0, _react.useEffect)(() => {
@@ -1174,7 +1161,13 @@ const InternalAppointmentForm = _ref => {
1174
1161
  placeholder: "",
1175
1162
  value: customer.zipCode,
1176
1163
  name: "zipCode",
1177
- onChange: handlePostalCodeChange,
1164
+ onChange: value => {
1165
+ updateCustomerField('zipCode', value);
1166
+ // Trigger address lookup if house number is also available
1167
+ if (customer.houseNumber) {
1168
+ handleAddressLookup(value, customer.houseNumber);
1169
+ }
1170
+ },
1178
1171
  key: "zipCode-".concat(refreshKey),
1179
1172
  isRequired: true,
1180
1173
  label: "Postcode:",
@@ -1226,7 +1219,7 @@ const InternalAppointmentForm = _ref => {
1226
1219
  options: countryOptions,
1227
1220
  name: "country",
1228
1221
  label: "Land:",
1229
- isRequired: true,
1222
+ isRequired: false,
1230
1223
  isLoading: isLoadingCountries,
1231
1224
  noOptionsMessage: "Geen landen beschikbaar",
1232
1225
  placeholder: "Selecteer een land",
@@ -1236,7 +1229,12 @@ const InternalAppointmentForm = _ref => {
1236
1229
  let {
1237
1230
  value
1238
1231
  } = _ref6;
1239
- return updateCustomerField('countryId', value);
1232
+ return dispatch({
1233
+ type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_COUNTRY_ID,
1234
+ payload: {
1235
+ countryId: value
1236
+ }
1237
+ });
1240
1238
  }
1241
1239
  }), /*#__PURE__*/_react.default.createElement("h6", {
1242
1240
  className: (0, _helpers__.withStyle)('modal-title mb-2 mt-3')
@@ -1272,7 +1270,13 @@ const InternalAppointmentForm = _ref => {
1272
1270
  placeholder: "",
1273
1271
  value: customer.zipCode,
1274
1272
  name: "zipCode",
1275
- onChange: handlePostalCodeChange,
1273
+ onChange: value => {
1274
+ updateCustomerField('zipCode', value);
1275
+ // Trigger address lookup if house number is also available
1276
+ if (customer.houseNumber) {
1277
+ handleAddressLookup(value, customer.houseNumber);
1278
+ }
1279
+ },
1276
1280
  key: "zipCode-".concat(refreshKey),
1277
1281
  isRequired: true,
1278
1282
  label: "Postcode:",
@@ -1324,7 +1328,7 @@ const InternalAppointmentForm = _ref => {
1324
1328
  options: countryOptions,
1325
1329
  name: "country",
1326
1330
  label: "Land:",
1327
- isRequired: true,
1331
+ isRequired: false,
1328
1332
  isLoading: isLoadingCountries,
1329
1333
  noOptionsMessage: "Geen landen beschikbaar",
1330
1334
  placeholder: "Selecteer een land",
@@ -1334,7 +1338,12 @@ const InternalAppointmentForm = _ref => {
1334
1338
  let {
1335
1339
  value
1336
1340
  } = _ref7;
1337
- return updateCustomerField('countryId', value);
1341
+ return dispatch({
1342
+ type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_COUNTRY_ID,
1343
+ payload: {
1344
+ countryId: value
1345
+ }
1346
+ });
1338
1347
  }
1339
1348
  })) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_TextInput.default, {
1340
1349
  placeholder: "",
@@ -1349,7 +1358,13 @@ const InternalAppointmentForm = _ref => {
1349
1358
  placeholder: "",
1350
1359
  value: customer.zipCode,
1351
1360
  name: "zipCode",
1352
- onChange: handlePostalCodeChange,
1361
+ onChange: value => {
1362
+ updateCustomerField('zipCode', value);
1363
+ // Trigger address lookup if house number is also available
1364
+ if (customer.houseNumber) {
1365
+ handleAddressLookup(value, customer.houseNumber);
1366
+ }
1367
+ },
1353
1368
  key: "zipCode-".concat(refreshKey),
1354
1369
  isRequired: true,
1355
1370
  label: "Postcode:",
@@ -1401,7 +1416,7 @@ const InternalAppointmentForm = _ref => {
1401
1416
  options: countryOptions,
1402
1417
  name: "country",
1403
1418
  label: "Land:",
1404
- isRequired: true,
1419
+ isRequired: false,
1405
1420
  isLoading: isLoadingCountries,
1406
1421
  noOptionsMessage: "Geen landen beschikbaar",
1407
1422
  placeholder: "Selecteer een land",
@@ -1411,7 +1426,12 @@ const InternalAppointmentForm = _ref => {
1411
1426
  let {
1412
1427
  value
1413
1428
  } = _ref8;
1414
- return updateCustomerField('countryId', value);
1429
+ return dispatch({
1430
+ type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_COUNTRY_ID,
1431
+ payload: {
1432
+ countryId: value
1433
+ }
1434
+ });
1415
1435
  }
1416
1436
  })))))), /*#__PURE__*/_react.default.createElement("div", {
1417
1437
  className: (0, _helpers__.withStyle)('col-12 mb-4')
@@ -46,7 +46,6 @@ var _AuthSessionContext = require("../../__context__/AuthSessionContext");
46
46
  var _FormulaContext = require("../../__context__/FormulaContext");
47
47
  var _OrderSessionContext = require("../../__context__/OrderSessionContext");
48
48
  var _helpers__ = require("../../__helpers__");
49
- var _countryOptions = require("../../__helpers__/countryOptions");
50
49
  var _product = require("../../__helpers__/product");
51
50
  var _ui = require("../../__helpers__/ui");
52
51
  var _useIsTmg = require("../../__hooks__/useIsTmg");
@@ -434,7 +433,14 @@ const InternalQuotationForm = _ref => {
434
433
  return (option === null || option === void 0 || (_option$value = option.value) === null || _option$value === void 0 ? void 0 : _option$value.entityId) === (customer === null || customer === void 0 ? void 0 : customer.leasemaatschappijEntityId);
435
434
  }) || buildLeaseCompanyOption(customer);
436
435
  }, [customer, leaseCompanyOptions]);
437
- const countryOptions = (0, _react.useMemo)(() => (0, _countryOptions.buildCountryDropdownOptions)(countries === null || countries === void 0 ? void 0 : countries.results), [countries]);
436
+ const countryOptions = (0, _react.useMemo)(() => {
437
+ var _countries$results;
438
+ if (!(countries !== null && countries !== void 0 && (_countries$results = countries.results) !== null && _countries$results !== void 0 && _countries$results.length)) return [];
439
+ return countries.results.map(country => ({
440
+ label: country.title,
441
+ value: country.entityId
442
+ }));
443
+ }, [countries]);
438
444
  const initialCountry = (0, _react.useMemo)(() => {
439
445
  if (!(countryOptions !== null && countryOptions !== void 0 && countryOptions.length)) return null;
440
446
 
@@ -3,14 +3,12 @@
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");
7
6
  require("core-js/modules/es.regexp.to-string.js");
8
7
  require("core-js/modules/es.string.ends-with.js");
9
8
  require("core-js/modules/es.string.replace.js");
10
9
  require("core-js/modules/es.string.trim.js");
11
10
  require("core-js/modules/esnext.iterator.constructor.js");
12
11
  require("core-js/modules/esnext.iterator.filter.js");
13
- require("core-js/modules/esnext.iterator.find.js");
14
12
  require("core-js/modules/esnext.iterator.for-each.js");
15
13
  require("core-js/modules/esnext.iterator.map.js");
16
14
  require("core-js/modules/esnext.iterator.reduce.js");
@@ -34,26 +32,21 @@ var _exportNames = {
34
32
  truncateAtPipe: true,
35
33
  parseJson: true,
36
34
  isBelgianDomain: true,
37
- isDutchPostalCode: true,
38
- isBelgianPostalCode: true,
39
- getCountryOptionForPostalCode: true,
40
35
  removeNullishProps: true,
41
36
  createSlug: true,
42
37
  getProxyApiErrorMessage: true,
43
38
  formatMontageTime: true
44
39
  };
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;
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;
46
41
  require("core-js/modules/es.array.reduce.js");
47
42
  require("core-js/modules/es.object.from-entries.js");
48
43
  require("core-js/modules/es.regexp.exec.js");
49
- require("core-js/modules/es.regexp.test.js");
50
44
  require("core-js/modules/es.regexp.to-string.js");
51
45
  require("core-js/modules/es.string.ends-with.js");
52
46
  require("core-js/modules/es.string.replace.js");
53
47
  require("core-js/modules/es.string.trim.js");
54
48
  require("core-js/modules/esnext.iterator.constructor.js");
55
49
  require("core-js/modules/esnext.iterator.filter.js");
56
- require("core-js/modules/esnext.iterator.find.js");
57
50
  require("core-js/modules/esnext.iterator.map.js");
58
51
  require("core-js/modules/esnext.iterator.reduce.js");
59
52
  require("core-js/modules/web.dom-collections.iterator.js");
@@ -299,33 +292,11 @@ const isBelgianDomain = () => {
299
292
  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();
300
293
  return Boolean(hostname && (hostname === 'be' || hostname.endsWith('.be')));
301
294
  };
302
- exports.isBelgianDomain = isBelgianDomain;
303
- const isDutchPostalCode = postalCode => {
304
- if (!postalCode) return false;
305
- const cleanedPostalCode = postalCode.replace(/\s/g, '');
306
- return /^[1-9][0-9]{3}[A-Z]{2}$/i.test(cleanedPostalCode);
307
- };
308
- exports.isDutchPostalCode = isDutchPostalCode;
309
- const isBelgianPostalCode = postalCode => {
310
- if (!postalCode) return false;
311
- const cleanedPostalCode = postalCode.replace(/\s/g, '');
312
- return /^[1-9][0-9]{3}$/.test(cleanedPostalCode);
313
- };
314
- exports.isBelgianPostalCode = isBelgianPostalCode;
315
- const normalizeCountryLabel = function normalizeCountryLabel() {
316
- let label = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
317
- return label.normalize('NFD').replace(/[\u0300-\u036f]/g, '').toUpperCase();
318
- };
319
- const getCountryOptionForPostalCode = exports.getCountryOptionForPostalCode = function getCountryOptionForPostalCode(postalCode) {
320
- let countryOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
321
- const countryName = isDutchPostalCode(postalCode) ? 'NEDERLAND' : isBelgianPostalCode(postalCode) ? 'BELGIE' : null;
322
- if (!countryName) return null;
323
- return countryOptions.find(option => normalizeCountryLabel(option === null || option === void 0 ? void 0 : option.label) === countryName) || null;
324
- };
325
295
 
326
296
  /**
327
297
  * @description Removes nullish properties from a passed object
328
298
  */
299
+ exports.isBelgianDomain = isBelgianDomain;
329
300
  const removeNullishProps = exports.removeNullishProps = function removeNullishProps() {
330
301
  let object = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
331
302
  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.404",
3
+ "version": "0.0.405",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "author": "EnoRm.",
@@ -1,42 +0,0 @@
1
- "use strict";
2
-
3
- require("core-js/modules/es.array.sort.js");
4
- require("core-js/modules/es.string.trim.js");
5
- require("core-js/modules/esnext.iterator.constructor.js");
6
- require("core-js/modules/esnext.iterator.filter.js");
7
- require("core-js/modules/esnext.iterator.map.js");
8
- Object.defineProperty(exports, "__esModule", {
9
- value: true
10
- });
11
- exports.buildCountryDropdownOptions = void 0;
12
- require("core-js/modules/es.array.sort.js");
13
- require("core-js/modules/es.string.trim.js");
14
- require("core-js/modules/esnext.iterator.constructor.js");
15
- require("core-js/modules/esnext.iterator.filter.js");
16
- require("core-js/modules/esnext.iterator.map.js");
17
- var _constants__ = require("../__constants__");
18
- const PRIORITY_COUNTRY_LABELS = [_constants__.COUNTRY_NAMES.NETHERLANDS, _constants__.COUNTRY_NAMES.BELGIUM, _constants__.COUNTRY_NAMES.BELGIUM_FALLBACK];
19
- const normalizeCountryLabel = label => (label || '').trim().toUpperCase();
20
- const getCountrySortPriority = label => {
21
- const normalized = normalizeCountryLabel(label);
22
- const index = PRIORITY_COUNTRY_LABELS.findIndex(priorityLabel => normalizeCountryLabel(priorityLabel) === normalized);
23
- return index === -1 ? PRIORITY_COUNTRY_LABELS.length : index;
24
- };
25
-
26
- /**
27
- * @description Maps Hyper countries to dropdown options: Nederland and België first, then A–Z.
28
- */
29
- const buildCountryDropdownOptions = exports.buildCountryDropdownOptions = function buildCountryDropdownOptions() {
30
- let countries = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
31
- if (!(countries !== null && countries !== void 0 && countries.length)) return [];
32
- return countries.filter(country => country.title && country.entityId).map(country => ({
33
- label: country.title,
34
- value: country.entityId
35
- })).sort((a, b) => {
36
- const priorityDiff = getCountrySortPriority(a.label) - getCountrySortPriority(b.label);
37
- if (priorityDiff !== 0) return priorityDiff;
38
- return (a.label || '').localeCompare(b.label || '', 'nl', {
39
- sensitivity: 'base'
40
- });
41
- });
42
- };