thm-p3-configurator 0.0.352 → 0.0.354

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,12 +476,17 @@ 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)();
480
- const orderQueryKey = (0, _queryKeyFactory.getOrderQueryKey)(normalizedOrderParams);
482
+ const isSessionContextReady = (0, _useSessionContextReady.useSessionContextReady)();
483
+ const orderQueryKey = APP_CONFIG.internal ? [...(0, _queryKeyFactory.getOrderQueryKey)(normalizedOrderParams), initialized, authenticated, isSessionContextReady] : (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);
483
486
  const orderQuery = (0, _reactQuery.useQuery)(orderQueryKey, {
487
+ // Internal embedded routes may resolve before the session context sync
488
+ // finishes. Include sync state in the query key so the order refetches
489
+ // automatically once the session context is ready.
484
490
  enabled: hasOrderInput && (!APP_CONFIG.internal || initialized),
485
491
  keepPreviousData: true,
486
492
  queryFn: async () => {
@@ -115,7 +115,7 @@ const BottomNavigationBar = () => {
115
115
  }, /*#__PURE__*/_react.default.createElement("div", {
116
116
  className: (0, _helpers__.withStyle)('row justify-content-center')
117
117
  }, buttons.map(_ref2 => {
118
- var _history$location3;
118
+ var _history$location3, _history$location4;
119
119
  let {
120
120
  to,
121
121
  label,
@@ -137,7 +137,7 @@ const BottomNavigationBar = () => {
137
137
  to = '/configurator/gegevens';
138
138
  }
139
139
  return /*#__PURE__*/_react.default.createElement("div", {
140
- key: 'link-' + label,
140
+ key: "link-".concat(history === null || history === void 0 || (_history$location3 = history.location) === null || _history$location3 === void 0 ? void 0 : _history$location3.pathname, "-").concat(label, "-").concat(to, "-").concat(type),
141
141
  className: (0, _helpers__.withStyle)("col-12 col-sm-auto d-flex order-2 order-sm-0 justify-content-".concat(buttons.length > 1 ? 'center' : 'end', " mt-1"))
142
142
  }, /*#__PURE__*/_react.default.createElement(ButtonByType, _extends({}, setType && {
143
143
  onClick: () => {
@@ -155,7 +155,7 @@ const BottomNavigationBar = () => {
155
155
  state: {
156
156
  prevPathName: history.location.pathname
157
157
  },
158
- isDisabled: (!selectedCableset || !selectedTowbar) && !selectedCombiset && type === 'next' || type === 'next' && (history === null || history === void 0 || (_history$location3 = history.location) === null || _history$location3 === void 0 ? void 0 : _history$location3.pathname) === '/configurator/montagelocatie' && !selectedBranch
158
+ isDisabled: (!selectedCableset || !selectedTowbar) && !selectedCombiset && type === 'next' || type === 'next' && (history === null || history === void 0 || (_history$location4 = history.location) === null || _history$location4 === void 0 ? void 0 : _history$location4.pathname) === '/configurator/montagelocatie' && !selectedBranch
159
159
  })));
160
160
  })))))));
161
161
  };
