thm-p3-configurator 0.0.160 → 0.0.162

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.
@@ -82,6 +82,18 @@ const authenticatedProxyApi = exports.authenticatedProxyApi = {
82
82
  getBranchTypes: () => authenticateClient("api/v1/branch-types", {
83
83
  method: 'GET'
84
84
  }),
85
+ getBranchesByType: _ref => {
86
+ let {
87
+ formula,
88
+ ownershipType,
89
+ organisationType,
90
+ searchTerm,
91
+ isTmg = false
92
+ } = _ref;
93
+ return authenticateClient("api/v1/branches/by-type?searchTerm=".concat(searchTerm, "&formula=").concat(formula, "&ownershipType=").concat(ownershipType, "&organisationType=").concat(organisationType, "&isTmg=").concat(isTmg, " "), {
94
+ method: 'GET'
95
+ });
96
+ },
85
97
  getMyBranchesByFormula: formula => authenticateClient("api/v1/profile/".concat(formula, "/branches"), {
86
98
  method: 'GET'
87
99
  }),
@@ -131,11 +143,11 @@ const authenticatedProxyApi = exports.authenticatedProxyApi = {
131
143
  'Content-Type': 'application/json'
132
144
  }
133
145
  }),
134
- putQuotationById: _ref => {
146
+ putQuotationById: _ref2 => {
135
147
  let {
136
148
  payload,
137
149
  id
138
- } = _ref;
150
+ } = _ref2;
139
151
  return authenticateClient("api/v1/quotations/".concat(id), {
140
152
  method: 'PUT',
141
153
  data: payload,
@@ -144,11 +156,11 @@ const authenticatedProxyApi = exports.authenticatedProxyApi = {
144
156
  }
145
157
  });
146
158
  },
147
- putAppointmentById: _ref2 => {
159
+ putAppointmentById: _ref3 => {
148
160
  let {
149
161
  payload,
150
162
  id
151
- } = _ref2;
163
+ } = _ref3;
152
164
  return authenticateClient("api/v1/appointments/".concat(id), {
153
165
  method: 'PUT',
154
166
  data: payload,
@@ -157,11 +169,11 @@ const authenticatedProxyApi = exports.authenticatedProxyApi = {
157
169
  }
158
170
  });
159
171
  },
160
- putAppointmentRequestById: _ref3 => {
172
+ putAppointmentRequestById: _ref4 => {
161
173
  let {
162
174
  payload,
163
175
  id
164
- } = _ref3;
176
+ } = _ref4;
165
177
  return authenticateClient("api/v1/appointment-requests/".concat(id), {
166
178
  method: 'PUT',
167
179
  data: payload,
@@ -170,12 +182,12 @@ const authenticatedProxyApi = exports.authenticatedProxyApi = {
170
182
  }
171
183
  });
172
184
  },
