thm-p3-configurator 0.0.36 → 0.0.38

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.
@@ -69,7 +69,7 @@ const App = () => {
69
69
  (0, _Experiments.default)();
70
70
  });
71
71
  return /*#__PURE__*/_react.default.createElement(_SentryWrapper.default, null, /*#__PURE__*/_react.default.createElement(_FormulaContext.FormulaController, {
72
- defaultFormula: _constants__.CONFIGURATOR_FORMULAS.THM
72
+ defaultFormula: _constants__.CONFIGURATOR_FORMULAS.THC
73
73
  }, /*#__PURE__*/_react.default.createElement(_CountryContext.CountryController, {
74
74
  defaultCountry: APP_CONFIG.country
75
75
  }, /*#__PURE__*/_react.default.createElement(_OrderSessionContext.OrderSessionController, null, /*#__PURE__*/_react.default.createElement(_reactQuery.QueryClientProvider, {
@@ -171,7 +171,7 @@ const useProductsQuery = orderParameters => {
171
171
  */
172
172
  exports.useProductsQuery = useProductsQuery;
173
173
  const useQuestionsQuery = questionParams => {
174
- var _questionsQuery$error, _questionsQuery$data$, _questionsQuery$data, _questionsQuery$data$2, _questionsQuery$data2, _questionsQuery$data$3, _questionsQuery$data3;
174
+ var _questionsQuery$data, _questionsQuery$data2, _questionsQuery$data3, _questionsQuery$error, _questionsQuery$data$, _questionsQuery$data4, _questionsQuery$data$2, _questionsQuery$data5, _questionsQuery$data$3, _questionsQuery$data6;
175
175
  const {
176
176
  licensePlate,
177
177
  model
@@ -180,21 +180,27 @@ const useQuestionsQuery = questionParams => {
180
180
  const questionsQuery = (0, _reactQuery.useQuery)(['questions', questionsParamsString], {
181
181
  enabled: (licensePlate === null || licensePlate === void 0 ? void 0 : licensePlate.length) > 5 || !!(model !== null && model !== void 0 && model.length),
182
182
  queryFn: () => _orderApi.orderApi.getOrder(questionsParamsString).then(res => {
183
- var _res$data5, _res$data6, _res$data7;
183
+ var _res$data5, _res$data6, _res$data7, _res$data8, _res$data9, _res$data10;
184
184
  return {
185
- durationQuestion: (0, _helpers__.parseArrayToInputOptions)(res === null || res === void 0 || (_res$data5 = res.data) === null || _res$data5 === void 0 || (_res$data5 = _res$data5.data) === null || _res$data5 === void 0 ? void 0 : _res$data5.durationAnswerOptions),
186
- execution1AnswerOptions: (0, _helpers__.parseArrayToInputOptions)(res === null || res === void 0 || (_res$data6 = res.data) === null || _res$data6 === void 0 || (_res$data6 = _res$data6.data) === null || _res$data6 === void 0 || (_res$data6 = _res$data6.executionAnswerOptions) === null || _res$data6 === void 0 ? void 0 : _res$data6.execution1AnswerOptions),
187
- execution2AnswerOptions: (0, _helpers__.parseArrayToInputOptions)(res === null || res === void 0 || (_res$data7 = res.data) === null || _res$data7 === void 0 || (_res$data7 = _res$data7.data) === null || _res$data7 === void 0 || (_res$data7 = _res$data7.executionAnswerOptions) === null || _res$data7 === void 0 ? void 0 : _res$data7.execution2AnswerOptions)
185
+ execution1Answer: res === null || res === void 0 || (_res$data5 = res.data) === null || _res$data5 === void 0 || (_res$data5 = _res$data5.data) === null || _res$data5 === void 0 || (_res$data5 = _res$data5.answers) === null || _res$data5 === void 0 ? void 0 : _res$data5.execution1,
186
+ execution2Answer: res === null || res === void 0 || (_res$data6 = res.data) === null || _res$data6 === void 0 || (_res$data6 = _res$data6.data) === null || _res$data6 === void 0 || (_res$data6 = _res$data6.answers) === null || _res$data6 === void 0 ? void 0 : _res$data6.execution2,
187
+ durationAnswer: res === null || res === void 0 || (_res$data7 = res.data) === null || _res$data7 === void 0 || (_res$data7 = _res$data7.data) === null || _res$data7 === void 0 || (_res$data7 = _res$data7.answers) === null || _res$data7 === void 0 ? void 0 : _res$data7.duration,
188
+ durationQuestion: (0, _helpers__.parseArrayToInputOptions)(res === null || res === void 0 || (_res$data8 = res.data) === null || _res$data8 === void 0 || (_res$data8 = _res$data8.data) === null || _res$data8 === void 0 ? void 0 : _res$data8.durationAnswerOptions),
189
+ execution1AnswerOptions: (0, _helpers__.parseArrayToInputOptions)(res === null || res === void 0 || (_res$data9 = res.data) === null || _res$data9 === void 0 || (_res$data9 = _res$data9.data) === null || _res$data9 === void 0 || (_res$data9 = _res$data9.executionAnswerOptions) === null || _res$data9 === void 0 ? void 0 : _res$data9.execution1AnswerOptions),
190
+ execution2AnswerOptions: (0, _helpers__.parseArrayToInputOptions)(res === null || res === void 0 || (_res$data10 = res.data) === null || _res$data10 === void 0 || (_res$data10 = _res$data10.data) === null || _res$data10 === void 0 || (_res$data10 = _res$data10.executionAnswerOptions) === null || _res$data10 === void 0 ? void 0 : _res$data10.execution2AnswerOptions)
188
191
  };
189
192
  })
190
193
  });
191
194
  return {
192
195
  isLoadingQuestions: questionsQuery.isFetching,
193
196
  isQuestionsError: questionsQuery.isError,
197
+ execution1Answer: questionsQuery === null || questionsQuery === void 0 || (_questionsQuery$data = questionsQuery.data) === null || _questionsQuery$data === void 0 ? void 0 : _questionsQuery$data.execution1Answer,
198
+ execution2Answer: questionsQuery === null || questionsQuery === void 0 || (_questionsQuery$data2 = questionsQuery.data) === null || _questionsQuery$data2 === void 0 ? void 0 : _questionsQuery$data2.execution2Answer,
199
+ durationAnswer: questionsQuery === null || questionsQuery === void 0 || (_questionsQuery$data3 = questionsQuery.data) === null || _questionsQuery$data3 === void 0 ? void 0 : _questionsQuery$data3.durationAnswer,
194
200
  questionsError: ((_questionsQuery$error = questionsQuery.error) === null || _questionsQuery$error === void 0 || (_questionsQuery$error = _questionsQuery$error.response) === null || _questionsQuery$error === void 0 || (_questionsQuery$error = _questionsQuery$error.data) === null || _questionsQuery$error === void 0 ? void 0 : _questionsQuery$error.code) || questionsQuery.error,
195
- execution1AnswerOptions: (_questionsQuery$data$ = questionsQuery === null || questionsQuery === void 0 || (_questionsQuery$data = questionsQuery.data) === null || _questionsQuery$data === void 0 ? void 0 : _questionsQuery$data.execution1AnswerOptions) !== null && _questionsQuery$data$ !== void 0 ? _questionsQuery$data$ : [],
196
- execution2AnswerOptions: (_questionsQuery$data$2 = questionsQuery === null || questionsQuery === void 0 || (_questionsQuery$data2 = questionsQuery.data) === null || _questionsQuery$data2 === void 0 ? void 0 : _questionsQuery$data2.execution2AnswerOptions) !== null && _questionsQuery$data$2 !== void 0 ? _questionsQuery$data$2 : [],
197
- durationQuestion: (_questionsQuery$data$3 = questionsQuery === null || questionsQuery === void 0 || (_questionsQuery$data3 = questionsQuery.data) === null || _questionsQuery$data3 === void 0 ? void 0 : _questionsQuery$data3.durationQuestion) !== null && _questionsQuery$data$3 !== void 0 ? _questionsQuery$data$3 : []
201
+ execution1AnswerOptions: (_questionsQuery$data$ = questionsQuery === null || questionsQuery === void 0 || (_questionsQuery$data4 = questionsQuery.data) === null || _questionsQuery$data4 === void 0 ? void 0 : _questionsQuery$data4.execution1AnswerOptions) !== null && _questionsQuery$data$ !== void 0 ? _questionsQuery$data$ : [],
202
+ execution2AnswerOptions: (_questionsQuery$data$2 = questionsQuery === null || questionsQuery === void 0 || (_questionsQuery$data5 = questionsQuery.data) === null || _questionsQuery$data5 === void 0 ? void 0 : _questionsQuery$data5.execution2AnswerOptions) !== null && _questionsQuery$data$2 !== void 0 ? _questionsQuery$data$2 : [],
203
+ durationQuestion: (_questionsQuery$data$3 = questionsQuery === null || questionsQuery === void 0 || (_questionsQuery$data6 = questionsQuery.data) === null || _questionsQuery$data6 === void 0 ? void 0 : _questionsQuery$data6.durationQuestion) !== null && _questionsQuery$data$3 !== void 0 ? _questionsQuery$data$3 : []
198
204
  };
199
205
  };
200
206
 
@@ -16,6 +16,7 @@ const ErrorMessage = _ref => {
16
16
  message
17
17
  } = _ref;
18
18
  return /*#__PURE__*/_react.default.createElement("div", {
19
+ name: 'error-message',
19
20
  className: (0, _helpers__.withStyle)('text-danger small')
20
21
  }, message);
21
22
  };
@@ -175,10 +175,10 @@ const AppointmentForm = () => {
175
175
  execution1: executionAnswer1,
176
176
  execution2: executionAnswer2
177
177
  }),
178
- customer: _objectSpread(_objectSpread({}, customer), {}, {
178
+ customer: (0, _helpers__.removeNullishProps)(_objectSpread(_objectSpread({}, customer), {}, {
179
179
  firstName: (customer === null || customer === void 0 ? void 0 : customer.firstName) || '(Onbekend)',
180
180
  lastName: (customer === null || customer === void 0 ? void 0 : customer.lastName) || '(Onbekend)'
181
- }),
181
+ })),
182
182
  formula,
183
183
  branchId: selectedBranch,
184
184
  selectBoardComputerUpdate: selectedBoardComputer != null,
@@ -333,7 +333,7 @@ const AppointmentForm = () => {
333
333
  }), /*#__PURE__*/_react.default.createElement(_PrimaryButton.default, {
334
334
  onClick: handleSubmit,
335
335
  isDisabled: isCreatingAppointmentRequest,
336
- label: 'Afspraak maken'
336
+ label: 'Afspraak maaken'
337
337
  }))));
338
338
  };
339
339
  var _default = exports.default = AppointmentForm;
@@ -25,7 +25,6 @@ var _react = _interopRequireWildcard(require("react"));
25
25
  var _reactRouter = require("react-router");
26
26
  var _yup = require("yup");
27
27
  var _mutations = require("../__api__/mutations");
28
- var _queries = require("../__api__/queries");
29
28
  var _LinkButton = _interopRequireDefault(require("../__components__/Buttons/LinkButton"));
30
29
  var _PrimaryButton = _interopRequireDefault(require("../__components__/Buttons/PrimaryButton"));
31
30
  var _Card = _interopRequireDefault(require("../__components__/Cards/Card"));
@@ -138,18 +137,9 @@ const ExitIntentModal = () => {
138
137
  selectedDiscountedProducts = []
139
138
  }, dispatch] = (0, _OrderSessionContext.useOrderSession)();
140
139
  const formula = (0, _FormulaContext.useFormula)();
141
- const {
142
- vehicleDetails
143
- } = (0, _queries.useProductsQuery)({
144
- licensePlate,
145
- model,
146
- executionAnswer1,
147
- executionAnswer2,
148
- durationAnswer: durationAnswer,
149
- formula,
150
- discountCode,
151
- priceCalculationDate
152
- });
140
+ (0, _react.useEffect)(() => {
141
+ (0, _ui.scrollToFirstErrorMessage)();
142
+ }, [errors]);
153
143
  const handleMouseLeave = event => {
154
144
  if (document.cookie.includes('exitIntentModalShown=true')) {
155
145
  return;
@@ -3,8 +3,10 @@
3
3
  require("core-js/modules/es.regexp.exec.js");
4
4
  require("core-js/modules/es.regexp.to-string.js");
5
5
  require("core-js/modules/es.string.search.js");
6
+ require("core-js/modules/es.weak-map.js");
6
7
  require("core-js/modules/web.dom-collections.iterator.js");
7
8
  require("core-js/modules/web.url-search-params.js");
9
+ require("core-js/modules/es.weak-map.js");
8
10
  Object.defineProperty(exports, "__esModule", {
9
11
  value: true
10
12
  });
@@ -14,7 +16,7 @@ require("core-js/modules/es.regexp.to-string.js");
14
16
  require("core-js/modules/es.string.search.js");
15
17
  require("core-js/modules/web.dom-collections.iterator.js");
16
18
  require("core-js/modules/web.url-search-params.js");
17
- var _react = _interopRequireDefault(require("react"));
19
+ var _react = _interopRequireWildcard(require("react"));
18
20
  var _reactRouter = require("react-router");
19
21
  var _queries = require("../__api__/queries");
20
22
  var _LinkButton = _interopRequireDefault(require("../__components__/Buttons/LinkButton"));
@@ -28,9 +30,35 @@ function _interopRequireDefault(e) {
28
30
  default: e
29
31
  };
30
32
  }
33
+ function _getRequireWildcardCache(e) {
34
+ if ("function" != typeof WeakMap) return null;
35
+ var r = new WeakMap(),
36
+ t = new WeakMap();
37
+ return (_getRequireWildcardCache = function _getRequireWildcardCache(e) {
38
+ return e ? t : r;
39
+ })(e);
40
+ }
41
+ function _interopRequireWildcard(e, r) {
42
+ if (!r && e && e.__esModule) return e;
43
+ if (null === e || "object" != typeof e && "function" != typeof e) return {
44
+ default: e
45
+ };
46
+ var t = _getRequireWildcardCache(r);
47
+ if (t && t.has(e)) return t.get(e);
48
+ var n = {
49
+ __proto__: null
50
+ },
51
+ a = Object.defineProperty && Object.getOwnPropertyDescriptor;
52
+ for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
53
+ var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
54
+ i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u];
55
+ }
56
+ return n.default = e, t && t.set(e, n), n;
57
+ }
31
58
  const ManualSelectionForm = _ref => {
32
59
  let {
33
- onSubmit
60
+ onSubmit,
61
+ initialValues = null
34
62
  } = _ref;
35
63
  const [{
36
64
  brand,
@@ -71,6 +99,19 @@ const ManualSelectionForm = _ref => {
71
99
  history.push("/configurator".concat(searchParams !== null && searchParams !== void 0 && searchParams.size ? "?".concat(searchParams.toString()) : '') // append search params if found
72
100
  );
73
101
  };
102
+ (0, _react.useEffect)(() => {
103
+ if (initialValues) {
104
+ handleBrandChange({
105
+ value: initialValues.brand
106
+ });
107
+ handleBuildYearChange({
108
+ value: initialValues.buildYear
109
+ });
110
+ handleModelChange({
111
+ value: initialValues.model
112
+ });
113
+ }
114
+ }, [initialValues]);
74
115
  const handleBrandChange = brandOption => {
75
116
  dispatch({
76
117
  type: _OrderSessionContext.orderSessionActions.SET_BRAND,
@@ -106,7 +147,10 @@ const ManualSelectionForm = _ref => {
106
147
  noOptionsMessage: "Geen opties beschikbaar",
107
148
  placeholder: "Maak een keuze",
108
149
  onChange: handleBrandChange,
109
- initialValue: !brand ? null : {
150
+ initialValue: !brand ? {
151
+ value: initialValues === null || initialValues === void 0 ? void 0 : initialValues.brand,
152
+ label: initialValues === null || initialValues === void 0 ? void 0 : initialValues.brand
153
+ } : {
110
154
  value: brand,
111
155
  label: brand
112
156
  }
@@ -119,7 +163,10 @@ const ManualSelectionForm = _ref => {
119
163
  noOptionsMessage: "Geen opties beschikbaar",
120
164
  placeholder: "Maak een keuze",
121
165
  onChange: handleBuildYearChange,
122
- initialValue: !buildYear ? null : {
166
+ initialValue: !buildYear ? {
167
+ value: initialValues === null || initialValues === void 0 ? void 0 : initialValues.buildYear,
168
+ label: initialValues === null || initialValues === void 0 ? void 0 : initialValues.buildYear
169
+ } : {
123
170
  value: buildYear,
124
171
  label: buildYear
125
172
  }
@@ -132,7 +179,10 @@ const ManualSelectionForm = _ref => {
132
179
  noOptionsMessage: "Geen opties beschikbaar",
133
180
  placeholder: "Maak een keuze",
134
181
  onChange: handleModelChange,
135
- initialValue: !model ? null : {
182
+ initialValue: !model ? {
183
+ value: initialValues === null || initialValues === void 0 ? void 0 : initialValues.model,
184
+ label: initialValues === null || initialValues === void 0 ? void 0 : initialValues.model
185
+ } : {
136
186
  value: model,
137
187
  label: model
138
188
  }
@@ -203,7 +203,7 @@ const ProductsOverview = () => {
203
203
  key: product.articleNumber,
204
204
  id: product.articleNumber,
205
205
  description: (0, _product.formatHyperDescription)(product === null || product === void 0 ? void 0 : product.description),
206
- title: product === null || product === void 0 ? void 0 : product.title,
206
+ title: product === null || product === void 0 ? void 0 : product.subgroupName,
207
207
  price: product === null || product === void 0 ? void 0 : product.price
208
208
  });
209
209
  }
@@ -212,7 +212,7 @@ const ProductsOverview = () => {
212
212
  hasCheckbox: (productsPerCategory === null || productsPerCategory === void 0 ? void 0 : productsPerCategory.length) > 1,
213
213
  isRecommended: isRecommended,
214
214
  productId: product === null || product === void 0 ? void 0 : product.articleNumber,
215
- productTitle: product === null || product === void 0 ? void 0 : product.title,
215
+ productTitle: product === null || product === void 0 ? void 0 : product.subgroupName,
216
216
  productDescription: product === null || product === void 0 ? void 0 : product.productDescription,
217
217
  productUsps: [{
218
218
  type: 'excl',
@@ -71,6 +71,7 @@ const QuestionsForm = _ref => {
71
71
  isLoadingQuestions,
72
72
  execution1AnswerOptions,
73
73
  execution2AnswerOptions,
74
+ durationAnswer: durationAnswerPrefilled,
74
75
  questionsError,
75
76
  durationQuestion
76
77
  } = (0, _queries.useQuestionsQuery)({
@@ -93,6 +94,19 @@ const QuestionsForm = _ref => {
93
94
  priceCalculationDate
94
95
  }); // Prefetch
95
96
 
97
+ /**
98
+ * @description This hook pre-fills the duration answer, only if it comes pre-filled from the API, and it's not set manually by the user.
99
+ */
100
+ (0, _react.useEffect)(() => {
101
+ if (!durationAnswer && durationAnswerPrefilled && !(durationOptions !== null && durationOptions !== void 0 && durationOptions.length) && !(durationQuestion !== null && durationQuestion !== void 0 && durationQuestion.length)) {
102
+ dispatch({
103
+ type: _OrderSessionContext.orderSessionActions.SET_DURATION_ANSWER,
104
+ payload: {
105
+ answer: durationAnswerPrefilled
106
+ }
107
+ });
108
+ }
109
+ }, [durationOptions, durationAnswerPrefilled, durationQuestion, durationAnswer]);
96
110
  (0, _react.useEffect)(() => {
97
111
  if (durationQuestion !== null && durationQuestion !== void 0 && durationQuestion.length) {
98
112
  dispatch({
@@ -20,7 +20,6 @@ var _react = _interopRequireWildcard(require("react"));
20
20
  var _reactRouter = require("react-router");
21
21
  var _yup = require("yup");
22
22
  var _mutations = require("../__api__/mutations");
23
- var _queries = require("../__api__/queries");
24
23
  var _NavigationButton = _interopRequireDefault(require("../__components__/Buttons/NavigationButton"));
25
24
  var _PrimaryButton = _interopRequireDefault(require("../__components__/Buttons/PrimaryButton"));
26
25
  var _Card = _interopRequireDefault(require("../__components__/Cards/Card"));
@@ -32,6 +31,7 @@ var _FormulaContext = require("../__context__/FormulaContext");
32
31
  var _OrderSessionContext = require("../__context__/OrderSessionContext");
33
32
  var _helpers__ = require("../__helpers__");
34
33
  var _product = require("../__helpers__/product");
34
+ var _ui = require("../__helpers__/ui");
35
35
  function _interopRequireDefault(e) {
36
36
  return e && e.__esModule ? e : {
37
37
  default: e
@@ -138,18 +138,9 @@ const QuotationForm = () => {
138
138
  isCreatingQuotation
139
139
  } = (0, _mutations.useCreateQuotationMutation)();
140
140
  const formula = (0, _FormulaContext.useFormula)();
141
- const {
142
- vehicleDetails,
143
- vehicleLogo
144
- } = (0, _queries.useProductsQuery)({
145
- licensePlate,
146
- model,
147
- executionAnswer1,
148
- executionAnswer2,
149
- durationAnswer: durationAnswer,
150
- formula,
151
- discountCode
152
- });
141
+ (0, _react.useEffect)(() => {
142
+ (0, _ui.scrollToFirstErrorMessage)();
143
+ }, [errors]);
153
144
  const handleSubmit = async () => {
154
145
  try {
155
146
  setErrors(null);
@@ -172,7 +163,7 @@ const QuotationForm = () => {
172
163
  code: discountCode
173
164
  } : null,
174
165
  formula,
175
- customer,
166
+ customer: (0, _helpers__.removeNullishProps)(customer),
176
167
  branchId: selectedBranch,
177
168
  selectBoardComputerUpdate: selectedBoardComputer != null,
178
169
  cart: (0, _product.validateCartInput)([{
@@ -32,7 +32,8 @@ const VehicleData = () => {
32
32
  executionAnswer2,
33
33
  durationAnswer,
34
34
  discountCode,
35
- priceCalculationDate
35
+ priceCalculationDate,
36
+ existingDossierId
36
37
  }] = (0, _OrderSessionContext.useOrderSession)();
37
38
  const formula = (0, _FormulaContext.useFormula)();
38
39
  const {
@@ -71,7 +72,7 @@ const VehicleData = () => {
71
72
  isDisabled: false,
72
73
  label: 'Wijzig voertuig',
73
74
  onClick: () => {
74
- history.push("/configurator".concat(licensePlate ? '' : '/manual'));
75
+ history.push("/configurator".concat(licensePlate ? '' : '/manual', "?persistSession=true"));
75
76
  },
76
77
  className: (0, _helpers__.withStyle)('license-plate__edit link-primary col-12'),
77
78
  type: "button"
@@ -44,6 +44,7 @@ var _FormulaContext = require("../../__context__/FormulaContext");
44
44
  var _OrderSessionContext = require("../../__context__/OrderSessionContext");
45
45
  var _helpers__ = require("../../__helpers__");
46
46
  var _product = require("../../__helpers__/product");
47
+ var _ui = require("../../__helpers__/ui");
47
48
  var _LicensePlateValidator = _interopRequireDefault(require("../../__services__/LicensePlateValidator"));
48
49
  var _LocalStorageWorker = require("../../__services__/LocalStorageWorker");
49
50
  var _InternalAppointmentSuccessModal = _interopRequireDefault(require("./InternalAppointmentSuccessModal"));
@@ -183,18 +184,9 @@ const InternalAppointmentForm = _ref => {
183
184
  } = (0, _queries.useBranchByIdOrWidgetId)(selectedBranch);
184
185
  const history = (0, _reactRouter.useHistory)();
185
186
  const formula = (0, _FormulaContext.useFormula)();
186
- const {
187
- vehicleDetails
188
- } = (0, _queries.useProductsQuery)({
189
- licensePlate,
190
- model,
191
- executionAnswer1,
192
- executionAnswer2,
193
- durationAnswer: durationAnswer,
194
- formula,
195
- discountCode,
196
- priceCalculationDate
197
- });
187
+ (0, _react.useEffect)(() => {
188
+ (0, _ui.scrollToFirstErrorMessage)();
189
+ }, [errors]);
198
190
 
199
191
  /**
200
192
  * @description Handles the validation of the license plate, if the session has not been started with a license plate
@@ -211,7 +203,7 @@ const InternalAppointmentForm = _ref => {
211
203
  const handleSubmit = async () => {
212
204
  try {
213
205
  var _ref2;
214
- setErrors(null);
206
+ setErrors([]);
215
207
 
216
208
  // Note: this does not throw on error.
217
209
  const licensePlateErrors = validateLicensePlate();
@@ -223,9 +215,14 @@ const InternalAppointmentForm = _ref => {
223
215
  }
224
216
 
225
217
  // Note: this throws on error.
226
- internalAppointmentFormSchema.validateSync(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, vehicle), customer), appointment), {}, {
227
- channelType: channel === null || channel === void 0 ? void 0 : channel.channelType,
228
- channelId: channel === null || channel === void 0 ? void 0 : channel.channelId
218
+ internalAppointmentFormSchema.validateSync(_objectSpread(_objectSpread(_objectSpread({}, vehicle), customer), {}, {
219
+ // Note: add string fallback here to prevent null check in Yup throwing weird errors
220
+ // However: dont submit empty strings to the API because the API doesnt accept empty strings in place of `undefined`
221
+ // Rule in custom API: a field can be optional (can be undefined), but once you fill it in with a value, that value has to be truthy.
222
+ date: (appointment === null || appointment === void 0 ? void 0 : appointment.date) || '',
223
+ time: (appointment === null || appointment === void 0 ? void 0 : appointment.time) || '',
224
+ channelType: (channel === null || channel === void 0 ? void 0 : channel.channelType) || '',
225
+ channelId: (channel === null || channel === void 0 ? void 0 : channel.channelId) || ''
229
226
  }), {
230
227
  strict: false,
231
228
  abortEarly: false
@@ -531,7 +528,7 @@ const InternalAppointmentForm = _ref => {
531
528
  initialValue: _licensePlate,
532
529
  name: "licensePlate",
533
530
  onChange: value => _setLicensePlate(value),
534
- isRequired: true,
531
+ isRequired: false,
535
532
  form: "quotation",
536
533
  label: "Kenteken:",
537
534
  errorMessage: errors === null || errors === void 0 ? void 0 : errors['licensePlate']
@@ -573,10 +570,10 @@ const InternalAppointmentForm = _ref => {
573
570
  className: (0, _helpers__.withStyle)('col-12 col-md-6')
574
571
  }, /*#__PURE__*/_react.default.createElement(_TextAreaInput.default, {
575
572
  placeholder: "",
576
- initialValue: appointment === null || appointment === void 0 ? void 0 : appointment.note,
573
+ initialValue: customer === null || customer === void 0 ? void 0 : customer.note,
577
574
  name: "note",
578
575
  onChange: value => dispatch({
579
- type: _OrderSessionContext.orderSessionActions.SET_APPOINTMENT_NOTE,
576
+ type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_NOTE,
580
577
  payload: {
581
578
  note: value
582
579
  }
@@ -601,7 +598,7 @@ const InternalAppointmentForm = _ref => {
601
598
  }), /*#__PURE__*/_react.default.createElement(_PrimaryButton.default, {
602
599
  onClick: handleSubmit,
603
600
  isDisabled: isLoading,
604
- label: 'Afspraak maken'
601
+ label: 'Afspraak maaken'
605
602
  }))), /*#__PURE__*/_react.default.createElement(_InternalAppointmentSuccessModal.default, {
606
603
  isOpen: isSuccess
607
604
  }));
@@ -39,6 +39,7 @@ var _FormulaContext = require("../../__context__/FormulaContext");
39
39
  var _OrderSessionContext = require("../../__context__/OrderSessionContext");
40
40
  var _helpers__ = require("../../__helpers__");
41
41
  var _product = require("../../__helpers__/product");
42
+ var _ui = require("../../__helpers__/ui");
42
43
  var _LicensePlateValidator = _interopRequireDefault(require("../../__services__/LicensePlateValidator"));
43
44
  var _LocalStorageWorker = require("../../__services__/LocalStorageWorker");
44
45
  var _InternalQuotationSuccessModal = _interopRequireDefault(require("./InternalQuotationSuccessModal"));
@@ -167,18 +168,9 @@ const InternalQuotationForm = _ref => {
167
168
  isLoadingMarketingChannels
168
169
  } = (0, _queries.useMarketingChannels)(branchType);
169
170
  const formula = (0, _FormulaContext.useFormula)();
170
- const {
171
- vehicleDetails
172
- } = (0, _queries.useProductsQuery)({
173
- licensePlate,
174
- model,
175
- executionAnswer1,
176
- executionAnswer2,
177
- durationAnswer: durationAnswer,
178
- formula,
179
- discountCode,
180
- priceCalculationDate
181
- });
171
+ (0, _react.useEffect)(() => {
172
+ (0, _ui.scrollToFirstErrorMessage)();
173
+ }, [errors]);
182
174
 
183
175
  /**
184
176
  * @description Handles the validation of the license plate, if the session has not been started with a license plate
@@ -211,8 +203,11 @@ const InternalQuotationForm = _ref => {
211
203
 
212
204
  // Note: this throws on error.
213
205
  internalQuotationFormSchema.validateSync(_objectSpread(_objectSpread(_objectSpread({}, vehicle), customer), {}, {
214
- channelType: channel === null || channel === void 0 ? void 0 : channel.channelType,
215
- channelId: channel === null || channel === void 0 ? void 0 : channel.channelId
206
+ // Note: add string fallback here to prevent null check in Yup throwing weird errors
207
+ // However: dont submit empty strings to the API because the API doesnt accept empty strings in place of `undefined`
208
+ // Rule in custom API: a field can be optional (can be undefined), but once you fill it in with a value, that value has to be truthy.
209
+ channelType: (channel === null || channel === void 0 ? void 0 : channel.channelType) || '',
210
+ channelId: (channel === null || channel === void 0 ? void 0 : channel.channelId) || ''
216
211
  }), {
217
212
  strict: false,
218
213
  abortEarly: false
@@ -411,7 +406,7 @@ const InternalQuotationForm = _ref => {
411
406
  initialValue: _licensePlate,
412
407
  name: "licensePlate",
413
408
  onChange: value => _setLicensePlate(value),
414
- isRequired: true,
409
+ isRequired: false,
415
410
  form: "quotation",
416
411
  label: "Kenteken:",
417
412
  errorMessage: errors === null || errors === void 0 ? void 0 : errors['licensePlate']
@@ -67,7 +67,7 @@ function _toPrimitive(t, r) {
67
67
  * @description Covnerts an existing hyper dossier object into a local order session
68
68
  */
69
69
  const parseDossierToOrderSession = exports.parseDossierToOrderSession = function parseDossierToOrderSession() {
70
- var _dossier$kanaal, _dossier$kanaalPartne, _dossier$vestiging, _dossier$typeEigendom, _Date, _dossier$klant, _dossier$klant2, _dossier$klant3, _dossier$klant4, _dossier$klant5, _dossier$klant6, _dossier$klant7, _dossier$klant8, _dossier$klant9;
70
+ var _dossier$kanaal, _dossier$kanaalPartne, _dossier$kanaalHoofka, _dossier$vestiging, _dossier$typeEigendom, _Date, _dossier$klant, _dossier$klant2, _dossier$klant3, _dossier$klant4, _dossier$klant5, _dossier$klant6, _dossier$klant7, _dossier$klant8, _dossier$klant9;
71
71
  let dossier = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
72
72
  return {
73
73
  licensePlate: dossier === null || dossier === void 0 ? void 0 : dossier.kenteken,
@@ -75,7 +75,7 @@ const parseDossierToOrderSession = exports.parseDossierToOrderSession = function
75
75
  // Note: only fill in when license plate is empty
76
76
  channel: {
77
77
  channelType: dossier === null || dossier === void 0 || (_dossier$kanaal = dossier.kanaal) === null || _dossier$kanaal === void 0 ? void 0 : _dossier$kanaal.entityId,
78
- channelId: dossier === null || dossier === void 0 || (_dossier$kanaalPartne = dossier.kanaalPartner) === null || _dossier$kanaalPartne === void 0 ? void 0 : _dossier$kanaalPartne.entityId
78
+ channelId: (dossier === null || dossier === void 0 || (_dossier$kanaalPartne = dossier.kanaalPartner) === null || _dossier$kanaalPartne === void 0 ? void 0 : _dossier$kanaalPartne.entityId) || (dossier === null || dossier === void 0 || (_dossier$kanaalHoofka = dossier.kanaalHoofkantoor) === null || _dossier$kanaalHoofka === void 0 ? void 0 : _dossier$kanaalHoofka.entityId)
79
79
  },
80
80
  durationAnswer: dossier === null || dossier === void 0 ? void 0 : dossier.looptijd,
81
81
  executionAnswer1: dossier === null || dossier === void 0 ? void 0 : dossier.uitvoeringTrekhaakExecuton1,
@@ -112,10 +112,11 @@ const parseDossierToOrderSession = exports.parseDossierToOrderSession = function
112
112
  appointment: {
113
113
  date: !(dossier !== null && dossier !== void 0 && dossier.geplandeTijd) ? new Date() : new Date().setTime(dossier === null || dossier === void 0 ? void 0 : dossier.geplandeTijd),
114
114
  time: !(dossier !== null && dossier !== void 0 && dossier.geplandeTijd) ? new Date() : (_Date = new Date()) === null || _Date === void 0 ? void 0 : _Date.setTime(dossier === null || dossier === void 0 ? void 0 : dossier.geplandeTijd),
115
- note: dossier === null || dossier === void 0 ? void 0 : dossier.interneOpmerking
115
+ note: dossier === null || dossier === void 0 ? void 0 : dossier.opmerkingKlant
116
116
  },
117
117
  priceCalculationDate: dossier !== null && dossier !== void 0 && dossier.prijsberekeningsdatum ? dossier === null || dossier === void 0 ? void 0 : dossier.prijsberekeningsdatum : new Date().getTime(),
118
118
  customer: {
119
+ note: dossier === null || dossier === void 0 ? void 0 : dossier.opmerkingKlant,
119
120
  firstName: (dossier === null || dossier === void 0 || (_dossier$klant = dossier.klant) === null || _dossier$klant === void 0 ? void 0 : _dossier$klant.firstName) || '',
120
121
  lastName: (dossier === null || dossier === void 0 || (_dossier$klant2 = dossier.klant) === null || _dossier$klant2 === void 0 ? void 0 : _dossier$klant2.lastName) || '',
121
122
  infix: (dossier === null || dossier === void 0 || (_dossier$klant3 = dossier.klant) === null || _dossier$klant3 === void 0 ? void 0 : _dossier$klant3.tussenvoegsel) || '',
@@ -202,7 +202,7 @@ const removeNullishProps = exports.removeNullishProps = function removeNullishPr
202
202
  let object = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
203
203
  return Object.fromEntries(Object.entries(object).filter(_ref3 => {
204
204
  let [key, value] = _ref3;
205
- return value != null;
205
+ return !!value;
206
206
  }));
207
207
  };
208
208
 
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.checkIfMouseOutsideWindow = void 0;
6
+ exports.scrollToFirstErrorMessage = exports.checkIfMouseOutsideWindow = void 0;
7
7
  /**
8
8
  * @description Checks whether the mouse inside the view
9
9
  * @param {Number} mouseY the "Y" coordinate of the mouse
@@ -17,4 +17,23 @@ const checkIfMouseOutsideWindow = _ref => {
17
17
  } = _ref;
18
18
  return mouseY > window.innerHeight - offset || mouseY < offset;
19
19
  };
20
- exports.checkIfMouseOutsideWindow = checkIfMouseOutsideWindow;
20
+
21
+ /**
22
+ * @description Finds the first instance of `error-message` on the DOM and scrolls to it
23
+ */
24
+ exports.checkIfMouseOutsideWindow = checkIfMouseOutsideWindow;
25
+ const scrollToFirstErrorMessage = () => {
26
+ if (typeof window === 'undefined') {
27
+ console.warn("scrollToFirstErrorMessage() should only run in browser");
28
+ return;
29
+ }
30
+ const errorMessage = window.document.querySelector("[name=\"error-message\"]");
31
+ if (!errorMessage) {
32
+ return;
33
+ }
34
+ errorMessage.scrollIntoView({
35
+ behavior: 'smooth',
36
+ block: 'center'
37
+ });
38
+ };
39
+ exports.scrollToFirstErrorMessage = scrollToFirstErrorMessage;
@@ -90,6 +90,7 @@ var _OverviewPage = _interopRequireDefault(require("./OverviewPage"));
90
90
  var _ProductsPage = _interopRequireDefault(require("./ProductsPage"));
91
91
  var _QuotationPage = _interopRequireDefault(require("./QuotationPage"));
92
92
  var _QuotationThanksPage = _interopRequireDefault(require("./QuotationThanksPage"));
93
+ var _internal = require("./internal");
93
94
  function _interopRequireDefault(e) {
94
95
  return e && e.__esModule ? e : {
95
96
  default: e
@@ -101,7 +102,7 @@ const Routes = () => {
101
102
  return /*#__PURE__*/_react.default.createElement(_reactRouterDom.Switch, null, /*#__PURE__*/_react.default.createElement(_reactRouterDom.Route, {
102
103
  exact: true,
103
104
  path: "/",
104
- render: props => /*#__PURE__*/_react.default.createElement(_LicensePlatePage.default, props)
105
+ render: props => /*#__PURE__*/_react.default.createElement(_internal.InternalLicensePlatePage, props)
105
106
  }), /*#__PURE__*/_react.default.createElement(_reactRouterDom.Route, {
106
107
  exact: true,
107
108
  path: "/configurator/geen-producten",
@@ -109,40 +110,44 @@ const Routes = () => {
109
110
  }), /*#__PURE__*/_react.default.createElement(_reactRouterDom.Route, {
110
111
  exact: true,
111
112
  path: "/configurator/montagelocatie",
112
- render: props => /*#__PURE__*/_react.default.createElement(_LocationsPage.default, props)
113
+ render: props => /*#__PURE__*/_react.default.createElement(_internal.InternalLocationsPage, props)
113
114
  }), /*#__PURE__*/_react.default.createElement(_reactRouterDom.Route, {
114
115
  exact: true,
115
116
  path: "/configurator/gegevens/bedankt",
116
- render: props => /*#__PURE__*/_react.default.createElement(_AppointmentThanksPage.default, props)
117
+ render: props => /*#__PURE__*/_react.default.createElement(_internal.InternalAppointmentPage, props)
117
118
  }), /*#__PURE__*/_react.default.createElement(_reactRouterDom.Route, {
118
119
  exact: true,
119
120
  path: "/configurator/offerte/bedankt",
120
121
  render: props => /*#__PURE__*/_react.default.createElement(_QuotationThanksPage.default, props)
121
122
  }), /*#__PURE__*/_react.default.createElement(_reactRouterDom.Route, {
122
123
  path: "/configurator/trekhaakpakket",
123
- render: props => /*#__PURE__*/_react.default.createElement(_ProductsPage.default, null)
124
+ render: props => /*#__PURE__*/_react.default.createElement(_internal.InternalProductsPage, null)
124
125
  }), /*#__PURE__*/_react.default.createElement(_reactRouterDom.Route, {
125
126
  path: "/configurator/manual",
126
- render: props => /*#__PURE__*/_react.default.createElement(_ManualSelectionPage.default, props)
127
+ render: props => /*#__PURE__*/_react.default.createElement(_internal.InternalManualSelectionPage, props)
127
128
  }), /*#__PURE__*/_react.default.createElement(_reactRouterDom.Route, {
128
129
  exact: true,
129
130
  path: "/configurator/overzicht",
130
- render: props => /*#__PURE__*/_react.default.createElement(_OverviewPage.default, null)
131
+ render: props => /*#__PURE__*/_react.default.createElement(_internal.InternalOverviewPage, null)
131
132
  }), /*#__PURE__*/_react.default.createElement(_reactRouterDom.Route, {
132
133
  exact: true,
133
134
  path: "/configurator/offerte",
134
- render: props => /*#__PURE__*/_react.default.createElement(_QuotationPage.default, null)
135
+ render: props => /*#__PURE__*/_react.default.createElement(_internal.InternalQuotationPage, null)
135
136
  }), /*#__PURE__*/_react.default.createElement(_reactRouterDom.Route, {
136
137
  exact: true,
137
138
  path: "/configurator/gegevens",
138
- render: props => /*#__PURE__*/_react.default.createElement(_AppointmentPage.default, null)
139
+ render: props => /*#__PURE__*/_react.default.createElement(_internal.InternalAppointmentPage, null)
139
140
  }), /*#__PURE__*/_react.default.createElement(_reactRouterDom.Route, {
140
141
  exact: true,
141
142
  path: "/configurator/toebehoren",
142
- render: props => /*#__PURE__*/_react.default.createElement(_ExtraProductsPage.default, null)
143
+ render: props => /*#__PURE__*/_react.default.createElement(_internal.InternalExtraProductsPage, null)
144
+ }), /*#__PURE__*/_react.default.createElement(_reactRouterDom.Route, {
145
+ exact: true,
146
+ path: "/configurator/:id",
147
+ render: props => /*#__PURE__*/_react.default.createElement(_internal.InternalSessionEditPage, props)
143
148
  }), /*#__PURE__*/_react.default.createElement(_reactRouterDom.Route, {
144
149
  path: "/configurator",
145
- render: props => /*#__PURE__*/_react.default.createElement(_LicensePlatePage.default, null)
150
+ render: props => /*#__PURE__*/_react.default.createElement(_internal.InternalLicensePlatePage, null)
146
151
  }), /*#__PURE__*/_react.default.createElement(_reactRouterDom.Route, {
147
152
  path: "/niet-gevonden",
148
153
  render: () => /*#__PURE__*/_react.default.createElement(_NotFoundPage.default, null)
@@ -70,9 +70,10 @@ const getSteps = _ref => {
70
70
  const licensePlateValidator = new _LicensePlateValidator.default();
71
71
  const InternalLicensePlatePage = () => {
72
72
  const [activeStep, setActiveStep] = (0, _react.useState)(0);
73
- const [_, dispatch] = (0, _OrderSessionContext.useOrderSession)();
73
+ const [session, dispatch] = (0, _OrderSessionContext.useOrderSession)();
74
+ const originalLicensePlate = (0, _react.useRef)();
74
75
  const formula = (0, _FormulaContext.useFormula)();
75
- const [licensePlateURL, discountCode] = (0, _useSearchParam.default)(['licensePlate', 'discountCode']);
76
+ const [licensePlateURL, discountCode, persistSession] = (0, _useSearchParam.default)(['licensePlate', 'discountCode', 'persistSession']);
76
77
  const history = (0, _reactRouter.useHistory)();
77
78
  (0, _queries.useProductFieldLabels)(); // Prefetch
78
79
 
@@ -85,6 +86,11 @@ const InternalLicensePlatePage = () => {
85
86
  const handleSubmit = () => {
86
87
  history.push('/configurator/trekhaakpakket');
87
88
  };
89
+ (0, _react.useEffect)(() => {
90
+ if (!originalLicensePlate.current && session !== null && session !== void 0 && session.licensePlate) {
91
+ originalLicensePlate.current = session.licensePlate;
92
+ }
93
+ }, [session]);
88
94
  (0, _react.useEffect)(() => {
89
95
  // If no license plate was found: initialize a new order
90
96
  if (!licensePlateURL) {
@@ -109,11 +115,11 @@ const InternalLicensePlatePage = () => {
109
115
  }
110
116
  }, [discountCode]);
111
117
  const Steps = (0, _react.useMemo)(() => getSteps({
112
- initialLicensePlate: licensePlateValidator.init(licensePlateURL),
118
+ initialLicensePlate: persistSession === 'true' ? originalLicensePlate.current : licensePlateValidator.init(licensePlateURL),
113
119
  onNext: handleNext,
114
120
  onPrev: handlePrev,
115
121
  onSubmit: handleSubmit
116
- }), []);
122
+ }), [persistSession, originalLicensePlate.current]);
117
123
  return /*#__PURE__*/_react.default.createElement("div", {
118
124
  className: (0, _helpers__.withStyle)('vh-100')
119
125
  }, /*#__PURE__*/_react.default.createElement(_internal.InternalCancelDossierEdit, null), /*#__PURE__*/_react.default.createElement("section", {
@@ -55,23 +55,39 @@ const getSteps = _ref => {
55
55
  let {
56
56
  onNext,
57
57
  onPrev,
58
- onSubmit
58
+ onSubmit,
59
+ initialValues
59
60
  } = _ref;
60
61
  return [/*#__PURE__*/_react.default.createElement(_ManualSelectionForm.default, {
61
- onSubmit: onNext
62
+ onSubmit: onNext,
63
+ initialValues: initialValues
62
64
  }), /*#__PURE__*/_react.default.createElement(_QuestionsForm.default, {
63
65
  onPrev: onPrev,
64
66
  onSubmit: onSubmit
65
67
  })];
66
68
  };
67
69
  const InternalManualSelectionPage = () => {
68
- const [_, dispatch] = (0, _OrderSessionContext.useOrderSession)();
70
+ const [{
71
+ brand,
72
+ model,
73
+ buildYear
74
+ }, dispatch] = (0, _OrderSessionContext.useOrderSession)();
69
75
  const [activeStep, setActiveStep] = (0, _react.useState)(0);
76
+ const originalVehicle = (0, _react.useRef)();
70
77
  const history = (0, _reactRouter.useHistory)();
71
78
  const formula = (0, _FormulaContext.useFormula)();
72
- const [discountCode] = (0, _useSearchParam.default)(['discountCode']);
79
+ const [discountCode, persistSession] = (0, _useSearchParam.default)(['discountCode', 'persistSession']);
73
80
  (0, _queries.useProductFieldLabels)(); // Prefetch
74
81
 
82
+ (0, _react.useEffect)(() => {
83
+ if (!(originalVehicle !== null && originalVehicle !== void 0 && originalVehicle.current)) {
84
+ originalVehicle.current = {
85
+ brand,
86
+ model,
87
+ buildYear
88
+ };
89
+ }
90
+ }, [brand, model, buildYear]);
75
91
  (0, _react.useEffect)(() => {
76
92
  dispatch({
77
93
  type: _OrderSessionContext.orderSessionActions.INITIALIZE_NEW_ORDER,
@@ -100,10 +116,15 @@ const InternalManualSelectionPage = () => {
100
116
  history.push('/configurator/trekhaakpakket');
101
117
  };
102
118
  const Steps = (0, _react.useMemo)(() => getSteps({
119
+ initialValues: persistSession ? originalVehicle.current : {
120
+ brand: null,
121
+ model: null,
122
+ buildYear: null
123
+ },
103
124
  onNext: handleNext,
104
125
  onPrev: handlePrev,
105
126
  onSubmit: handleSubmit
106
- }), []);
127
+ }), [persistSession, originalVehicle.current]);
107
128
  return /*#__PURE__*/_react.default.createElement("div", {
108
129
  className: (0, _helpers__.withStyle)('vh-100')
109
130
  }, /*#__PURE__*/_react.default.createElement(_internal.InternalCancelDossierEdit, null), /*#__PURE__*/_react.default.createElement("section", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thm-p3-configurator",
3
- "version": "0.0.36",
3
+ "version": "0.0.38",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "author": "EnoRm.",