thm-p3-configurator 0.0.56 → 0.0.58

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.
@@ -50,9 +50,18 @@ const authenticatedProxyApi = exports.authenticatedProxyApi = {
50
50
  getMyProfile: () => authenticateClient('api/v1/profile', {
51
51
  method: 'GET'
52
52
  }),
53
+ getBranchTypes: () => authenticateClient("api/v1/branch-types", {
54
+ method: 'GET'
55
+ }),
53
56
  getMyBranchesByFormula: formula => authenticateClient("api/v1/profile/".concat(formula, "/branches"), {
54
57
  method: 'GET'
55
58
  }),
59
+ getSingleOrderBranchTypes: branchTypesParamsString => authenticateClient("api/v1/branch-types?".concat(branchTypesParamsString), {
60
+ method: 'GET'
61
+ }),
62
+ getSingleOrderBranches: branchesParamsString => authenticateClient("api/v1/branches?".concat(branchesParamsString), {
63
+ method: 'GET'
64
+ }),
56
65
  getBranchById: id => authenticateClient("api/v1/branches/".concat(id), {
57
66
  method: 'GET'
58
67
  }),
@@ -101,7 +101,9 @@ const useCreateSingleOrderMutation = () => {
101
101
  customer,
102
102
  formula,
103
103
  branchId,
104
- channel
104
+ channel,
105
+ preferredDateTime,
106
+ internalNote
105
107
  } = _ref3;
106
108
  return _authenticatedProxyApi.authenticatedProxyApi.postSingleOrder({
107
109
  licensePlate,
@@ -110,7 +112,9 @@ const useCreateSingleOrderMutation = () => {
110
112
  customer,
111
113
  formula,
112
114
  branchId,
113
- channel
115
+ channel,
116
+ preferredDateTime,
117
+ internalNote
114
118
  });
115
119
  });
