thm-p3-configurator 0.0.366 → 0.0.368

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.
@@ -106,7 +106,7 @@ const App = () => {
106
106
  (0, _Experiments.default)();
107
107
  });
108
108
  return /*#__PURE__*/_react.default.createElement(_SentryWrapper.default, null, /*#__PURE__*/_react.default.createElement(_FormulaContext.FormulaController, {
109
- defaultFormula: _constants__.CONFIGURATOR_FORMULAS.THM
109
+ defaultFormula: APP_CONFIG.internal ? null : _constants__.CONFIGURATOR_FORMULAS.THM
110
110
  }, /*#__PURE__*/_react.default.createElement(_CountryContext.CountryController, {
111
111
  defaultCountry: APP_CONFIG.country
112
112
  }, /*#__PURE__*/_react.default.createElement(_OrderSessionContext.OrderSessionController, null, /*#__PURE__*/_react.default.createElement(_reactQuery.QueryClientProvider, {
@@ -81,6 +81,7 @@ describe('queryKeyFactory', () => {
81
81
  });
82
82
  it('includes formula in brands and build-years keys', () => {
83
83
  expect((0, _queryKeyFactory.getBrandsQueryKey)('TMG')).toEqual(['brands', 'TMG']);
84
+ expect((0, _queryKeyFactory.getBrandsQueryKey)('THCB')).toEqual(['brands', 'THCB']);
84
85
  expect((0, _queryKeyFactory.getBuildYearsQueryKey)({
85
86
  brand: 'Volvo',
86
87
  formula: 'TMG'
@@ -16,19 +16,13 @@ const publicOrderClient = _axios.default.create({
16
16
  });
17
17
  const orderApi = exports.orderApi = {
18
18
  getArticles: filters => publicOrderClient("api/public/articles?".concat(filters)),
19
- getBrands: function getBrands() {
20
- let formula = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'THC';
21
- return publicOrderClient("api/public/v1/configurator/makes?formula=".concat(formula));
22
- },
23
- getBuildYears: function getBuildYears(brand) {
24
- let formula = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'THC';
25
- return publicOrderClient("api/public/v1/configurator/makes/".concat(brand, "/years?formula=").concat(formula));
26
- },
19
+ getBrands: formula => publicOrderClient("api/public/v1/configurator/makes?formula=".concat(formula)),
20
+ getBuildYears: (brand, formula) => publicOrderClient("api/public/v1/configurator/makes/".concat(brand, "/years?formula=").concat(formula)),
27
21
  getModels: _ref => {
28
22
  let {
29
23
  brand,
30
24
  year,
31
- formula = 'THC'
25
+ formula
32
26
  } = _ref;
33
27
  return publicOrderClient("api/public/v1/configurator/makes/".concat(brand, "/models").concat(year ? "?year=".concat(year, "&formula=").concat(formula) : "?formula=".concat(formula)));
34
28
  }
@@ -90,8 +90,9 @@ function _toPrimitive(t, r) {
90
90
  * @description Retrieves the car brand options
91
91
  */
92
92
  const useBrandsQuery = exports.useBrandsQuery = function useBrandsQuery() {
93
- let formula = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'THC';
93
+ let formula = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
94
94
  const brandsQuery = (0, _reactQuery.useQuery)((0, _queryKeyFactory.getBrandsQueryKey)(formula), {
95
+ enabled: Boolean(formula),
95
96
  queryFn: () => _orderApi.orderApi.getBrands(formula).then(res => {
96
97
  var _res$data;
97
98
  return (0, _helpers__.parseArrayToInputOptions)((_res$data = res === null || res === void 0 ? void 0 : res.data) !== null && _res$data !== void 0 ? _res$data : []);
@@ -110,13 +111,13 @@ const useBrandsQuery = exports.useBrandsQuery = function useBrandsQuery() {
110
111
  const useBuildYearsQuery = _ref => {
111
112
  let {
112
113
  brand,
113
- formula = 'THC'
114
+ formula = null
114
115
  } = _ref;
115
116
  const buildYearsQuery = (0, _reactQuery.useQuery)((0, _queryKeyFactory.getBuildYearsQueryKey)({
116
117
  brand,
117
118
  formula
118
119
  }), {
119
- enabled: !!(brand !== null && brand !== void 0 && brand.length),
120
+ enabled: !!(brand !== null && brand !== void 0 && brand.length) && Boolean(formula),
120
121
  queryFn: () => _orderApi.orderApi.getBuildYears(brand, formula).then(res => {
121
122
  var _res$data2;
122
123
  return (0, _helpers__.parseArrayToInputOptions)((_res$data2 = res === null || res === void 0 ? void 0 : res.data) !== null && _res$data2 !== void 0 ? _res$data2 : []);
@@ -219,14 +220,14 @@ const useModelsQuery = _ref2 => {
219
220
  let {
220
221
  brand,
221
222
  year,
222
- formula = 'THC'
223
+ formula = null
223
224
  } = _ref2;
224
225
  const modelsQuery = (0, _reactQuery.useQuery)(['models', JSON.stringify({
225
226
  brand,
226
227
  year,
227
228
  formula
228
229
  })], {
229
- enabled: !!(brand !== null && brand !== void 0 && brand.length),
230
+ enabled: !!(brand !== null && brand !== void 0 && brand.length) && Boolean(formula),
230
231
  queryFn: () => {
231
232
  return _orderApi.orderApi.getModels({
232
233
  brand,
@@ -721,12 +722,13 @@ const useBranchesByType = _ref4 => {
721
722
  };
722
723
  exports.useBranchesByType = useBranchesByType;
723
724
  const useBusinessBranches = _ref5 => {
725
+ var _getConfiguratorFormu;
724
726
  let {
725
727
  searchTerm,
726
728
  formula: formulaRaw,
727
729
  enabled = true
728
730
  } = _ref5;
729
- const formula = formulaRaw == null ? undefined : typeof formulaRaw === 'string' ? formulaRaw : formulaRaw === null || formulaRaw === void 0 ? void 0 : formulaRaw.entityId;
731
+ const formula = (_getConfiguratorFormu = (0, _constants__.getConfiguratorFormulaCode)(formulaRaw)) !== null && _getConfiguratorFormu !== void 0 ? _getConfiguratorFormu : typeof formulaRaw === 'string' ? formulaRaw : formulaRaw === null || formulaRaw === void 0 ? void 0 : formulaRaw.entityId;
730
732
  const businessBranchesQuery = (0, _reactQuery.useQuery)(['businessBranches', searchTerm, formula], {
731
733
  queryFn: async () => {
732
734
  const response = await _authenticatedProxyApi.authenticatedProxyApi.getBusinessBranches({
@@ -125,13 +125,13 @@ const getOrderQueryKey = exports.getOrderQueryKey = function getOrderQueryKey()
125
125
  return ['order', serializeOrderParams(orderParameters)];
126
126
  };
127
127
  const getBrandsQueryKey = exports.getBrandsQueryKey = function getBrandsQueryKey() {
128
- let formula = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'THC';
128
+ let formula = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
129
129
  return ['brands', formula];
130
130
  };
131
131
  const getBuildYearsQueryKey = exports.getBuildYearsQueryKey = function getBuildYearsQueryKey() {
132
132
  let {
133
133
  brand,
134
- formula = 'THC'
134
+ formula = null
135
135
  } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
136
136
  return ['buildYears', brand, formula];
137
137
  };
@@ -124,7 +124,7 @@ function _toPrimitive(t, r) {
124
124
  return ("string" === r ? String : Number)(t);
125
125
  }
126
126
  const LocationClusteredTreeMarkers = _ref => {
127
- var _selectedTree$afbeeld;
127
+ var _ref2, _selectedTree$formula, _selectedTree$formule, _selectedTree$afbeeld;
128
128
  let {
129
129
  locationIds,
130
130
  locationsById
@@ -232,7 +232,7 @@ const LocationClusteredTreeMarkers = _ref => {
232
232
  anchor: markers[activeMarkerId],
233
233
  onCloseClick: handleInfoWindowClose
234
234
  }, /*#__PURE__*/_react.default.createElement(_LocationInfo.default, {
235
- formula: selectedTree === null || selectedTree === void 0 ? void 0 : selectedTree.formule,
235
+ formula: (_ref2 = (_selectedTree$formula = selectedTree === null || selectedTree === void 0 ? void 0 : selectedTree.formulaCode) !== null && _selectedTree$formula !== void 0 ? _selectedTree$formula : selectedTree === null || selectedTree === void 0 || (_selectedTree$formule = selectedTree.formule) === null || _selectedTree$formule === void 0 ? void 0 : _selectedTree$formule.code) !== null && _ref2 !== void 0 ? _ref2 : selectedTree === null || selectedTree === void 0 ? void 0 : selectedTree.formule,
236
236
  openingHours: selectedTree === null || selectedTree === void 0 ? void 0 : selectedTree.openingstijden,
237
237
  locationImage: selectedTree === null || selectedTree === void 0 || (_selectedTree$afbeeld = selectedTree.afbeeldingLogo) === null || _selectedTree$afbeeld === void 0 ? void 0 : _selectedTree$afbeeld[0],
238
238
  street: selectedTree === null || selectedTree === void 0 ? void 0 : selectedTree.street,
@@ -24,6 +24,7 @@ const FORMULAS = {
24
24
  nFbSnWdtLZBmEhhpHFGVO: _logoThcWhite.default
25
25
  };
26
26
  const LocationInfo = _ref => {
27
+ var _FORMULAS$formula;
27
28
  let {
28
29
  street,
29
30
  houseNumber,
@@ -39,7 +40,7 @@ const LocationInfo = _ref => {
39
40
  province,
40
41
  formula
41
42
  } = _ref;
42
- const address = [street, postCode, city].join(', ');
43
+ const fallbackLogo = (0, _constants__.getThemeFormulaForConfiguratorFormula)(formula) === _constants__.CONFIGURATOR_FORMULAS.THC ? _logoThcWhite.default : (_FORMULAS$formula = FORMULAS[formula]) !== null && _FORMULAS$formula !== void 0 ? _FORMULAS$formula : _thLogoBlack.default;
43
44
 
44
45
  // Function to format opening hours display text
45
46
  const formatOpeningHours = dayData => {
@@ -132,7 +133,7 @@ const LocationInfo = _ref => {
132
133
  className: (0, _helpers__.withStyle)('mb-1'),
133
134
  src: locationImage !== null && locationImage !== void 0 && locationImage.length ? (0, _image.getImageFromHyper)({
134
135
  imageId: locationImage
135
- }) : FORMULAS[formula],
136
+ }) : fallbackLogo,
136
137
  alt: title
137
138
  }))));
138
139
  };
@@ -56,16 +56,17 @@ const LocationTreeMarker = /*#__PURE__*/_react.default.memo(_ref => {
56
56
  const formula = (0, _FormulaContext.useFormula)();
57
57
  // Cache marker icon configuration
58
58
  const markerIcon = (0, _react.useMemo)(() => {
59
+ const markerIconUrl = (0, _constants__.isThcFamilyFormula)(formula) ? _mapMarkerThc.default : _mapMarker.default;
59
60
  if (!core) return {
60
- url: formula == _constants__.CONFIGURATOR_FORMULAS.THC ? _mapMarkerThc.default : _mapMarker.default
61
+ url: markerIconUrl
61
62
  };
62
63
  return {
63
- url: formula == _constants__.CONFIGURATOR_FORMULAS.THC ? _mapMarkerThc.default : _mapMarker.default,
64
+ url: markerIconUrl,
64
65
  size: new core.Size(32, 42),
65
66
  anchor: new core.Point(16, 32),
66
67
  scaledSize: new core.Size(32, 42)
67
68
  };
68
- }, [core]);
69
+ }, [core, formula]);
69
70
  const handleClick = (0, _react.useCallback)(() => onClick(tree), [onClick, tree]);
70
71
  const ref = (0, _react.useCallback)(marker => setMarkerRef(marker, tree === null || tree === void 0 ? void 0 : tree.entityId), [setMarkerRef, tree === null || tree === void 0 ? void 0 : tree.entityId]);
71
72
 
@@ -1,9 +1,15 @@
1
1
  "use strict";
2
2
 
3
3
  require("core-js/modules/es.weak-map.js");
4
+ require("core-js/modules/esnext.iterator.constructor.js");
5
+ require("core-js/modules/esnext.iterator.filter.js");
6
+ require("core-js/modules/esnext.iterator.for-each.js");
4
7
  require("core-js/modules/esnext.iterator.map.js");
5
8
  require("core-js/modules/web.dom-collections.iterator.js");
6
9
  require("core-js/modules/es.weak-map.js");
10
+ require("core-js/modules/esnext.iterator.constructor.js");
11
+ require("core-js/modules/esnext.iterator.filter.js");
12
+ require("core-js/modules/esnext.iterator.for-each.js");
7
13
  Object.defineProperty(exports, "__esModule", {
8
14
  value: true
9
15
  });
@@ -14,6 +20,7 @@ var _react = _interopRequireWildcard(require("react"));
14
20
  var _queries = require("../../__api__/queries");
15
21
  var _constants__ = require("../../__constants__");
16
22
  var _helpers__ = require("../../__helpers__");
23
+ var _singleOrderArticles = require("../../__helpers__/singleOrderArticles");
17
24
  var _ProductCardCheckbox = _interopRequireDefault(require("./ProductCardCheckbox"));
18
25
  var _ProductCardDescription = _interopRequireDefault(require("./ProductCardDescription"));
19
26
  var _ProductCardDiscountAlert = _interopRequireDefault(require("./ProductCardDiscountAlert"));
@@ -52,8 +59,51 @@ function _interopRequireWildcard(e, r) {
52
59
  }
53
60
  return n.default = e, t && t.set(e, n), n;
54
61
  }
62
+ function ownKeys(e, r) {
63
+ var t = Object.keys(e);
64
+ if (Object.getOwnPropertySymbols) {
65
+ var o = Object.getOwnPropertySymbols(e);
66
+ r && (o = o.filter(function (r) {
67
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
68
+ })), t.push.apply(t, o);
69
+ }
70
+ return t;
71
+ }
72
+ function _objectSpread(e) {
73
+ for (var r = 1; r < arguments.length; r++) {
74
+ var t = null != arguments[r] ? arguments[r] : {};
75
+ r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
76
+ _defineProperty(e, r, t[r]);
77
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
78
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
79
+ });
80
+ }
81
+ return e;
82
+ }
83
+ function _defineProperty(e, r, t) {
84
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
85
+ value: t,
86
+ enumerable: !0,
87
+ configurable: !0,
88
+ writable: !0
89
+ }) : e[r] = t, e;
90
+ }
91
+ function _toPropertyKey(t) {
92
+ var i = _toPrimitive(t, "string");
93
+ return "symbol" == typeof i ? i : i + "";
94
+ }
95
+ function _toPrimitive(t, r) {
96
+ if ("object" != typeof t || !t) return t;
97
+ var e = t[Symbol.toPrimitive];
98
+ if (void 0 !== e) {
99
+ var i = e.call(t, r || "default");
100
+ if ("object" != typeof i) return i;
101
+ throw new TypeError("@@toPrimitive must return a primitive value.");
102
+ }
103
+ return ("string" === r ? String : Number)(t);
104
+ }
55
105
  const ProductCard = _ref => {
56
- var _stock$quantity, _stock$quantity2;
106
+ var _normalizedStock$quan, _normalizedStock$quan2;
57
107
  let {
58
108
  hasCheckbox = true,
59
109
  isRecommended = false,
@@ -82,6 +132,9 @@ const ProductCard = _ref => {
82
132
  const {
83
133
  productFieldLabels
84
134
  } = (0, _queries.useProductFieldLabels)();
135
+ const normalizedStock = stock && stock.status ? _objectSpread(_objectSpread({}, stock), {}, {
136
+ status: (0, _singleOrderArticles.mapApiStockStatusToStockStatus)(stock.status)
137
+ }) : stock;
85
138
  const handleSelected = isSelected => {
86
139
  if (!canUnselect && !isSelected) {
87
140
  // Do not update local state, only call onSelect
@@ -159,13 +212,13 @@ const ProductCard = _ref => {
159
212
  className: (0, _helpers__.withStyle)('card-footer pt-2 col-12 col-md-8 col-xxl-6 pb-0 justify-content-end')
160
213
  }, /*#__PURE__*/_react.default.createElement("div", {
161
214
  className: (0, _helpers__.withStyle)('d-flex flex-column align-items-end')
162
- }, showPrice && stock && /*#__PURE__*/_react.default.createElement("div", null, (stock === null || stock === void 0 ? void 0 : stock.status) === _constants__.StockStatus.OutOfStock ? /*#__PURE__*/_react.default.createElement("div", {
215
+ }, showPrice && normalizedStock && /*#__PURE__*/_react.default.createElement("div", null, normalizedStock.status === _constants__.StockStatus.OutOfStock ? /*#__PURE__*/_react.default.createElement("div", {
163
216
  className: (0, _helpers__.withStyle)('text-danger mb-1')
164
- }, "Niet op voorraad") : stock === _constants__.StockStatus.InsufficientStock ? /*#__PURE__*/_react.default.createElement("div", {
217
+ }, "Niet op voorraad") : normalizedStock.status === _constants__.StockStatus.InsufficientStock ? /*#__PURE__*/_react.default.createElement("div", {
165
218
  className: (0, _helpers__.withStyle)('text-warning mb-1')
166
- }, isTmg ? "".concat((_stock$quantity = stock === null || stock === void 0 ? void 0 : stock.quantity) !== null && _stock$quantity !== void 0 ? _stock$quantity : 0, " op voorraad") : 'Weinig op voorraad') : /*#__PURE__*/_react.default.createElement("div", {
219
+ }, isTmg ? "".concat((_normalizedStock$quan = normalizedStock.quantity) !== null && _normalizedStock$quan !== void 0 ? _normalizedStock$quan : 0, " op voorraad") : 'Weinig op voorraad') : /*#__PURE__*/_react.default.createElement("div", {
167
220
  className: (0, _helpers__.withStyle)('text-success mb-1')
168
- }, isTmg ? "".concat((_stock$quantity2 = stock === null || stock === void 0 ? void 0 : stock.quantity) !== null && _stock$quantity2 !== void 0 ? _stock$quantity2 : 0, " op voorraad") : 'Op voorraad')), hasCheckbox && /*#__PURE__*/_react.default.createElement(_ProductCardCheckbox.default, {
221
+ }, isTmg ? "".concat((_normalizedStock$quan2 = normalizedStock.quantity) !== null && _normalizedStock$quan2 !== void 0 ? _normalizedStock$quan2 : 0, " op voorraad") : 'Op voorraad')), hasCheckbox && /*#__PURE__*/_react.default.createElement(_ProductCardCheckbox.default, {
169
222
  id: productId,
170
223
  isDisabled: isDisabled,
171
224
  defaultChecked: isSelected,
@@ -2,6 +2,7 @@
2
2
 
3
3
  require("core-js/modules/es.array.reduce.js");
4
4
  require("core-js/modules/es.promise.js");
5
+ require("core-js/modules/es.string.trim.js");
5
6
  require("core-js/modules/es.weak-map.js");
6
7
  require("core-js/modules/esnext.iterator.constructor.js");
7
8
  require("core-js/modules/esnext.iterator.filter.js");
@@ -18,6 +19,7 @@ Object.defineProperty(exports, "__esModule", {
18
19
  exports.default = void 0;
19
20
  require("core-js/modules/es.array.reduce.js");
20
21
  require("core-js/modules/es.promise.js");
22
+ require("core-js/modules/es.string.trim.js");
21
23
  require("core-js/modules/esnext.iterator.constructor.js");
22
24
  require("core-js/modules/esnext.iterator.find.js");
23
25
  require("core-js/modules/esnext.iterator.for-each.js");
@@ -159,7 +161,7 @@ const customerDetailsFormSchema = (0, _yup.object)({
159
161
  })
160
162
  });
161
163
  const InternalCustomerDetailsForm = (_ref, ref) => {
162
- var _branchTypes$byId$aut, _authSession$branch;
164
+ var _customer$vatNumber, _customer$kvkNumber, _branchTypes$byId$aut, _authSession$branch;
163
165
  let {
164
166
  errors = {},
165
167
  onValidationError,
@@ -249,6 +251,21 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
249
251
 
250
252
  // Get customer data for the active ownership type
251
253
  const customer = customerDataPerType[activeOwnershipType] || (0, _helpers__.getEmptySingleOrderCustomer)();
254
+ const selectedCountry = (0, _react.useMemo)(() => {
255
+ if (!(countryOptions !== null && countryOptions !== void 0 && countryOptions.length)) return null;
256
+ if (customer !== null && customer !== void 0 && customer.countryId) {
257
+ return countryOptions.find(option => option.value === customer.countryId) || null;
258
+ }
259
+ const defaultCountry = countryOptions.find(option => option.label === 'NEDERLAND');
260
+ return defaultCountry || null;
261
+ }, [customer === null || customer === void 0 ? void 0 : customer.countryId, countryOptions]);
262
+ const isBusinessOwnership = activeOwnershipType === _constants__.VEHICLE_SINGLE_ORDER_OWNERSHIP_TYPE.Zakelijk;
263
+ const isNetherlandsSelected = (0, _react.useMemo)(() => {
264
+ if (!(selectedCountry !== null && selectedCountry !== void 0 && selectedCountry.label)) return false;
265
+ return selectedCountry.label.toUpperCase() === 'NEDERLAND';
266
+ }, [selectedCountry === null || selectedCountry === void 0 ? void 0 : selectedCountry.label]);
267
+ const shouldRequireKvkNumber = isBusinessOwnership && (isNetherlandsSelected || !(customer !== null && customer !== void 0 && (_customer$vatNumber = customer.vatNumber) !== null && _customer$vatNumber !== void 0 && _customer$vatNumber.trim()));
268
+ const shouldRequireVatNumber = isBusinessOwnership && !isNetherlandsSelected && !(customer !== null && customer !== void 0 && (_customer$kvkNumber = customer.kvkNumber) !== null && _customer$kvkNumber !== void 0 && _customer$kvkNumber.trim());
252
269
 
253
270
  // Helper to update customer data for the active ownership type
254
271
  const updateCustomerField = (0, _react.useCallback)((field, value) => {
@@ -491,6 +508,24 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
491
508
  }, [addressLookupTimeoutId]);
492
509
  const validateForm = async () => {
493
510
  try {
511
+ var _customer$kvkNumber2, _customer$vatNumber2;
512
+ const hasKvkNumber = !!(customer !== null && customer !== void 0 && (_customer$kvkNumber2 = customer.kvkNumber) !== null && _customer$kvkNumber2 !== void 0 && _customer$kvkNumber2.trim());
513
+ const hasVatNumber = !!(customer !== null && customer !== void 0 && (_customer$vatNumber2 = customer.vatNumber) !== null && _customer$vatNumber2 !== void 0 && _customer$vatNumber2.trim());
514
+ if (isBusinessOwnership) {
515
+ if (isNetherlandsSelected && !hasKvkNumber) {
516
+ onValidationError === null || onValidationError === void 0 || onValidationError({
517
+ kvkNumber: 'KVK-nummer is verplicht voor zakelijke dossiers in Nederland'
518
+ });
519
+ return false;
520
+ }
521
+ if (!isNetherlandsSelected && !hasKvkNumber && !hasVatNumber) {
522
+ onValidationError === null || onValidationError === void 0 || onValidationError({
523
+ kvkNumber: 'Vul een KVK- of BTW-nummer in',
524
+ vatNumber: 'Vul een KVK- of BTW-nummer in'
525
+ });
526
+ return false;
527
+ }
528
+ }
494
529
  let validationSchema = webshop || !isTmg ? customerDetailsFormSchema.omit(['channelType', 'channelId']) : customerDetailsFormSchema;
495
530
  const requiredFields = (0, _helpers__.getSingleOrderRequiredFields)({
496
531
  webshop,
@@ -779,19 +814,21 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
779
814
  }
780
815
  }, branch.name)))), /*#__PURE__*/_react.default.createElement(_TextInput.default, {
781
816
  placeholder: "",
782
- initialValue: customer.kvkNumber,
817
+ value: customer.kvkNumber,
783
818
  name: "kvkNumber",
784
819
  onChange: value => updateCustomerField('kvkNumber', value),
785
- isRequired: false,
820
+ key: "kvkNumber-".concat(refreshKey),
821
+ isRequired: shouldRequireKvkNumber,
786
822
  form: form,
787
823
  label: "KVK-nummer:",
788
824
  errorMessage: errors === null || errors === void 0 ? void 0 : errors['kvkNumber']
789
825
  }), /*#__PURE__*/_react.default.createElement(_TextInput.default, {
790
826
  placeholder: "",
791
- initialValue: customer.vatNumber,
827
+ value: customer.vatNumber,
792
828
  name: "vatNumber",
793
829
  onChange: value => updateCustomerField('vatNumber', value),
794
- isRequired: false,
830
+ key: "vatNumber-".concat(refreshKey),
831
+ isRequired: shouldRequireVatNumber,
795
832
  form: form,
796
833
  label: "BTW-nummer:",
797
834
  errorMessage: errors === null || errors === void 0 ? void 0 : errors['vatNumber']
@@ -829,7 +866,7 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
829
866
  label: "Contact e-mailadres:"
830
867
  })) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("br", null)), /*#__PURE__*/_react.default.createElement(_TextInput.default, {
831
868
  placeholder: "",
832
- initialValue: customer.zipCode,
869
+ value: customer.zipCode,
833
870
  name: "zipCode",
834
871
  onChange: value => {
835
872
  updateCustomerField('zipCode', value);
@@ -839,12 +876,13 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
839
876
  }
840
877
  },
841
878
  isRequired: webshop || anderAfleveradres,
879
+ key: "zipCode-".concat(refreshKey),
842
880
  form: form,
843
881
  label: "Postcode:",
844
882
  errorMessage: errors === null || errors === void 0 ? void 0 : errors['zipCode']
845
883
  }), /*#__PURE__*/_react.default.createElement(_TextInput.default, {
846
884
  placeholder: "",
847
- initialValue: customer.houseNumber,
885
+ value: customer.houseNumber,
848
886
  name: "houseNumber",
849
887
  onChange: value => {
850
888
  updateCustomerField('houseNumber', value);
@@ -854,33 +892,37 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
854
892
  }
855
893
  },
856
894
  isRequired: webshop || anderAfleveradres,
895
+ key: "houseNumber-".concat(refreshKey),
857
896
  form: form,
858
897
  label: "Huisnummer:",
859
898
  errorMessage: errors === null || errors === void 0 ? void 0 : errors['houseNumber']
860
899
  }), /*#__PURE__*/_react.default.createElement(_TextInput.default, {
861
900
  placeholder: "",
862
- initialValue: customer.houseNumberAddition,
901
+ value: customer.houseNumberAddition,
863
902
  name: "houseNumberAddition",
864
903
  onChange: value => updateCustomerField('houseNumberAddition', value),
865
904
  isRequired: false,
905
+ key: "houseNumberAddition-".concat(refreshKey),
866
906
  form: form,
867
907
  label: "Huisnummer toevoeging:",
868
908
  errorMessage: errors === null || errors === void 0 ? void 0 : errors['houseNumberAddition']
869
909
  }), /*#__PURE__*/_react.default.createElement(_TextInput.default, {
870
910
  placeholder: addressLookupLoading ? 'Adres wordt opgezocht...' : '',
871
- initialValue: customer.streetName,
911
+ value: customer.streetName,
872
912
  name: "streetName",
873
913
  onChange: value => updateCustomerField('streetName', value),
874
914
  isRequired: webshop || anderAfleveradres,
915
+ key: "streetName-".concat(refreshKey),
875
916
  form: form,
876
917
  label: "Straat:".concat(addressLookupLoading ? ' (wordt opgezocht...)' : ''),
877
918
  errorMessage: errors === null || errors === void 0 ? void 0 : errors['streetName']
878
919
  }), /*#__PURE__*/_react.default.createElement(_TextInput.default, {
879
920
  placeholder: addressLookupLoading ? 'Stad wordt opgezocht...' : '',
880
- initialValue: customer.city,
921
+ value: customer.city,
881
922
  name: "city",
882
923
  onChange: value => updateCustomerField('city', value),
883
924
  isRequired: webshop || anderAfleveradres,
925
+ key: "city-".concat(refreshKey),
884
926
  form: form,
885
927
  label: "Stad:".concat(addressLookupLoading ? ' (wordt opgezocht...)' : ''),
886
928
  errorMessage: errors === null || errors === void 0 ? void 0 : errors['city']
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ var _index = require("../index");
4
+ describe('__constants__/formula helpers', () => {
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
+ });
9
+ it('normalizes known formula titles and codes without collapsing unknown codes', () => {
10
+ expect((0, _index.getConfiguratorFormulaCode)('Trekhaakcentrum')).toBe(_index.CONFIGURATOR_FORMULAS.THC);
11
+ expect((0, _index.getConfiguratorFormulaCode)('TowMotive')).toBe(_index.CONFIGURATOR_FORMULAS.TOW);
12
+ expect((0, _index.getConfiguratorFormulaCode)('thcb')).toBe(_index.CONFIGURATOR_FORMULAS.THCB);
13
+ expect((0, _index.getConfiguratorFormulaCode)('abc')).toBe('ABC');
14
+ });
15
+ it('treats THCB as THC-family for theme decisions only', () => {
16
+ expect((0, _index.isThcFamilyFormula)(_index.CONFIGURATOR_FORMULAS.THC)).toBe(true);
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
+ });
20
+ });
@@ -1,9 +1,15 @@
1
1
  "use strict";
2
2
 
3
+ require("core-js/modules/es.array.includes.js");
4
+ require("core-js/modules/es.string.includes.js");
5
+ require("core-js/modules/es.string.trim.js");
3
6
  Object.defineProperty(exports, "__esModule", {
4
7
  value: true
5
8
  });
6
- exports.mapBranchFormulaToConfiguratorFormula = exports.VESTIGING_TYPE_ID = exports.VEHICLE_SINGLE_ORDER_OWNERSHIP_TYPE = exports.VEHICLE_OWNERSHIP_TYPE = exports.VEHICLE_CODING_SUBGROUP_NAME = exports.USER_GEOLOCATION_KEY = exports.TOWMOTIVE_ORGANIZATION_TYPE = exports.TMG_ORGANIZATION_TYPE = exports.StockStatus = exports.STATUS_ASSESSMENT = exports.PRODUCT_CATEGORIES = exports.PRIVATE_SINGLE_ORDER_SESSION_KEY = exports.PARTNER_PORTAL_PAGE_TITLES_BY_THEME = exports.PARTNER_PORTAL_CHANNEL_TITLE = exports.ORDER_SESSION_KEY = exports.NO_PRODUCTS_CONTACT_DETAILS_BY_FORMULA = exports.NAVIGATION_STEPS_INTERNAL = exports.NAVIGATION_STEPS_EXTERNAL = exports.NAVIGATION_BUTTONS = exports.MOUSE_EXIT_INTENT_THROTTLE = exports.MOUSE_EXIT_INTENT_OFFSET = exports.LOCATION_TYPE = exports.LOCATION_CHANGE_BUTTON_LABEL = exports.LOCALE = exports.LEASE_TYPE_ID = exports.FORM_ERROR_MESSAGES = exports.EXECUTION_HELP_CONTACT_DETAILS_BY_FORMULA = exports.DOSSIER_TYPES = exports.DISCOUNT_TYPES = exports.DEFAULT_MAP_LONGITUDE = exports.DEFAULT_MAP_LATITUDE = exports.DEFAULT_ARTICLE_BRAND = exports.DAY_NAMES = exports.CONFIGURATOR_FORMULAS = exports.BRANCH_THEME_BY_FORMULA = exports.BRANCH_FORMULAS = exports.BOARD_COMPUTER_DISABLED_KEY = exports.ApiStockStatus = exports.AUTH_SESSION_KEY = exports.ARTICLE_SPECS_TRANSLATIONS = exports.ARTICLES_SYSTEM_FIELDS = exports.API_ERROR_CODES = exports.ALL_EXPERIMENTS = exports.ACTIVE_VARIANTS = void 0;
9
+ exports.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
+ require("core-js/modules/es.array.includes.js");
11
+ require("core-js/modules/es.string.includes.js");
12
+ require("core-js/modules/es.string.trim.js");
7
13
  const DOSSIER_TYPES = exports.DOSSIER_TYPES = {
8
14
  Quotation: 'quotation',
9
15
  AppointmentRequest: 'appointment-request',
@@ -222,12 +228,69 @@ const ApiStockStatus = exports.ApiStockStatus = {
222
228
  const CONFIGURATOR_FORMULAS = exports.CONFIGURATOR_FORMULAS = {
223
229
  THM: 'THM',
224
230
  THC: 'THC',
231
+ THCB: 'THCB',
225
232
  TMG: 'TMG',
226
233
  TOW: 'TOW',
227
234
  TM: 'TOW',
228
235
  TH: 'TH',
229
236
  TowMotive: 'TowMotive'
230
237
  };
238
+ const normalizeFormulaInput = formula => {
239
+ if (formula == null) {
240
+ return null;
241
+ }
242
+ if (typeof formula === 'object') {
243
+ var _ref, _ref2, _ref3, _formula$code;
244
+ return normalizeFormulaInput((_ref = (_ref2 = (_ref3 = (_formula$code = formula === null || formula === void 0 ? void 0 : formula.code) !== null && _formula$code !== void 0 ? _formula$code : formula === null || formula === void 0 ? void 0 : formula.title) !== null && _ref3 !== void 0 ? _ref3 : formula === null || formula === void 0 ? void 0 : formula.formulaCode) !== null && _ref2 !== void 0 ? _ref2 : formula === null || formula === void 0 ? void 0 : formula.formule) !== null && _ref !== void 0 ? _ref : null);
245
+ }
246
+ if (typeof formula !== 'string') {
247
+ return null;
248
+ }
249
+ const normalizedFormula = formula.trim();
250
+ return normalizedFormula.length > 0 ? normalizedFormula : null;
251
+ };
252
+ const getConfiguratorFormulaCode = formula => {
253
+ const normalizedFormula = normalizeFormulaInput(formula);
254
+ if (!normalizedFormula) {
255
+ return null;
256
+ }
257
+ switch (normalizedFormula.toLowerCase()) {
258
+ case 'tow':
259
+ case 'tm':
260
+ case 'th':
261
+ case 'towmotive':
262
+ return CONFIGURATOR_FORMULAS.TOW;
263
+ case 'tmg':
264
+ case 'towmotive group':
265
+ return CONFIGURATOR_FORMULAS.TMG;
266
+ case 'thc':
267
+ case 'trekhaakcentrum':
268
+ return CONFIGURATOR_FORMULAS.THC;
269
+ case 'thcb':
270
+ case 'trekhaakcentrum belgie':
271
+ case 'trekhaakcentrum business':
272
+ return CONFIGURATOR_FORMULAS.THCB;
273
+ case 'thm':
274
+ case 'trekhaakmontage':
275
+ return CONFIGURATOR_FORMULAS.THM;
276
+ default:
277
+ return normalizedFormula.includes(' ') ? normalizedFormula : normalizedFormula.toUpperCase();
278
+ }
279
+ };
280
+ exports.getConfiguratorFormulaCode = getConfiguratorFormulaCode;
281
+ const isThcFamilyFormula = formula => {
282
+ const normalizedFormula = getConfiguratorFormulaCode(formula);
283
+ return normalizedFormula === CONFIGURATOR_FORMULAS.THC || normalizedFormula === CONFIGURATOR_FORMULAS.THCB;
284
+ };
285
+ exports.isThcFamilyFormula = isThcFamilyFormula;
286
+ const getThemeFormulaForConfiguratorFormula = formula => {
287
+ const normalizedFormula = getConfiguratorFormulaCode(formula);
288
+ if (!normalizedFormula) {
289
+ return null;
290
+ }
291
+ return isThcFamilyFormula(normalizedFormula) ? CONFIGURATOR_FORMULAS.THC : normalizedFormula;
292
+ };
293
+ exports.getThemeFormulaForConfiguratorFormula = getThemeFormulaForConfiguratorFormula;
231
294
  const NO_PRODUCTS_CONTACT_DETAILS_BY_FORMULA = exports.NO_PRODUCTS_CONTACT_DETAILS_BY_FORMULA = {
232
295
  [CONFIGURATOR_FORMULAS.THM]: {
233
296
  email: 'order@trekhaakmontage.nl',
@@ -243,6 +306,13 @@ const NO_PRODUCTS_CONTACT_DETAILS_BY_FORMULA = exports.NO_PRODUCTS_CONTACT_DETAI
243
306
  companyName: 'Trekhaakcentrum',
244
307
  logoAltText: 'Trekhaakcentrum Logo'
245
308
  },
309
+ [CONFIGURATOR_FORMULAS.THCB]: {
310
+ email: 'order@trekhaakcentrum.nl',
311
+ phoneDisplay: '+31 162 - 490 910',
312
+ phoneHref: 'tel:+31162490910',
313
+ companyName: 'Trekhaakcentrum',
314
+ logoAltText: 'Trekhaakcentrum Logo'
315
+ },
246
316
  [CONFIGURATOR_FORMULAS.TMG]: {
247
317
  email: 'order@towmotivegroup.com',
248
318
  phoneDisplay: '+31 85 - 203 0167',
@@ -273,6 +343,10 @@ const EXECUTION_HELP_CONTACT_DETAILS_BY_FORMULA = exports.EXECUTION_HELP_CONTACT
273
343
  [CONFIGURATOR_FORMULAS.THC]: {
274
344
  phoneDisplay: '+31 85 202 0660',
275
345
  phoneHref: 'tel:+31852020660'
346
+ },
347
+ [CONFIGURATOR_FORMULAS.THCB]: {
348
+ phoneDisplay: '+31 85 202 0660',
349
+ phoneHref: 'tel:+31852020660'
276
350
  }
277
351
  };
278
352
  const LOCATION_CHANGE_BUTTON_LABEL = exports.LOCATION_CHANGE_BUTTON_LABEL = 'Wijzig de locatie';
@@ -283,23 +357,7 @@ const TOWMOTIVE_ORGANIZATION_TYPE = exports.TOWMOTIVE_ORGANIZATION_TYPE = 'TowMo
283
357
  * Maps branch formula values to CONFIGURATOR_FORMULAS
284
358
  */
285
359
  const mapBranchFormulaToConfiguratorFormula = branchFormula => {
286
- if (!branchFormula) return CONFIGURATOR_FORMULAS.THM;
287
- switch (branchFormula.toLowerCase()) {
288
- case 'tow':
289
- case 'tm':
290
- case 'th':
291
- return CONFIGURATOR_FORMULAS.TOW;
292
- case 'tmg':
293
- case 'towmotive group':
294
- return CONFIGURATOR_FORMULAS.TMG;
295
- case 'thc':
296
- return CONFIGURATOR_FORMULAS.THC;
297
- case 'thm':
298
- case 'trekhaakmontage':
299
- return CONFIGURATOR_FORMULAS.THM;
300
- default:
301
- return CONFIGURATOR_FORMULAS.THM;
302
- }
360
+ return getConfiguratorFormulaCode(branchFormula);
303
361
  };
304
362
  exports.mapBranchFormulaToConfiguratorFormula = mapBranchFormulaToConfiguratorFormula;
305
363
  const LOCATION_TYPE = exports.LOCATION_TYPE = 'Vestiging';
@@ -192,7 +192,7 @@ const ExtraProductsOverview = () => {
192
192
  className: (0, _helpers__.withStyle)(index === 0 ? 'mt-0' : 'mt-5'),
193
193
  key: "category-".concat(item.categoryName)
194
194
  }, /*#__PURE__*/_react.default.createElement("h2", null, item.categoryName), item.products.map((product, index) => {
195
- var _product$price, _product$locationPric, _product$images, _product$images2, _product$boldDescript;
195
+ var _product$price, _product$consumerPric, _product$consumerPric2, _product$locationPric, _product$images, _product$images2, _product$boldDescript;
196
196
  const isSelectedExtra = selectedExtras.hasOwnProperty(product.articleNumber);
197
197
 
198
198
  // GetOrder is the single source of truth for prices
@@ -202,7 +202,7 @@ const ExtraProductsOverview = () => {
202
202
  const resolvedProductDiscountedPrice = typeof (product === null || product === void 0 ? void 0 : product.fromPrice) === 'number' ? product.fromPrice : 0;
203
203
  return /*#__PURE__*/_react.default.createElement(_ProductCard.default, {
204
204
  isTmg: isTmg,
205
- stock: product === null || product === void 0 || (_product$locationPric = product.locationPrices) === null || _product$locationPric === void 0 ? void 0 : _product$locationPric.stock,
205
+ stock: (_product$consumerPric = product === null || product === void 0 || (_product$consumerPric2 = product.consumerPrices) === null || _product$consumerPric2 === void 0 ? void 0 : _product$consumerPric2.stock) !== null && _product$consumerPric !== void 0 ? _product$consumerPric : product === null || product === void 0 || (_product$locationPric = product.locationPrices) === null || _product$locationPric === void 0 ? void 0 : _product$locationPric.stock,
206
206
  key: product.articleNumber,
207
207
  hasCheckbox: true,
208
208
  isRecommended: false,
@@ -248,7 +248,7 @@ const DeferredMontageRateInput = _ref2 => {
248
248
 
249
249
  const ProductCartTable = () => {
250
250
  const formula = (0, _FormulaContext.useFormula)();
251
- const isThc = formula === _constants__.CONFIGURATOR_FORMULAS.THC;
251
+ const isThc = (0, _constants__.isThcFamilyFormula)(formula);
252
252
  const isTowFormula = formula === _constants__.CONFIGURATOR_FORMULAS.TOW || formula === _constants__.CONFIGURATOR_FORMULAS.TM;
253
253
  const isTmg = (0, _useIsTmg.useIsTmg)();
254
254
  const isTowmotive = (0, _useIsTowmotive.useIsTowmotive)();
@@ -345,7 +345,7 @@ const ProductsOverview = () => {
345
345
  product: a,
346
346
  category: productCategory
347
347
  }) ? -1 : 0).map(product => {
348
- var _product$images, _product$images2, _product$locationPric;
348
+ var _product$images, _product$images2, _product$consumerPric, _product$consumerPric2, _product$locationPric;
349
349
  const isRecommended = (0, _product.checkIfTowbarIsRecommended)({
350
350
  product,
351
351
  category: productCategory
@@ -389,7 +389,7 @@ const ProductsOverview = () => {
389
389
  }
390
390
  return /*#__PURE__*/_react.default.createElement(_ProductCard.default, {
391
391
  isTmg: isTmg,
392
- stock: product === null || product === void 0 || (_product$locationPric = product.locationPrices) === null || _product$locationPric === void 0 ? void 0 : _product$locationPric.stock,
392
+ stock: (_product$consumerPric = product === null || product === void 0 || (_product$consumerPric2 = product.consumerPrices) === null || _product$consumerPric2 === void 0 ? void 0 : _product$consumerPric2.stock) !== null && _product$consumerPric !== void 0 ? _product$consumerPric : product === null || product === void 0 || (_product$locationPric = product.locationPrices) === null || _product$locationPric === void 0 ? void 0 : _product$locationPric.stock,
393
393
  key: product.articleNumber,
394
394
  hasCheckbox: (productsPerCategory === null || productsPerCategory === void 0 ? void 0 : productsPerCategory.length) > 1,
395
395
  isRecommended: isRecommended,
@@ -220,12 +220,20 @@ const SingleOrderModalContent = _ref6 => {
220
220
  if (formula === _constants__.CONFIGURATOR_FORMULAS.TMG || !singleOrderBranches) {
221
221
  return singleOrderBranches;
222
222
  }
223
- return singleOrderBranches.filter(branch => (branch === null || branch === void 0 ? void 0 : branch.formulaCode) === formula);
223
+ const normalizedFormula = (0, _constants__.getConfiguratorFormulaCode)(formula);
224
+ return singleOrderBranches.filter(branch => {
225
+ var _ref7, _branch$formulaCode, _branch$formule;
226
+ const branchFormula = (0, _constants__.getConfiguratorFormulaCode)((_ref7 = (_branch$formulaCode = branch === null || branch === void 0 ? void 0 : branch.formulaCode) !== null && _branch$formulaCode !== void 0 ? _branch$formulaCode : branch === null || branch === void 0 || (_branch$formule = branch.formule) === null || _branch$formule === void 0 ? void 0 : _branch$formule.code) !== null && _ref7 !== void 0 ? _ref7 : branch === null || branch === void 0 ? void 0 : branch.formule);
227
+ if ((0, _constants__.isThcFamilyFormula)(normalizedFormula)) {
228
+ return (0, _constants__.isThcFamilyFormula)(branchFormula);
229
+ }
230
+ return branchFormula === normalizedFormula;
231
+ });
224
232
  }, [singleOrderBranches, formula]);
225
233
  const branchIdWithFormulaCode = new Map();
226
234
  filteredBranches === null || filteredBranches === void 0 || filteredBranches.forEach(branch => {
227
- var _branch$formule$code, _branch$formule;
228
- branchIdWithFormulaCode.set(branch === null || branch === void 0 ? void 0 : branch.entityId, (_branch$formule$code = branch === null || branch === void 0 || (_branch$formule = branch.formule) === null || _branch$formule === void 0 ? void 0 : _branch$formule.code) !== null && _branch$formule$code !== void 0 ? _branch$formule$code : _constants__.CONFIGURATOR_FORMULAS.THC);
235
+ var _getConfiguratorFormu, _ref8, _branch$formulaCode2, _branch$formule2;
236
+ branchIdWithFormulaCode.set(branch === null || branch === void 0 ? void 0 : branch.entityId, (_getConfiguratorFormu = (0, _constants__.getConfiguratorFormulaCode)((_ref8 = (_branch$formulaCode2 = branch === null || branch === void 0 ? void 0 : branch.formulaCode) !== null && _branch$formulaCode2 !== void 0 ? _branch$formulaCode2 : branch === null || branch === void 0 || (_branch$formule2 = branch.formule) === null || _branch$formule2 === void 0 ? void 0 : _branch$formule2.code) !== null && _ref8 !== void 0 ? _ref8 : branch === null || branch === void 0 ? void 0 : branch.formule)) !== null && _getConfiguratorFormu !== void 0 ? _getConfiguratorFormu : (0, _constants__.getConfiguratorFormulaCode)(formula));
229
237
  });
230
238
  const branchOptions = filteredBranches === null || filteredBranches === void 0 ? void 0 : filteredBranches.map(branch => ({
231
239
  label: "".concat(branch === null || branch === void 0 ? void 0 : branch.naamVestiging, " - ").concat(branch === null || branch === void 0 ? void 0 : branch.name),
@@ -243,11 +251,11 @@ const SingleOrderModalContent = _ref6 => {
243
251
  noOptionsMessage: "Geen opties beschikbaar",
244
252
  placeholder: "Maak een keuze",
245
253
  initialValue: singleOrderBranchType,
246
- onChange: _ref7 => {
254
+ onChange: _ref9 => {
247
255
  let {
248
256
  label,
249
257
  value
250
- } = _ref7;
258
+ } = _ref9;
251
259
  setSingleOrderBranchType(value);
252
260
  setSelectedBranchId(undefined);
253
261
  setLocalBranchId(undefined);
@@ -261,11 +269,11 @@ const SingleOrderModalContent = _ref6 => {
261
269
  noOptionsMessage: "Geen opties beschikbaar",
262
270
  placeholder: "Maak een keuze",
263
271
  initialValue: selectedBranchId,
264
- onChange: _ref8 => {
272
+ onChange: _ref10 => {
265
273
  let {
266
274
  label,
267
275
  value
268
- } = _ref8;
276
+ } = _ref10;
269
277
  setSelectedBranchId(value);
270
278
  setLocalBranchId(value);
271
279
  const formulaCode = branchIdWithFormulaCode.get(value);
@@ -134,14 +134,14 @@ const getConfiguratorThemeClass = theme => {
134
134
  };
135
135
  exports.getConfiguratorThemeClass = getConfiguratorThemeClass;
136
136
  const getConfiguratorThemeClassByFormula = formula => {
137
- switch (formula) {
138
- case 'THC':
137
+ switch ((0, _constants__.getThemeFormulaForConfiguratorFormula)(formula)) {
138
+ case _constants__.CONFIGURATOR_FORMULAS.THC:
139
139
  return 'thc';
140
- case 'TMG':
140
+ case _constants__.CONFIGURATOR_FORMULAS.TMG:
141
141
  return 'tmg';
142
- case 'TOW':
143
- case 'TH':
144
- case 'TowMotive':
142
+ case _constants__.CONFIGURATOR_FORMULAS.TOW:
143
+ case _constants__.CONFIGURATOR_FORMULAS.TH:
144
+ case _constants__.CONFIGURATOR_FORMULAS.TowMotive:
145
145
  return 'tm';
146
146
  default:
147
147
  return '';
@@ -286,11 +286,11 @@ const enrichArticlesWithBrandsAndPrices = exports.enrichArticlesWithBrandsAndPri
286
286
  throw new Error('Failed to fetch the brands of the articles');
287
287
  }
288
288
  const articlesWithBrands = articles.map(article => {
289
- var _ref3, _ref4, _preferredPricePart$p, _preferredPricePart$p2;
289
+ var _preferredPricePart$p, _ref3, _ref4, _preferredPricePart$p2, _ref5, _brandData$brandNumbe;
290
290
  const brandData = findBrandDataForArticle(article, brandResponse.data);
291
291
  const preferredPricePart = findPreferredPricePart(article);
292
- const resolvedBrandNumber = (_ref3 = (_ref4 = (_preferredPricePart$p = preferredPricePart === null || preferredPricePart === void 0 ? void 0 : preferredPricePart.partBrandId) !== null && _preferredPricePart$p !== void 0 ? _preferredPricePart$p : brandData === null || brandData === void 0 ? void 0 : brandData.preferredPartBrandNumber) !== null && _ref4 !== void 0 ? _ref4 : brandData === null || brandData === void 0 ? void 0 : brandData.brandNumber) !== null && _ref3 !== void 0 ? _ref3 : _index2.DEFAULT_ARTICLE_BRAND;
293
- const pricingPartNumber = (_preferredPricePart$p2 = preferredPricePart === null || preferredPricePart === void 0 ? void 0 : preferredPricePart.partNumber) !== null && _preferredPricePart$p2 !== void 0 ? _preferredPricePart$p2 : article.articleNumber;
292
+ const pricingPartNumber = (_preferredPricePart$p = preferredPricePart === null || preferredPricePart === void 0 ? void 0 : preferredPricePart.partNumber) !== null && _preferredPricePart$p !== void 0 ? _preferredPricePart$p : article.articleNumber;
293
+ const resolvedBrandNumber = preferredPricePart ? (_ref3 = (_ref4 = (_preferredPricePart$p2 = preferredPricePart === null || preferredPricePart === void 0 ? void 0 : preferredPricePart.partBrandId) !== null && _preferredPricePart$p2 !== void 0 ? _preferredPricePart$p2 : brandData === null || brandData === void 0 ? void 0 : brandData.preferredPartBrandNumber) !== null && _ref4 !== void 0 ? _ref4 : brandData === null || brandData === void 0 ? void 0 : brandData.brandNumber) !== null && _ref3 !== void 0 ? _ref3 : _index2.DEFAULT_ARTICLE_BRAND : (_ref5 = (_brandData$brandNumbe = brandData === null || brandData === void 0 ? void 0 : brandData.brandNumber) !== null && _brandData$brandNumbe !== void 0 ? _brandData$brandNumbe : brandData === null || brandData === void 0 ? void 0 : brandData.preferredPartBrandNumber) !== null && _ref5 !== void 0 ? _ref5 : _index2.DEFAULT_ARTICLE_BRAND;
294
294
  return _objectSpread(_objectSpread({}, article), {}, {
295
295
  brand: resolvedBrandNumber,
296
296
  pricingPartNumber
@@ -318,11 +318,11 @@ const enrichArticlesWithBrandsAndPrices = exports.enrichArticlesWithBrandsAndPri
318
318
  consumer: Object.fromEntries(consumerPrices.map(price => [price.partNumber, price])),
319
319
  location: Object.fromEntries(locationPrices.map(price => [price.partNumber, price]))
320
320
  };
321
- let currentArticles = articlesWithBrands.map(_ref5 => {
321
+ let currentArticles = articlesWithBrands.map(_ref6 => {
322
322
  let {
323
323
  pricingPartNumber
324
- } = _ref5,
325
- article = _objectWithoutProperties(_ref5, _excluded);
324
+ } = _ref6,
325
+ article = _objectWithoutProperties(_ref6, _excluded);
326
326
  return _objectSpread(_objectSpread({}, article), {}, {
327
327
  consumerPrices: pricesMap.consumer[pricingPartNumber],
328
328
  locationPrices: pricesMap.location[pricingPartNumber]
@@ -331,10 +331,10 @@ const enrichArticlesWithBrandsAndPrices = exports.enrichArticlesWithBrandsAndPri
331
331
  return currentArticles;
332
332
  };
333
333
  const formatModelArticle = article => {
334
- var _ref6, _article$name, _ref7, _article$description$, _article$description, _article$boldDescript, _article$boldDescript2, _article$specificatio, _article$images, _article$images2, _article$articleNumbe;
334
+ var _ref7, _article$name, _ref8, _article$description$, _article$description, _article$boldDescript, _article$boldDescript2, _article$specificatio, _article$images, _article$images2, _article$articleNumbe;
335
335
  return _objectSpread(_objectSpread({}, article), {}, {
336
- name: (_ref6 = (_article$name = article.name) !== null && _article$name !== void 0 ? _article$name : article === null || article === void 0 ? void 0 : article.title) !== null && _ref6 !== void 0 ? _ref6 : null,
337
- description: (_ref7 = (_article$description$ = article === null || article === void 0 || (_article$description = article.description) === null || _article$description === void 0 || (_article$description = _article$description.ops) === null || _article$description === void 0 || (_article$description = _article$description[0]) === null || _article$description === void 0 ? void 0 : _article$description.insert) !== null && _article$description$ !== void 0 ? _article$description$ : article === null || article === void 0 ? void 0 : article.remark) !== null && _ref7 !== void 0 ? _ref7 : null,
336
+ name: (_ref7 = (_article$name = article.name) !== null && _article$name !== void 0 ? _article$name : article === null || article === void 0 ? void 0 : article.title) !== null && _ref7 !== void 0 ? _ref7 : null,
337
+ description: (_ref8 = (_article$description$ = article === null || article === void 0 || (_article$description = article.description) === null || _article$description === void 0 || (_article$description = _article$description.ops) === null || _article$description === void 0 || (_article$description = _article$description[0]) === null || _article$description === void 0 ? void 0 : _article$description.insert) !== null && _article$description$ !== void 0 ? _article$description$ : article === null || article === void 0 ? void 0 : article.remark) !== null && _ref8 !== void 0 ? _ref8 : null,
338
338
  subTitle: (_article$boldDescript = article === null || article === void 0 || (_article$boldDescript2 = article.boldDescription) === null || _article$boldDescript2 === void 0 || (_article$boldDescript2 = _article$boldDescript2.ops) === null || _article$boldDescript2 === void 0 || (_article$boldDescript2 = _article$boldDescript2[0]) === null || _article$boldDescript2 === void 0 ? void 0 : _article$boldDescript2.insert) !== null && _article$boldDescript !== void 0 ? _article$boldDescript : null,
339
339
  specifications: Array.isArray(article === null || article === void 0 ? void 0 : article.specifications) ? article === null || article === void 0 ? void 0 : article.specifications.join(' \n ') : (_article$specificatio = article === null || article === void 0 ? void 0 : article.specifications) !== null && _article$specificatio !== void 0 ? _article$specificatio : null,
340
340
  image: article !== null && article !== void 0 && (_article$images = article.images) !== null && _article$images !== void 0 && _article$images[0] ? (0, _image.getImageFromHyper)({
@@ -349,11 +349,11 @@ const formatModelArticle = article => {
349
349
  const formatGenericArticle = article => {
350
350
  var _article$articleNumbe2, _article$type, _article$group, _article$subgroup;
351
351
  const specificationPairs = [['C2 module', article === null || article === void 0 ? void 0 : article.c2Module], ['Check control', article === null || article === void 0 ? void 0 : article.checkControl], ['Direct current', article === null || article === void 0 ? void 0 : article.directCurrent], ['Draw weight', article === null || article === void 0 ? void 0 : article.drawWeight], ['D value', article === null || article === void 0 ? void 0 : article.dValue], ['Foglight shutdown', article === null || article === void 0 ? void 0 : article.foglightShutdown], ['PDC shutdown', article === null || article === void 0 ? void 0 : article.pdcShutdown], ['Switched PSU', article === null || article === void 0 ? void 0 : article.switchedPsu], ['LED', article === null || article === void 0 ? void 0 : article.led]];
352
- const specification = specificationPairs.filter(_ref8 => {
353
- let [_, value] = _ref8;
352
+ const specification = specificationPairs.filter(_ref9 => {
353
+ let [_, value] = _ref9;
354
354
  return value;
355
- }).map(_ref9 => {
356
- let [label, value] = _ref9;
355
+ }).map(_ref10 => {
356
+ let [label, value] = _ref10;
357
357
  return "".concat(label, ": ").concat(value);
358
358
  }).join(' \n ');
359
359
  return _objectSpread(_objectSpread({}, article), {}, {
@@ -37,23 +37,19 @@ const useBranchTheme = () => {
37
37
  if (!formula) {
38
38
  return cachedTheme || _constants__.BRANCH_THEME_BY_FORMULA.Trekhaakmontage;
39
39
  }
40
- switch (formula) {
41
- case _constants__.BRANCH_FORMULAS.Trekhaakmontage:
40
+ switch ((0, _constants__.getThemeFormulaForConfiguratorFormula)(formula)) {
42
41
  case _constants__.CONFIGURATOR_FORMULAS.THM:
43
42
  {
44
43
  return _constants__.BRANCH_THEME_BY_FORMULA.Trekhaakmontage;
45
44
  }
46
- case _constants__.BRANCH_FORMULAS.Trekhaakcentrum:
47
45
  case _constants__.CONFIGURATOR_FORMULAS.THC:
48
46
  {
49
47
  return _constants__.BRANCH_THEME_BY_FORMULA.Trekhaakcentrum;
50
48
  }
51
- case _constants__.BRANCH_FORMULAS.TowMotiveGroup:
52
49
  case _constants__.CONFIGURATOR_FORMULAS.TMG:
53
50
  {
54
51
  return _constants__.BRANCH_THEME_BY_FORMULA.TowMotiveGroup;
55
52
  }
56
- case _constants__.BRANCH_FORMULAS.TowMotive:
57
53
  case _constants__.CONFIGURATOR_FORMULAS.TOW:
58
54
  case _constants__.CONFIGURATOR_FORMULAS.TH:
59
55
  case _constants__.CONFIGURATOR_FORMULAS.TowMotive:
@@ -62,7 +58,7 @@ const useBranchTheme = () => {
62
58
  }
63
59
  default:
64
60
  {
65
- return cachedTheme;
61
+ return cachedTheme || null;
66
62
  }
67
63
  }
68
64
  }, [themeFromContext, cachedTheme, formula]);
@@ -54,8 +54,15 @@ function _interopRequireWildcard(e, r) {
54
54
  const NoProductsPage = () => {
55
55
  const mailLinkRef = (0, _react.useRef)(null);
56
56
  const formula = (0, _FormulaContext.useFormula)();
57
- const themeClass = (0, _helpers__.getConfiguratorThemeClass)((0, _useBranchTheme.useBranchTheme)());
58
- const contactDetails = _constants__.NO_PRODUCTS_CONTACT_DETAILS_BY_FORMULA[formula] || _constants__.NO_PRODUCTS_CONTACT_DETAILS_BY_FORMULA[_constants__.CONFIGURATOR_FORMULAS.THM];
57
+ const branchTheme = (0, _useBranchTheme.useBranchTheme)();
58
+ const themeClass = (0, _helpers__.getConfiguratorThemeClass)(branchTheme);
59
+ const fallbackFormulaByTheme = {
60
+ [_constants__.BRANCH_THEME_BY_FORMULA.Trekhaakcentrum]: _constants__.CONFIGURATOR_FORMULAS.THC,
61
+ [_constants__.BRANCH_THEME_BY_FORMULA.Trekhaakmontage]: _constants__.CONFIGURATOR_FORMULAS.THM,
62
+ [_constants__.BRANCH_THEME_BY_FORMULA.TowMotiveGroup]: _constants__.CONFIGURATOR_FORMULAS.TMG,
63
+ [_constants__.BRANCH_THEME_BY_FORMULA.TowMotive]: _constants__.CONFIGURATOR_FORMULAS.TOW
64
+ };
65
+ const contactDetails = _constants__.NO_PRODUCTS_CONTACT_DETAILS_BY_FORMULA[(0, _constants__.getThemeFormulaForConfiguratorFormula)(formula)] || _constants__.NO_PRODUCTS_CONTACT_DETAILS_BY_FORMULA[fallbackFormulaByTheme[branchTheme]];
59
66
  const handleClick = () => {
60
67
  (0, _Datalayer.pushToDataLayer)({
61
68
  event: 'configurator',
@@ -50,8 +50,15 @@ function _interopRequireWildcard(e, r) {
50
50
  const InternalNoProductsPage = () => {
51
51
  const mailLinkRef = (0, _react.useRef)(null);
52
52
  const formula = (0, _FormulaContext.useFormula)();
53
- const themeClass = (0, _helpers__.getConfiguratorThemeClass)((0, _useBranchTheme.useBranchTheme)());
54
- const contactDetails = _constants__.NO_PRODUCTS_CONTACT_DETAILS_BY_FORMULA[formula] || _constants__.NO_PRODUCTS_CONTACT_DETAILS_BY_FORMULA[_constants__.CONFIGURATOR_FORMULAS.THM];
53
+ const branchTheme = (0, _useBranchTheme.useBranchTheme)();
54
+ const themeClass = (0, _helpers__.getConfiguratorThemeClass)(branchTheme);
55
+ const fallbackFormulaByTheme = {
56
+ [_constants__.BRANCH_THEME_BY_FORMULA.Trekhaakcentrum]: _constants__.CONFIGURATOR_FORMULAS.THC,
57
+ [_constants__.BRANCH_THEME_BY_FORMULA.Trekhaakmontage]: _constants__.CONFIGURATOR_FORMULAS.THM,
58
+ [_constants__.BRANCH_THEME_BY_FORMULA.TowMotiveGroup]: _constants__.CONFIGURATOR_FORMULAS.TMG,
59
+ [_constants__.BRANCH_THEME_BY_FORMULA.TowMotive]: _constants__.CONFIGURATOR_FORMULAS.TOW
60
+ };
61
+ const contactDetails = _constants__.NO_PRODUCTS_CONTACT_DETAILS_BY_FORMULA[(0, _constants__.getThemeFormulaForConfiguratorFormula)(formula)] || _constants__.NO_PRODUCTS_CONTACT_DETAILS_BY_FORMULA[fallbackFormulaByTheme[branchTheme]];
55
62
  const handleClick = () => {
56
63
  if (mailLinkRef.current) {
57
64
  mailLinkRef.current.click();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thm-p3-configurator",
3
- "version": "0.0.366",
3
+ "version": "0.0.368",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "author": "EnoRm.",