thm-p3-configurator 0.0.400 → 0.0.403

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.
@@ -684,7 +684,7 @@ const useProductsQuery = exports.useProductsQuery = function useProductsQuery()
684
684
  * @description Retrieves the order questions based on the provided license plate or brand/build-year/model
685
685
  */
686
686
  const useQuestionsQuery = exports.useQuestionsQuery = function useQuestionsQuery() {
687
- var _orderData$executionA2, _orderData$executionA4, _orderData$answers, _orderData$answers2, _orderData$answers3, _orderError$response;
687
+ var _orderError$response$, _orderError$response, _orderError$response$2, _orderError$response2, _orderData$executionA2, _orderData$executionA4, _orderData$answers, _orderData$answers2, _orderData$answers3;
688
688
  let questionParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
689
689
  const normalizedQuestionParams = (0, _queryKeyFactory.normalizeOrderParams)(questionParams);
690
690
  const {
@@ -693,6 +693,8 @@ const useQuestionsQuery = exports.useQuestionsQuery = function useQuestionsQuery
693
693
  isOrderError,
694
694
  orderError
695
695
  } = useOrderDataQuery(normalizedQuestionParams);
696
+ const questionsErrorCode = (_orderError$response$ = orderError === null || orderError === void 0 || (_orderError$response = orderError.response) === null || _orderError$response === void 0 || (_orderError$response = _orderError$response.data) === null || _orderError$response === void 0 ? void 0 : _orderError$response.code) !== null && _orderError$response$ !== void 0 ? _orderError$response$ : null;
697
+ const questionsErrorStatus = (_orderError$response$2 = orderError === null || orderError === void 0 || (_orderError$response2 = orderError.response) === null || _orderError$response2 === void 0 ? void 0 : _orderError$response2.status) !== null && _orderError$response$2 !== void 0 ? _orderError$response$2 : null;
696
698
  const execution1AnswerOptions = (0, _react.useMemo)(() => {
697
699
  var _orderData$executionA;
698
700
  return (0, _helpers__.parseArrayToInputOptions)(orderData === null || orderData === void 0 || (_orderData$executionA = orderData.executionAnswerOptions) === null || _orderData$executionA === void 0 ? void 0 : _orderData$executionA.execution1AnswerOptions);
@@ -708,7 +710,9 @@ const useQuestionsQuery = exports.useQuestionsQuery = function useQuestionsQuery
708
710
  execution1Answer: orderData === null || orderData === void 0 || (_orderData$answers = orderData.answers) === null || _orderData$answers === void 0 ? void 0 : _orderData$answers.execution1,
709
711
  execution2Answer: orderData === null || orderData === void 0 || (_orderData$answers2 = orderData.answers) === null || _orderData$answers2 === void 0 ? void 0 : _orderData$answers2.execution2,
710
712
  durationAnswer: orderData === null || orderData === void 0 || (_orderData$answers3 = orderData.answers) === null || _orderData$answers3 === void 0 ? void 0 : _orderData$answers3.duration,
711
- questionsError: (orderError === null || orderError === void 0 || (_orderError$response = orderError.response) === null || _orderError$response === void 0 || (_orderError$response = _orderError$response.data) === null || _orderError$response === void 0 ? void 0 : _orderError$response.code) || orderError,
713
+ questionsError: questionsErrorCode || orderError,
714
+ questionsErrorCode,
715
+ questionsErrorStatus,
712
716
  execution1AnswerOptions,
713
717
  execution2AnswerOptions,
714
718
  durationQuestion
@@ -58,6 +58,12 @@ function _interopRequireWildcard(e, r) {
58
58
  return n.default = e, t && t.set(e, n), n;
59
59
  }
60
60
  const licensePlateValidator = new _LicensePlateValidator.default();
61
+ const isValidLicensePlate = function isValidLicensePlate() {
62
+ let value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
63
+ const normalizedValue = String(value !== null && value !== void 0 ? value : '');
64
+ const stripped = normalizedValue.replace(/-/g, '').toUpperCase();
65
+ return stripped.length === 6 && licensePlateValidator.getSideCode(stripped) > 0;
66
+ };
61
67
  const LicensePlateForm = _ref => {
62
68
  var _ref2;
63
69
  let {
@@ -109,8 +115,7 @@ const LicensePlateForm = _ref => {
109
115
  action: 'submit',
110
116
  action_value: buttonLabel
111
117
  });
112
- const stripped = (plate !== null && plate !== void 0 ? plate : '').replace(/-/g, '').toUpperCase();
113
- const isValid = stripped.length === 6 && licensePlateValidator.getSideCode(stripped) > 0;
118
+ const isValid = isValidLicensePlate(plate !== null && plate !== void 0 ? plate : '');
114
119
  (0, _Datalayer.pushToDataLayer)({
115
120
  event: 'configurator',
116
121
  component: trackingComponent,
@@ -119,6 +124,9 @@ const LicensePlateForm = _ref => {
119
124
  action: 'submit',
120
125
  action_value: isValid ? 'valid' : 'invalid - Uw kenteken staat (nog) niet in onze database. Kies uw voertuig via de merk/model selectie.'
121
126
  });
127
+ if (!isValid) {
128
+ return;
129
+ }
122
130
  onSubmit(isFilter ? overridePlate : undefined);
123
131
  };
124
132
  const handleLicensePlateChange = value => {
@@ -162,7 +170,7 @@ const LicensePlateForm = _ref => {
162
170
  onClick: () => {
163
171
  handleSubmitWithTracking(isFilter ? filterLicensePlate : undefined);
164
172
  },
165
- isDisabled: !isFilter ? !licensePlate || licensePlate.length < 6 : false,
173
+ isDisabled: !isValidLicensePlate(isFilter ? filterLicensePlate : licensePlate),
166
174
  label: isFilter ? 'Filteren' : 'Volgende'
167
175
  })))));
