abmp-npm 10.0.56 → 10.0.57
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.
|
@@ -148,7 +148,9 @@ function buildMembersSearchQuery(data) {
|
|
|
148
148
|
latitude: filter.latitude,
|
|
149
149
|
longitude: filter.longitude,
|
|
150
150
|
},
|
|
151
|
-
findMainAddress(item.addressDisplayOption, item.addresses
|
|
151
|
+
findMainAddress(item.addressDisplayOption, item.addresses, {
|
|
152
|
+
requireValidCoordinates: true,
|
|
153
|
+
})
|
|
152
154
|
),
|
|
153
155
|
}));
|
|
154
156
|
const resultWithDistances = {
|
package/package.json
CHANGED
|
@@ -66,20 +66,31 @@ function debouncedFunction({ func, debounceTimeout, timeoutType, args }) {
|
|
|
66
66
|
|
|
67
67
|
const isValidLocation = location => location.latitude && location.longitude;
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
/**
|
|
70
|
+
* @param {Array} addressDisplayOption
|
|
71
|
+
* @param {Array} addresses
|
|
72
|
+
* @param {Object|boolean} [options] - Optional. Pass { requireValidCoordinates: true } for home search/distance; omit or false for profile display.
|
|
73
|
+
*/
|
|
74
|
+
function findMainAddress(addressDisplayOption = [], addresses = [], options = {}) {
|
|
75
|
+
const requireValidCoordinates =
|
|
76
|
+
typeof options === 'boolean' ? options : Boolean(options?.requireValidCoordinates);
|
|
77
|
+
const optionsArr = Array.isArray(addressDisplayOption) ? addressDisplayOption : [];
|
|
78
|
+
const mainOpt = optionsArr.find(opt => opt.isMain);
|
|
72
79
|
if (mainOpt) {
|
|
73
80
|
const mainAddr = addresses.find(
|
|
74
|
-
addr =>
|
|
81
|
+
addr =>
|
|
82
|
+
addr.key === mainOpt.key &&
|
|
83
|
+
addr.addressStatus !== ADDRESS_STATUS_TYPES.DONT_SHOW &&
|
|
84
|
+
(!requireValidCoordinates || isValidLocation(addr))
|
|
75
85
|
);
|
|
76
86
|
if (mainAddr) {
|
|
77
87
|
return mainAddr;
|
|
78
88
|
}
|
|
79
89
|
}
|
|
80
|
-
// 2) fallback: if there is any visible address, use it
|
|
81
90
|
const visibleAddresses = addresses.filter(
|
|
82
|
-
addr =>
|
|
91
|
+
addr =>
|
|
92
|
+
addr.addressStatus !== ADDRESS_STATUS_TYPES.DONT_SHOW &&
|
|
93
|
+
(!requireValidCoordinates || isValidLocation(addr))
|
|
83
94
|
);
|
|
84
95
|
if (visibleAddresses.length) {
|
|
85
96
|
return visibleAddresses[0];
|
|
@@ -107,8 +118,13 @@ function formatAddress(item) {
|
|
|
107
118
|
return addressParts.filter(Boolean).join(', ');
|
|
108
119
|
}
|
|
109
120
|
|
|
110
|
-
|
|
111
|
-
|
|
121
|
+
/**
|
|
122
|
+
* @param {Array} addressDisplayOption
|
|
123
|
+
* @param {Array} addresses
|
|
124
|
+
* @param {Object|boolean} [options] - Optional. Pass { requireValidCoordinates: true } for home search/distance; omit or false for profile display.
|
|
125
|
+
*/
|
|
126
|
+
function getMainAddress(addressDisplayOption = [], addresses = [], options = {}) {
|
|
127
|
+
const mainAddr = findMainAddress(addressDisplayOption, addresses, options);
|
|
112
128
|
if (mainAddr) {
|
|
113
129
|
return formatAddress(mainAddr);
|
|
114
130
|
}
|