thm-p3-configurator 0.0.38 → 0.0.39

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.
@@ -57,6 +57,9 @@ const CheckboxInput = _ref => {
57
57
  setChecked(!isChecked);
58
58
  onChange(!isChecked);
59
59
  };
60
+ (0, _react.useEffect)(() => {
61
+ setChecked(initialValue);
62
+ }, [initialValue]);
60
63
  return /*#__PURE__*/_react.default.createElement("div", {
61
64
  className: (0, _helpers__.withStyle)('form-group')
62
65
  }, /*#__PURE__*/_react.default.createElement("div", {
@@ -66,6 +69,7 @@ const CheckboxInput = _ref => {
66
69
  id: name,
67
70
  name: name,
68
71
  form: form,
72
+ checked: isChecked,
69
73
  required: isRequired,
70
74
  className: "".concat((0, _helpers__.withStyle)('form-check-input'), " ").concat(errorMessage ? (0, _helpers__.withStyle)('is-invalid') : ''),
71
75
  onChange: e => {
@@ -32,6 +32,7 @@ var _LinkButton = _interopRequireDefault(require("../../__components__/Buttons/L
32
32
  var _NavigationButton = _interopRequireDefault(require("../../__components__/Buttons/NavigationButton"));
33
33
  var _PrimaryButton = _interopRequireDefault(require("../../__components__/Buttons/PrimaryButton"));
34
34
  var _CardWide = _interopRequireDefault(require("../../__components__/Cards/CardWide"));
35
+ var _CheckboxInput = _interopRequireDefault(require("../../__components__/Form/CheckboxInput"));
35
36
  var _DatePickerInput = _interopRequireDefault(require("../../__components__/Form/DatePickerInput"));
36
37
  var _DropdownInput = _interopRequireDefault(require("../../__components__/Form/DropdownInput"));
37
38
  var _ErrorMessage = _interopRequireDefault(require("../../__components__/Form/ErrorMessage"));
@@ -137,8 +138,13 @@ const internalAppointmentFormSchema = (0, _yup.object)({
137
138
  streetName: (0, _yup.string)().required(_constants__.FORM_ERROR_MESSAGES.required),
138
139
  city: (0, _yup.string)().required(_constants__.FORM_ERROR_MESSAGES.required),
139
140
  date: (0, _yup.string)().required(_constants__.FORM_ERROR_MESSAGES.required),
140
- time: (0, _yup.string)().required(_constants__.FORM_ERROR_MESSAGES.required)
141
+ time: (0, _yup.string)().required(_constants__.FORM_ERROR_MESSAGES.required),
142
+ customerAgreed: (0, _yup.boolean)().required(_constants__.FORM_ERROR_MESSAGES.required).isTrue(_constants__.FORM_ERROR_MESSAGES.required)
141
143
  });
144
+
145
+ /**
146
+ * TODO: Split this component - file is too long at the moment.
147
+ */
142
148
  const InternalAppointmentForm = _ref => {
143
149
  var _branchTypes$byId$aut, _authSession$branch;
144
150
  let {
@@ -148,6 +154,7 @@ const InternalAppointmentForm = _ref => {
148
154
  isLoading = false
149
155
  } = _ref;
150
156
  const [{
157
+ customerAgreed,
151
158
  customer,
152
159
  licensePlate,
153
160
  model,
@@ -187,6 +194,21 @@ const InternalAppointmentForm = _ref => {
187
194
  (0, _react.useEffect)(() => {
188
195
  (0, _ui.scrollToFirstErrorMessage)();
189
196
  }, [errors]);
197
+ const {
198
+ products
199
+ } = (0, _queries.useProductsQuery)({
200
+ licensePlate,
201
+ model,
202
+ executionAnswer1,
203
+ executionAnswer2,
204
+ durationAnswer: durationAnswer,
205
+ formula,
206
+ priceCalculationDate,
207
+ discountCode
208
+ });
209
+ const productSpecifications = (0, _react.useMemo)(() => {
210
+ return (0, _product.parseProductSpecifications)([products[_constants__.PRODUCT_CATEGORIES.TOWBAR].find(towbar => towbar.articleNumber === selectedTowbar), products[_constants__.PRODUCT_CATEGORIES.CABLESET].find(cableset => cableset.articleNumber === selectedCableset), products[_constants__.PRODUCT_CATEGORIES.COMBISET].find(combiset => combiset.articleNumber === selectedCombiset)]);
211
+ }, [products]);
190
212
 
191
213
  /**
192
214
  * @description Handles the validation of the license plate, if the session has not been started with a license plate
@@ -222,7 +244,8 @@ const InternalAppointmentForm = _ref => {
222
244
  date: (appointment === null || appointment === void 0 ? void 0 : appointment.date) || '',
223
245
  time: (appointment === null || appointment === void 0 ? void 0 : appointment.time) || '',
224
246
  channelType: (channel === null || channel === void 0 ? void 0 : channel.channelType) || '',
225
- channelId: (channel === null || channel === void 0 ? void 0 : channel.channelId) || ''
247
+ channelId: (channel === null || channel === void 0 ? void 0 : channel.channelId) || '',
248
+ customerAgreed: productSpecifications !== null && productSpecifications !== void 0 && productSpecifications.length ? customerAgreed : true // Note: this skips validation if no productSpecifications are found
226
249
  }), {
227
250
  strict: false,
228
251
  abortEarly: false
@@ -333,7 +356,7 @@ const InternalAppointmentForm = _ref => {
333
356
  onClick: handleAutofillButtonClicked,
334
357
  isDisabled: !branchById
335
358
  })), /*#__PURE__*/_react.default.createElement("div", {
336
- className: (0, _helpers__.withStyle)('col-12 mb-2')
359
+ className: (0, _helpers__.withStyle)('col-12 col-md-6 mb-2')
337
360
  }, /*#__PURE__*/_react.default.createElement(_DropdownInput.default, {
338
361
  options: marketingChannels === null || marketingChannels === void 0 ? void 0 : marketingChannels.map(channel => ({
339
362
  label: channel === null || channel === void 0 ? void 0 : channel.title,
@@ -369,37 +392,6 @@ const InternalAppointmentForm = _ref => {
369
392
  }
370
393
  });
371
394
  }
372
- }), /*#__PURE__*/_react.default.createElement(_RadioButtons.default, {
373
- name: "ownershipType",
374
- label: "Type:",
375
- initialValue: vehicle === null || vehicle === void 0 ? void 0 : vehicle.ownershipType,
376
- onChange: val => {
377
- dispatch({
378
- type: _OrderSessionContext.orderSessionActions.SET_VEHICLE_OWNERSHIP_TYPE,
379
- payload: {
380
- ownershipType: val
381
- }
382
- });
383
- },
384
- options: Object.values(_constants__.VEHICLE_OWNERSHIP_TYPE),
385
- isRequired: true,
386
- errorMessage: errors === null || errors === void 0 ? void 0 : errors['ownershipType']
387
- })), /*#__PURE__*/_react.default.createElement("div", {
388
- className: (0, _helpers__.withStyle)('col-12 col-md-6')
389
- }, (vehicle === null || vehicle === void 0 ? void 0 : vehicle.ownershipType) === _constants__.VEHICLE_OWNERSHIP_TYPE.Leasemaatschappij && /*#__PURE__*/_react.default.createElement(_TextInput.default, {
390
- placeholder: "",
391
- initialValue: vehicle === null || vehicle === void 0 ? void 0 : vehicle.leaseNumber,
392
- name: "leaseNumber",
393
- onChange: value => dispatch({
394
- type: _OrderSessionContext.orderSessionActions.SET_VEHICLE_LEASE_NUMBER,
395
- payload: {
396
- leaseNumber: value
397
- }
398
- }),
399
- isRequired: false,
400
- form: "quotation",
401
- label: "Code van de leasemaatschappij:",
402
- errorMessage: errors === null || errors === void 0 ? void 0 : errors['leaseNumber']
403
395
  }), /*#__PURE__*/_react.default.createElement(_TextInput.default, {
404
396
  placeholder: "",
405
397
  initialValue: customer.firstName,
@@ -523,6 +515,45 @@ const InternalAppointmentForm = _ref => {
523
515
  isRequired: true,
524
516
  label: "Stad:",
525
517
  errorMessage: errors === null || errors === void 0 ? void 0 : errors['city']
518
+ }))))), /*#__PURE__*/_react.default.createElement("div", {
519
+ className: (0, _helpers__.withStyle)('col-12 mb-4')
520
+ }, /*#__PURE__*/_react.default.createElement(_CardWide.default, null, /*#__PURE__*/_react.default.createElement("div", {
521
+ className: (0, _helpers__.withStyle)('row')
522
+ }, /*#__PURE__*/_react.default.createElement("h6", {
523
+ className: (0, _helpers__.withStyle)('modal-title col-12 mb-2')
524
+ }, "Gegevens van de klant ", /*#__PURE__*/_react.default.createElement("br", null)), /*#__PURE__*/_react.default.createElement("div", {
525
+ className: (0, _helpers__.withStyle)('col-12 mb-2')
526
+ }, /*#__PURE__*/_react.default.createElement(_RadioButtons.default, {
527
+ name: "ownershipType",
528
+ label: "Type:",
529
+ initialValue: vehicle === null || vehicle === void 0 ? void 0 : vehicle.ownershipType,
530
+ onChange: val => {
531
+ dispatch({
532
+ type: _OrderSessionContext.orderSessionActions.SET_VEHICLE_OWNERSHIP_TYPE,
533
+ payload: {
534
+ ownershipType: val
535
+ }
536
+ });
537
+ },
538
+ options: Object.values(_constants__.VEHICLE_OWNERSHIP_TYPE),
539
+ isRequired: true,
540
+ errorMessage: errors === null || errors === void 0 ? void 0 : errors['ownershipType']
541
+ })), /*#__PURE__*/_react.default.createElement("div", {
542
+ className: (0, _helpers__.withStyle)('col-12')
543
+ }, (vehicle === null || vehicle === void 0 ? void 0 : vehicle.ownershipType) === _constants__.VEHICLE_OWNERSHIP_TYPE.Leasemaatschappij && /*#__PURE__*/_react.default.createElement(_TextInput.default, {
544
+ placeholder: "",
545
+ initialValue: vehicle === null || vehicle === void 0 ? void 0 : vehicle.leaseNumber,
546
+ name: "leaseNumber",
547
+ onChange: value => dispatch({
548
+ type: _OrderSessionContext.orderSessionActions.SET_VEHICLE_LEASE_NUMBER,
549
+ payload: {
550
+ leaseNumber: value
551
+ }
552
+ }),
553
+ isRequired: false,
554
+ form: "quotation",
555
+ label: "Code van de leasemaatschappij:",
556
+ errorMessage: errors === null || errors === void 0 ? void 0 : errors['leaseNumber']
526
557
  }), !licensePlate && /*#__PURE__*/_react.default.createElement(_TextInput.default, {
527
558
  placeholder: "",
528
559
  initialValue: _licensePlate,
@@ -532,7 +563,25 @@ const InternalAppointmentForm = _ref => {
532
563
  form: "quotation",
533
564
  label: "Kenteken:",
534
565
  errorMessage: errors === null || errors === void 0 ? void 0 : errors['licensePlate']
535
- }))))), /*#__PURE__*/_react.default.createElement("div", {
566
+ }), /*#__PURE__*/_react.default.createElement("div", {
567
+ className: (0, _helpers__.withStyle)('my-2 fw-bold')
568
+ }, "Opties aanwezig:"), productSpecifications !== null && productSpecifications !== void 0 && productSpecifications.length ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, ' ', /*#__PURE__*/_react.default.createElement("ul", null, productSpecifications === null || productSpecifications === void 0 ? void 0 : productSpecifications.map(specification => /*#__PURE__*/_react.default.createElement("li", {
569
+ key: specification
570
+ }, specification))), /*#__PURE__*/_react.default.createElement(_CheckboxInput.default, {
571
+ isRequired: true,
572
+ name: 'customerAgreed',
573
+ initialValue: customerAgreed,
574
+ onChange: value => dispatch({
575
+ type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_AGREED,
576
+ payload: {
577
+ customerAgreed: value
578
+ }
579
+ }),
580
+ errorMessage: errors === null || errors === void 0 ? void 0 : errors['customerAgreed'],
581
+ label: /*#__PURE__*/_react.default.createElement("strong", null, "Klant gaat akkoord met bovenstaande")
582
+ })) : /*#__PURE__*/_react.default.createElement("div", {
583
+ className: (0, _helpers__.withStyle)('text-muted my-2')
584
+ }, "Geen opties gevonden..."))), ' ')), /*#__PURE__*/_react.default.createElement("div", {
536
585
  className: (0, _helpers__.withStyle)('col-12')
537
586
  }, /*#__PURE__*/_react.default.createElement(_CardWide.default, null, /*#__PURE__*/_react.default.createElement("div", {
538
587
  className: (0, _helpers__.withStyle)('row')
@@ -119,6 +119,7 @@ const INITIAL_ORDER_SESSION_STATE = {
119
119
  selectedBranch: null,
120
120
  discountCode: null,
121
121
  franchiseName: null,
122
+ customerAgreed: undefined,
122
123
  vehicle: {
123
124
  ownershipType: _constants__.VEHICLE_OWNERSHIP_TYPE.Particulier,
124
125
  leaseNumber: ''
@@ -191,7 +192,8 @@ const orderSessionActions = exports.orderSessionActions = {
191
192
  SET_DISCOUNT_PERCENTAGE: 'SET_DISCOUNT_PERCENTAGE',
192
193
  CLEAR_DISCOUNT: 'CLEAR_DISCOUNT',
193
194
  SET_FRANCHISE_NAME: 'SET_FRANCHISE_NAME',
194
- SET_PRICE_CALCULATION_DATE: 'SET_PRICE_CALCULATION_DATE'
195
+ SET_PRICE_CALCULATION_DATE: 'SET_PRICE_CALCULATION_DATE',
196
+ SET_CUSTOMER_AGREED: 'SET_CUSTOMER_AGREED'
195
197
  };
196
198
  const orderSessionReducer = (state, action) => {
197
199
  switch (action.type) {
@@ -777,6 +779,15 @@ const orderSessionReducer = (state, action) => {
777
779
  priceCalculationDate: date
778
780
  });
779
781
  }
782
+ case orderSessionActions.SET_CUSTOMER_AGREED:
783
+ {
784
+ const {
785
+ customerAgreed = false
786
+ } = action.payload;
787
+ return _objectSpread(_objectSpread({}, state), {}, {
788
+ customerAgreed
789
+ });
790
+ }
780
791
  default:
781
792
  return state;
782
793
  }
@@ -7,12 +7,13 @@ require("core-js/modules/es.string.includes.js");
7
7
  require("core-js/modules/esnext.iterator.constructor.js");
8
8
  require("core-js/modules/esnext.iterator.filter.js");
9
9
  require("core-js/modules/esnext.iterator.flat-map.js");
10
+ require("core-js/modules/esnext.iterator.for-each.js");
10
11
  require("core-js/modules/esnext.iterator.map.js");
11
12
  require("core-js/modules/web.dom-collections.iterator.js");
12
13
  Object.defineProperty(exports, "__esModule", {
13
14
  value: true
14
15
  });
15
- exports.validateCartInput = exports.formatHyperDescription = exports.extractProductSpecsArray = exports.checkIfTowbarIsRecommended = void 0;
16
+ exports.validateCartInput = exports.parseProductSpecifications = exports.formatHyperDescription = exports.extractProductSpecsArray = exports.checkIfTowbarIsRecommended = void 0;
16
17
  require("core-js/modules/es.array.flat-map.js");
17
18
  require("core-js/modules/es.array.includes.js");
18
19
  require("core-js/modules/es.array.unscopables.flat-map.js");
@@ -20,6 +21,7 @@ require("core-js/modules/es.string.includes.js");
20
21
  require("core-js/modules/esnext.iterator.constructor.js");
21
22
  require("core-js/modules/esnext.iterator.filter.js");
22
23
  require("core-js/modules/esnext.iterator.flat-map.js");
24
+ require("core-js/modules/esnext.iterator.for-each.js");
23
25
  require("core-js/modules/esnext.iterator.map.js");
24
26
  require("core-js/modules/web.dom-collections.iterator.js");
25
27
  var _constants__ = require("../__constants__");
@@ -71,4 +73,26 @@ exports.checkIfTowbarIsRecommended = checkIfTowbarIsRecommended;
71
73
  const formatHyperDescription = description => {
72
74
  return description === null || description === void 0 ? void 0 : description.ops.map(phrase => phrase.insert).join('');
73
75
  };
74
- exports.formatHyperDescription = formatHyperDescription;
76
+
77
+ /**
78
+ * @description Parses a product EXCL/INCL/OPM orderlines
79
+ */
80
+ exports.formatHyperDescription = formatHyperDescription;
81
+ const parseProductSpecifications = exports.parseProductSpecifications = function parseProductSpecifications() {
82
+ let productLines = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
83
+ const allSpecifications = [];
84
+ productLines.forEach(line => {
85
+ if (line !== null && line !== void 0 && line.excl) {
86
+ allSpecifications.push("Niet Geschikt voor: ".concat(line === null || line === void 0 ? void 0 : line.excl));
87
+ }
88
+ if (line !== null && line !== void 0 && line.incl) {
89
+ allSpecifications.push("Geschikt voor: ".concat(line === null || line === void 0 ? void 0 : line.incl));
90
+ }
91
+ if (line !== null && line !== void 0 && line.remark) {
92
+ allSpecifications.push("Opmerking: ".concat(line === null || line === void 0 ? void 0 : line.remark));
93
+ }
94
+ });
95
+
96
+ // Note: filter non-unique values out
97
+ return [...new Set(allSpecifications)];
98
+ };
@@ -90,7 +90,6 @@ 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");
94
93
  function _interopRequireDefault(e) {
95
94
  return e && e.__esModule ? e : {
96
95
  default: e
@@ -102,7 +101,7 @@ const Routes = () => {
102
101
  return /*#__PURE__*/_react.default.createElement(_reactRouterDom.Switch, null, /*#__PURE__*/_react.default.createElement(_reactRouterDom.Route, {
103
102
  exact: true,
104
103
  path: "/",
105
- render: props => /*#__PURE__*/_react.default.createElement(_internal.InternalLicensePlatePage, props)
104
+ render: props => /*#__PURE__*/_react.default.createElement(_LicensePlatePage.default, props)
106
105
  }), /*#__PURE__*/_react.default.createElement(_reactRouterDom.Route, {
107
106
  exact: true,
108
107
  path: "/configurator/geen-producten",
@@ -110,44 +109,40 @@ const Routes = () => {
110
109
  }), /*#__PURE__*/_react.default.createElement(_reactRouterDom.Route, {
111
110
  exact: true,
112
111
  path: "/configurator/montagelocatie",
113
- render: props => /*#__PURE__*/_react.default.createElement(_internal.InternalLocationsPage, props)
112
+ render: props => /*#__PURE__*/_react.default.createElement(_LocationsPage.default, props)
114
113
  }), /*#__PURE__*/_react.default.createElement(_reactRouterDom.Route, {
115
114
  exact: true,
116
115
  path: "/configurator/gegevens/bedankt",
117
- render: props => /*#__PURE__*/_react.default.createElement(_internal.InternalAppointmentPage, props)
116
+ render: props => /*#__PURE__*/_react.default.createElement(_AppointmentThanksPage.default, props)
118
117
  }), /*#__PURE__*/_react.default.createElement(_reactRouterDom.Route, {
119
118
  exact: true,
120
119
  path: "/configurator/offerte/bedankt",
121
120
  render: props => /*#__PURE__*/_react.default.createElement(_QuotationThanksPage.default, props)
122
121
  }), /*#__PURE__*/_react.default.createElement(_reactRouterDom.Route, {
123
122
  path: "/configurator/trekhaakpakket",
124
- render: props => /*#__PURE__*/_react.default.createElement(_internal.InternalProductsPage, null)
123
+ render: props => /*#__PURE__*/_react.default.createElement(_ProductsPage.default, null)
125
124
  }), /*#__PURE__*/_react.default.createElement(_reactRouterDom.Route, {
126
125
  path: "/configurator/manual",
127
- render: props => /*#__PURE__*/_react.default.createElement(_internal.InternalManualSelectionPage, props)
126
+ render: props => /*#__PURE__*/_react.default.createElement(_ManualSelectionPage.default, props)
128
127
  }), /*#__PURE__*/_react.default.createElement(_reactRouterDom.Route, {
129
128
  exact: true,
130
129
  path: "/configurator/overzicht",
131
- render: props => /*#__PURE__*/_react.default.createElement(_internal.InternalOverviewPage, null)
130
+ render: props => /*#__PURE__*/_react.default.createElement(_OverviewPage.default, null)
132
131
  }), /*#__PURE__*/_react.default.createElement(_reactRouterDom.Route, {
133
132
  exact: true,
134
133
  path: "/configurator/offerte",
135
- render: props => /*#__PURE__*/_react.default.createElement(_internal.InternalQuotationPage, null)
134
+ render: props => /*#__PURE__*/_react.default.createElement(_QuotationPage.default, null)
136
135
  }), /*#__PURE__*/_react.default.createElement(_reactRouterDom.Route, {
137
136
  exact: true,
138
137
  path: "/configurator/gegevens",
139
- render: props => /*#__PURE__*/_react.default.createElement(_internal.InternalAppointmentPage, null)
138
+ render: props => /*#__PURE__*/_react.default.createElement(_AppointmentPage.default, null)
140
139
  }), /*#__PURE__*/_react.default.createElement(_reactRouterDom.Route, {
141
140
  exact: true,
142
141
  path: "/configurator/toebehoren",
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)
142
+ render: props => /*#__PURE__*/_react.default.createElement(_ExtraProductsPage.default, null)
148
143
  }), /*#__PURE__*/_react.default.createElement(_reactRouterDom.Route, {
149
144
  path: "/configurator",
150
- render: props => /*#__PURE__*/_react.default.createElement(_internal.InternalLicensePlatePage, null)
145
+ render: props => /*#__PURE__*/_react.default.createElement(_LicensePlatePage.default, null)
151
146
  }), /*#__PURE__*/_react.default.createElement(_reactRouterDom.Route, {
152
147
  path: "/niet-gevonden",
153
148
  render: () => /*#__PURE__*/_react.default.createElement(_NotFoundPage.default, null)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thm-p3-configurator",
3
- "version": "0.0.38",
3
+ "version": "0.0.39",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "author": "EnoRm.",