thm-p3-configurator 0.0.376 → 0.0.378

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.
Files changed (26) hide show
  1. package/dist/src/shared/__api__/publicProxyApi.js +6 -0
  2. package/dist/src/shared/__api__/queries.js +29 -3
  3. package/dist/src/shared/__api__/queryKeyFactory.js +9 -0
  4. package/dist/src/shared/__components__/LocationsSelector/LocationAutoComplete.js +57 -26
  5. package/dist/src/shared/__components__/LocationsSelector/LocationDetails.js +5 -30
  6. package/dist/src/shared/__components__/LocationsSelector/LocationList.js +45 -35
  7. package/dist/src/shared/__components__/LocationsSelector/LocationListItem.js +3 -2
  8. package/dist/src/shared/__components__/LocationsSelector/index.js +10 -22
  9. package/dist/src/shared/__containers__/DiscountProductsSelector.js +3 -1
  10. package/dist/src/shared/__containers__/ExtraProductsOverview.js +7 -56
  11. package/dist/src/shared/__containers__/LicensePlateForm.js +1 -19
  12. package/dist/src/shared/__containers__/ManualSelectionForm.js +1 -9
  13. package/dist/src/shared/__containers__/ProductCartSide.js +5 -1
  14. package/dist/src/shared/__containers__/ProductDiscountCard.js +3 -1
  15. package/dist/src/shared/__containers__/ProductsCartOverview.js +5 -1
  16. package/dist/src/shared/__containers__/ProductsOverview.js +5 -1
  17. package/dist/src/shared/__containers__/QuestionsForm.js +9 -55
  18. package/dist/src/shared/__containers__/VehicleData.js +5 -1
  19. package/dist/src/shared/__context__/OrderSessionContext.js +16 -2
  20. package/dist/src/shared/__pages__/index.js +61 -8
  21. package/dist/src/shared/__pages__/internal/InternalAppointmentPage.js +2 -2
  22. package/dist/src/shared/__pages__/internal/InternalExtraProductsPage.js +2 -2
  23. package/dist/src/shared/__pages__/internal/InternalOverviewPage.js +2 -2
  24. package/dist/src/shared/__pages__/internal/InternalProductsPage.js +2 -2
  25. package/dist/src/shared/__pages__/internal/InternalSingleOrderPage.js +2 -2
  26. package/package.json +1 -1
@@ -44,6 +44,12 @@ const publicProxyApi = exports.publicProxyApi = {
44
44
  'Content-Type': 'application/json'
45
45
  }
46
46
  }),