173
- getActiveDiscounts: _ref4 => {
185
+ getActiveDiscounts: _ref5 => {
174
186
  let {
175
187
  formulaCode,
176
188
  limit,
177
189
  offset
178
- } = _ref4;
190
+ } = _ref5;
179
191
  return authenticateClient("api/v1/discounts?limit=".concat(limit, "&offset=").concat(offset, "&formulaCode=").concat(formulaCode), {
180
192
  method: 'GET',
181
193
  headers: {
@@ -15,7 +15,7 @@ require("core-js/modules/esnext.iterator.filter.js");
15
15
  Object.defineProperty(exports, "__esModule", {
16
16
  value: true
17
17
  });
18
- exports.useSingleOrderCart = exports.useSingleOrderBranchesQuery = exports.useSingleOrderBranchTypes = exports.useSingleOrderArticles = exports.useQuestionsQuery = exports.useProductsQuery = exports.useProductFieldLabels = exports.usePrivateDossierByTypeAndIdQuery = exports.useMyBranches = exports.useModelsQuery = exports.useMarketingChannels = exports.useCountriesQuery = exports.useBuildYearsQuery = exports.useBrandsQuery = exports.useBranchesQuery = exports.useBranchTypes = exports.useBranchByIdOrWidgetId = exports.useArticleTypes = exports.useArticleSubGroups = exports.useArticleGroups = exports.useActiveDiscounts = void 0;
18
+ exports.useSingleOrderCart = exports.useSingleOrderBranchesQuery = exports.useSingleOrderBranchTypes = exports.useSingleOrderArticles = exports.useQuestionsQuery = exports.useProductsQuery = exports.useProductFieldLabels = exports.usePrivateDossierByTypeAndIdQuery = exports.useMyBranches = exports.useModelsQuery = exports.useMarketingChannels = exports.useCountriesQuery = exports.useBuildYearsQuery = exports.useBrandsQuery = exports.useBranchesQuery = exports.useBranchesByType = exports.useBranchTypes = exports.useBranchByIdOrWidgetId = exports.useArticleTypes = exports.useArticleSubGroups = exports.useArticleGroups = exports.useActiveDiscounts = void 0;
19
19
  require("core-js/modules/es.symbol.description.js");
20
20
  require("core-js/modules/es.json.stringify.js");
21
21
  require("core-js/modules/es.object.from-entries.js");
@@ -567,9 +567,45 @@ const useBranchesQuery = branchesParams => {
567
567
  };
568
568
 
569
569
  /**
570
- * @description finds a branch either by its Id, or its widget id
570
+ * @description Retrieves available branches by type
571
+ * @param {String} type - The type of branches to retrieve
571
572
  */
572
573
  exports.useBranchesQuery = useBranchesQuery;
574
+ const useBranchesByType = _ref3 => {
575
+ let {
576
+ formula,
577
+ ownershipType,
578
+ organisationType,
579
+ searchTerm,
580
+ isTmg = false
581
+ } = _ref3;
582
+ const branchesByTypeQuery = (0, _reactQuery.useQuery)(['branchesByType', formula, ownershipType, organisationType, searchTerm, isTmg], {
583
+ queryFn: async () => {
584
+ const response = await _authenticatedProxyApi.authenticatedProxyApi.getBranchesByType({
585
+ formula,
586
+ ownershipType,
587
+ organisationType,
588
+ searchTerm,
589
+ isTmg
590
+ });
591
+ if (response.data.length === 0) {
592
+ return null;
593
+ }
594
+ return response.data;
595
+ },
596
+ enabled: !!searchTerm && searchTerm.length >= 3
597
+ });
598
+ return {
599
+ isLoadingBranchesByType: branchesByTypeQuery.isLoading,
600
+ branchesByTypeError: branchesByTypeQuery.isError,
601
+ branchesByType: branchesByTypeQuery === null || branchesByTypeQuery === void 0 ? void 0 : branchesByTypeQuery.data
602
+ };
603
+ };
604
+
605
+ /**
606
+ * @description finds a branch either by its Id, or its widget id
607
+ */
608
+ exports.useBranchesByType = useBranchesByType;
573
609
  const useBranchByIdOrWidgetId = exports.useBranchByIdOrWidgetId = function useBranchByIdOrWidgetId() {
574
610
  let id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
575
611
  const branchByIdQuery = (0, _reactQuery.useQuery)(['branchById', id], {
@@ -648,11 +684,11 @@ const useBranchTypes = () => {
648
684
  * Available types: Quotation, appointment request and planned appointment.
649
685
  */
650
686
  exports.useBranchTypes = useBranchTypes;
651
- const usePrivateDossierByTypeAndIdQuery = _ref3 => {
687
+ const usePrivateDossierByTypeAndIdQuery = _ref4 => {
652
688
  let {
653
689
  dossierId,
654
690
  dossierType
655
- } = _ref3;
691
+ } = _ref4;
656
692
  const dossierByIdQuery = (0, _reactQuery.useQuery)([dossierType, dossierId], {
657
693
  enabled: !!dossierId && !!dossierType,
658
694
  queryFn: () => {
@@ -695,14 +731,14 @@ const usePrivateDossierByTypeAndIdQuery = _ref3 => {
695
731
  * @description Query the discounts from Hyper, allows for pagination and filtering with formula
696
732
  */
697
733
  exports.usePrivateDossierByTypeAndIdQuery = usePrivateDossierByTypeAndIdQuery;
698
- const useActiveDiscounts = _ref4 => {
734
+ const useActiveDiscounts = _ref5 => {
699
735
  var _discountsQuery$data;
700
736
  let {
701
737
  formulaCode,
702
738
  offset,
703
739
  limit,
704
740
  authSession
705
- } = _ref4;
741
+ } = _ref5;
706
742
  const discountsQuery = (0, _reactQuery.useQuery)({
707
743
  queryKey: ['discounts', formulaCode, offset, limit, authSession],
708
744
  queryFn: () => _authenticatedProxyApi.authenticatedProxyApi.getActiveDiscounts({
@@ -41,14 +41,16 @@ const LinkButton = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
41
41
  isDisabled,
42
42
  onClick,
43
43
  label,
44
- className = ''
44
+ className = '',
45
+ style = {}
45
46
  } = _ref;
46
47
  return /*#__PURE__*/_react.default.createElement("button", {
47
48
  className: (0, _helpers__.withStyle)("btn btn-link p-0 ".concat(className)),
48
49
  type: type,
49
50
  ref: ref,
50
51
  disabled: isDisabled,
51
- onClick: onClick
52
+ onClick: onClick,
53
+ style: style
52
54
  }, label);
53
55
  });
54
56
  var _default = exports.default = LinkButton;
@@ -0,0 +1,227 @@
1
+ "use strict";
2
+
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");
7
+ require("core-js/modules/web.dom-collections.iterator.js");
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");
12
+ Object.defineProperty(exports, "__esModule", {
13
+ value: true
14
+ });
15
+ exports.default = void 0;
16
+ require("core-js/modules/web.dom-collections.iterator.js");
17
+ var _react = _interopRequireWildcard(require("react"));
18
+ var _reactSelect = _interopRequireDefault(require("react-select"));
19
+ var _constants__ = require("../../__constants__");
20
+ var _ErrorMessage = _interopRequireDefault(require("./ErrorMessage"));
21
+ function _interopRequireDefault(e) {
22
+ return e && e.__esModule ? e : {
23
+ default: e
24
+ };
25
+ }
26
+ function _getRequireWildcardCache(e) {
27
+ if ("function" != typeof WeakMap) return null;
28
+ var r = new WeakMap(),
29
+ t = new WeakMap();
30
+ return (_getRequireWildcardCache = function _getRequireWildcardCache(e) {
31
+ return e ? t : r;
32
+ })(e);
33
+ }
34
+ function _interopRequireWildcard(e, r) {
35
+ if (!r && e && e.__esModule) return e;
36
+ if (null === e || "object" != typeof e && "function" != typeof e) return {
37
+ default: e
38
+ };
39
+ var t = _getRequireWildcardCache(r);
40
+ if (t && t.has(e)) return t.get(e);
41
+ var n = {
42
+ __proto__: null
43
+ },
44
+ a = Object.defineProperty && Object.getOwnPropertyDescriptor;
45
+ for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
46
+ var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
47
+ i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u];
48
+ }
49
+ return n.default = e, t && t.set(e, n), n;
50
+ }
51
+ function ownKeys(e, r) {
52
+ var t = Object.keys(e);
53
+ if (Object.getOwnPropertySymbols) {
54
+ var o = Object.getOwnPropertySymbols(e);
55
+ r && (o = o.filter(function (r) {
56
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
57
+ })), t.push.apply(t, o);
58
+ }
59
+ return t;
60
+ }
61
+ function _objectSpread(e) {
62
+ for (var r = 1; r < arguments.length; r++) {
63
+ var t = null != arguments[r] ? arguments[r] : {};
64
+ r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
65
+ _defineProperty(e, r, t[r]);
66
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
67
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
68
+ });
69
+ }
70
+ return e;
71
+ }
72
+ function _defineProperty(e, r, t) {
73
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
74
+ value: t,
75
+ enumerable: !0,
76
+ configurable: !0,
77
+ writable: !0
78
+ }) : e[r] = t, e;
79
+ }
80
+ function _toPropertyKey(t) {
81
+ var i = _toPrimitive(t, "string");
82
+ return "symbol" == typeof i ? i : i + "";
83
+ }
84
+ function _toPrimitive(t, r) {
85
+ if ("object" != typeof t || !t) return t;
86
+ var e = t[Symbol.toPrimitive];
87
+ if (void 0 !== e) {
88
+ var i = e.call(t, r || "default");
89
+ if ("object" != typeof i) return i;
90
+ throw new TypeError("@@toPrimitive must return a primitive value.");
91
+ }
92
+ return ("string" === r ? String : Number)(t);
93
+ }
94
+ const SearchableDropdownInput = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
95
+ let {
96
+ searchHook,
97
+ name,
98
+ label,
99
+ isRequired,
100
+ placeholder = 'Zoeken...',
101
+ onChange,
102
+ onInputChange = () => {},
103
+ form,
104
+ initialValue,
105
+ debounceMs = 500,
106
+ errorMessage,
107
+ extraHookFilters = [],
108
+ preserveInput = false,
109
+ allowCustomValue = false
110
+ } = _ref;
111
+ const [isTouched, setIsTouched] = (0, _react.useState)(false);
112
+ const [value, setValue] = (0, _react.useState)(initialValue || '');
113
+ const [internalError, setInternalError] = (0, _react.useState)();
114
+ const [searchTerm, setSearchTerm] = (0, _react.useState)('');
115
+ const [debouncedSearchTerm, setDebouncedSearchTerm] = (0, _react.useState)('');
116
+ const [typedValue, setTypedValue] = (0, _react.useState)('');
117
+
118
+ // Only search when we have at least 3 characters to avoid excessive API calls
119
+ const minSearchLength = 3;
120
+ const effectiveSearchTerm = debouncedSearchTerm.length >= minSearchLength ? debouncedSearchTerm : '';
121
+ const {
122
+ data: options = [],
123
+ isLoading
124
+ } = searchHook(effectiveSearchTerm, extraHookFilters);
125
+ const lgSize = window.matchMedia('(min-width: 960px)');
126
+ const xxlSize = window.matchMedia('(min-width: 1440px)');
127
+ (0, _react.useEffect)(() => {
128
+ setValue(initialValue || '');
129
+
130
+ // Set initial typed value from initialValue if it's a string or has label
131
+ if (initialValue) {
132
+ if (typeof initialValue === 'object' && initialValue.label) {
133
+ setTypedValue(initialValue.label);
134
+ } else if (typeof initialValue === 'string') {
135
+ setTypedValue(initialValue);
136
+ }
137
+ }
138
+ }, [initialValue]);
139
+ (0, _react.useEffect)(() => {
140
+ const timer = setTimeout(() => {
141
+ setDebouncedSearchTerm(searchTerm);
142
+ }, debounceMs);
143
+ return () => clearTimeout(timer);
144
+ }, [searchTerm, debounceMs]);
145
+ const handleFocus = () => {
146
+ setIsTouched(true);
147
+ };
148
+ const handleBlur = () => {
149
+ if (!value && isRequired && isTouched) {
150
+ setInternalError(_constants__.FORM_ERROR_MESSAGES.required);
151
+ }
152
+
153
+ // On blur, if we have typed text but no selection and preserveInput is true
154
+ if (preserveInput && typedValue && !value) {
155
+ onChange(typedValue);
156
+ }
157
+ };
158
+ const handleChange = selectedOption => {
159
+ setInternalError('');
160
+ setValue(selectedOption);
161
+ if (selectedOption) {
162
+ // Normal selection behavior
163
+ onChange(selectedOption);
164
+ } else {
165
+ // Handle clearing the field
166
+ if (preserveInput && typedValue) {
167
+ // If we're preserving input and there's text, use that
168
+ onChange(typedValue);
169
+ } else {
170
+ // Otherwise just clear normally
171
+ onChange(null);
172
+ setTypedValue('');
173
+ }
174
+ }
175
+ };
176
+ const handleInputChange = inputText => {
177
+ setTypedValue(inputText);
178
+ setSearchTerm(inputText);
179
+ onInputChange(inputText);
180
+ };
181
+ const displayError = errorMessage || internalError;
182
+
183
+ // Determine the appropriate no-options message based on search term length
184
+ const getNoOptionsMessage = () => {
185
+ if (searchTerm.length > 0 && searchTerm.length < minSearchLength) {
186
+ return "Typ minimaal ".concat(minSearchLength, " karakters om te zoeken");
187
+ }
188
+ return 'Geen resultaten gevonden';
189
+ };
190
+ return /*#__PURE__*/_react.default.createElement("div", {
191
+ className: "form-group form-select__group ".concat(displayError ? 'is-invalid' : '')
192
+ }, /*#__PURE__*/_react.default.createElement("label", {
193
+ htmlFor: name,
194
+ className: 'form-label'
195
+ }, label, isRequired && /*#__PURE__*/_react.default.createElement("span", null, "*")), /*#__PURE__*/_react.default.createElement(_reactSelect.default, {
196
+ ref: ref,
197
+ onFocus: handleFocus,
198
+ onBlur: handleBlur,
199
+ id: name,
200
+ name: name,
201
+ form: form,
202
+ value: value,
203
+ options: options,
204
+ placeholder: placeholder,
205
+ noOptionsMessage: getNoOptionsMessage,
206
+ classNamePrefix: 'form-select',
207
+ onChange: handleChange,
208
+ onInputChange: handleInputChange,
209
+ isLoading: isLoading,
210
+ isSearchable: true,
211
+ isClearable: true,
212
+ styles: {
213
+ menuList: base => _objectSpread(_objectSpread({}, base), {}, {
214
+ maxHeight: lgSize ? '20vh' : xxlSize ? '10vh' : '18vh'
215
+ }),
216
+ control: base => _objectSpread(_objectSpread({}, base), {}, {
217
+ borderColor: displayError ? '#dc3545' : base.borderColor,
218
+ '&:hover': {
219
+ borderColor: displayError ? '#dc3545' : base.borderColor
220
+ }
221
+ })
222
+ }
223
+ }), displayError && /*#__PURE__*/_react.default.createElement(_ErrorMessage.default, {
224
+ message: displayError
225
+ }));
226
+ });
227
+ var _default = exports.default = SearchableDropdownInput;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.VESTIGING_TYPE_ID = exports.VEHICLE_SINGLE_ORDER_OWNERSHIP_TYPE = exports.VEHICLE_OWNERSHIP_TYPE = exports.VEHICLE_CODING_SUBGROUP_NAME = exports.USER_GEOLOCATION_KEY = exports.TMG_ORGANIZATION_TYPE = exports.StockStatus = exports.PRODUCT_CATEGORIES = exports.PRIVATE_SINGLE_ORDER_SESSION_KEY = exports.ORDER_SESSION_KEY = exports.NAVIGATION_STEPS_INTERNAL = exports.NAVIGATION_STEPS_EXTERNAL = exports.NAVIGATION_BUTTONS = exports.MOUSE_EXIT_INTENT_THROTTLE = exports.MOUSE_EXIT_INTENT_OFFSET = exports.LOCATION_TYPE = exports.LOCATION_CHANGE_BUTTON_LABEL = exports.LOCALE = exports.FORM_ERROR_MESSAGES = exports.DOSSIER_TYPES = exports.DISCOUNT_TYPES = exports.DEFAULT_MAP_LONGITUDE = exports.DEFAULT_MAP_LATITUDE = exports.DEFAULT_ARTICLE_BRAND = exports.DAY_NAMES = exports.CONFIGURATOR_FORMULAS = exports.BOARD_COMPUTER_DISABLED_KEY = exports.AUTH_SESSION_KEY = exports.ARTICLE_SPECS_TRANSLATIONS = exports.ARTICLES_SYSTEM_FIELDS = exports.API_ERROR_CODES = exports.ANWB_DISCOUNT_CODE = exports.ALL_EXPERIMENTS = exports.ACTIVE_VARIANTS = void 0;
6
+ exports.VESTIGING_TYPE_ID = exports.VEHICLE_SINGLE_ORDER_OWNERSHIP_TYPE = exports.VEHICLE_OWNERSHIP_TYPE = exports.VEHICLE_CODING_SUBGROUP_NAME = exports.USER_GEOLOCATION_KEY = exports.TMG_ORGANIZATION_TYPE = exports.StockStatus = exports.PRODUCT_CATEGORIES = exports.PRIVATE_SINGLE_ORDER_SESSION_KEY = exports.ORDER_SESSION_KEY = exports.NAVIGATION_STEPS_INTERNAL = exports.NAVIGATION_STEPS_EXTERNAL = exports.NAVIGATION_BUTTONS = exports.MOUSE_EXIT_INTENT_THROTTLE = exports.MOUSE_EXIT_INTENT_OFFSET = exports.LOCATION_TYPE = exports.LOCATION_CHANGE_BUTTON_LABEL = exports.LOCALE = exports.LEASE_TYPE_ID = exports.FORM_ERROR_MESSAGES = exports.DOSSIER_TYPES = exports.DISCOUNT_TYPES = exports.DEFAULT_MAP_LONGITUDE = exports.DEFAULT_MAP_LATITUDE = exports.DEFAULT_ARTICLE_BRAND = exports.DAY_NAMES = exports.CONFIGURATOR_FORMULAS = exports.BOARD_COMPUTER_DISABLED_KEY = exports.AUTH_SESSION_KEY = exports.ARTICLE_SPECS_TRANSLATIONS = exports.ARTICLES_SYSTEM_FIELDS = exports.API_ERROR_CODES = exports.ANWB_DISCOUNT_CODE = exports.ALL_EXPERIMENTS = exports.ACTIVE_VARIANTS = void 0;
7
7
  const DOSSIER_TYPES = exports.DOSSIER_TYPES = {
8
8
  Quotation: 'quotation',
9
9
  AppointmentRequest: 'appointment-request',
@@ -29,6 +29,7 @@ const DAY_NAMES = exports.DAY_NAMES = {
29
29
  };
30
30
  const VEHICLE_CODING_SUBGROUP_NAME = exports.VEHICLE_CODING_SUBGROUP_NAME = 'Voertuigcodering trekhaak';
31
31
  const VESTIGING_TYPE_ID = exports.VESTIGING_TYPE_ID = 'kyDouClQsfmXWWloLdwzG';
32
+ const LEASE_TYPE_ID = exports.LEASE_TYPE_ID = 'SJvJbwMGBoXvOsatNStxr';
32
33
  const NAVIGATION_STEPS_INTERNAL = exports.NAVIGATION_STEPS_INTERNAL = [{
33
34
  to: '/configurator/trekhaakpakket',
34
35
  title: '1. Trekhaakpakket',