@@ -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");
@@ -22,9 +30,11 @@ var _PrimaryButton = _interopRequireDefault(require("../__components__/Buttons/P
22
30
  var _RadioInput = _interopRequireDefault(require("../__components__/Form/RadioInput"));
23
31
  var _TextSpinner = _interopRequireDefault(require("../__components__/Spinners/TextSpinner"));
24
32
  var _constants__ = require("../__constants__");
33
+ var _AuthSessionContext = require("../__context__/AuthSessionContext");
25
34
  var _FormulaContext = require("../__context__/FormulaContext");
26
35
  var _OrderSessionContext = require("../__context__/OrderSessionContext");
27
36
  var _helpers__ = require("../__helpers__");
37
+ var _useSessionContextReady = require("../__hooks__/useSessionContextReady");
28
38
  function _interopRequireDefault(e) {
29
39
  return e && e.__esModule ? e : {
30
40
  default: e
@@ -134,10 +144,23 @@ const QuestionsForm = _ref => {
134
144
  priceCalculationDate
135
145
  }, dispatch] = (0, _OrderSessionContext.useOrderSession)();
136
146
  let formula = (0, _FormulaContext.useFormula)();
147
+ const {
148
+ authenticated,
149
+ initialized
150
+ } = (0, _AuthSessionContext.useAuthSession)();
151
+ const isSessionContextReady = (0, _useSessionContextReady.useSessionContextReady)();
137
152
  if (isFilter && singleOrderFormulaCode) {
138
153
  formula = singleOrderFormulaCode;
139
154
  }
140
155
  const history = (0, _reactRouter.useHistory)();
156
+ const {
157
+ search
158
+ } = (0, _reactRouter.useLocation)();
159
+ const notFoundRedirectTarget = (0, _react.useMemo)(() => {
160
+ const searchParams = new URLSearchParams(search);
161
+ searchParams.set('notFound', 'true');
162
+ return "/configurator".concat(searchParams.size ? "?".concat(searchParams.toString()) : '');
163
+ }, [search]);
141
164
 
142
165
  // Create a modified version of execution answers for the query
143
166
  // Only include both execution answers if both are provided
@@ -314,17 +337,15 @@ const QuestionsForm = _ref => {
314
337
  }
315
338
  }
316
339
  }
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"
340
+ }, [isLoadingQuestions, durationOptions, execution1Options, execution2Options, execution2AnswerOptions, execution1AnswerOptions, durationQuestion, isFilter, questionsError]);
341
+ const isNotFoundQuestionError = questionsError === _constants__.API_ERROR_CODES.notFound || questionsError === _constants__.API_ERROR_CODES.notFoundAldoc;
342
+ const isWaitingForInternalSessionContext = APP_CONFIG.internal && initialized && authenticated && !isSessionContextReady;
343
+ const handlePrev = () => {
344
+ dispatch({
345
+ type: _OrderSessionContext.orderSessionActions.CLEAR_ANSWERS
326
346
  });
327
- }
347
+ onPrev();
348
+ };
328
349
  if (isLoadingQuestions) {
329
350
  return /*#__PURE__*/_react.default.createElement("div", {
330
351
  className: (0, _helpers__.withStyle)('card-body__loading')
@@ -332,6 +353,36 @@ const QuestionsForm = _ref => {
332
353
  title: 'Zoeken naar mogelijke opties'
333
354
  }));
334
355
  }
356
+ if (isWaitingForInternalSessionContext && isNotFoundQuestionError) {
357
+ return /*#__PURE__*/_react.default.createElement("div", {
358
+ className: (0, _helpers__.withStyle)('card-body__loading')
359
+ }, /*#__PURE__*/_react.default.createElement(_TextSpinner.default, {
360
+ title: 'Zoeken naar mogelijke opties'
361
+ }));
362
+ }
363
+ if (isNotFoundQuestionError) {
364
+ return /*#__PURE__*/_react.default.createElement(_reactRouter.Redirect, {
365
+ to: notFoundRedirectTarget
366
+ });
367
+ }
368
+ if (questionsError) {
369
+ return /*#__PURE__*/_react.default.createElement("div", {
370
+ className: (0, _helpers__.withStyle)('card-body')
371
+ }, /*#__PURE__*/_react.default.createElement("div", {
372
+ className: (0, _helpers__.withStyle)('alert alert-danger mb-3')
373
+ }, /*#__PURE__*/_react.default.createElement("small", null, "We konden de voertuiggegevens tijdelijk niet ophalen. Probeer het opnieuw.")), /*#__PURE__*/_react.default.createElement("div", {
374
+ className: (0, _helpers__.withStyle)('row align-items-center justify-content-end')
375
+ }, /*#__PURE__*/_react.default.createElement("div", {
376
+ className: (0, _helpers__.withStyle)("col col-sm-auto mt-1")
377
+ }, /*#__PURE__*/_react.default.createElement("div", {
378
+ className: (0, _helpers__.withStyle)('d-grid gap-2')
379
+ }, /*#__PURE__*/_react.default.createElement(_LinkButton.default, {
380
+ type: "button",
381
+ isDisabled: false,
382
+ onClick: handlePrev,
383
+ label: 'Ga terug'
384
+ })))));
385
+ }
335
386
  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
