thm-p3-configurator 0.0.352 → 0.0.353

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.
@@ -38,6 +38,7 @@ var _FormulaContext = require("../__context__/FormulaContext");
38
38
  var _OrderSessionContext = require("../__context__/OrderSessionContext");
39
39
  var _helpers__ = require("../__helpers__");
40
40
  var _singleOrderArticles = require("../__helpers__/singleOrderArticles");
41
+ var _useSessionContextReady = require("../__hooks__/useSessionContextReady");
41
42
  var _authenticatedProxyApi = require("./authenticatedProxyApi");
42
43
  var _orderApi = require("./orderApi");
43
44
  var _publicProxyApi = require("./publicProxyApi");
@@ -475,13 +476,18 @@ const useOrderDataQuery = exports.useOrderDataQuery = function useOrderDataQuery
475
476
  model
476
477
  } = normalizedOrderParams;
477
478
  const {
479
+ authenticated,
478
480
  initialized
479
481
  } = (0, _AuthSessionContext.useAuthSession)();
482
+ const isSessionContextReady = (0, _useSessionContextReady.useSessionContextReady)();
480
483
  const orderQueryKey = (0, _queryKeyFactory.getOrderQueryKey)(normalizedOrderParams);
481
484
  const serializedOrderParams = (0, _queryKeyFactory.serializeOrderParams)(normalizedOrderParams);
482
485
  const hasOrderInput = (licensePlate === null || licensePlate === void 0 ? void 0 : licensePlate.length) > 5 || !!(model !== null && model !== void 0 && model.length);
486
+ const isWaitingForInternalSessionContext = APP_CONFIG.internal && hasOrderInput && (!initialized || authenticated && !isSessionContextReady);
483
487
  const orderQuery = (0, _reactQuery.useQuery)(orderQueryKey, {
484
- enabled: hasOrderInput && (!APP_CONFIG.internal || initialized),
488
+ // Embedded internal routes need the session context synced before order
489
+ // endpoints can resolve the correct branch/formula combination.
490
+ enabled: hasOrderInput && (!APP_CONFIG.internal || initialized && isSessionContextReady),
485
491
  keepPreviousData: true,
486
492
  queryFn: async () => {
487
493
  var _response$data;
@@ -491,8 +497,8 @@ const useOrderDataQuery = exports.useOrderDataQuery = function useOrderDataQuery
491
497
  });
492
498
  return {
493
499
  orderData: orderQuery === null || orderQuery === void 0 ? void 0 : orderQuery.data,
494
- isLoadingOrder: orderQuery.isLoading,
495
- isFetchingOrder: orderQuery.isFetching,
500
+ isLoadingOrder: orderQuery.isLoading || isWaitingForInternalSessionContext,
501
+ isFetchingOrder: orderQuery.isFetching || isWaitingForInternalSessionContext,
496
502
  isOrderError: orderQuery.isError,
497
503
  orderError: orderQuery.error
498
504
  };
@@ -1,10 +1,14 @@
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
6
  require("core-js/modules/es.weak-map.js");
4
7
  require("core-js/modules/esnext.iterator.constructor.js");
5
8
  require("core-js/modules/esnext.iterator.filter.js");
6
9
  require("core-js/modules/esnext.iterator.for-each.js");
7
10
  require("core-js/modules/web.dom-collections.iterator.js");
11
+ require("core-js/modules/web.url-search-params.js");
8
12
  require("core-js/modules/es.weak-map.js");
9
13
  require("core-js/modules/esnext.iterator.constructor.js");
10
14
  require("core-js/modules/esnext.iterator.filter.js");
@@ -13,7 +17,11 @@ Object.defineProperty(exports, "__esModule", {
13
17
  value: true
14
18
  });
15
19
  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");
16
23
  require("core-js/modules/web.dom-collections.iterator.js");
24
+ require("core-js/modules/web.url-search-params.js");
17
25
  var _react = _interopRequireWildcard(require("react"));
18
26
  var _reactRouter = require("react-router");
19
27
  var _queries = require("../__api__/queries");
@@ -138,6 +146,14 @@ const QuestionsForm = _ref => {
138
146
  formula = singleOrderFormulaCode;
139
147
  }
140
148
  const history = (0, _reactRouter.useHistory)();
149
+ const {
150
+ search
151
+ } = (0, _reactRouter.useLocation)();
152
+ const notFoundRedirectTarget = (0, _react.useMemo)(() => {
153
+ const searchParams = new URLSearchParams(search);
154
+ searchParams.set('notFound', 'true');
155
+ return "/configurator".concat(searchParams.size ? "?".concat(searchParams.toString()) : '');
156
+ }, [search]);
141
157
 
142
158
  // Create a modified version of execution answers for the query
143
159
  // Only include both execution answers if both are provided
@@ -314,17 +330,14 @@ const QuestionsForm = _ref => {
314
330
  }
315
331
  }
