abmp-npm 2.0.75 → 2.0.76
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/package.json +1 -1
- package/pages/Home.js +18 -13
package/package.json
CHANGED
package/pages/Home.js
CHANGED
|
@@ -13,6 +13,7 @@ const { createHomepageUtils } = require('../public/Utils/homePage.js');
|
|
|
13
13
|
const {
|
|
14
14
|
getMainAddress,
|
|
15
15
|
findMainAddress,
|
|
16
|
+
checkAddressIsVisible,
|
|
16
17
|
formatPracticeAreasForDisplay,
|
|
17
18
|
isWixHostedImage,
|
|
18
19
|
normalizeExternalUrl,
|
|
@@ -35,19 +36,23 @@ const pagination = {
|
|
|
35
36
|
let searchResults = [];
|
|
36
37
|
let isMobile = false;
|
|
37
38
|
|
|
39
|
+
const isMappable = addr =>
|
|
40
|
+
addr?.addressStatus === ADDRESS_STATUS_TYPES.FULL_ADDRESS && addr.latitude && addr.longitude;
|
|
41
|
+
|
|
42
|
+
// The button is only offered when the member has at least one mappable address, which is
|
|
43
|
+
// the same condition as before the lightbox was introduced. When that address is not the
|
|
44
|
+
// primary one we still show the button but withhold the link, so the click opens the
|
|
45
|
+
// lightbox instead of sending the visitor to a secondary address in another city.
|
|
38
46
|
const getDirectionsTarget = itemData => {
|
|
39
47
|
const addresses = Array.isArray(itemData?.addresses) ? itemData.addresses : [];
|
|
40
|
-
const
|
|
41
|
-
if (!
|
|
42
|
-
return {
|
|
48
|
+
const showButton = checkAddressIsVisible(addresses).some(isMappable);
|
|
49
|
+
if (!showButton) {
|
|
50
|
+
return { showButton: false, mapsLink: null };
|
|
43
51
|
}
|
|
44
|
-
const
|
|
45
|
-
mainAddr.addressStatus === ADDRESS_STATUS_TYPES.FULL_ADDRESS &&
|
|
46
|
-
mainAddr.latitude &&
|
|
47
|
-
mainAddr.longitude;
|
|
52
|
+
const mainAddr = findMainAddress(itemData?.addressDisplayOption, addresses);
|
|
48
53
|
return {
|
|
49
|
-
|
|
50
|
-
mapsLink:
|
|
54
|
+
showButton: true,
|
|
55
|
+
mapsLink: isMappable(mainAddr)
|
|
51
56
|
? `https://maps.google.com/?q=${mainAddr.latitude},${mainAddr.longitude}`
|
|
52
57
|
: null,
|
|
53
58
|
};
|
|
@@ -209,8 +214,8 @@ const homePageOnReady = async ({
|
|
|
209
214
|
if (!member) {
|
|
210
215
|
return;
|
|
211
216
|
}
|
|
212
|
-
const { mapsLink } = getDirectionsTarget(member);
|
|
213
|
-
if (!mapsLink) {
|
|
217
|
+
const { showButton, mapsLink } = getDirectionsTarget(member);
|
|
218
|
+
if (showButton && !mapsLink) {
|
|
214
219
|
wixWindow.openLightbox(LIGHTBOX_NAMES.CONTACT_FOR_LOCATION, member);
|
|
215
220
|
}
|
|
216
221
|
});
|
|
@@ -260,9 +265,9 @@ const homePageOnReady = async ({
|
|
|
260
265
|
|
|
261
266
|
// 7) "Show maps" button. Links to the primary address when it is a full address;
|
|
262
267
|
// otherwise it stays visible and the page-level onClick opens a lightbox.
|
|
263
|
-
const {
|
|
268
|
+
const { showButton, mapsLink } = getDirectionsTarget(itemData);
|
|
264
269
|
|
|
265
|
-
if (!
|
|
270
|
+
if (!showButton) {
|
|
266
271
|
$item('#showMaps').hide();
|
|
267
272
|
} else {
|
|
268
273
|
$item('#showMaps').enable();
|