116
120
  return {
@@ -1,11 +1,9 @@
1
1
  "use strict";
2
2
 
3
- require("core-js/modules/es.promise.js");
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.orderApi = void 0;
8
- require("core-js/modules/es.promise.js");
9
7
  var _axios = _interopRequireDefault(require("axios"));
10
8
  var _index = require("../__constants__/index.js");
11
9
  var _LocalStorageWorker = require("../__services__/LocalStorageWorker.js");
@@ -31,18 +29,6 @@ orderClient.interceptors.request.use(config => {
31
29
  config.headers.Authorization = "Bearer ".concat(authSession === null || authSession === void 0 ? void 0 : authSession.accessToken);
32
30
  return config;
33
31
  });
34
-
35
- // Add response interceptor to log 4xx errors
36
- orderClient.interceptors.response.use(response => response, error => {
37
- if (error.response && error.response.status >= 400 && error.response.status < 500) {
38
- console.error('4xx Error Response:', {
39
- status: error.response.status,
40
- url: error.config.url,
41
- data: error.response.data
42
- });
43
- }
44
- return Promise.reject(error);
45
- });
46
32
  const orderApi = exports.orderApi = {
47
33
  getOrder: orderParameters => orderClient("api".concat(APP_CONFIG.internal ? '' : '/public', "/order?").concat(orderParameters) // Remove the `/public` param if the configurator is internal,
48
34
  ),
@@ -16,7 +16,7 @@ require("core-js/modules/esnext.iterator.for-each.js");
16
16
  Object.defineProperty(exports, "__esModule", {
17
17
  value: true
18
18
  });
19
- exports.useSingleOrderCart = exports.useSingleOrderArticles = exports.useQuestionsQuery = exports.useProductsQuery = exports.useProductFieldLabels = exports.usePrivateDossierByTypeAndIdQuery = exports.useMyBranches = exports.useModelsQuery = exports.useMarketingChannels = exports.useBuildYearsQuery = exports.useBrandsQuery = exports.useBranchesQuery = exports.useBranchTypes = exports.useBranchByIdOrWidgetId = exports.useArticleTypes = exports.useArticleSubGroups = exports.useArticleGroups = exports.useActiveDiscounts = void 0;
19
+ exports.useSingleOrderCart = exports.useSingleOrderBranchesQuery = exports.useSingleOrderBranchTypes = exports.useSingleOrderArticles = exports.useQuestionsQuery = exports.useProductsQuery = exports.useProductFieldLabels = exports.usePrivateDossierByTypeAndIdQuery = exports.useMyBranches = exports.useModelsQuery = exports.useMarketingChannels = exports.useBuildYearsQuery = exports.useBrandsQuery = exports.useBranchesQuery = exports.useBranchTypes = exports.useBranchByIdOrWidgetId = exports.useArticleTypes = exports.useArticleSubGroups = exports.useArticleGroups = exports.useActiveDiscounts = void 0;
20
20
  require("core-js/modules/es.symbol.description.js");
21
21
  require("core-js/modules/es.json.stringify.js");
22
22
  require("core-js/modules/es.object.from-entries.js");
@@ -430,14 +430,30 @@ const useQuestionsQuery = questionParams => {
430
430
  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 : []
431
431
  };
432
432
  };
433
-
433
+ exports.useQuestionsQuery = useQuestionsQuery;
434
+ const useSingleOrderBranchesQuery = branchesParams => {
435
+ var _branchesParams;
436
+ branchesParams = _objectSpread(_objectSpread({}, branchesParams), {}, {
437
+ type: 'single-order'
438
+ });
439
+ const branchesParamsString = new URLSearchParams((0, _helpers__.removeNullishProps)(branchesParams)).toString();
440
+ const branchesQuery = (0, _reactQuery.useQuery)(['single-order-branches', branchesParamsString], {
441
+ queryFn: () => _authenticatedProxyApi.authenticatedProxyApi.getSingleOrderBranches(branchesParamsString).then(res => res.data),
442
+ enabled: !!((_branchesParams = branchesParams) !== null && _branchesParams !== void 0 && _branchesParams.branchTypeId)
443
+ });
444
+ return {
445
+ isLoadingSingleOrderBranches: branchesQuery.isLoading,
446
+ isSingleOrderBranchesError: branchesQuery.isError,
447
+ singleOrderBranches: branchesQuery === null || branchesQuery === void 0 ? void 0 : branchesQuery.data
448
+ };
449
+ };
434
450
  /**
435
451
  * @description Retrieves the branches
436
452
  */
437
- exports.useQuestionsQuery = useQuestionsQuery;
453
+ exports.useSingleOrderBranchesQuery = useSingleOrderBranchesQuery;
438
454
  const useBranchesQuery = branchesParams => {
439
455
  const branchesParamsString = new URLSearchParams((0, _helpers__.removeNullishProps)(branchesParams)).toString();
440
- const branchesQuery = (0, _reactQuery.useQuery)(['branches', branchesParamsString], {
456
+ const branchesQuery = (0, _reactQuery.useQuery)(['branches-test', branchesParamsString], {
441
457
  queryFn: () => _publicProxyApi.publicProxyApi.getBranches(branchesParamsString).then(res => res.data)
442
458
  });
443
459
  return {
@@ -481,11 +497,26 @@ const useMyBranches = formula => {
481
497
  myBranches: (_myBranchesQuery$data = myBranchesQuery === null || myBranchesQuery === void 0 ? void 0 : myBranchesQuery.data) !== null && _myBranchesQuery$data !== void 0 ? _myBranchesQuery$data : []
482
498
  };
483
499
  };
484
-
500
+ exports.useMyBranches = useMyBranches;
501
+ const useSingleOrderBranchTypes = branchTypesParams => {
502
+ branchTypesParams = _objectSpread(_objectSpread({}, branchTypesParams), {}, {
503
+ type: 'single-order'
504
+ });
505
+ const branchTypesParamsString = new URLSearchParams((0, _helpers__.removeNullishProps)(branchTypesParams)).toString();
506
+ const singleOrderBranchTypesQuery = (0, _reactQuery.useQuery)({
507
+ queryKey: ['single-order-branch-types', branchTypesParamsString],
508
+ queryFn: () => _authenticatedProxyApi.authenticatedProxyApi.getSingleOrderBranchTypes(branchTypesParamsString).then(res => res.data)
509
+ });
510
+ return {
511
+ isLoadingSingleOrderBranchTypes: singleOrderBranchTypesQuery.isLoading,
512
+ singleOrderBranchTypesError: singleOrderBranchTypesQuery.isError,
513
+ singleOrderBranchTypes: singleOrderBranchTypesQuery === null || singleOrderBranchTypesQuery === void 0 ? void 0 : singleOrderBranchTypesQuery.data
514
+ };
515
+ };
485
516
  /**
486
517
  * @description Query the branch type mappings from hyper, returns the value normalized
487
518
  */
488
- exports.useMyBranches = useMyBranches;
519
+ exports.useSingleOrderBranchTypes = useSingleOrderBranchTypes;
489
520
  const useBranchTypes = () => {
490
521
  var _branchTypesQuery$dat;
491
522
  const branchTypesQuery = (0, _reactQuery.useQuery)({
@@ -40,10 +40,11 @@ const LinkButton = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
40
40
  type = 'button',
41
41
  isDisabled,
42
42
  onClick,
43
- label
43
+ label,
44
+ className = ''
44
45
  } = _ref;
45
46
  return /*#__PURE__*/_react.default.createElement("button", {
46
- className: (0, _helpers__.withStyle)("btn btn-link p-0"),
47
+ className: (0, _helpers__.withStyle)("btn btn-link p-0 ".concat(className)),
47
48
  type: type,
48
49
  ref: ref,
49
50
  disabled: isDisabled,
@@ -95,7 +95,7 @@ function _toPrimitive(t, r) {
95
95
  }
96
96
  const DropdownInput = _ref => {
97
97
  let {
98
- options,
98
+ options = [],
99
99
  name,
100
100
  label,
101
101
  isRequired,
@@ -110,21 +110,25 @@ const DropdownInput = _ref => {
110
110
  isClearable = false
111
111
  } = _ref;
112
112
  const [value, setValue] = (0, _react.useState)(() => {
113
- if (initialValue) {
114
- const matchingOption = options.find(opt => opt.value === initialValue);
115
- return matchingOption || null;
113
+ if (!initialValue || !(options !== null && options !== void 0 && options.length)) return null;
114
+ if (typeof initialValue === 'object' && initialValue.value && initialValue.label) {
115
+ return initialValue;
116
116
  }
117
- return null;
117
+ return options.find(opt => opt.value === initialValue) || null;
118
118
  });
119
119
  const lgSize = window.matchMedia('(min-width: 960px)');
120
120
  const xxlSize = window.matchMedia('(min-width: 1440px)');
121
121
  (0, _react.useEffect)(() => {
122
- if (initialValue === '' || initialValue === null) {
122
+ if (!initialValue || !(options !== null && options !== void 0 && options.length)) {
123
123
  setValue(null);
124
- } else {
125
- const matchingOption = options.find(opt => opt.value === initialValue);
126
- setValue(matchingOption || null);
124
+ return;
127
125
  }
126
+ if (typeof initialValue === 'object' && initialValue.value && initialValue.label) {
127
+ setValue(initialValue);
128
+ return;
129
+ }
130
+ const matchingOption = options.find(opt => opt.value === initialValue);
131
+ setValue(matchingOption || null);
128
132
  }, [initialValue, options]);
129
133
  const handleChange = option => {
130
134
  setValue(option);
@@ -17,7 +17,8 @@ function _interopRequireDefault(e) {
17
17
  }
18
18
  const Header = _ref => {
19
19
  let {
20
- title
20
+ title,
21
+ subtitle = ''
21
22
  } = _ref;
22
23
  const formula = (0, _FormulaContext.useFormula)();
23
24
  return /*#__PURE__*/_react.default.createElement("div", {
@@ -34,6 +35,8 @@ const Header = _ref => {
34
35
  alt: "Trekhaak Montage"
35
36
  }), /*#__PURE__*/_react.default.createElement("div", {
36
37
  className: (0, _helpers__.withStyle)('hero__inner d-none d-lg-block')
37
- }, /*#__PURE__*/_react.default.createElement("h2", null, (title === null || title === void 0 ? void 0 : title.length) > 0 ? title : 'Trekhaak offerte opstellen'))))));
38
+ }, /*#__PURE__*/_react.default.createElement("h2", null, (title === null || title === void 0 ? void 0 : title.length) > 0 ? title : 'Trekhaak offerte opstellen'), (subtitle === null || subtitle === void 0 ? void 0 : subtitle.length) > 0 && /*#__PURE__*/_react.default.createElement("p", {
39
+ className: (0, _helpers__.withStyle)('hero__subtitle')
40
+ }, subtitle))))));
38
41
  };
39
42
  var _default = exports.default = Header;
@@ -29,8 +29,11 @@ var _helpers__ = require("../../__helpers__");
29
29
  var _LocalStorageWorker = require("../../__services__/LocalStorageWorker");
30
30
  var _LinkButton = _interopRequireDefault(require("../Buttons/LinkButton"));
31
31
  var _CardWide = _interopRequireDefault(require("../Cards/CardWide"));
32
+ var _DatePickerInput = _interopRequireDefault(require("../Form/DatePickerInput"));
32
33
  var _DropdownInput = _interopRequireDefault(require("../Form/DropdownInput"));
34
+ var _TextAreaInput = _interopRequireDefault(require("../Form/TextAreaInput"));
33
35
  var _TextInput = _interopRequireDefault(require("../Form/TextInput"));
36
+ var _TimePickerInput = _interopRequireDefault(require("../Form/TimePickerInput"));
34
37
  function _interopRequireDefault(e) {
35
38
  return e && e.__esModule ? e : {
36
39
  default: e
@@ -111,10 +114,13 @@ const customerDetailsFormSchema = (0, _yup.object)({
111
114
  infix: (0, _yup.string)().nullable(),
112
115
  lastName: (0, _yup.string)().required(_constants__.FORM_ERROR_MESSAGES.required),
113
116
  email: (0, _yup.string)().email(_constants__.FORM_ERROR_MESSAGES.email).required(_constants__.FORM_ERROR_MESSAGES.required),
114
- phoneNumber: (0, _yup.string)().required(_constants__.FORM_ERROR_MESSAGES.required)
117
+ phoneNumber: (0, _yup.string)().required(_constants__.FORM_ERROR_MESSAGES.required),
118
+ date: (0, _yup.string)().nullable(),
119
+ time: (0, _yup.string)().nullable(),
120
+ internalNote: (0, _yup.string)().nullable()
115
121
  });
116
122
  const InternalCustomerDetailsForm = (_ref, ref) => {
117
- var _branchTypes$byId$aut, _authSession$branch;
123
+ var _branchTypes$byId$aut, _authSession$branch, _marketingChannels$fi;
118
124
  let {
119
125
  errors = {},
120
126
  onValidationError,
@@ -123,7 +129,9 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
123
129
  const [{
124
130
  customer,
125
131
  channel,
126
- selectedBranch
132
+ selectedBranch,
133
+ appointment,
134
+ internalNote
127
135
  }, dispatch] = (0, _OrderSessionContext.useOrderSession)();
128
136
  const {
129
137
  branchById
@@ -181,7 +189,7 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
181
189
  (0, _react.useImperativeHandle)(ref, () => ({
182
190
  validateForm
183
191
  }));
184
- return /*#__PURE__*/_react.default.createElement("div", {
192
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
185
193
  className: (0, _helpers__.withStyle)('col-12 mt-2 mb-4')
186
194
  }, /*#__PURE__*/_react.default.createElement(_CardWide.default, null, /*#__PURE__*/_react.default.createElement("div", {
187
195
  className: (0, _helpers__.withStyle)('row')
@@ -204,13 +212,10 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
204
212
  noOptionsMessage: "Geen opties beschikbaar",
205
213
  placeholder: "Maak een keuze",
206
214
  errorMessage: (errors === null || errors === void 0 ? void 0 : errors['channelType']) || (errors === null || errors === void 0 ? void 0 : errors['channelId']),
207
- initialValue: () => {
208
- const foundChannel = marketingChannels.find(marketingC => (marketingC === null || marketingC === void 0 ? void 0 : marketingC.entityId) === (channel === null || channel === void 0 ? void 0 : channel.channelId));
209
- return {
210
- label: foundChannel === null || foundChannel === void 0 ? void 0 : foundChannel.title,
211
- value: foundChannel
212
- };
213
- },
215
+ initialValue: channel !== null && channel !== void 0 && channel.channelId ? {
216
+ label: marketingChannels === null || marketingChannels === void 0 || (_marketingChannels$fi = marketingChannels.find(marketingC => (marketingC === null || marketingC === void 0 ? void 0 : marketingC.entityId) === (channel === null || channel === void 0 ? void 0 : channel.channelId))) === null || _marketingChannels$fi === void 0 ? void 0 : _marketingChannels$fi.title,
217
+ value: marketingChannels === null || marketingChannels === void 0 ? void 0 : marketingChannels.find(marketingC => (marketingC === null || marketingC === void 0 ? void 0 : marketingC.entityId) === (channel === null || channel === void 0 ? void 0 : channel.channelId))
218
+ } : null,
214
219
  onChange: _ref2 => {
215
220
  var _value$kanaalType;
216
221
  let {
@@ -302,6 +307,54 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
302
307
  isRequired: true,
303
308
  label: "Telefoonnummer:",
304
309
  errorMessage: errors === null || errors === void 0 ? void 0 : errors['phoneNumber']
305
- }))));
310
+ })))), /*#__PURE__*/_react.default.createElement("div", {
311
+ className: (0, _helpers__.withStyle)('col-12')
312
+ }, /*#__PURE__*/_react.default.createElement(_CardWide.default, null, /*#__PURE__*/_react.default.createElement("div", {
313
+ className: (0, _helpers__.withStyle)('row')
314
+ }, /*#__PURE__*/_react.default.createElement("h6", {
315
+ className: (0, _helpers__.withStyle)('modal-title col-12 mb-2')
316
+ }, "Gegevens voor de afspraak", /*#__PURE__*/_react.default.createElement("br", null)), /*#__PURE__*/_react.default.createElement("div", {
317
+ className: (0, _helpers__.withStyle)('col-12 col-md-6')
318
+ }, /*#__PURE__*/_react.default.createElement(_DatePickerInput.default, {
319
+ onChange: value => dispatch({
320
+ type: _OrderSessionContext.orderSessionActions.SET_APPOINTMENT_DATE,
321
+ payload: {
322
+ date: value
323
+ }
324
+ }),
325
+ name: 'Datum',
326
+ label: "Datum",
327
+ initialValue: appointment !== null && appointment !== void 0 && appointment.date ? new Date(appointment === null || appointment === void 0 ? void 0 : appointment.date) : null,
328
+ isStrict: false,
329
+ errorMessage: errors === null || errors === void 0 ? void 0 : errors['date']
330
+ }), /*#__PURE__*/_react.default.createElement(_TimePickerInput.default, {
331
+ onChange: value => dispatch({
332
+ type: _OrderSessionContext.orderSessionActions.SET_APPOINTMENT_TIME,
333
+ payload: {
334
+ time: value
335
+ }
336
+ }),
337
+ initialValue: appointment !== null && appointment !== void 0 && appointment.time ? new Date(appointment === null || appointment === void 0 ? void 0 : appointment.time) : null,
338
+ name: 'Tijd',
339
+ label: "Tijd",
340
+ isStrict: false,
341
+ errorMessage: errors === null || errors === void 0 ? void 0 : errors['time']
342
+ })), /*#__PURE__*/_react.default.createElement("div", {
343
+ className: (0, _helpers__.withStyle)('col-12 col-md-6')
344
+ }, /*#__PURE__*/_react.default.createElement(_TextAreaInput.default, {
345
+ placeholder: "",
346
+ initialValue: internalNote === null || internalNote === void 0 ? void 0 : internalNote.internalNote,
347
+ name: "internalNote",
348
+ onChange: value => dispatch({
349
+ type: _OrderSessionContext.orderSessionActions.SET_INTERNAL_NOTE,
350
+ payload: {
351
+ internalNote: value
352
+ }
353
+ }),
354
+ isRequired: false,
355
+ form: form,
356
+ label: "Eventuele opmerkingen:",
357
+ errorMessage: errors === null || errors === void 0 ? void 0 : errors['internalNote']
358
+ }))))));
306
359
  };
307
360
  var _default = exports.default = /*#__PURE__*/(0, _react.forwardRef)(InternalCustomerDetailsForm);
@@ -129,10 +129,9 @@ const LicensePlateForm = _ref => {
129
129
  }, /*#__PURE__*/_react.default.createElement(_PrimaryButton.default, {
130
130
  className: (0, _helpers__.withStyle)('btn btn-primary'),
131
131
  type: "button",
132
- onClick: () => onSubmit(isFilter ? {
133
- value: filterLicensePlate,
134
- type: 'licenseplate'
135
- } : undefined),
132
+ onClick: () => {
133
+ onSubmit(isFilter ? filterLicensePlate : undefined);
134
+ },
136
135
  isDisabled: !isFilter ? !licensePlate || licensePlate.length < 6 : false,
137
136
  label: isFilter ? 'Filteren' : 'Volgende'
138
137
  })))));
