thm-p3-configurator 0.0.200 → 0.0.202
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/__components__/LocationsSelector/LocationAutoComplete.js +6 -12
- package/dist/src/shared/__components__/LocationsSelector/LocationClusteredMap.js +13 -16
- package/dist/src/shared/__components__/LocationsSelector/LocationClusteredTreeMarkers.js +6 -1
- package/dist/src/shared/__components__/LocationsSelector/LocationInfo.js +11 -4
- package/dist/src/shared/__components__/LocationsSelector/LocationList.js +13 -8
- package/dist/src/shared/__components__/LocationsSelector/index.js +53 -20
- package/package.json +1 -1
|
@@ -54,7 +54,7 @@ const LocationsLoading = () => {
|
|
|
54
54
|
};
|
|
55
55
|
const LocationAutoComplete = _ref => {
|
|
56
56
|
let {
|
|
57
|
-
|
|
57
|
+
onLocationUpdate,
|
|
58
58
|
label = 'Postcode'
|
|
59
59
|
} = _ref;
|
|
60
60
|
const [sessionToken, setSessionToken] = (0, _react.useState)();
|
|
@@ -65,21 +65,15 @@ const LocationAutoComplete = _ref => {
|
|
|
65
65
|
const [dropdownActive, setDropdownActive] = (0, _react.useState)(false);
|
|
66
66
|
const [loading, setLoading] = (0, _react.useState)(false);
|
|
67
67
|
const [error, setError] = (0, _react.useState)('');
|
|
68
|
-
const [place, setPlace] = (0, _react.useState)(null);
|
|
69
68
|
const map = (0, _reactGoogleMaps.useMap)();
|
|
70
69
|
const places = (0, _reactGoogleMaps.useMapsLibrary)('places');
|
|
71
70
|
(0, _react.useEffect)(() => {
|
|
72
|
-
var _place$geometry;
|
|
73
71
|
if (!places || !map) return;
|
|
74
72
|
setAutocompleteService(new places.AutocompleteService());
|
|
75
73
|
setPlacesService(new places.PlacesService(map));
|
|
76
74
|
setSessionToken(new places.AutocompleteSessionToken());
|
|
77
|
-
if (place && (_place$geometry = place.geometry) !== null && _place$geometry !== void 0 && _place$geometry.viewport) {
|
|
78
|
-
var _place$geometry2;
|
|
79
|
-
map.fitBounds((_place$geometry2 = place.geometry) === null || _place$geometry2 === void 0 ? void 0 : _place$geometry2.viewport);
|
|
80
|
-
}
|
|
81
75
|
return () => setAutocompleteService(null);
|
|
82
|
-
}, [map, places
|
|
76
|
+
}, [map, places]);
|
|
83
77
|
const fetchPredictions = (0, _react.useCallback)(async inputValue => {
|
|
84
78
|
if (!autocompleteService || !inputValue) {
|
|
85
79
|
setPredictionResults([]);
|
|
@@ -122,21 +116,21 @@ const LocationAutoComplete = _ref => {
|
|
|
122
116
|
setInputValue((_placeDetails$formatt = placeDetails === null || placeDetails === void 0 ? void 0 : placeDetails.formatted_address) !== null && _placeDetails$formatt !== void 0 ? _placeDetails$formatt : '');
|
|
123
117
|
setSessionToken(new places.AutocompleteSessionToken());
|
|
124
118
|
setDropdownActive(false);
|
|
125
|
-
setPlace(placeDetails);
|
|
126
119
|
if (placeDetails !== null && placeDetails !== void 0 && (_placeDetails$geometr = placeDetails.geometry) !== null && _placeDetails$geometr !== void 0 && _placeDetails$geometr.location) {
|
|
127
120
|
const {
|
|
128
121
|
lat,
|
|
129
122
|
lng
|
|
130
123
|
} = placeDetails.geometry.location;
|
|
131
|
-
|
|
124
|
+
const coordinates = {
|
|
132
125
|
lat: lat(),
|
|
133
126
|
lng: lng()
|
|
134
|
-
}
|
|
127
|
+
};
|
|
128
|
+
onLocationUpdate(coordinates, true);
|
|
135
129
|
}
|
|
136
130
|
};
|
|
137
131
|
placesService === null || placesService === void 0 || placesService.getDetails(detailRequestOptions, detailsRequestCallback);
|
|
138
132
|
(_document$querySelect = document.querySelector((0, _helpers__.withStyle)("dealer-autocomplete__list"))) === null || _document$querySelect === void 0 || _document$querySelect.scrollTo(0, 0);
|
|
139
|
-
}, [places, placesService, sessionToken,
|
|
133
|
+
}, [places, placesService, sessionToken, onLocationUpdate, predictionResults]);
|
|
140
134
|
const handleSubmit = event => {
|
|
141
135
|
event.preventDefault();
|
|
142
136
|
};
|
|
@@ -66,26 +66,23 @@ const LocationClusteredMap = /*#__PURE__*/_react.default.memo(_ref => {
|
|
|
66
66
|
}, [core]);
|
|
67
67
|
const fitBoundsToMarkers = (0, _react.useCallback)(() => {
|
|
68
68
|
if (!map || !bounds || locationIds.length === 0) return;
|
|
69
|
+
|
|
70
|
+
// Get all valid coordinates from locations
|
|
71
|
+
const validCoordinates = locationIds.map(id => locationsById[id]).map(location => (0, _geolocation.getCoordinatesByString)(location.googleMapsLocation)).filter(Boolean);
|
|
69
72
|
if (userLocation) {
|
|
70
|
-
|
|
73
|
+
map.setCenter(userLocation);
|
|
74
|
+
map.setZoom(11);
|
|
75
|
+
} else {
|
|
76
|
+
validCoordinates.forEach(_ref2 => {
|
|
77
|
+
let {
|
|
78
|
+
lat,
|
|
79
|
+
lng
|
|
80
|
+
} = _ref2;
|
|
81
|
+
bounds.extend(new core.LatLng(lat, lng));
|
|
82
|
+
});
|
|
71
83
|
map.fitBounds(bounds);
|
|
72
|
-
map.setZoom(10);
|
|
73
|
-
return;
|
|
74
84
|
}
|
|
75
|
-
|
|
76
|
-
// Batch coordinate calculations
|
|
77
|
-
const validCoordinates = locationIds.map(id => locationsById[id]).map(location => (0, _geolocation.getCoordinatesByString)(location.googleMapsLocation)).filter(Boolean);
|
|
78
|
-
validCoordinates.forEach(_ref2 => {
|
|
79
|
-
let {
|
|
80
|
-
lat,
|
|
81
|
-
lng
|
|
82
|
-
} = _ref2;
|
|
83
|
-
bounds.extend(new core.LatLng(lat, lng));
|
|
84
|
-
});
|
|
85
|
-
map.fitBounds(bounds);
|
|
86
85
|
}, [map, bounds, locationIds, locationsById, userLocation, core]);
|
|
87
|
-
|
|
88
|
-
// Debounce bounds fitting
|
|
89
86
|
(0, _react.useEffect)(() => {
|
|
90
87
|
if (!core) return;
|
|
91
88
|
const debounceFitBounds = (0, _lodash.default)(fitBoundsToMarkers, 150);
|
|
@@ -142,7 +142,11 @@ const LocationClusteredTreeMarkers = _ref => {
|
|
|
142
142
|
}, [locationIds, locationsById]);
|
|
143
143
|
const selectedTree = (0, _react.useMemo)(() => {
|
|
144
144
|
var _trees$find;
|
|
145
|
-
|
|
145
|
+
const currentTree = trees && activeMarkerId ? (_trees$find = trees.find(t => t.entityId === activeMarkerId)) !== null && _trees$find !== void 0 ? _trees$find : null : null;
|
|
146
|
+
if (currentTree) {
|
|
147
|
+
return currentTree;
|
|
148
|
+
}
|
|
149
|
+
return null;
|
|
146
150
|
}, [trees, activeMarkerId]);
|
|
147
151
|
const map = (0, _reactGoogleMaps.useMap)();
|
|
148
152
|
const clusterer = (0, _react.useMemo)(() => {
|
|
@@ -228,6 +232,7 @@ const LocationClusteredTreeMarkers = _ref => {
|
|
|
228
232
|
anchor: markers[activeMarkerId],
|
|
229
233
|
onCloseClick: handleInfoWindowClose
|
|
230
234
|
}, /*#__PURE__*/_react.default.createElement(_LocationInfo.default, {
|
|
235
|
+
formula: selectedTree === null || selectedTree === void 0 ? void 0 : selectedTree.formule,
|
|
231
236
|
openingHours: selectedTree === null || selectedTree === void 0 ? void 0 : selectedTree.openingstijden,
|
|
232
237
|
locationImage: selectedTree === null || selectedTree === void 0 || (_selectedTree$afbeeld = selectedTree.afbeeldingLogo) === null || _selectedTree$afbeeld === void 0 ? void 0 : _selectedTree$afbeeld[0],
|
|
233
238
|
street: selectedTree === null || selectedTree === void 0 ? void 0 : selectedTree.street,
|
|
@@ -9,15 +9,21 @@ exports.default = void 0;
|
|
|
9
9
|
require("core-js/modules/esnext.iterator.constructor.js");
|
|
10
10
|
require("core-js/modules/esnext.iterator.filter.js");
|
|
11
11
|
var _react = _interopRequireDefault(require("react"));
|
|
12
|
-
var
|
|
12
|
+
var _logoPrimary = _interopRequireDefault(require("../../../../public/assets/images/logo-primary.png"));
|
|
13
|
+
var _logoThcWhite = _interopRequireDefault(require("../../../../public/assets/images/logo-thc-white.svg"));
|
|
13
14
|
var _helpers__ = require("../../__helpers__");
|
|
14
15
|
var _image = require("../../__helpers__/image");
|
|
15
16
|
var _constants__ = require("../../__constants__");
|
|
17
|
+
var _FormulaContext = require("../../__context__/FormulaContext");
|
|
16
18
|
function _interopRequireDefault(e) {
|
|
17
19
|
return e && e.__esModule ? e : {
|
|
18
20
|
default: e
|
|
19
21
|
};
|
|
20
22
|
}
|
|
23
|
+
const FORMULAS = {
|
|
24
|
+
mZHgPhfuStmqHfHqSOhWY: _logoPrimary.default,
|
|
25
|
+
nFbSnWdtLZBmEhhpHFGVO: _logoThcWhite.default
|
|
26
|
+
};
|
|
21
27
|
const LocationInfo = _ref => {
|
|
22
28
|
let {
|
|
23
29
|
street,
|
|
@@ -31,7 +37,8 @@ const LocationInfo = _ref => {
|
|
|
31
37
|
email,
|
|
32
38
|
website,
|
|
33
39
|
openingHours,
|
|
34
|
-
province
|
|
40
|
+
province,
|
|
41
|
+
formula
|
|
35
42
|
} = _ref;
|
|
36
43
|
const address = [street, postCode, city].join(', ');
|
|
37
44
|
|
|
@@ -66,7 +73,7 @@ const LocationInfo = _ref => {
|
|
|
66
73
|
isUnknown: true
|
|
67
74
|
};
|
|
68
75
|
};
|
|
69
|
-
|
|
76
|
+
console.log(formula);
|
|
70
77
|
// Order of days to display
|
|
71
78
|
const daysOrder = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'];
|
|
72
79
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -127,7 +134,7 @@ const LocationInfo = _ref => {
|
|
|
127
134
|
className: (0, _helpers__.withStyle)('mb-1'),
|
|
128
135
|
src: locationImage !== null && locationImage !== void 0 && locationImage.length ? (0, _image.getImageFromHyper)({
|
|
129
136
|
imageId: locationImage
|
|
130
|
-
}) :
|
|
137
|
+
}) : FORMULAS[formula],
|
|
131
138
|
alt: title
|
|
132
139
|
}))));
|
|
133
140
|
};
|
|
@@ -119,6 +119,7 @@ const LocationList = _ref => {
|
|
|
119
119
|
locationsById,
|
|
120
120
|
locationIds,
|
|
121
121
|
userLocation,
|
|
122
|
+
isLocationSetViaSearch = false,
|
|
122
123
|
isLoading = false
|
|
123
124
|
} = _ref;
|
|
124
125
|
const {
|
|
@@ -127,7 +128,7 @@ const LocationList = _ref => {
|
|
|
127
128
|
const [{
|
|
128
129
|
selectedBranch
|
|
129
130
|
}] = (0, _OrderSessionContext.useOrderSession)();
|
|
130
|
-
const
|
|
131
|
+
const listRef = (0, _react.useRef)(null);
|
|
131
132
|
const locationsWithDistance = locationIds.map((locationId, index) => {
|
|
132
133
|
const location = locationsById[locationId];
|
|
133
134
|
const coordinates = location.googleMapsLocation;
|
|
@@ -146,22 +147,26 @@ const LocationList = _ref => {
|
|
|
146
147
|
});
|
|
147
148
|
}).filter(location => location !== null);
|
|
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
|
+
|
|
149
155
|
if (a.distance === null) return 1;
|
|
150
156
|
if (b.distance === null) return -1;
|
|
151
157
|
return a.distance - b.distance;
|
|
152
158
|
});
|
|
159
|
+
|
|
160
|
+
// Handle scrolling when location is set via search
|
|
153
161
|
(0, _react.useEffect)(() => {
|
|
154
|
-
if (
|
|
155
|
-
|
|
156
|
-
behavior: 'smooth',
|
|
157
|
-
block: 'center'
|
|
158
|
-
});
|
|
162
|
+
if (isLocationSetViaSearch && listRef.current) {
|
|
163
|
+
listRef.current.scrollTop = 0;
|
|
159
164
|
}
|
|
160
|
-
}, [
|
|
165
|
+
}, [isLocationSetViaSearch, userLocation]);
|
|
161
166
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
167
|
+
ref: listRef,
|
|
162
168
|
className: (0, _helpers__.withStyle)('dealer-list')
|
|
163
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, {
|
|
164
|
-
ref: location.entityId === activeMarkerId || location.entityId === selectedBranch ? selectedRef : null,
|
|
165
170
|
openingHours: location.openingstijden,
|
|
166
171
|
title: location.naamVestiging,
|
|
167
172
|
city: location.city,
|
|
@@ -12,6 +12,7 @@ var _reactGoogleMaps = require("@vis.gl/react-google-maps");
|
|
|
12
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
13
|
var _queries = require("../../__api__/queries");
|
|
14
14
|
var _constants__ = require("../../__constants__");
|
|
15
|
+
var _ActiveMarkerContext = require("../../__context__/ActiveMarkerContext");
|
|
15
16
|
var _FormulaContext = require("../../__context__/FormulaContext");
|
|
16
17
|
var _OrderSessionContext = require("../../__context__/OrderSessionContext");
|
|
17
18
|
var _helpers__ = require("../../__helpers__");
|
|
@@ -19,6 +20,7 @@ var _useBreakpoint = _interopRequireDefault(require("../../__hooks__/useBreakpoi
|
|
|
19
20
|
var _useUserLocation = _interopRequireDefault(require("../../__hooks__/useUserLocation"));
|
|
20
21
|
var _LocalStorageWorker = require("../../__services__/LocalStorageWorker");
|
|
21
22
|
var _LocationAutoComplete = _interopRequireDefault(require("./LocationAutoComplete"));
|
|
23
|
+
var _LocationClusteredMap = _interopRequireDefault(require("./LocationClusteredMap"));
|
|
22
24
|
var _LocationList = _interopRequireDefault(require("./LocationList"));
|
|
23
25
|
function _interopRequireDefault(e) {
|
|
24
26
|
return e && e.__esModule ? e : {
|
|
@@ -60,9 +62,13 @@ const Loaded = /*#__PURE__*/_react.default.memo(_ref => {
|
|
|
60
62
|
});
|
|
61
63
|
const LocationsSelector = /*#__PURE__*/_react.default.memo(() => {
|
|
62
64
|
const [userLocation, setUserLocation] = (0, _useUserLocation.default)();
|
|
65
|
+
const [isLocationSetViaSearch, setIsLocationSetViaSearch] = (0, _react.useState)(false);
|
|
66
|
+
const {
|
|
67
|
+
setActiveMarkerId
|
|
68
|
+
} = (0, _ActiveMarkerContext.useActiveMarker)();
|
|
69
|
+
const [, dispatch] = (0, _OrderSessionContext.useOrderSession)();
|
|
63
70
|
const screen = (0, _useBreakpoint.default)();
|
|
64
71
|
const isDesktop = screen.size >= 1200;
|
|
65
|
-
const [visibleIds, setVisibleIds] = (0, _react.useState)([]);
|
|
66
72
|
const formula = (0, _FormulaContext.useFormula)();
|
|
67
73
|
const [{
|
|
68
74
|
franchiseName
|
|
@@ -99,36 +105,63 @@ const LocationsSelector = /*#__PURE__*/_react.default.memo(() => {
|
|
|
99
105
|
array: locations || [],
|
|
100
106
|
key: 'entityId'
|
|
101
107
|
}), [locations]);
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
108
|
+
|
|
109
|
+
// Handle location updates from search
|
|
110
|
+
const handleLocationUpdate = function handleLocationUpdate(newLocation) {
|
|
111
|
+
let fromSearch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
112
|
+
setUserLocation(newLocation);
|
|
113
|
+
setIsLocationSetViaSearch(fromSearch);
|
|
114
|
+
|
|
115
|
+
// Close any open marker popups when searching for a new location
|
|
116
|
+
if (fromSearch) {
|
|
117
|
+
setActiveMarkerId(null);
|
|
118
|
+
|
|
119
|
+
// Also clear any selected branch to avoid confusion
|
|
120
|
+
dispatch({
|
|
121
|
+
payload: {
|
|
122
|
+
branchId: null
|
|
123
|
+
},
|
|
124
|
+
type: _OrderSessionContext.orderSessionActions.SET_SELECTED_BRANCH
|
|
125
|
+
});
|
|
105
126
|
}
|
|
106
|
-
|
|
107
|
-
const addIdsInBatches = index => {
|
|
108
|
-
const offset = 10;
|
|
109
|
-
const nextBatch = allIds.slice(index, index + offset);
|
|
110
|
-
setVisibleIds(prev => [...prev, ...nextBatch]);
|
|
111
|
-
if (index + offset < allIds.length) {
|
|
112
|
-
requestAnimationFrame(() => addIdsInBatches(index + offset));
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
addIdsInBatches(0);
|
|
116
|
-
}, [allIds]);
|
|
127
|
+
};
|
|
117
128
|
return /*#__PURE__*/_react.default.createElement(_reactGoogleMaps.APIProvider, {
|
|
118
129
|
apiKey: APP_CONFIG.googleMapsApiKey,
|
|
119
130
|
libraries: ['marker']
|
|
120
|
-
}, /*#__PURE__*/_react.default.createElement(Loaded, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
121
|
-
className:
|
|
131
|
+
}, /*#__PURE__*/_react.default.createElement(Loaded, null, APP_CONFIG.internal ? /*#__PURE__*/_react.default.createElement("div", {
|
|
132
|
+
className: (0, _helpers__.withStyle)('row gx-5 mt-3 mt-xl-5')
|
|
133
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
134
|
+
className: (0, _helpers__.withStyle)('content col-xl-8')
|
|
135
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
136
|
+
className: (0, _helpers__.withStyle)(isDesktop ? 'dealer-map__container' : 'dealer-map')
|
|
137
|
+
}, /*#__PURE__*/_react.default.createElement(_LocationClusteredMap.default, {
|
|
138
|
+
locationIds: allIds,
|
|
139
|
+
locationsById: byId,
|
|
140
|
+
userLocation: userLocation
|
|
141
|
+
}))), /*#__PURE__*/_react.default.createElement("aside", {
|
|
142
|
+
className: (0, _helpers__.withStyle)('dealer-sidebar col-xl-4 mt-3 mt-xl-0')
|
|
143
|
+
}, isDesktop && /*#__PURE__*/_react.default.createElement(_LocationAutoComplete.default, {
|
|
144
|
+
onLocationUpdate: handleLocationUpdate
|
|
145
|
+
}), franchiseName && /*#__PURE__*/_react.default.createElement("h6", {
|
|
146
|
+
className: (0, _helpers__.withStyle)('my-2')
|
|
147
|
+
}, "Keten: ", franchiseName), /*#__PURE__*/_react.default.createElement(_LocationList.default, {
|
|
148
|
+
locationIds: allIds,
|
|
149
|
+
locationsById: byId,
|
|
150
|
+
userLocation: userLocation,
|
|
151
|
+
isLocationSetViaSearch: isLocationSetViaSearch
|
|
152
|
+
}))) : /*#__PURE__*/_react.default.createElement("div", {
|
|
153
|
+
className: (0, _helpers__.withStyle)('row gx-5 mt-3 mt-xl-5 justify-content-center')
|
|
122
154
|
}, /*#__PURE__*/_react.default.createElement("aside", {
|
|
123
|
-
className:
|
|
155
|
+
className: (0, _helpers__.withStyle)('dealer-sidebar col-xl-4 mt-3 mt-xl-0')
|
|
124
156
|
}, isDesktop && /*#__PURE__*/_react.default.createElement(_LocationAutoComplete.default, {
|
|
125
|
-
|
|
157
|
+
onLocationUpdate: handleLocationUpdate
|
|
126
158
|
}), franchiseName && /*#__PURE__*/_react.default.createElement("h6", {
|
|
127
159
|
className: (0, _helpers__.withStyle)('my-2')
|
|
128
160
|
}, "Keten: ", franchiseName), /*#__PURE__*/_react.default.createElement(_LocationList.default, {
|
|
129
161
|
locationIds: allIds,
|
|
130
162
|
locationsById: byId,
|
|
131
|
-
userLocation: userLocation
|
|
163
|
+
userLocation: userLocation,
|
|
164
|
+
isLocationSetViaSearch: isLocationSetViaSearch
|
|
132
165
|
})))));
|
|
133
166
|
});
|
|
134
167
|
var _default = exports.default = LocationsSelector;
|