168
176
  };
@@ -1,14 +1,12 @@
1
1
  "use strict";
2
2
 
3
- require("core-js/modules/es.regexp.exec.js");
4
- require("core-js/modules/es.regexp.to-string.js");
5
- require("core-js/modules/es.string.search.js");
3
+ require("core-js/modules/es.array.includes.js");
4
+ require("core-js/modules/es.string.includes.js");
6
5
  require("core-js/modules/es.weak-map.js");
7
6
  require("core-js/modules/esnext.iterator.constructor.js");
8
7
  require("core-js/modules/esnext.iterator.filter.js");
9
8
  require("core-js/modules/esnext.iterator.for-each.js");
10
9
  require("core-js/modules/web.dom-collections.iterator.js");
11
- require("core-js/modules/web.url-search-params.js");
12
10
  require("core-js/modules/es.weak-map.js");
13
11
  require("core-js/modules/esnext.iterator.constructor.js");
14
12
  require("core-js/modules/esnext.iterator.filter.js");
@@ -17,11 +15,9 @@ Object.defineProperty(exports, "__esModule", {
17
15
  value: true
18
16
  });
19
17
  exports.default = void 0;
20
- require("core-js/modules/es.regexp.exec.js");
21
- require("core-js/modules/es.regexp.to-string.js");
22
- require("core-js/modules/es.string.search.js");
18
+ require("core-js/modules/es.array.includes.js");
19
+ require("core-js/modules/es.string.includes.js");
23
20
  require("core-js/modules/web.dom-collections.iterator.js");
24
- require("core-js/modules/web.url-search-params.js");
25
21
  var _react = _interopRequireWildcard(require("react"));
26
22
  var _reactRouter = require("react-router");
27
23
  var _queries = require("../__api__/queries");
@@ -163,14 +159,6 @@ const QuestionsForm = _ref => {
163
159
  formula = singleOrderFormulaCode;
164
160
  }
165
161
  const history = (0, _reactRouter.useHistory)();
166
- const {
167
- search
168
- } = (0, _reactRouter.useLocation)();
169
- const notFoundRedirectTarget = (0, _react.useMemo)(() => {
170
- const searchParams = new URLSearchParams(search);
171
- searchParams.set('notFound', 'true');
172
- return "/configurator".concat(searchParams.size ? "?".concat(searchParams.toString()) : '');
173
- }, [search]);
174
162
 
175
163
  // Create a modified version of execution answers for the query
176
164
  // Only include both execution answers if both are provided
@@ -209,6 +197,8 @@ const QuestionsForm = _ref => {
209
197
  execution2AnswerOptions,
210
198
  durationAnswer: durationAnswerPrefilled,
211
199
  questionsError,
200
+ questionsErrorCode,
201
+ questionsErrorStatus,
212
202
  durationQuestion
213
203
  } = questionsObject;
214
204
 
@@ -278,6 +268,9 @@ const QuestionsForm = _ref => {
278
268
  type: _OrderSessionContext.orderSessionActions.CLEAR_ANSWERS
279
269
  });
280
270
  if (isFilter) {
271
+ if (questionsError) {
272
+ return;
273
+ }
281
274
  if (!initialModel) {
282
275
  onSubmit({
283
276
  type: 'licensePlate',
@@ -293,16 +286,14 @@ const QuestionsForm = _ref => {
293
286
  }
294
287
  return;
295
288
  } else {
296
- if (questionsError) {
297
- onPrev(1);
298
- } else {
289
+ if (!questionsError) {
299
290
  history.push('/configurator/trekhaakpakket');
300
291
  }
301
292
  }
302
293
  }
303
294
  }
304
295
  }, [isLoadingQuestions, durationOptions, execution1Options, execution2Options, execution2AnswerOptions, execution1AnswerOptions, durationQuestion, isFilter, questionsError]);