@@ -223,7 +223,7 @@ const ManualSelectionForm = _ref => {
223
223
  type: 'model'
224
224
  } : undefined),
225
225
  isDisabled: !model && !isFilter,
226
- label: isFilter ? 'Filter' : 'Sluiten'
226
+ label: isFilter ? 'Filter' : 'Volgende'
227
227
  })))));
228
228
  };
229
229
  var _default = exports.default = ManualSelectionForm;
@@ -1,8 +1,14 @@
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/web.dom-collections.iterator.js");
5
8
  require("core-js/modules/es.weak-map.js");
9
+ require("core-js/modules/esnext.iterator.constructor.js");
10
+ require("core-js/modules/esnext.iterator.filter.js");
11
+ require("core-js/modules/esnext.iterator.for-each.js");
6
12
  Object.defineProperty(exports, "__esModule", {
7
13
  value: true
8
14
  });
@@ -49,11 +55,61 @@ function _interopRequireWildcard(e, r) {
49
55
  }
50
56
  return n.default = e, t && t.set(e, n), n;
51
57
  }
58
+ function ownKeys(e, r) {
59
+ var t = Object.keys(e);
60
+ if (Object.getOwnPropertySymbols) {
61
+ var o = Object.getOwnPropertySymbols(e);
62
+ r && (o = o.filter(function (r) {
63
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
64
+ })), t.push.apply(t, o);
65
+ }
66
+ return t;
67
+ }
68
+ function _objectSpread(e) {
69
+ for (var r = 1; r < arguments.length; r++) {
70
+ var t = null != arguments[r] ? arguments[r] : {};
71
+ r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
72
+ _defineProperty(e, r, t[r]);
73
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
74
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
75
+ });
76
+ }
77
+ return e;
78
+ }
79
+ function _defineProperty(e, r, t) {
80
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
81
+ value: t,
82
+ enumerable: !0,
83
+ configurable: !0,
84
+ writable: !0
85
+ }) : e[r] = t, e;
86
+ }
87
+ function _toPropertyKey(t) {
88
+ var i = _toPrimitive(t, "string");
89
+ return "symbol" == typeof i ? i : i + "";
90
+ }
91
+ function _toPrimitive(t, r) {
92
+ if ("object" != typeof t || !t) return t;
93
+ var e = t[Symbol.toPrimitive];
94
+ if (void 0 !== e) {
95
+ var i = e.call(t, r || "default");
96
+ if ("object" != typeof i) return i;
97
+ throw new TypeError("@@toPrimitive must return a primitive value.");
98
+ }
99
+ return ("string" === r ? String : Number)(t);
100
+ }
52
101
  const QuestionsForm = _ref => {
53
102
  let {
54
103
  onPrev = () => {},
55
- onSubmit = () => {}
104
+ onSubmit = () => {},
105
+ isFilter = false,
106
+ initialLicensePlate = null
56
107
  } = _ref;
108
+ const [filterAnswers, setFilterAnswers] = (0, _react.useState)({
109
+ executionAnswer1: '',
110
+ executionAnswer2: '',
111
+ durationAnswer: ''
112
+ });
57
113
  const [{
58
114
  licensePlate,
59
115
  model,
@@ -67,6 +123,7 @@ const QuestionsForm = _ref => {
67
123
  priceCalculationDate
68
124
  }, dispatch] = (0, _OrderSessionContext.useOrderSession)();
69
125
  const formula = (0, _FormulaContext.useFormula)();
126
+ const history = (0, _reactRouter.useHistory)();
70
127
  const {
71
128
  isLoadingQuestions,
72
129
  execution1AnswerOptions,
@@ -75,7 +132,7 @@ const QuestionsForm = _ref => {
75
132
  questionsError,
76
133
  durationQuestion
77
134
  } = (0, _queries.useQuestionsQuery)({
78
- licensePlate,
135
+ licensePlate: initialLicensePlate !== null && initialLicensePlate !== void 0 ? initialLicensePlate : licensePlate,
79
136
  model,
80
137
  formula,
81
138
  discountCode,
@@ -84,7 +141,7 @@ const QuestionsForm = _ref => {
84
141
  durationAnswer: durationAnswer
85
142
  });
86
143
  (0, _queries.useProductsQuery)({
87
- licensePlate,
144
+ licensePlate: initialLicensePlate !== null && initialLicensePlate !== void 0 ? initialLicensePlate : licensePlate,
88
145
  model,
89
146
  executionAnswer1,
90
147
  executionAnswer2,
@@ -137,6 +194,27 @@ const QuestionsForm = _ref => {
137
194
  });
138
195
  }
139
196
  }, [execution2AnswerOptions]);
197
+ (0, _react.useEffect)(() => {
198
+ if (!isLoadingQuestions) {
199
+ const hasNoQuestions = !(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);
200
+ if (hasNoQuestions) {
201
+ dispatch({
202
+ type: _OrderSessionContext.orderSessionActions.CLEAR_ANSWERS
203
+ });
204
+ if (isFilter) {
205
+ onSubmit({
206
+ type: 'licensePlate',
207
+ value: {
208
+ licensePlate: initialLicensePlate
209
+ }
210
+ });
211
+ return;
212
+ } else {
213
+ history.push('/configurator/trekhaakpakket');
214
+ }
215
+ }
216
+ }
217
+ }, [isLoadingQuestions, durationOptions, execution1Options, execution2Options, execution2AnswerOptions, execution1AnswerOptions, durationQuestion, isFilter]);
140
218
  if (questionsError === _constants__.API_ERROR_CODES.notFound || questionsError === _constants__.API_ERROR_CODES.notFoundAldoc) {
141
219
  return /*#__PURE__*/_react.default.createElement(_reactRouter.Redirect, {
142
220
  to: "/configurator/geen-producten"
@@ -156,9 +234,11 @@ const QuestionsForm = _ref => {
156
234
  }));
157
235
  }
158
236
  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)) {
159
- return /*#__PURE__*/_react.default.createElement(_reactRouter.Redirect, {
160
- to: "/configurator/trekhaakpakket"
161
- });
237
+ if (!isFilter) {
238
+ return /*#__PURE__*/_react.default.createElement(_reactRouter.Redirect, {
239
+ to: "/configurator/trekhaakpakket"
240
+ });
241
+ }
162
242
  }