387
  if (!isFilter) {
337
388
  return /*#__PURE__*/_react.default.createElement(_reactRouter.Redirect, {
@@ -339,12 +390,6 @@ const QuestionsForm = _ref => {
339
390
  });
340
391
  }
341
392
  }
342
- const handlePrev = () => {
343
- dispatch({
344
- type: _OrderSessionContext.orderSessionActions.CLEAR_ANSWERS
345
- });
346
- onPrev();
347
- };
348
393
  const handleDurationChange = value => {
349
394
  if (isFilter) {
350
395
  setFilterAnswers(prev => _objectSpread(_objectSpread({}, prev), {}, {
@@ -844,7 +844,7 @@ const InternalAppointmentForm = _ref => {
844
844
  form: "quotation",
845
845
  label: "Leasemaatschappij:",
846
846
  errorMessage: errors === null || errors === void 0 ? void 0 : errors['companyName']
847
- }), isCompanyInputFocused && companySearchTerm && companySearchTerm.length >= 3 && businessBranches && businessBranches.length > 0 && /*#__PURE__*/_react.default.createElement("div", {
847
+ }), isCompanyInputFocused && companySearchTerm && companySearchTerm.length >= 3 && branchesByType && branchesByType.length > 0 && /*#__PURE__*/_react.default.createElement("div", {
848
848
  className: (0, _helpers__.withStyle)('dropdown-results position-absolute w-100 border rounded bg-white shadow'),
849
849
  style: {
850
850
  maxHeight: '200px',
@@ -857,9 +857,9 @@ const InternalAppointmentForm = _ref => {
857
857
  onMouseDown: e => {
858
858
  e.preventDefault();
859
859
  }
860
- }, isLoadingBusinessBranches && /*#__PURE__*/_react.default.createElement("div", {
860
+ }, isLoadingBranchesByType && /*#__PURE__*/_react.default.createElement("div", {
861
861
  className: (0, _helpers__.withStyle)('p-2 text-center')
862
- }, /*#__PURE__*/_react.default.createElement("span", null, "Zoeken...")), businessBranches.map(branch => /*#__PURE__*/_react.default.createElement("div", {
862
+ }, /*#__PURE__*/_react.default.createElement("span", null, "Zoeken...")), branchesByType.map(branch => /*#__PURE__*/_react.default.createElement("div", {
863
863
  key: branch.entityId,
864
864
  className: (0, _helpers__.withStyle)('dropdown-item p-2 border-bottom'),
865
865
  style: {
@@ -10,6 +10,7 @@ exports.useFormulaDispatch = exports.useFormula = exports.FormulaController = vo
10
10
  require("core-js/modules/web.dom-collections.iterator.js");
11
11
  var _react = _interopRequireWildcard(require("react"));
12
12
  var _constants__ = require("../__constants__");
13
+ var _AuthSessionContext = require("./AuthSessionContext");
13
14
  function _getRequireWildcardCache(e) {
14
15
  if ("function" != typeof WeakMap) return null;
15
16
  var r = new WeakMap(),
@@ -58,8 +59,15 @@ const FormulaController = _ref => {
58
59
  };
59
60
  exports.FormulaController = FormulaController;
60
61
  const useFormula = () => {
62
+ var _ref2, _ref3, _branch$formule$code, _branch$formule, _branch$formule2;
61
63
  const formulaContext = (0, _react.useContext)(FormulaContext);
62
- return formulaContext;
64
+ const {
65
+ branch
66
+ } = (0, _AuthSessionContext.useAuthSession)();
67
+ if (formulaContext) {
68
+ return formulaContext;
69
+ }
70
+ return (0, _constants__.mapBranchFormulaToConfiguratorFormula)((_ref2 = (_ref3 = (_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 : branch === null || branch === void 0 || (_branch$formule2 = branch.formule) === null || _branch$formule2 === void 0 ? void 0 : _branch$formule2.title) !== null && _ref3 !== void 0 ? _ref3 : branch === null || branch === void 0 ? void 0 : branch.formule) !== null && _ref2 !== void 0 ? _ref2 : branch === null || branch === void 0 ? void 0 : branch.formulaCode);
63
71
  };
64
72
  exports.useFormula = useFormula;
65
73
  const useFormulaDispatch = () => {
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.354",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "author": "EnoRm.",