47
+ getConfiguratorLocations: locationsParams => client("api/public/v1/configurator/locations?".concat(locationsParams), {
48
+ method: 'GET',
49
+ headers: {
50
+ 'Content-Type': 'application/json'
51
+ }
52
+ }),
47
53
  getHeadquartersChannels: () => client("api/public/v1/channels?type=Hoofdkantoor", {
48
54
  method: 'GET',
49
55
  headers: {
@@ -16,7 +16,7 @@ require("core-js/modules/web.url-search-params.js");
16
16
  Object.defineProperty(exports, "__esModule", {
17
17
  value: true
18
18
  });
19
- exports.useSingleOrderCart = exports.useSingleOrderBranchesQuery = exports.useSingleOrderBranchTypes = exports.useSingleOrderArticles = exports.useQuestionsQuery = exports.useProductsQuery = exports.useProductFieldLabels = exports.usePrivateDossierByTypeAndIdQuery = exports.usePartBrands = exports.useOrderDataQuery = exports.useMyBranches = exports.useModelsQuery = exports.useMarketingChannels = exports.useCountriesQuery = exports.useBusinessBranches = exports.useBuildYearsQuery = exports.useBrandsQuery = exports.useBranchesQuery = exports.useBranchesByType = 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.usePartBrands = exports.useOrderDataQuery = exports.useMyBranches = exports.useModelsQuery = exports.useMarketingChannels = exports.useCountriesQuery = exports.useConfiguratorLocationsQuery = exports.useBusinessBranches = exports.useBuildYearsQuery = exports.useBrandsQuery = exports.useBranchesQuery = exports.useBranchesByType = 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.array.sort.js");
22
22
  require("core-js/modules/es.json.stringify.js");
@@ -86,6 +86,7 @@ function _toPrimitive(t, r) {
86
86
  }
87
87
  return ("string" === r ? String : Number)(t);
88
88
  }
89
+ const ORDER_QUERY_STALE_TIME_MS = 5 * 60 * 1000;
89
90
  /**
90
91
  * @description Retrieves the car brand options
91
92
  */
@@ -490,6 +491,9 @@ const useOrderDataQuery = exports.useOrderDataQuery = function useOrderDataQuery
490
491
  // automatically once the session context is ready.
491
492
  enabled: hasOrderInput && (!APP_CONFIG.internal || initialized),
492
493
  keepPreviousData: true,
494
+ staleTime: ORDER_QUERY_STALE_TIME_MS,
495
+ refetchOnMount: false,
496
+ refetchOnWindowFocus: false,
493
497
  queryFn: async () => {
494
498
  var _response$data;
495
499
  const response = await _authenticatedProxyApi.authenticatedProxyApi.getOrder(serializedOrderParams);
@@ -671,7 +675,10 @@ exports.useSingleOrderBranchesQuery = useSingleOrderBranchesQuery;
671
675
  const useBranchesQuery = branchesParams => {
672
676
  const branchesParamsString = new URLSearchParams((0, _helpers__.removeNullishProps)(branchesParams)).toString();
673
677
  const branchesQuery = (0, _reactQuery.useQuery)(['branches-test', branchesParamsString], {
674
- queryFn: () => _publicProxyApi.publicProxyApi.getBranches(branchesParamsString).then(res => res.data)
678
+ queryFn: () => _publicProxyApi.publicProxyApi.getBranches(branchesParamsString).then(res => res.data),
679
+ keepPreviousData: true,
680
+ staleTime: 5 * 60 * 1000,
681
+ refetchOnWindowFocus: false
675
682
  });
676
683
  return {
677
684
  isBranchesError: branchesQuery.isError,
@@ -680,11 +687,30 @@ const useBranchesQuery = branchesParams => {
680
687
  };
681
688
  };
682
689
 
690
+ /**
691
+ * @description Retrieves the compact configurator locations view model
692
+ */
693
+ exports.useBranchesQuery = useBranchesQuery;
694
+ const useConfiguratorLocationsQuery = locationsParams => {
695
+ const locationsParamsString = new URLSearchParams((0, _helpers__.removeNullishProps)(locationsParams)).toString();
696
+ const locationsQuery = (0, _reactQuery.useQuery)(['configurator-locations', locationsParamsString], {
697
+ queryFn: () => _publicProxyApi.publicProxyApi.getConfiguratorLocations(locationsParamsString).then(res => res.data),
698
+ keepPreviousData: true,
699
+ staleTime: 5 * 60 * 1000,
700
+ refetchOnWindowFocus: false
701
+ });
702
+ return {
703
+ isLocationsError: locationsQuery.isError,
704
+ isLoadingLocations: locationsQuery.isLoading,
705
+ locations: locationsQuery === null || locationsQuery === void 0 ? void 0 : locationsQuery.data
706
+ };
707
+ };
708
+
683
709
  /**
684
710
  * @description Retrieves available branches by type
685
711
  * @param {String} type - The type of branches to retrieve
686
712
  */
687
- exports.useBranchesQuery = useBranchesQuery;
713
+ exports.useConfiguratorLocationsQuery = useConfiguratorLocationsQuery;
688
714
  const useBranchesByType = _ref4 => {
689
715
  let {
690
716
  formula,
@@ -98,6 +98,15 @@ const normalizeOrderParams = exports.normalizeOrderParams = function normalizeOr
98
98
  normalizedParams.constructionYear = normalizedParams.buildYear;
99
99
  delete normalizedParams.buildYear;
100
100
  }
101
+ if (normalizedParams.selectBoardComputerUpdate === false || normalizedParams.selectBoardComputerUpdate === 'false') {
102
+ delete normalizedParams.selectBoardComputerUpdate;
103
+ }
104
+ if (Array.isArray(normalizedParams.cart) && normalizedParams.cart.length === 0) {
105
+ delete normalizedParams.cart;
106
+ }
107
+ if (normalizedParams.cart === '[]') {
108
+ delete normalizedParams.cart;
109
+ }
101
110
  if (!APP_CONFIG.internal) {
102
111
  delete normalizedParams.priceCalculationDate;
103
112
  }
@@ -73,24 +73,32 @@ const LocationAutoComplete = _ref => {
73
73
  const [loading, setLoading] = (0, _react.useState)(false);
74
74
  const [error, setError] = (0, _react.useState)('');
75
75
  const debounceTimer = (0, _react.useRef)(null);
76
+ const placesServiceContainerRef = (0, _react.useRef)(null);
76
77
  const trackInput = (0, _useDebouncedPush.default)();
77
78
  const map = (0, _reactGoogleMaps.useMap)();
78
79
  const places = (0, _reactGoogleMaps.useMapsLibrary)('places');
79
80
  (0, _react.useEffect)(() => {
80
- if (!places || !map) return;
81
+ if (!places) return;
81
82
  setAutocompleteService(new places.AutocompleteService());
82
- setPlacesService(new places.PlacesService(map));
83
+ setPlacesService(new places.PlacesService(map || placesServiceContainerRef.current));
83
84
  setSessionToken(new places.AutocompleteSessionToken());
84
- return () => setAutocompleteService(null);
85
+ return () => {
86
+ setAutocompleteService(null);
87
+ setPlacesService(null);
88
+ };
85
89
  }, [map, places]);
86
90
  (0, _react.useEffect)(() => {
87
91
  return () => clearTimeout(debounceTimer.current);
88
92
  }, []);
89
93
  const fetchPredictions = (0, _react.useCallback)(async inputValue => {
94
+ var _response$predictions;
90
95
  if (!autocompleteService || !inputValue) {
91
96
  setPredictionResults([]);
97
+ setLoading(false);
98
+ setError('');
92
99
  return;
93
100
  }
101
+ setError('');
94
102
  const request = {
95
103
  input: inputValue,
96
104
  sessionToken,
@@ -100,11 +108,21 @@ const LocationAutoComplete = _ref => {
100
108
  }
101
109
  };
102
110
  const response = await autocompleteService.getPlacePredictions(request);
103
- response.predictions.length > 0 && setLoading(false);
104
- if (response.status !== 'OK') {
105
- setError(response.status);
111
+ const predictions = (_response$predictions = response === null || response === void 0 ? void 0 : response.predictions) !== null && _response$predictions !== void 0 ? _response$predictions : [];
112
+ const status = response === null || response === void 0 ? void 0 : response.status;
113
+ setLoading(false);
114
+ if (predictions.length > 0) {
115
+ setError('');
116
+ setPredictionResults(predictions);
117
+ return;
118
+ }
119
+ if (status && status !== 'OK') {
120
+ setPredictionResults([]);
121
+ setError(status);
122
+ return;
106
123
  }
107
- setPredictionResults(response.predictions);
124
+ setPredictionResults([]);
125
+ setError('ZERO_RESULTS');
108
126
  }, [autocompleteService, sessionToken]);
109
127
  const onInputChange = (0, _react.useCallback)(event => {
110
128
  var _event$target;
@@ -124,33 +142,36 @@ const LocationAutoComplete = _ref => {
124
142
  }, [fetchPredictions, trackInput]);
125
143
  const handleSuggestionClick = (0, _react.useCallback)(placeId => {
126
144
  var _document$querySelect;
127
- if (!places) return;
145
+ if (!places || !placesService) return;
128
146
  const detailRequestOptions = {
129
147
  placeId,
130
148
  fields: ['geometry', 'name', 'formatted_address'],
131
149
  sessionToken
132
150
  };
133
- const detailsRequestCallback = placeDetails => {
134
- var _placeDetails$formatt, _placeDetails$geometr;
151
+ const detailsRequestCallback = (placeDetails, status) => {
152
+ var _placeDetails$geometr, _placeDetails$formatt;
153
+ if (status !== 'OK' || !(placeDetails !== null && placeDetails !== void 0 && (_placeDetails$geometr = placeDetails.geometry) !== null && _placeDetails$geometr !== void 0 && _placeDetails$geometr.location)) {
154
+ setPredictionResults([]);
155
+ setDropdownActive(false);
156
+ return;
157
+ }
135
158
  setPredictionResults([]);
136
159
  setInputValue((_placeDetails$formatt = placeDetails === null || placeDetails === void 0 ? void 0 : placeDetails.formatted_address) !== null && _placeDetails$formatt !== void 0 ? _placeDetails$formatt : '');
137
160
  setSessionToken(new places.AutocompleteSessionToken());
138
161
  setDropdownActive(false);
139
- if (placeDetails !== null && placeDetails !== void 0 && (_placeDetails$geometr = placeDetails.geometry) !== null && _placeDetails$geometr !== void 0 && _placeDetails$geometr.location) {
140
- const {
141
- lat,
142
- lng
143
- } = placeDetails.geometry.location;
144
- const coordinates = {
145
- lat: lat(),
146
- lng: lng()
147
- };
148
- onLocationUpdate(coordinates, true);
149
- }
162
+ const {
163
+ lat,
164
+ lng
165
+ } = placeDetails.geometry.location;
166
+ const coordinates = {
167
+ lat: lat(),
168
+ lng: lng()
169
+ };
170
+ onLocationUpdate(coordinates, true);
150
171
  };
151
- placesService === null || placesService === void 0 || placesService.getDetails(detailRequestOptions, detailsRequestCallback);
172
+ placesService.getDetails(detailRequestOptions, detailsRequestCallback);
152
173
  (_document$querySelect = document.querySelector((0, _helpers__.withStyle)("dealer-autocomplete__list"))) === null || _document$querySelect === void 0 || _document$querySelect.scrollTo(0, 0);
153
- }, [places, placesService, sessionToken, onLocationUpdate, predictionResults]);
174
+ }, [places, placesService, sessionToken, onLocationUpdate]);
154
175
  const handleSubmit = event => {
155
176
  event.preventDefault();
156
177
  };
@@ -175,10 +196,10 @@ const LocationAutoComplete = _ref => {
175
196
  }), /*#__PURE__*/_react.default.createElement("i", {
176
197
  className: "".concat((0, _helpers__.withStyle)('dealer-autocomplete__search-icon'), " far fa-search")
177
198
  }), /*#__PURE__*/_react.default.createElement("div", {
178
- className: (0, _helpers__.withStyle)("dealer-autocomplete__loader ".concat(dropdownActive ? 'active' : ''))
199
+ className: (0, _helpers__.withStyle)("dealer-autocomplete__loader ".concat(loading ? 'active' : ''))
179
200
  }, /*#__PURE__*/_react.default.createElement("i", {
180
201
  className: "fas fa-cog fa-spin"
181
- })), predictionResults.length > 0 && /*#__PURE__*/_react.default.createElement("div", {
202
+ })), dropdownActive && (loading || error || predictionResults.length > 0) && /*#__PURE__*/_react.default.createElement("div", {
182
203
  className: (0, _helpers__.withStyle)("dealer-autocomplete__list ".concat(dropdownActive ? 'active' : ''))
183
204
  }, loading && /*#__PURE__*/_react.default.createElement(LocationsLoading, null), error && /*#__PURE__*/_react.default.createElement(LocationsNotFound, null), predictionResults.map(_ref2 => {
184
205
  let {
@@ -193,6 +214,16 @@ const LocationAutoComplete = _ref => {
193
214
  className: className,
194
215
  onClick: () => handleSuggestionClick(place_id)
195
216
  }, /*#__PURE__*/_react.default.createElement("p", null, description));
196
- })));
217
+ })), /*#__PURE__*/_react.default.createElement("div", {
218
+ ref: placesServiceContainerRef,
219
+ style: {
220
+ height: 0,
221
+ left: -9999,
222
+ overflow: 'hidden',
223
+ position: 'absolute',
224
+ top: -9999,
225
+ width: 0
226
+ }
227
+ }));
197
228
  };