163
243
  const handlePrev = () => {
164
244
  dispatch({
@@ -166,42 +246,69 @@ const QuestionsForm = _ref => {
166
246
  });
167
247
  onPrev();
168
248
  };
249
+ const handleDurationChange = value => {
250
+ if (isFilter) {
251
+ setFilterAnswers(prev => _objectSpread(_objectSpread({}, prev), {}, {
252
+ durationAnswer: value
253
+ }));
254
+ } else {
255
+ dispatch({
256
+ type: _OrderSessionContext.orderSessionActions.SET_DURATION_ANSWER,
257
+ payload: {
258
+ answer: value
259
+ }
260
+ });
261
+ }
262
+ };
263
+ const handleExecution1Change = value => {
264
+ if (isFilter) {
265
+ setFilterAnswers(prev => _objectSpread(_objectSpread({}, prev), {}, {
266
+ executionAnswer1: value
267
+ }));
268
+ } else {
269
+ dispatch({
270
+ type: _OrderSessionContext.orderSessionActions.SET_EXECUTION1_ANSWER,
271
+ payload: {
272
+ answer: value
273
+ }
274
+ });
275
+ }
276
+ };
277
+ const handleExecution2Change = value => {
278
+ if (isFilter) {
279
+ setFilterAnswers(prev => _objectSpread(_objectSpread({}, prev), {}, {
280
+ executionAnswer2: value
281
+ }));
282
+ } else {
283
+ dispatch({
284
+ type: _OrderSessionContext.orderSessionActions.SET_EXECUTION2_ANSWER,
285
+ payload: {
286
+ answer: value
287
+ }
288
+ });
289
+ }
290
+ };
169
291
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("p", null, "We hebben nog een aantal vragen (max 4) voordat we de juiste trekhaak voor jouw auto kunnen adviseren."), /*#__PURE__*/_react.default.createElement("div", {
170
292
  className: (0, _helpers__.withStyle)('my-2')
171
293
  }, (durationOptions === null || durationOptions === void 0 ? void 0 : durationOptions.length) > 0 && /*#__PURE__*/_react.default.createElement(_RadioInput.default, {
172
294
  name: "questions-duration",
173
295
  label: "Selecteer uw uitvoering",
174
- onChange: value => dispatch({
175
- type: _OrderSessionContext.orderSessionActions.SET_DURATION_ANSWER,
176
- payload: {
177
- answer: value
178
- }
179
- }),
180
- initialValue: durationAnswer,
296
+ onChange: handleDurationChange,
297
+ initialValue: isFilter ? filterAnswers.durationAnswer : durationAnswer,
181
298
  options: durationOptions,
182
299
  isRequired: true
183
300
  }), (execution1Options === null || execution1Options === void 0 ? void 0 : execution1Options.length) > 0 && /*#__PURE__*/_react.default.createElement(_RadioInput.default, {
184
301
  name: "questions-1",
185
302
  label: "Selecteer uw uitvoering",
186
- onChange: value => dispatch({
187
- type: _OrderSessionContext.orderSessionActions.SET_EXECUTION1_ANSWER,
188
- payload: {
189
- answer: value
190
- }
191
- }),
192
- initialValue: executionAnswer1,
303
+ onChange: handleExecution1Change,
304
+ initialValue: isFilter ? filterAnswers.executionAnswer1 : executionAnswer1,
193
305
  options: execution1Options,
194
306
  isRequired: true
195
307
  }), (execution2Options === null || execution2Options === void 0 ? void 0 : execution2Options.length) > 0 && /*#__PURE__*/_react.default.createElement(_RadioInput.default, {
196
308
  name: "questions-2",
197
309
  label: "Selecteer uw uitvoering",
198
- onChange: value => dispatch({
199
- type: _OrderSessionContext.orderSessionActions.SET_EXECUTION2_ANSWER,
200
- payload: {
201
- answer: value
202
- }
203
- }),
204
- initialValue: executionAnswer2,
310
+ onChange: handleExecution2Change,
311
+ initialValue: isFilter ? filterAnswers.executionAnswer2 : executionAnswer2,
205
312
  options: execution2Options,
206
313
  isRequired: true
207
314
  })), /*#__PURE__*/_react.default.createElement("div", {
@@ -220,13 +327,21 @@ const QuestionsForm = _ref => {
220
327
  }, /*#__PURE__*/_react.default.createElement("div", {
221
328
  className: (0, _helpers__.withStyle)('d-grid gap-2')
222
329
  }, /*#__PURE__*/_react.default.createElement(_PrimaryButton.default, {
223
- isDisabled: execution1AnswerOptions.length && !executionAnswer1 || execution2AnswerOptions.length && !executionAnswer2 || durationQuestion.length && !durationAnswer,
224
- onClick: () => onSubmit({
330
+ isDisabled: isFilter ? execution1AnswerOptions.length && !filterAnswers.executionAnswer1 || execution2AnswerOptions.length && !filterAnswers.executionAnswer2 || durationQuestion.length && !filterAnswers.durationAnswer : execution1AnswerOptions.length && !executionAnswer1 || execution2AnswerOptions.length && !executionAnswer2 || durationQuestion.length && !durationAnswer,
331
+ onClick: () => onSubmit(isFilter ? {
332
+ type: 'licensePlate',
333
+ value: {
334
+ licensePlate: initialLicensePlate,
335
+ executionAnswer1: filterAnswers.executionAnswer1,
336
+ executionAnswer2: filterAnswers.executionAnswer2,
337
+ durationAnswer: filterAnswers.durationAnswer
338
+ }
339
+ } : {
225
340
  executionAnswer1,
226
341
  executionAnswer2,
227
342
  durationAnswer
228
343
  }),
229
- label: "Bekijk de mogelijkheden"
344
+ label: isFilter ? 'Filter' : 'Bekijk de mogelijkheden'
230
345
  })))));
231
346
  };
232
347
  var _default = exports.default = QuestionsForm;
@@ -146,7 +146,7 @@ const internalAppointmentFormSchema = (0, _yup.object)({
146
146
  * TODO: Split this component - file is too long at the moment.
147
147
  */
148
148
  const InternalAppointmentForm = _ref => {
149
- var _branchTypes$byId$aut, _authSession$branch;
149
+ var _branchTypes$byId$aut, _authSession$branch, _marketingChannels$fi;
150
150
  let {
151
151
  onSubmit = payload => {},
152
152
  isError = false,
@@ -387,13 +387,10 @@ const InternalAppointmentForm = _ref => {
387
387
  noOptionsMessage: "Geen opties beschikbaar",
388
388
  placeholder: "Maak een keuze",
389
389
  errorMessage: (errors === null || errors === void 0 ? void 0 : errors['channelType']) || (errors === null || errors === void 0 ? void 0 : errors['channelId']),
390
- initialValue: () => {
391
- const foundChannel = marketingChannels.find(marketingC => (marketingC === null || marketingC === void 0 ? void 0 : marketingC.entityId) === (channel === null || channel === void 0 ? void 0 : channel.channelId));
392
- return {
393
- label: foundChannel === null || foundChannel === void 0 ? void 0 : foundChannel.title,
394
- value: foundChannel
395
- };
396
- },
390
+ initialValue: channel !== null && channel !== void 0 && channel.channelId ? {
391
+ label: marketingChannels === null || marketingChannels === void 0 || (_marketingChannels$fi = marketingChannels.find(marketingC => (marketingC === null || marketingC === void 0 ? void 0 : marketingC.entityId) === (channel === null || channel === void 0 ? void 0 : channel.channelId))) === null || _marketingChannels$fi === void 0 ? void 0 : _marketingChannels$fi.title,
392
+ value: marketingChannels === null || marketingChannels === void 0 ? void 0 : marketingChannels.find(marketingC => (marketingC === null || marketingC === void 0 ? void 0 : marketingC.entityId) === (channel === null || channel === void 0 ? void 0 : channel.channelId))
393
+ } : null,
397
394
  onChange: _ref3 => {
398
395
  var _value$kanaalType;
399
396
  let {