316
332
  }
317
- }, [isLoadingQuestions, durationOptions, execution1Options, execution2Options, execution2AnswerOptions, execution1AnswerOptions, durationQuestion, isFilter]);
318
- if (questionsError === _constants__.API_ERROR_CODES.notFound || questionsError === _constants__.API_ERROR_CODES.notFoundAldoc) {
319
- return /*#__PURE__*/_react.default.createElement(_reactRouter.Redirect, {
320
- to: "/configurator?notFound=true"
321
- });
322
- }
323
- if (questionsError) {
324
- return /*#__PURE__*/_react.default.createElement(_reactRouter.Redirect, {
325
- to: "/configurator?notFound=true"
333
+ }, [isLoadingQuestions, durationOptions, execution1Options, execution2Options, execution2AnswerOptions, execution1AnswerOptions, durationQuestion, isFilter, questionsError]);
334
+ const isNotFoundQuestionError = questionsError === _constants__.API_ERROR_CODES.notFound || questionsError === _constants__.API_ERROR_CODES.notFoundAldoc;
335
+ const handlePrev = () => {
336
+ dispatch({
337
+ type: _OrderSessionContext.orderSessionActions.CLEAR_ANSWERS
326
338
  });
327
- }
339
+ onPrev();
340
+ };
328
341
  if (isLoadingQuestions) {
329
342
  return /*#__PURE__*/_react.default.createElement("div", {
330
343
  className: (0, _helpers__.withStyle)('card-body__loading')
@@ -332,6 +345,29 @@ const QuestionsForm = _ref => {
332
345
  title: 'Zoeken naar mogelijke opties'
333
346
  }));
334
347
  }
348
+ if (isNotFoundQuestionError) {
349
+ return /*#__PURE__*/_react.default.createElement(_reactRouter.Redirect, {
350
+ to: notFoundRedirectTarget
351
+ });
352
+ }
353
+ if (questionsError) {
354
+ return /*#__PURE__*/_react.default.createElement("div", {
355
+ className: (0, _helpers__.withStyle)('card-body')
356
+ }, /*#__PURE__*/_react.default.createElement("div", {
357
+ className: (0, _helpers__.withStyle)('alert alert-danger mb-3')
358
+ }, /*#__PURE__*/_react.default.createElement("small", null, "We konden de voertuiggegevens tijdelijk niet ophalen. Probeer het opnieuw.")), /*#__PURE__*/_react.default.createElement("div", {
359
+ className: (0, _helpers__.withStyle)('row align-items-center justify-content-end')
360
+ }, /*#__PURE__*/_react.default.createElement("div", {
361
+ className: (0, _helpers__.withStyle)("col col-sm-auto mt-1")
362
+ }, /*#__PURE__*/_react.default.createElement("div", {
363
+ className: (0, _helpers__.withStyle)('d-grid gap-2')
364
+ }, /*#__PURE__*/_react.default.createElement(_LinkButton.default, {
365
+ type: "button",
366
+ isDisabled: false,
367
+ onClick: handlePrev,
368
+ label: 'Ga terug'
369
+ })))));
370
+ }
335
371
  if (!(durationOptions !== null && durationOptions !== void 0 && durationOptions.length) && !(execution1Options !== null && execution1Options !== void 0 && execution1Options.length) && !(execution2Options !== null && execution2Options !== void 0 && execution2Options.length) && !(execution2AnswerOptions !== null && execution2AnswerOptions !== void 0 && execution2AnswerOptions.length) && !(execution1AnswerOptions !== null && execution1AnswerOptions !== void 0 && execution1AnswerOptions.length) && !(durationQuestion !== null && durationQuestion !== void 0 && durationQuestion.length)) {
336
372
  if (!isFilter) {
337
373
  return /*#__PURE__*/_react.default.createElement(_reactRouter.Redirect, {
@@ -339,12 +375,6 @@ const QuestionsForm = _ref => {
339
375
  });
340
376
  }
341
377
  }
342
- const handlePrev = () => {
343
- dispatch({
344
- type: _OrderSessionContext.orderSessionActions.CLEAR_ANSWERS
345
- });
346
- onPrev();
347
- };
348
378
  const handleDurationChange = value => {
349
379
  if (isFilter) {
350
380
  setFilterAnswers(prev => _objectSpread(_objectSpread({}, prev), {}, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thm-p3-configurator",
3
- "version": "0.0.352",
3
+ "version": "0.0.353",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "author": "EnoRm.",