198
229
  var _default = exports.default = LocationAutoComplete;
@@ -17,7 +17,6 @@ require("core-js/modules/esnext.iterator.constructor.js");
17
17
  require("core-js/modules/esnext.iterator.filter.js");
18
18
  require("core-js/modules/esnext.iterator.map.js");
19
19
  var _react = _interopRequireWildcard(require("react"));
20
- var _queries = require("../../__api__/queries");
21
20
  var _helpers__ = require("../../__helpers__");
22
21
  function _getRequireWildcardCache(e) {
23
22
  if ("function" != typeof WeakMap) return null;
@@ -157,6 +156,7 @@ const formatDate = dateStr => {
157
156
  * Normalises a raw branch object (from GET /branches/:id) into display props.
158
157
  */
159
158
  const buildDetailProps = branch => {
159
+ var _branch$haalEnBrengSe, _branch$extraGesloten;
160
160
  if (!branch) return null;
161
161
  return {
162
162
  leenauto: {
@@ -169,11 +169,11 @@ const buildDetailProps = branch => {
169
169
  voorwaarden: branch.leenfietsVoorwaarden
170
170
  },
171
171
  haalEnBrengservice: {
172
- status: branch.haalEnBrengServiceJaNee,
172
+ status: (_branch$haalEnBrengSe = branch.haalEnBrengServiceJaNee) !== null && _branch$haalEnBrengSe !== void 0 ? _branch$haalEnBrengSe : branch.haalEnBrengService,
173
173
  voorwaarden: branch.haalEnBrengServiceVoorwaarden
174
174
  },
175
175
  betaalmethoden: Array.isArray(branch.betaalmethoden) ? branch.betaalmethoden.map(m => m && typeof m === 'object' ? m.title : m).filter(Boolean) : branch.betaalmethoden,
176
- extraGeslotenDagen: branch.extraGeslotenDagen
176
+ extraGeslotenDagen: (_branch$extraGesloten = branch.extraGeslotenDagen) !== null && _branch$extraGesloten !== void 0 ? _branch$extraGesloten : branch.extraGeslotenDagenVestiging
177
177
  };
178
178
  };
179
179
 
@@ -183,39 +183,14 @@ const buildDetailProps = branch => {
183
183
  */
184
184
  const LocationDetails = _ref4 => {
185
185
  let {
186
- id
186
+ initialBranch = null
187
187
  } = _ref4;
188
- const {
189
- branchById,
190
- isLoadingBranchById
191
- } = (0, _queries.useBranchByIdOrWidgetId)(id || '');
192
188
  const today = (0, _react.useMemo)(() => {
193
189
  const d = new Date();
194
190
  d.setHours(0, 0, 0, 0);
195
191
  return d;
196
192
  }, []);
197
- if (isLoadingBranchById && !branchById) {
198
- return /*#__PURE__*/_react.default.createElement("div", {
199
- className: (0, _helpers__.withStyle)('d-flex align-items-center gap-1 mt-2 pt-2'),
200
- style: {
201
- borderTop: '1px solid #e9ecef'
202
- }
203
- }, /*#__PURE__*/_react.default.createElement("div", {
204
- className: (0, _helpers__.withStyle)('spinner-border spinner-border-sm text-primary'),
205
- role: "status",
206
- style: {
207
- width: 12,
208
- height: 12,
209
- borderWidth: 2
210
- }
211
- }), /*#__PURE__*/_react.default.createElement("small", {
212
- className: (0, _helpers__.withStyle)('text-muted'),
213
- style: {
214
- fontSize: 11
215
- }
216
- }, "Vestigingsdetails laden\u2026"));
217
- }
218
- const props = buildDetailProps(branchById);
193
+ const props = buildDetailProps(initialBranch);
219
194
  if (!props) return null;
220
195
  const {
221
196
  leenauto,
@@ -2,7 +2,6 @@
2
2
 
3
3
  require("core-js/modules/es.array.sort.js");
4
4
  require("core-js/modules/es.number.to-fixed.js");
5
- require("core-js/modules/es.parse-float.js");
6
5
  require("core-js/modules/es.weak-map.js");
7
6
  require("core-js/modules/esnext.iterator.constructor.js");
8
7
  require("core-js/modules/esnext.iterator.filter.js");
@@ -17,12 +16,13 @@ Object.defineProperty(exports, "__esModule", {
17
16
  exports.default = void 0;
18
17
  require("core-js/modules/es.array.sort.js");
19
18
  require("core-js/modules/es.number.to-fixed.js");
20
- require("core-js/modules/es.parse-float.js");
21
19
  require("core-js/modules/esnext.iterator.constructor.js");
22
20
  require("core-js/modules/esnext.iterator.filter.js");
23
21
  require("core-js/modules/esnext.iterator.map.js");
24
22
  require("core-js/modules/web.dom-collections.iterator.js");
25
23
  var _react = _interopRequireWildcard(require("react"));
24
+ var _LinkButton = _interopRequireDefault(require("../Buttons/LinkButton"));
25
+ var _InlineSpinner = _interopRequireDefault(require("../Spinners/InlineSpinner"));
26
26
  var _ActiveMarkerContext = require("../../__context__/ActiveMarkerContext");
27
27
  var _OrderSessionContext = require("../../__context__/OrderSessionContext");
28
28
  var _helpers__ = require("../../__helpers__");
@@ -101,15 +101,13 @@ function _toPrimitive(t, r) {
101
101
  }
102
102
  return ("string" === r ? String : Number)(t);
103
103
  }
104
+ const LOCATION_PAGE_SIZE = 10;
104
105
  const LocationsLoading = () => {
105
106
  return /*#__PURE__*/_react.default.createElement("div", {
106
107
  className: (0, _helpers__.withStyle)('w-100 text-center')
107
- }, /*#__PURE__*/_react.default.createElement("div", {
108
- className: (0, _helpers__.withStyle)('spinner-border text-primary mx-auto'),
109
- role: "status"
110
- }, /*#__PURE__*/_react.default.createElement("span", {
111
- className: "sr-only"
112
- }, "Loading...")));
108
+ }, /*#__PURE__*/_react.default.createElement(_InlineSpinner.default, {
109
+ size: "2rem"
110
+ }));
113
111
  };
114
112
  const NoLocationFound = () => {
115
113
  return /*#__PURE__*/_react.default.createElement("h4", null, "Geen montagelocaties gevonden");
@@ -128,34 +126,33 @@ const LocationList = _ref => {
128
126
  const [{
129
127
  selectedBranch
130
128
  }] = (0, _OrderSessionContext.useOrderSession)();
129
+ const [visibleCount, setVisibleCount] = (0, _react.useState)(LOCATION_PAGE_SIZE);
131
130
  const listRef = (0, _react.useRef)(null);
132
- const locationsWithDistance = locationIds.map((locationId, index) => {
133
- const location = locationsById[locationId];
134
- const coordinates = location.googleMapsLocation;
135
- if (!coordinates) return null;
136
- const [latStr, lngStr] = coordinates.split(',');
137
- const lat = parseFloat(latStr);
138
- const lng = parseFloat(lngStr);
139
- const distance = userLocation ? (0, _geolocation.calculateDistance)({
140
- lat1: userLocation.lat,
141
- lng1: userLocation.lng,
142
- lat2: lat,
143
- lng2: lng
144
- }).toFixed(2) : null;
145
- return _objectSpread(_objectSpread({}, location), {}, {
146
- distance: distance ? parseFloat(distance) : null
131
+ const sortedLocations = (0, _react.useMemo)(() => {
132
+ const locationsWithDistance = locationIds.map(locationId => {
133
+ const location = locationsById[locationId];
134
+ const coordinates = (0, _geolocation.getCoordinatesByString)(location.googleMapsLocation);
135
+ if (!coordinates) return null;
136
+ const distance = userLocation ? (0, _geolocation.calculateDistance)({
137
+ lat1: Number(userLocation.lat),
138
+ lng1: Number(userLocation.lng),
139
+ lat2: coordinates.lat,
140
+ lng2: coordinates.lng
141
+ }) : null;
142
+ return _objectSpread(_objectSpread({}, location), {}, {
143
+ distance: distance != null ? Number(distance.toFixed(2)) : null
144
+ });
145
+ }).filter(location => location !== null);
146
+ return [...locationsWithDistance].sort((a, b) => {
147
+ const aIsSelected = a.entityId === activeMarkerId || a.entityId === selectedBranch;
148
+ const bIsSelected = b.entityId === activeMarkerId || b.entityId === selectedBranch;
149
+ if (aIsSelected && !bIsSelected) return -1;
150
+ if (!aIsSelected && bIsSelected) return 1;
151
+ if (a.distance === null) return 1;
152
+ if (b.distance === null) return -1;
153
+ return a.distance - b.distance;
147
154
  });
148
- }).filter(location => location !== null);
149
- const sortedLocations = locationsWithDistance.sort((a, b) => {
150
- const aIsSelected = a.entityId === activeMarkerId || a.entityId === selectedBranch;
151
- const bIsSelected = b.entityId === activeMarkerId || b.entityId === selectedBranch;
152
- if (aIsSelected && !bIsSelected) return -1; // a goes to top
153
- if (!aIsSelected && bIsSelected) return 1; // b goes to top
154
-
155
- if (a.distance === null) return 1;
156
- if (b.distance === null) return -1;
157
- return a.distance - b.distance;
158
- });
155
+ }, [activeMarkerId, locationIds, locationsById, selectedBranch, userLocation]);
159
156
 
160
157
  // Handle scrolling when location is set via search
161
158
  (0, _react.useEffect)(() => {
@@ -163,18 +160,31 @@ const LocationList = _ref => {
163
160
  listRef.current.scrollTop = 0;
164
161
  }
165
162
  }, [isLocationSetViaSearch, userLocation]);
163
+ (0, _react.useEffect)(() => {
164
+ setVisibleCount(LOCATION_PAGE_SIZE);
165
+ }, [locationIds, userLocation]);
166
+ const visibleLocations = sortedLocations.slice(0, visibleCount);
167
+ const hasMoreLocations = visibleCount < sortedLocations.length;
166
168
  return /*#__PURE__*/_react.default.createElement("div", {
167
169
  ref: listRef,
168
170
  className: (0, _helpers__.withStyle)('dealer-list')
169
- }, /*#__PURE__*/_react.default.createElement("h5", null, userLocation ? 'Dichtsbijzijnde montagelocaties' : 'Montagelocaties'), isLoading && /*#__PURE__*/_react.default.createElement(LocationsLoading, null), !isLoading && !locationIds.length && /*#__PURE__*/_react.default.createElement(NoLocationFound, null), sortedLocations.map(location => /*#__PURE__*/_react.default.createElement(_LocationListItem.default, {
171
+ }, /*#__PURE__*/_react.default.createElement("h5", null, userLocation ? 'Dichtsbijzijnde montagelocaties' : 'Montagelocaties'), isLoading && /*#__PURE__*/_react.default.createElement(LocationsLoading, null), !isLoading && !locationIds.length && /*#__PURE__*/_react.default.createElement(NoLocationFound, null), visibleLocations.map(location => /*#__PURE__*/_react.default.createElement(_LocationListItem.default, {
170
172
  openingHours: location.openingstijden,
171
173
  title: location.naamVestiging,
172
174
  city: location.city,
173
175
  distance: location.distance ? location.distance : null,
174
176
  id: location.entityId,
175
177
  key: location.entityId,
178
+ branch: location,
176
179
  isSelected: location.entityId === activeMarkerId || location.entityId === selectedBranch,
177
180
  userLocation: userLocation
181
+ })), hasMoreLocations && /*#__PURE__*/_react.default.createElement("div", {
182
+ className: (0, _helpers__.withStyle)('text-center mt-3')
183
+ }, /*#__PURE__*/_react.default.createElement(_LinkButton.default, {
184
+ label: "Laad meer",
185
+ onClick: () => {
186
+ setVisibleCount(currentCount => Math.min(currentCount + LOCATION_PAGE_SIZE, sortedLocations.length));
187
+ }
178
188
  })));
179
189
  };
180
190
  var _default = exports.default = LocationList;
@@ -51,7 +51,8 @@ const LocationListItem = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
51
51
  distance,
52
52
  id,
53
53
  isSelected,
54
- userLocation
54
+ userLocation,
55
+ branch
55
56
  } = _ref;
56
57
  const [{
57
58
  selectedBranch
@@ -109,7 +110,7 @@ const LocationListItem = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
109
110
  className: (0, _helpers__.withStyle)('form-check-label'),
110
111
  htmlFor: "dealer-item-check-".concat(id)
111
112
  }, isSelected ? 'Geselecteerd' : 'Selecteren')))), isSelected && APP_CONFIG.internal && /*#__PURE__*/_react.default.createElement(_LocationDetails.default, {
112
- id: id
113
+ initialBranch: branch
113
114
  }));
114
115
  });
115
116
  var _default = exports.default = LocationListItem;
@@ -11,9 +11,7 @@ require("core-js/modules/web.dom-collections.iterator.js");
11
11
  var _reactGoogleMaps = require("@vis.gl/react-google-maps");
12
12
  var _react = _interopRequireWildcard(require("react"));
13
13
  var _queries = require("../../__api__/queries");
14
- var _constants__ = require("../../__constants__");
15
14
  var _ActiveMarkerContext = require("../../__context__/ActiveMarkerContext");
16
- var _AuthSessionContext = require("../../__context__/AuthSessionContext");
17
15
  var _FormulaContext = require("../../__context__/FormulaContext");
18
16
  var _OrderSessionContext = require("../../__context__/OrderSessionContext");
19
17
  var _helpers__ = require("../../__helpers__");
@@ -73,26 +71,14 @@ const LocationsSelector = /*#__PURE__*/_react.default.memo(() => {
73
71
  const [{
74
72
  franchiseName
75
73
  }] = (0, _OrderSessionContext.useOrderSession)();
76
- const authSession = (0, _AuthSessionContext.useAuthSession)();
77
74
  const {
78
- branchTypes
79
- } = (0, _queries.useBranchTypes)();
80
- const isTMGOrganization = _react.default.useMemo(() => {
81
- var _branchTypes$byId$aut, _authSession$branch;
82
- return (branchTypes === null || branchTypes === void 0 || (_branchTypes$byId$aut = branchTypes.byId[authSession === null || authSession === void 0 || (_authSession$branch = authSession.branch) === null || _authSession$branch === void 0 || (_authSession$branch = _authSession$branch.organisatietype) === null || _authSession$branch === void 0 ? void 0 : _authSession$branch[0]]) === null || _branchTypes$byId$aut === void 0 ? void 0 : _branchTypes$byId$aut.title) === _constants__.TMG_ORGANIZATION_TYPE;
83
- }, [branchTypes, authSession]);
84
- const {
85
- branches
86
- } = (0, _queries.useBranchesQuery)({
87
- offset: 0,
88
- limit: 400,
75
+ locations: locationsData,
76
+ isLoadingLocations
77
+ } = (0, _queries.useConfiguratorLocationsQuery)({
89
78
  formula,
90
79
  franchiseName
91
80
  });
92
- const {
93
- myBranches
94
- } = (0, _queries.useMyBranches)(formula);
95
- const locations = isTMGOrganization || !APP_CONFIG.internal ? (branches === null || branches === void 0 ? void 0 : branches.results) || [] : myBranches || [];
81
+ const locations = (locationsData === null || locationsData === void 0 ? void 0 : locationsData.results) || [];
96
82
  const {
97
83
  byId,
98
84
  allIds
@@ -135,7 +121,7 @@ const LocationsSelector = /*#__PURE__*/_react.default.memo(() => {
135
121
  userLocation: userLocation
136
122
  }))), /*#__PURE__*/_react.default.createElement("aside", {
137
123
  className: (0, _helpers__.withStyle)('dealer-sidebar col-xl-4 mt-3 mt-xl-0')
138
- }, isDesktop && /*#__PURE__*/_react.default.createElement(_LocationAutoComplete.default, {
124
+ }, /*#__PURE__*/_react.default.createElement(_LocationAutoComplete.default, {
139
125
  onLocationUpdate: handleLocationUpdate
140
126
  }), franchiseName && /*#__PURE__*/_react.default.createElement("h6", {
141
127
  className: (0, _helpers__.withStyle)('my-2')
@@ -143,12 +129,13 @@ const LocationsSelector = /*#__PURE__*/_react.default.memo(() => {
143
129
  locationIds: allIds,
144
130
  locationsById: byId,
145
131
  userLocation: userLocation,
146
- isLocationSetViaSearch: isLocationSetViaSearch
132
+ isLocationSetViaSearch: isLocationSetViaSearch,
133
+ isLoading: isLoadingLocations
147
134
  }))) : /*#__PURE__*/_react.default.createElement("div", {
148
135
  className: (0, _helpers__.withStyle)('row gx-5 mt-3 mt-xl-5 justify-content-center')
149
136
  }, /*#__PURE__*/_react.default.createElement("aside", {
150
137
  className: (0, _helpers__.withStyle)('dealer-sidebar col-xl-4 mt-3 mt-xl-0')
151
- }, isDesktop && /*#__PURE__*/_react.default.createElement(_LocationAutoComplete.default, {
138
+ }, /*#__PURE__*/_react.default.createElement(_LocationAutoComplete.default, {
152
139
  onLocationUpdate: handleLocationUpdate
153
140
  }), franchiseName && /*#__PURE__*/_react.default.createElement("h6", {
154
141
  className: (0, _helpers__.withStyle)('my-2')
@@ -156,7 +143,8 @@ const LocationsSelector = /*#__PURE__*/_react.default.memo(() => {
156
143
  locationIds: allIds,
157
144
  locationsById: byId,
158
145
  userLocation: userLocation,
159
- isLocationSetViaSearch: isLocationSetViaSearch
146
+ isLocationSetViaSearch: isLocationSetViaSearch,
147
+ isLoading: isLoadingLocations
160
148
  })))));
161
149
  });
162
150
  var _default = exports.default = LocationsSelector;
@@ -64,6 +64,7 @@ const DiscountProductsSelector = _ref => {
64
64
  licensePlate,
65
65
  model,
66
66
  durationAnswer,
67
+ durationAnswerIsPrefilled,
67
68
  executionAnswer1,
68
69
  executionAnswer2,
69
70
  priceCalculationDate,
@@ -73,6 +74,7 @@ const DiscountProductsSelector = _ref => {
73
74
  discountsInitialized
74
75
  }, dispatch] = (0, _OrderSessionContext.useOrderSession)();
75
76
  const formula = (0, _FormulaContext.useFormula)();
77
+ const durationAnswerForQuery = durationAnswerIsPrefilled ? undefined : durationAnswer;
76
78
  const {
77
79
  discountProducts
78
80
  } = (0, _queries.useProductsQuery)({
@@ -80,7 +82,7 @@ const DiscountProductsSelector = _ref => {
80
82
  model,
81
83
  executionAnswer1,
82
84
  executionAnswer2,
83
- durationAnswer: durationAnswer,
85
+ durationAnswer: durationAnswerForQuery,
84
86
  formula,
85
87
  priceCalculationDate,
86
88
  discountCode