305
- const isNotFoundQuestionError = questionsError === _constants__.API_ERROR_CODES.notFound || questionsError === _constants__.API_ERROR_CODES.notFoundAldoc;
296
+ const isNotFoundQuestionError = questionsErrorCode === _constants__.API_ERROR_CODES.notFound || questionsErrorCode === _constants__.API_ERROR_CODES.notFoundAldoc || questionsErrorStatus === 404 || typeof questionsErrorCode === 'string' && questionsErrorCode.includes('NOT_FOUND');
306
297
  const isWaitingForInternalSessionContext = APP_CONFIG.internal && initialized && authenticated && !isSessionContextReady;
307
298
  const handlePrev = () => {
308
299
  (0, _Datalayer.pushToDataLayer)({
@@ -333,8 +324,26 @@ const QuestionsForm = _ref => {
333
324
  }));
334
325
  }
335
326
  if (isNotFoundQuestionError) {
327
+ if (isFilter) {
328
+ return /*#__PURE__*/_react.default.createElement("div", {
329
+ className: (0, _helpers__.withStyle)('card-body')
330
+ }, /*#__PURE__*/_react.default.createElement("div", {
331
+ className: (0, _helpers__.withStyle)('alert alert-danger mb-3')
332
+ }, /*#__PURE__*/_react.default.createElement("small", null, "Het opgegeven kenteken kon niet worden gevonden. Probeer een ander kenteken of zoek via merk.")), /*#__PURE__*/_react.default.createElement("div", {
333
+ className: (0, _helpers__.withStyle)('row align-items-center justify-content-end')
334
+ }, /*#__PURE__*/_react.default.createElement("div", {
335
+ className: (0, _helpers__.withStyle)("col col-sm-auto mt-1")
336
+ }, /*#__PURE__*/_react.default.createElement("div", {
337
+ className: (0, _helpers__.withStyle)('d-grid gap-2')
338
+ }, /*#__PURE__*/_react.default.createElement(_LinkButton.default, {
339
+ type: "button",
340
+ isDisabled: false,
341
+ onClick: handlePrev,
342
+ label: 'Ga terug'
343
+ })))));
344
+ }
336
345
  return /*#__PURE__*/_react.default.createElement(_reactRouter.Redirect, {
337
- to: notFoundRedirectTarget
346
+ to: "/configurator/geen-producten"
338
347
  });
339
348
  }
340
349
  if (questionsError) {
@@ -77,7 +77,7 @@ const LicensePlatePage = () => {
77
77
  const [activeStep, setActiveStep] = (0, _react.useState)(0);
78
78
  const [, dispatch] = (0, _OrderSessionContext.useOrderSession)();
79
79
  const themeClass = (0, _helpers__.getConfiguratorThemeClass)((0, _useBranchTheme.useBranchTheme)());
80
- const [licensePlateURL, widgetOrEntityId, discountCode, franchiseName, notFound, vestigingRecId] = (0, _useSearchParam.default)(['licensePlate', 'branch', 'discountCode', 'naamKeten', 'notFound', 'vestigingRecId']);
80
+ const [licensePlateURL, widgetOrEntityId, discountCode, franchiseName, vestigingRecId] = (0, _useSearchParam.default)(['licensePlate', 'branch', 'discountCode', 'naamKeten', 'vestigingRecId']);
81
81
  const branchIdOrVestigingRecId = widgetOrEntityId || vestigingRecId;
82
82
  const {
83
83
  branchById,
@@ -173,9 +173,7 @@ const LicensePlatePage = () => {
173
173
  isCentered: true,
174
174
  isScrollable: true,
175
175
  title: 'Wij zoeken naar de beste oplossing'
176
- }, branchIdOrVestigingRecId && isLoadingBranchById && /*#__PURE__*/_react.default.createElement(_TextSpinner.default, null), notFound === 'true' && /*#__PURE__*/_react.default.createElement("div", {
177
- className: (0, _helpers__.withStyle)('alert alert-danger mb-3')
178
- }, /*#__PURE__*/_react.default.createElement("small", null, "Het opgegeven kenteken kon niet worden gevonden. Probeer een ander kenteken of zoek via merk.")), Steps[activeStep], /*#__PURE__*/_react.default.createElement("div", {
176
+ }, branchIdOrVestigingRecId && isLoadingBranchById && /*#__PURE__*/_react.default.createElement(_TextSpinner.default, null), Steps[activeStep], /*#__PURE__*/_react.default.createElement("div", {
179
177
  className: (0, _helpers__.withStyle)('align-items-center justify-content-center text-center mt-2')
180
178
  }, /*#__PURE__*/_react.default.createElement(_FormSteps.default, {
181
179
  count: Steps.length,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thm-p3-configurator",
3
- "version": "0.0.400",
3
+ "version": "0.0.403",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "author": "EnoRm.",