thm-p3-configurator 0.0.375 → 0.0.377
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.
- package/dist/src/shared/__api__/publicProxyApi.js +6 -0
- package/dist/src/shared/__api__/queries.js +29 -3
- package/dist/src/shared/__api__/queryKeyFactory.js +9 -0
- package/dist/src/shared/__components__/LocationsSelector/LocationAutoComplete.js +57 -26
- package/dist/src/shared/__components__/LocationsSelector/LocationDetails.js +5 -30
- package/dist/src/shared/__components__/LocationsSelector/LocationList.js +45 -35
- package/dist/src/shared/__components__/LocationsSelector/LocationListItem.js +3 -2
- package/dist/src/shared/__components__/LocationsSelector/index.js +10 -22
- package/dist/src/shared/__containers__/DiscountProductsSelector.js +3 -1
- package/dist/src/shared/__containers__/ExtraProductsOverview.js +7 -56
- package/dist/src/shared/__containers__/LicensePlateForm.js +1 -19
- package/dist/src/shared/__containers__/ManualSelectionForm.js +1 -9
- package/dist/src/shared/__containers__/ProductCartSide.js +5 -1
- package/dist/src/shared/__containers__/ProductDiscountCard.js +3 -1
- package/dist/src/shared/__containers__/ProductsCartOverview.js +5 -1
- package/dist/src/shared/__containers__/ProductsOverview.js +5 -1
- package/dist/src/shared/__containers__/QuestionsForm.js +9 -55
- package/dist/src/shared/__containers__/VehicleData.js +5 -1
- package/dist/src/shared/__containers__/internal/InternalAppointmentForm.js +7 -2
- package/dist/src/shared/__containers__/internal/InternalQuotationForm.js +7 -2
- package/dist/src/shared/__context__/OrderSessionContext.js +16 -2
- package/dist/src/shared/__pages__/index.js +61 -8
- 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.
|
|
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
|
|
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 () =>
|
|
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
|
|
104
|
-
|
|
105
|
-
|
|
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(
|
|
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$
|
|
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
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
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
|
|
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
|
|
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(
|
|
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
|
-
|
|
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
|
-
|
|
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(
|
|
108
|
-
|
|
109
|
-
|
|
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
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
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
|
-
}
|
|
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),
|
|
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
|
-
|
|
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
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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:
|
|
85
|
+
durationAnswer: durationAnswerForQuery,
|
|
84
86
|
formula,
|
|
85
87
|
priceCalculationDate,
|
|
86
88
|
discountCode
|
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
require("core-js/modules/es.symbol.description.js");
|
|
4
|
-
require("core-js/modules/es.json.stringify.js");
|
|
5
|
-
require("core-js/modules/es.weak-map.js");
|
|
6
4
|
require("core-js/modules/esnext.iterator.map.js");
|
|
7
5
|
require("core-js/modules/web.dom-collections.iterator.js");
|
|
8
|
-
require("core-js/modules/es.weak-map.js");
|
|
9
6
|
Object.defineProperty(exports, "__esModule", {
|
|
10
7
|
value: true
|
|
11
8
|
});
|
|
12
9
|
exports.default = void 0;
|
|
13
10
|
require("core-js/modules/es.symbol.description.js");
|
|
14
|
-
require("core-js/modules/es.json.stringify.js");
|
|
15
11
|
require("core-js/modules/esnext.iterator.map.js");
|
|
16
12
|
require("core-js/modules/web.dom-collections.iterator.js");
|
|
17
|
-
var _react =
|
|
13
|
+
var _react = _interopRequireDefault(require("react"));
|
|
18
14
|
var _reactRouter = require("react-router");
|
|
19
15
|
var _thLogoBlack = _interopRequireDefault(require("../../../public/assets/images/th-logo-black.png"));
|
|
20
16
|
var _queries = require("../__api__/queries");
|
|
@@ -29,74 +25,32 @@ var _image = require("../__helpers__/image");
|
|
|
29
25
|
var _montageRate = require("../__helpers__/montageRate");
|
|
30
26
|
var _product = require("../__helpers__/product");
|
|
31
27
|
var _useIsTmg = require("../__hooks__/useIsTmg");
|
|
32
|
-
var _useIsTowmotive = require("../__hooks__/useIsTowmotive");
|
|
33
28
|
function _interopRequireDefault(e) {
|
|
34
29
|
return e && e.__esModule ? e : {
|
|
35
30
|
default: e
|
|
36
31
|
};
|
|
37
32
|
}
|
|
38
|
-
function _getRequireWildcardCache(e) {
|
|
39
|
-
if ("function" != typeof WeakMap) return null;
|
|
40
|
-
var r = new WeakMap(),
|
|
41
|
-
t = new WeakMap();
|
|
42
|
-
return (_getRequireWildcardCache = function _getRequireWildcardCache(e) {
|
|
43
|
-
return e ? t : r;
|
|
44
|
-
})(e);
|
|
45
|
-
}
|
|
46
|
-
function _interopRequireWildcard(e, r) {
|
|
47
|
-
if (!r && e && e.__esModule) return e;
|
|
48
|
-
if (null === e || "object" != typeof e && "function" != typeof e) return {
|
|
49
|
-
default: e
|
|
50
|
-
};
|
|
51
|
-
var t = _getRequireWildcardCache(r);
|
|
52
|
-
if (t && t.has(e)) return t.get(e);
|
|
53
|
-
var n = {
|
|
54
|
-
__proto__: null
|
|
55
|
-
},
|
|
56
|
-
a = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
57
|
-
for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
|
|
58
|
-
var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
|
|
59
|
-
i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u];
|
|
60
|
-
}
|
|
61
|
-
return n.default = e, t && t.set(e, n), n;
|
|
62
|
-
}
|
|
63
33
|
const ExtraProductsOverview = () => {
|
|
64
34
|
var _products$Extras;
|
|
65
35
|
const formula = (0, _FormulaContext.useFormula)();
|
|
66
36
|
const isTmg = (0, _useIsTmg.useIsTmg)();
|
|
67
|
-
const
|
|
37
|
+
const skipFilters = false;
|
|
68
38
|
const [{
|
|
69
39
|
licensePlate,
|
|
70
40
|
model,
|
|
71
|
-
selectedBoardComputer,
|
|
72
41
|
selectedExtras,
|
|
73
|
-
selectedCableset,
|
|
74
|
-
selectedCombiset,
|
|
75
|
-
selectedTowbar,
|
|
76
42
|
discountCode,
|
|
77
43
|
executionAnswer1,
|
|
78
44
|
executionAnswer2,
|
|
79
45
|
durationAnswer,
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
touchedConsumerDiscounts,
|
|
46
|
+
durationAnswerIsPrefilled,
|
|
47
|
+
buildYear,
|
|
83
48
|
discountAmount,
|
|
84
49
|
discountPercentage,
|
|
85
50
|
montageRate,
|
|
86
51
|
extraPriceAmount
|
|
87
52
|
}, dispatch] = (0, _OrderSessionContext.useOrderSession)();
|
|
88
|
-
const
|
|
89
|
-
const cartInput = (0, _product.buildCartInput)({
|
|
90
|
-
selectedCableset,
|
|
91
|
-
selectedCombiset,
|
|
92
|
-
selectedTowbar,
|
|
93
|
-
selectedBoardComputer,
|
|
94
|
-
selectedExtras,
|
|
95
|
-
isTowmotiveFormula: isTowmotive,
|
|
96
|
-
vehicleCodingDiscountPercentage,
|
|
97
|
-
consumerDiscounts,
|
|
98
|
-
touchedConsumerDiscounts
|
|
99
|
-
});
|
|
53
|
+
const durationAnswerForQuery = durationAnswerIsPrefilled ? undefined : durationAnswer;
|
|
100
54
|
const {
|
|
101
55
|
products,
|
|
102
56
|
isLoadingProducts,
|
|
@@ -106,9 +60,8 @@ const ExtraProductsOverview = () => {
|
|
|
106
60
|
model,
|
|
107
61
|
executionAnswer1,
|
|
108
62
|
executionAnswer2,
|
|
109
|
-
durationAnswer:
|
|
110
|
-
|
|
111
|
-
cart: cartInput ? JSON.stringify(cartInput) : undefined,
|
|
63
|
+
durationAnswer: durationAnswerForQuery,
|
|
64
|
+
buildYear,
|
|
112
65
|
formula,
|
|
113
66
|
discountCode,
|
|
114
67
|
skipFilters,
|
|
@@ -193,8 +146,6 @@ const ExtraProductsOverview = () => {
|
|
|
193
146
|
key: "category-".concat(item.categoryName)
|
|
194
147
|
}, /*#__PURE__*/_react.default.createElement("h2", null, item.categoryName), item.products.map((product, index) => {
|
|
195
148
|
var _product$price, _product$consumerPric, _product$consumerPric2, _product$locationPric, _product$images, _product$images2, _product$boldDescript;
|
|
196
|
-
const isSelectedExtra = selectedExtras.hasOwnProperty(product.articleNumber);
|
|
197
|
-
|
|
198
149
|
// GetOrder is the single source of truth for prices
|
|
199
150
|
const resolvedProductPrice = (_product$price = product === null || product === void 0 ? void 0 : product.price) !== null && _product$price !== void 0 ? _product$price : null;
|
|
200
151
|
|
|
@@ -20,11 +20,9 @@ require("core-js/modules/web.dom-collections.iterator.js");
|
|
|
20
20
|
require("core-js/modules/web.url-search-params.js");
|
|
21
21
|
var _react = _interopRequireWildcard(require("react"));
|
|
22
22
|
var _reactRouter = require("react-router");
|
|
23
|
-
var _queries = require("../__api__/queries");
|
|
24
23
|
var _LinkButton = _interopRequireDefault(require("../__components__/Buttons/LinkButton"));
|
|
25
24
|
var _PrimaryButton = _interopRequireDefault(require("../__components__/Buttons/PrimaryButton"));
|
|
26
25
|
var _LicensePlateInput = _interopRequireDefault(require("../__components__/Form/LicensePlateInput"));
|
|
27
|
-
var _FormulaContext = require("../__context__/FormulaContext");
|
|
28
26
|
var _OrderSessionContext = require("../__context__/OrderSessionContext");
|
|
29
27
|
var _helpers__ = require("../__helpers__");
|
|
30
28
|
var _Datalayer = require("../__services__/Datalayer");
|
|
@@ -70,26 +68,10 @@ const LicensePlateForm = _ref => {
|
|
|
70
68
|
trackingComponent = 'license_plate_form'
|
|
71
69
|
} = _ref;
|
|
72
70
|
const [{
|
|
73
|
-
licensePlate
|
|
74
|
-
discountCode,
|
|
75
|
-
singleOrderFormulaCode,
|
|
76
|
-
buildYear
|
|
71
|
+
licensePlate
|
|
77
72
|
}, dispatch] = (0, _OrderSessionContext.useOrderSession)();
|
|
78
73
|
const [filterLicensePlate, setFilterLicensePlate] = (0, _react.useState)(initialValue || '');
|
|
79
74
|
const history = (0, _reactRouter.useHistory)();
|
|
80
|
-
let formula = (0, _FormulaContext.useFormula)();
|
|
81
|
-
if (isFilter && singleOrderFormulaCode) {
|
|
82
|
-
formula = singleOrderFormulaCode;
|
|
83
|
-
}
|
|
84
|
-
if (!isFilter) {
|
|
85
|
-
(0, _queries.useQuestionsQuery)({
|
|
86
|
-
licensePlate,
|
|
87
|
-
formula,
|
|
88
|
-
discountCode,
|
|
89
|
-
buildYear
|
|
90
|
-
}); // Prefetch
|
|
91
|
-
(0, _queries.useBrandsQuery)(formula); // Prefetch
|
|
92
|
-
}
|
|
93
75
|
const {
|
|
94
76
|
search
|
|
95
77
|
} = (0, _reactRouter.useLocation)();
|
|
@@ -77,7 +77,6 @@ const ManualSelectionForm = _ref => {
|
|
|
77
77
|
brand,
|
|
78
78
|
model,
|
|
79
79
|
buildYear,
|
|
80
|
-
discountCode,
|
|
81
80
|
singleOrderFormulaCode
|
|
82
81
|
}, dispatch] = (0, _OrderSessionContext.useOrderSession)();
|
|
83
82
|
let formula = (0, _FormulaContext.useFormula)();
|
|
@@ -108,7 +107,7 @@ const ManualSelectionForm = _ref => {
|
|
|
108
107
|
dispatch({
|
|
109
108
|
type: _OrderSessionContext.orderSessionActions.SET_DURATION_ANSWER,
|
|
110
109
|
payload: {
|
|
111
|
-
|
|
110
|
+
answer: null
|
|
112
111
|
}
|
|
113
112
|
});
|
|
114
113
|
onSubmit(isFilter ? {
|
|
@@ -116,13 +115,6 @@ const ManualSelectionForm = _ref => {
|
|
|
116
115
|
type: 'model'
|
|
117
116
|
} : undefined);
|
|
118
117
|
};
|
|
119
|
-
(0, _queries.useQuestionsQuery)({
|
|
120
|
-
model,
|
|
121
|
-
formula,
|
|
122
|
-
discountCode,
|
|
123
|
-
buildYear
|
|
124
|
-
}); // Prefetch
|
|
125
|
-
|
|
126
118
|
const {
|
|
127
119
|
search
|
|
128
120
|
} = (0, _reactRouter.useLocation)();
|
|
@@ -87,6 +87,8 @@ const ProductCartSide = () => {
|
|
|
87
87
|
executionAnswer1,
|
|
88
88
|
executionAnswer2,
|
|
89
89
|
durationAnswer,
|
|
90
|
+
durationAnswerIsPrefilled,
|
|
91
|
+
buildYear,
|
|
90
92
|
selectedTowbar,
|
|
91
93
|
selectedCableset,
|
|
92
94
|
selectedCombiset,
|
|
@@ -107,6 +109,7 @@ const ProductCartSide = () => {
|
|
|
107
109
|
} = order;
|
|
108
110
|
const isTmg = (0, _useIsTmg.useIsTmg)();
|
|
109
111
|
const isTowmotive = (0, _useIsTowmotive.useIsTowmotive)();
|
|
112
|
+
const durationAnswerForQuery = durationAnswerIsPrefilled ? undefined : durationAnswer;
|
|
110
113
|
const cartInput = (0, _product.buildCartInput)({
|
|
111
114
|
selectedCableset,
|
|
112
115
|
selectedCombiset,
|
|
@@ -129,7 +132,8 @@ const ProductCartSide = () => {
|
|
|
129
132
|
model,
|
|
130
133
|
executionAnswer1,
|
|
131
134
|
executionAnswer2,
|
|
132
|
-
durationAnswer,
|
|
135
|
+
durationAnswer: durationAnswerForQuery,
|
|
136
|
+
buildYear,
|
|
133
137
|
selectBoardComputerUpdate: selectedBoardComputer != null ? 'true' : 'false',
|
|
134
138
|
cart: cartInput ? JSON.stringify(cartInput) : undefined,
|
|
135
139
|
formula,
|
|
@@ -60,6 +60,7 @@ const ProductDiscountCard = () => {
|
|
|
60
60
|
licensePlate,
|
|
61
61
|
model,
|
|
62
62
|
durationAnswer,
|
|
63
|
+
durationAnswerIsPrefilled,
|
|
63
64
|
executionAnswer1,
|
|
64
65
|
executionAnswer2,
|
|
65
66
|
discountCode,
|
|
@@ -67,6 +68,7 @@ const ProductDiscountCard = () => {
|
|
|
67
68
|
priceCalculationDate
|
|
68
69
|
}, dispatch] = (0, _OrderSessionContext.useOrderSession)();
|
|
69
70
|
const formula = (0, _FormulaContext.useFormula)();
|
|
71
|
+
const durationAnswerForQuery = durationAnswerIsPrefilled ? undefined : durationAnswer;
|
|
70
72
|
|
|
71
73
|
// Always hold the latest values so the unmount cleanup reads fresh state.
|
|
72
74
|
const anwbStateRef = (0, _react.useRef)({
|
|
@@ -105,7 +107,7 @@ const ProductDiscountCard = () => {
|
|
|
105
107
|
model,
|
|
106
108
|
executionAnswer1,
|
|
107
109
|
executionAnswer2,
|
|
108
|
-
durationAnswer:
|
|
110
|
+
durationAnswer: durationAnswerForQuery,
|
|
109
111
|
formula,
|
|
110
112
|
discountCode,
|
|
111
113
|
priceCalculationDate
|
|
@@ -257,6 +257,8 @@ const ProductCartTable = () => {
|
|
|
257
257
|
licensePlate,
|
|
258
258
|
model,
|
|
259
259
|
durationAnswer,
|
|
260
|
+
durationAnswerIsPrefilled,
|
|
261
|
+
buildYear,
|
|
260
262
|
selectedTowbar,
|
|
261
263
|
selectedCableset,
|
|
262
264
|
selectedCombiset,
|
|
@@ -345,6 +347,7 @@ const ProductCartTable = () => {
|
|
|
345
347
|
consumerDiscounts,
|
|
346
348
|
touchedConsumerDiscounts
|
|
347
349
|
});
|
|
350
|
+
const durationAnswerForQuery = durationAnswerIsPrefilled ? undefined : durationAnswer;
|
|
348
351
|
const {
|
|
349
352
|
cart,
|
|
350
353
|
totals,
|
|
@@ -356,7 +359,8 @@ const ProductCartTable = () => {
|
|
|
356
359
|
model,
|
|
357
360
|
executionAnswer1,
|
|
358
361
|
executionAnswer2,
|
|
359
|
-
durationAnswer,
|
|
362
|
+
durationAnswer: durationAnswerForQuery,
|
|
363
|
+
buildYear,
|
|
360
364
|
selectBoardComputerUpdate: selectedBoardComputer != null ? 'true' : 'false',
|
|
361
365
|
cart: JSON.stringify(cartInput || []),
|
|
362
366
|
branchId: isToggled ? selectedBranch : null,
|
|
@@ -80,6 +80,8 @@ const ProductsOverview = () => {
|
|
|
80
80
|
executionAnswer1,
|
|
81
81
|
executionAnswer2,
|
|
82
82
|
durationAnswer,
|
|
83
|
+
durationAnswerIsPrefilled,
|
|
84
|
+
buildYear,
|
|
83
85
|
selectedTowbar,
|
|
84
86
|
selectedCableset,
|
|
85
87
|
selectedCombiset,
|
|
@@ -97,6 +99,7 @@ const ProductsOverview = () => {
|
|
|
97
99
|
extraPriceAmount
|
|
98
100
|
}, dispatch] = (0, _OrderSessionContext.useOrderSession)();
|
|
99
101
|
const isTowmotive = (0, _useIsTowmotive.useIsTowmotive)();
|
|
102
|
+
const durationAnswerForQuery = durationAnswerIsPrefilled ? undefined : durationAnswer;
|
|
100
103
|
const cartInput = (0, _product.buildCartInput)({
|
|
101
104
|
selectedCableset,
|
|
102
105
|
selectedCombiset,
|
|
@@ -118,7 +121,8 @@ const ProductsOverview = () => {
|
|
|
118
121
|
model,
|
|
119
122
|
executionAnswer1,
|
|
120
123
|
executionAnswer2,
|
|
121
|
-
durationAnswer:
|
|
124
|
+
durationAnswer: durationAnswerForQuery,
|
|
125
|
+
buildYear,
|
|
122
126
|
selectBoardComputerUpdate: selectedBoardComputer != null ? 'true' : 'false',
|
|
123
127
|
cart: cartInput ? JSON.stringify(cartInput) : undefined,
|
|
124
128
|
formula,
|
|
@@ -143,6 +143,7 @@ const QuestionsForm = _ref => {
|
|
|
143
143
|
licensePlate,
|
|
144
144
|
model,
|
|
145
145
|
durationAnswer,
|
|
146
|
+
durationAnswerIsPrefilled,
|
|
146
147
|
executionAnswer1,
|
|
147
148
|
buildYear,
|
|
148
149
|
executionAnswer2,
|
|
@@ -150,8 +151,7 @@ const QuestionsForm = _ref => {
|
|
|
150
151
|
execution1Options,
|
|
151
152
|
singleOrderFormulaCode,
|
|
152
153
|
execution2Options,
|
|
153
|
-
durationOptions
|
|
154
|
-
priceCalculationDate
|
|
154
|
+
durationOptions
|
|
155
155
|
}, dispatch] = (0, _OrderSessionContext.useOrderSession)();
|
|
156
156
|
let formula = (0, _FormulaContext.useFormula)();
|
|
157
157
|
const {
|
|
@@ -176,6 +176,7 @@ const QuestionsForm = _ref => {
|
|
|
176
176
|
// Only include both execution answers if both are provided
|
|
177
177
|
const createQueryParams = () => {
|
|
178
178
|
const hasMultipleExecutionQuestions = initialOptions.execution1.length > 0 && initialOptions.execution2.length > 0;
|
|
179
|
+
const durationAnswerForQuery = durationAnswerIsPrefilled ? undefined : durationAnswer;
|
|
179
180
|
|
|
180
181
|
// If we have multiple execution questions, only include answers if both are provided
|
|
181
182
|
if (hasMultipleExecutionQuestions && (!executionAnswer1 || !executionAnswer2)) {
|
|
@@ -183,8 +184,9 @@ const QuestionsForm = _ref => {
|
|
|
183
184
|
licensePlate: initialLicensePlate !== null && initialLicensePlate !== void 0 ? initialLicensePlate : licensePlate,
|
|
184
185
|
model: initialModel !== null && initialModel !== void 0 ? initialModel : model,
|
|
185
186
|
formula,
|
|
187
|
+
buildYear: initialBuildYear !== null && initialBuildYear !== void 0 ? initialBuildYear : buildYear,
|
|
186
188
|
discountCode,
|
|
187
|
-
durationAnswer:
|
|
189
|
+
durationAnswer: durationAnswerForQuery
|
|
188
190
|
};
|
|
189
191
|
}
|
|
190
192
|
|
|
@@ -197,7 +199,7 @@ const QuestionsForm = _ref => {
|
|
|
197
199
|
discountCode,
|
|
198
200
|
executionAnswer1,
|
|
199
201
|
executionAnswer2,
|
|
200
|
-
durationAnswer:
|
|
202
|
+
durationAnswer: durationAnswerForQuery
|
|
201
203
|
};
|
|
202
204
|
};
|
|
203
205
|
const questionsObject = (0, _queries.useQuestionsQuery)(createQueryParams());
|
|
@@ -252,26 +254,7 @@ const QuestionsForm = _ref => {
|
|
|
252
254
|
});
|
|
253
255
|
}
|
|
254
256
|
}, [durationQuestion]);
|
|
255
|
-
|
|
256
|
-
// Only prefetch products when all required answers are provided
|
|
257
257
|
const hasMultipleExecutionQuestions = initialOptions.execution1.length > 0 && initialOptions.execution2.length > 0;
|
|
258
|
-
const shouldPrefetchProducts = !hasMultipleExecutionQuestions || executionAnswer1 && executionAnswer2;
|
|
259
|
-
(0, _queries.useProductsQuery)(shouldPrefetchProducts ? {
|
|
260
|
-
licensePlate: initialLicensePlate !== null && initialLicensePlate !== void 0 ? initialLicensePlate : licensePlate,
|
|
261
|
-
model: initialModel !== null && initialModel !== void 0 ? initialModel : model,
|
|
262
|
-
executionAnswer1,
|
|
263
|
-
executionAnswer2,
|
|
264
|
-
durationAnswer,
|
|
265
|
-
formula,
|
|
266
|
-
discountCode,
|
|
267
|
-
priceCalculationDate
|
|
268
|
-
} : {
|
|
269
|
-
licensePlate: initialLicensePlate !== null && initialLicensePlate !== void 0 ? initialLicensePlate : licensePlate,
|
|
270
|
-
model: initialModel !== null && initialModel !== void 0 ? initialModel : model,
|
|
271
|
-
formula,
|
|
272
|
-
discountCode,
|
|
273
|
-
priceCalculationDate
|
|
274
|
-
});
|
|
275
258
|
|
|
276
259
|
/**
|
|
277
260
|
* @description This hook pre-fills the duration answer, only if it comes pre-filled from the API, and it's not set manually by the user.
|
|
@@ -281,41 +264,12 @@ const QuestionsForm = _ref => {
|
|
|
281
264
|
dispatch({
|
|
282
265
|
type: _OrderSessionContext.orderSessionActions.SET_DURATION_ANSWER,
|
|
283
266
|
payload: {
|
|
284
|
-
answer: durationAnswerPrefilled
|
|
285
|
-
|
|
286
|
-
});
|
|
287
|
-
}
|
|
288
|
-
}, [durationOptions, durationAnswerPrefilled, durationQuestion, durationAnswer]);
|
|
289
|
-
(0, _react.useEffect)(() => {
|
|
290
|
-
if (durationQuestion !== null && durationQuestion !== void 0 && durationQuestion.length) {
|
|
291
|
-
dispatch({
|
|
292
|
-
type: _OrderSessionContext.orderSessionActions.SET_DURATION_OPTIONS,
|
|
293
|
-
payload: {
|
|
294
|
-
options: durationQuestion
|
|
295
|
-
}
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
}, [durationQuestion]);
|
|
299
|
-
(0, _react.useEffect)(() => {
|
|
300
|
-
if (execution1AnswerOptions !== null && execution1AnswerOptions !== void 0 && execution1AnswerOptions.length) {
|
|
301
|
-
dispatch({
|
|
302
|
-
type: _OrderSessionContext.orderSessionActions.SET_EXECUTION1_OPTIONS,
|
|
303
|
-
payload: {
|
|
304
|
-
options: execution1AnswerOptions
|
|
267
|
+
answer: durationAnswerPrefilled,
|
|
268
|
+
isPrefilled: true
|
|
305
269
|
}
|
|
306
270
|
});
|
|
307
271
|
}
|
|
308
|
-
}, [
|
|
309
|
-
(0, _react.useEffect)(() => {
|
|
310
|
-
if (execution2AnswerOptions !== null && execution2AnswerOptions !== void 0 && execution2AnswerOptions.length) {
|
|
311
|
-
dispatch({
|
|
312
|
-
type: _OrderSessionContext.orderSessionActions.SET_EXECUTION2_OPTIONS,
|
|
313
|
-
payload: {
|
|
314
|
-
options: execution2AnswerOptions
|
|
315
|
-
}
|
|
316
|
-
});
|
|
317
|
-
}
|
|
318
|
-
}, [execution2AnswerOptions]);
|
|
272
|
+
}, [durationOptions, durationAnswerPrefilled, durationQuestion, durationAnswer, durationAnswerIsPrefilled]);
|
|
319
273
|
(0, _react.useEffect)(() => {
|
|
320
274
|
if (!isLoadingQuestions) {
|
|
321
275
|
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);
|
|
@@ -89,6 +89,8 @@ const VehicleData = _ref => {
|
|
|
89
89
|
executionAnswer1,
|
|
90
90
|
executionAnswer2,
|
|
91
91
|
durationAnswer,
|
|
92
|
+
durationAnswerIsPrefilled,
|
|
93
|
+
buildYear: orderBuildYear,
|
|
92
94
|
discountCode,
|
|
93
95
|
priceCalculationDate,
|
|
94
96
|
singleOrderFormulaCode,
|
|
@@ -99,6 +101,7 @@ const VehicleData = _ref => {
|
|
|
99
101
|
if (isFilter && singleOrderFormulaCode) {
|
|
100
102
|
formula = singleOrderFormulaCode;
|
|
101
103
|
}
|
|
104
|
+
const durationAnswerForQuery = durationAnswerIsPrefilled ? undefined : durationAnswer;
|
|
102
105
|
const {
|
|
103
106
|
orderData,
|
|
104
107
|
isLoadingOrder
|
|
@@ -107,7 +110,8 @@ const VehicleData = _ref => {
|
|
|
107
110
|
model,
|
|
108
111
|
executionAnswer1,
|
|
109
112
|
executionAnswer2,
|
|
110
|
-
durationAnswer:
|
|
113
|
+
durationAnswer: durationAnswerForQuery,
|
|
114
|
+
buildYear: orderBuildYear,
|
|
111
115
|
formula,
|
|
112
116
|
discountCode,
|
|
113
117
|
priceCalculationDate
|
|
@@ -212,6 +212,10 @@ const buildLeaseCompanyOption = function buildLeaseCompanyOption() {
|
|
|
212
212
|
}
|
|
213
213
|
};
|
|
214
214
|
};
|
|
215
|
+
const getBranchCity = function getBranchCity() {
|
|
216
|
+
let branch = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
217
|
+
return (branch === null || branch === void 0 ? void 0 : branch.city) || (branch === null || branch === void 0 ? void 0 : branch.gemeente) || '';
|
|
218
|
+
};
|
|
215
219
|
const InternalAppointmentForm = _ref => {
|
|
216
220
|
var _branchTypes$byId$aut, _authSession$branch, _authSession$branch2, _contextCustomer$note2;
|
|
217
221
|
let {
|
|
@@ -1108,8 +1112,9 @@ const InternalAppointmentForm = _ref => {
|
|
|
1108
1112
|
if (branch.street) {
|
|
1109
1113
|
updateCustomerField('streetName', branch.street);
|
|
1110
1114
|
}
|
|
1111
|
-
|
|
1112
|
-
|
|
1115
|
+
const branchCity = getBranchCity(branch);
|
|
1116
|
+
if (branchCity) {
|
|
1117
|
+
updateCustomerField('city', branchCity);
|
|
1113
1118
|
}
|
|
1114
1119
|
if (branch.street2) {
|
|
1115
1120
|
updateCustomerField('houseNumber', branch.street2);
|
|
@@ -169,6 +169,10 @@ const buildLeaseCompanyOption = function buildLeaseCompanyOption() {
|
|
|
169
169
|
}
|
|
170
170
|
};
|
|
171
171
|
};
|
|
172
|
+
const getBranchCity = function getBranchCity() {
|
|
173
|
+
let branch = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
174
|
+
return (branch === null || branch === void 0 ? void 0 : branch.city) || (branch === null || branch === void 0 ? void 0 : branch.gemeente) || '';
|
|
175
|
+
};
|
|
172
176
|
const internalQuotationFormSchema = (0, _yup.object)({
|
|
173
177
|
ownershipType: (0, _yup.string)().required(_constants__.FORM_ERROR_MESSAGES.required),
|
|
174
178
|
leaseNumber: (0, _yup.string)().nullable(),
|
|
@@ -780,8 +784,9 @@ const InternalQuotationForm = _ref => {
|
|
|
780
784
|
if (branch.street) {
|
|
781
785
|
updateCustomerField('streetName', branch.street);
|
|
782
786
|
}
|
|
783
|
-
|
|
784
|
-
|
|
787
|
+
const branchCity = getBranchCity(branch);
|
|
788
|
+
if (branchCity) {
|
|
789
|
+
updateCustomerField('city', branchCity);
|
|
785
790
|
}
|
|
786
791
|
if (branch.street2) {
|
|
787
792
|
updateCustomerField('houseNumber', branch.street2);
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
require("core-js/modules/es.symbol.description.js");
|
|
4
4
|
require("core-js/modules/es.json.stringify.js");
|
|
5
|
+
require("core-js/modules/es.regexp.exec.js");
|
|
6
|
+
require("core-js/modules/es.string.search.js");
|
|
5
7
|
require("core-js/modules/es.weak-map.js");
|
|
6
8
|
require("core-js/modules/esnext.iterator.constructor.js");
|
|
7
9
|
require("core-js/modules/esnext.iterator.filter.js");
|
|
@@ -9,6 +11,7 @@ require("core-js/modules/esnext.iterator.for-each.js");
|
|
|
9
11
|
require("core-js/modules/esnext.iterator.map.js");
|
|
10
12
|
require("core-js/modules/esnext.iterator.some.js");
|
|
11
13
|
require("core-js/modules/web.dom-collections.iterator.js");
|
|
14
|
+
require("core-js/modules/web.url-search-params.js");
|
|
12
15
|
require("core-js/modules/es.weak-map.js");
|
|
13
16
|
require("core-js/modules/esnext.iterator.for-each.js");
|
|
14
17
|
Object.defineProperty(exports, "__esModule", {
|
|
@@ -17,11 +20,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
17
20
|
exports.useOrderSession = exports.orderSessionActions = exports.OrderSessionController = void 0;
|
|
18
21
|
require("core-js/modules/es.symbol.description.js");
|
|
19
22
|
require("core-js/modules/es.json.stringify.js");
|
|
23
|
+
require("core-js/modules/es.regexp.exec.js");
|
|
24
|
+
require("core-js/modules/es.string.search.js");
|
|
20
25
|
require("core-js/modules/esnext.iterator.constructor.js");
|
|
21
26
|
require("core-js/modules/esnext.iterator.filter.js");
|
|
22
27
|
require("core-js/modules/esnext.iterator.map.js");
|
|
23
28
|
require("core-js/modules/esnext.iterator.some.js");
|
|
24
29
|
require("core-js/modules/web.dom-collections.iterator.js");
|
|
30
|
+
require("core-js/modules/web.url-search-params.js");
|
|
25
31
|
var _react = _interopRequireWildcard(require("react"));
|
|
26
32
|
var _constants__ = require("../__constants__");
|
|
27
33
|
var _authenticatedProxyApi = require("../__api__/authenticatedProxyApi");
|
|
@@ -117,6 +123,7 @@ const INITIAL_ORDER_SESSION_STATE = {
|
|
|
117
123
|
brand: null,
|
|
118
124
|
channel: null,
|
|
119
125
|
durationAnswer: undefined,
|
|
126
|
+
durationAnswerIsPrefilled: false,
|
|
120
127
|
executionAnswer1: null,
|
|
121
128
|
executionAnswer2: null,
|
|
122
129
|
priceCalculationDate: new Date().getTime(),
|
|
@@ -713,10 +720,12 @@ const orderSessionReducer = (state, action) => {
|
|
|
713
720
|
case orderSessionActions.SET_DURATION_ANSWER:
|
|
714
721
|
{
|
|
715
722
|
const {
|
|
716
|
-
answer
|
|
723
|
+
answer,
|
|
724
|
+
isPrefilled = false
|
|
717
725
|
} = action.payload;
|
|
718
726
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
719
727
|
durationAnswer: answer,
|
|
728
|
+
durationAnswerIsPrefilled: isPrefilled,
|
|
720
729
|
// Remove subsequent questions and answers
|
|
721
730
|
executionAnswer1: null,
|
|
722
731
|
executionAnswer2: null,
|
|
@@ -1351,8 +1360,13 @@ const initializeOrderSession = function initializeOrderSession() {
|
|
|
1351
1360
|
let isPrivateSingleOrder = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
1352
1361
|
// Check if we're on a single-order page by examining window.location
|
|
1353
1362
|
const storageKey = isPrivateSingleOrder ? _constants__.PRIVATE_SINGLE_ORDER_SESSION_KEY : _constants__.ORDER_SESSION_KEY;
|
|
1363
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
1364
|
+
const shouldRestorePublicSession = APP_CONFIG.internal || searchParams.get('persistSession') === 'true';
|
|
1354
1365
|
const cachedSession = (0, _helpers__.parseJson)(window.sessionStorage.getItem(storageKey));
|
|
1355
|
-
if (!cachedSession) {
|
|
1366
|
+
if (!cachedSession || !shouldRestorePublicSession) {
|
|
1367
|
+
if (!isPrivateSingleOrder && !APP_CONFIG.internal) {
|
|
1368
|
+
window.sessionStorage.removeItem(storageKey);
|
|
1369
|
+
}
|
|
1356
1370
|
return INITIAL_ORDER_SESSION_STATE;
|
|
1357
1371
|
}
|
|
1358
1372
|
return cachedSession;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
require("core-js/modules/es.array.includes.js");
|
|
4
|
+
require("core-js/modules/es.object.assign.js");
|
|
5
|
+
require("core-js/modules/es.string.includes.js");
|
|
6
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
7
|
+
require("core-js/modules/es.array.includes.js");
|
|
8
|
+
require("core-js/modules/es.object.assign.js");
|
|
9
|
+
require("core-js/modules/es.string.includes.js");
|
|
3
10
|
Object.defineProperty(exports, "__esModule", {
|
|
4
11
|
value: true
|
|
5
12
|
});
|
|
@@ -76,8 +83,10 @@ Object.defineProperty(exports, "QuotationThanksPage", {
|
|
|
76
83
|
}
|
|
77
84
|
});
|
|
78
85
|
exports.default = void 0;
|
|
86
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
79
87
|
var _react = _interopRequireDefault(require("react"));
|
|
80
88
|
var _reactRouterDom = require("react-router-dom");
|
|
89
|
+
var _OrderSessionContext = require("../__context__/OrderSessionContext");
|
|
81
90
|
var _AppointmentPage = _interopRequireDefault(require("./AppointmentPage"));
|
|
82
91
|
var _AppointmentThanksPage = _interopRequireDefault(require("./AppointmentThanksPage"));
|
|
83
92
|
var _ExtraProductsPage = _interopRequireDefault(require("./ExtraProductsPage"));
|
|
@@ -90,13 +99,57 @@ var _OverviewPage = _interopRequireDefault(require("./OverviewPage"));
|
|
|
90
99
|
var _ProductsPage = _interopRequireDefault(require("./ProductsPage"));
|
|
91
100
|
var _QuotationPage = _interopRequireDefault(require("./QuotationPage"));
|
|
92
101
|
var _QuotationThanksPage = _interopRequireDefault(require("./QuotationThanksPage"));
|
|
102
|
+
const _excluded = ["render"]; // Pages
|
|
93
103
|
function _interopRequireDefault(e) {
|
|
94
104
|
return e && e.__esModule ? e : {
|
|
95
105
|
default: e
|
|
96
106
|
};
|
|
97
107
|
}
|
|
98
|
-
|
|
99
|
-
|
|
108
|
+
function _extends() {
|
|
109
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
110
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
111
|
+
var t = arguments[e];
|
|
112
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
113
|
+
}
|
|
114
|
+
return n;
|
|
115
|
+
}, _extends.apply(null, arguments);
|
|
116
|
+
}
|
|
117
|
+
function _objectWithoutProperties(e, t) {
|
|
118
|
+
if (null == e) return {};
|
|
119
|
+
var o,
|
|
120
|
+
r,
|
|
121
|
+
i = _objectWithoutPropertiesLoose(e, t);
|
|
122
|
+
if (Object.getOwnPropertySymbols) {
|
|
123
|
+
var s = Object.getOwnPropertySymbols(e);
|
|
124
|
+
for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
|
|
125
|
+
}
|
|
126
|
+
return i;
|
|
127
|
+
}
|
|
128
|
+
function _objectWithoutPropertiesLoose(r, e) {
|
|
129
|
+
if (null == r) return {};
|
|
130
|
+
var t = {};
|
|
131
|
+
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
132
|
+
if (e.includes(n)) continue;
|
|
133
|
+
t[n] = r[n];
|
|
134
|
+
}
|
|
135
|
+
return t;
|
|
136
|
+
}
|
|
137
|
+
const ProtectedConfiguratorRoute = _ref => {
|
|
138
|
+
let {
|
|
139
|
+
render: _render
|
|
140
|
+
} = _ref,
|
|
141
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
142
|
+
const [{
|
|
143
|
+
licensePlate,
|
|
144
|
+
model
|
|
145
|
+
}] = (0, _OrderSessionContext.useOrderSession)();
|
|
146
|
+
const hasVehicleInput = Boolean(licensePlate || model);
|
|
147
|
+
return /*#__PURE__*/_react.default.createElement(_reactRouterDom.Route, _extends({}, props, {
|
|
148
|
+
render: routeProps => hasVehicleInput ? _render(routeProps) : /*#__PURE__*/_react.default.createElement(_reactRouterDom.Redirect, {
|
|
149
|
+
to: "/configurator"
|
|
150
|
+
})
|
|
151
|
+
}));
|
|
152
|
+
};
|
|
100
153
|
const Routes = () => {
|
|
101
154
|
return /*#__PURE__*/_react.default.createElement(_reactRouterDom.Switch, null, /*#__PURE__*/_react.default.createElement(_reactRouterDom.Route, {
|
|
102
155
|
exact: true,
|
|
@@ -106,7 +159,7 @@ const Routes = () => {
|
|
|
106
159
|
exact: true,
|
|
107
160
|
path: "/configurator/geen-producten",
|
|
108
161
|
render: props => /*#__PURE__*/_react.default.createElement(_NoProductsPage.default, props)
|
|
109
|
-
}), /*#__PURE__*/_react.default.createElement(
|
|
162
|
+
}), /*#__PURE__*/_react.default.createElement(ProtectedConfiguratorRoute, {
|
|
110
163
|
exact: true,
|
|
111
164
|
path: "/configurator/montagelocatie",
|
|
112
165
|
render: props => /*#__PURE__*/_react.default.createElement(_LocationsPage.default, props)
|
|
@@ -118,25 +171,25 @@ const Routes = () => {
|
|
|
118
171
|
exact: true,
|
|
119
172
|
path: "/configurator/offerte/bedankt",
|
|
120
173
|
render: props => /*#__PURE__*/_react.default.createElement(_QuotationThanksPage.default, props)
|
|
121
|
-
}), /*#__PURE__*/_react.default.createElement(
|
|
174
|
+
}), /*#__PURE__*/_react.default.createElement(ProtectedConfiguratorRoute, {
|
|
122
175
|
path: "/configurator/trekhaakpakket",
|
|
123
176
|
render: props => /*#__PURE__*/_react.default.createElement(_ProductsPage.default, null)
|
|
124
177
|
}), /*#__PURE__*/_react.default.createElement(_reactRouterDom.Route, {
|
|
125
178
|
path: "/configurator/manual",
|
|
126
179
|
render: props => /*#__PURE__*/_react.default.createElement(_ManualSelectionPage.default, props)
|
|
127
|
-
}), /*#__PURE__*/_react.default.createElement(
|
|
180
|
+
}), /*#__PURE__*/_react.default.createElement(ProtectedConfiguratorRoute, {
|
|
128
181
|
exact: true,
|
|
129
182
|
path: "/configurator/overzicht",
|
|
130
183
|
render: props => /*#__PURE__*/_react.default.createElement(_OverviewPage.default, null)
|
|
131
|
-
}), /*#__PURE__*/_react.default.createElement(
|
|
184
|
+
}), /*#__PURE__*/_react.default.createElement(ProtectedConfiguratorRoute, {
|
|
132
185
|
exact: true,
|
|
133
186
|
path: "/configurator/offerte",
|
|
134
187
|
render: props => /*#__PURE__*/_react.default.createElement(_QuotationPage.default, null)
|
|
135
|
-
}), /*#__PURE__*/_react.default.createElement(
|
|
188
|
+
}), /*#__PURE__*/_react.default.createElement(ProtectedConfiguratorRoute, {
|
|
136
189
|
exact: true,
|
|
137
190
|
path: "/configurator/gegevens",
|
|
138
191
|
render: props => /*#__PURE__*/_react.default.createElement(_AppointmentPage.default, null)
|
|
139
|
-
}), /*#__PURE__*/_react.default.createElement(
|
|
192
|
+
}), /*#__PURE__*/_react.default.createElement(ProtectedConfiguratorRoute, {
|
|
140
193
|
exact: true,
|
|
141
194
|
path: "/configurator/toebehoren",
|
|
142
195
|
render: props => /*#__PURE__*/_react.default.createElement(_ExtraProductsPage.default, null)
|