abmp-npm 1.1.43 → 1.1.45
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 +16 -42
- package/public/Utils/homePage.js +7 -7
package/package.json
CHANGED
package/pages/Home.js
CHANGED
|
@@ -77,7 +77,7 @@ const homePageOnReady = async ({
|
|
|
77
77
|
showFiltersOnDesktop();
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
|
|
80
|
+
function attachEventListeners() {
|
|
81
81
|
/**
|
|
82
82
|
* PAGINATION CODE
|
|
83
83
|
*/
|
|
@@ -108,8 +108,8 @@ const homePageOnReady = async ({
|
|
|
108
108
|
_$w('#resetFilter').onClick(resetFilter);
|
|
109
109
|
_$w('#clearButton').onClick(resetFilter);
|
|
110
110
|
|
|
111
|
-
_$w('#searchDesktop').onInput(event => searchProfilesOnSearchText(event));
|
|
112
|
-
_$w('#searchTabletMobile').onInput(event => searchProfilesOnSearchText(event));
|
|
111
|
+
_$w('#searchDesktop').onInput(async event => await searchProfilesOnSearchText(event));
|
|
112
|
+
_$w('#searchTabletMobile').onInput(async event => await searchProfilesOnSearchText(event));
|
|
113
113
|
// Use onChange for the switch and onClick for the retry button
|
|
114
114
|
_$w('#nearBy').onChange(() => {
|
|
115
115
|
updateFiltersState();
|
|
@@ -124,7 +124,7 @@ const homePageOnReady = async ({
|
|
|
124
124
|
});
|
|
125
125
|
|
|
126
126
|
// ZIP CODE FILTER
|
|
127
|
-
_$w('#zipcode').onInput(event => {
|
|
127
|
+
_$w('#zipcode').onInput(async event => {
|
|
128
128
|
const zipcode = event.target.value.trim();
|
|
129
129
|
zipcode === '' ? (filter.postalcode = null) : (filter.postalcode = zipcode);
|
|
130
130
|
updateFiltersState();
|
|
@@ -133,7 +133,7 @@ const homePageOnReady = async ({
|
|
|
133
133
|
return;
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
updateResults('filterTimeout');
|
|
136
|
+
await updateResults('filterTimeout');
|
|
137
137
|
});
|
|
138
138
|
|
|
139
139
|
_$w('#filterButton').onClick(() => {
|
|
@@ -179,8 +179,8 @@ const homePageOnReady = async ({
|
|
|
179
179
|
|
|
180
180
|
await updateResults('zeroTimeout');
|
|
181
181
|
});
|
|
182
|
-
|
|
183
|
-
_$w('#profileRepeater').onItemReady(($item, itemData) => {
|
|
182
|
+
|
|
183
|
+
_$w('#profileRepeater').onItemReady(async ($item, itemData) => {
|
|
184
184
|
// 1) safely default to arrays
|
|
185
185
|
const addresses = Array.isArray(itemData.addresses) ? itemData.addresses : [];
|
|
186
186
|
const areasOfPractices = Array.isArray(itemData.areasOfPractices)
|
|
@@ -200,6 +200,7 @@ const homePageOnReady = async ({
|
|
|
200
200
|
if (itemData.showWebsite) {
|
|
201
201
|
$item('#website').link = itemData.website;
|
|
202
202
|
} else {
|
|
203
|
+
const baseUrl = await wixLocation.baseUrl();
|
|
203
204
|
$item('#website').link = `${baseUrl}/profile/${itemData.url}`;
|
|
204
205
|
}
|
|
205
206
|
$item('#website').target = '_blank';
|
|
@@ -264,23 +265,17 @@ const homePageOnReady = async ({
|
|
|
264
265
|
}
|
|
265
266
|
|
|
266
267
|
async function handleUrlParams() {
|
|
267
|
-
const renderingEnv = await rendering.env();
|
|
268
268
|
const { isDefaultStateParams, filter: newFilter } = await parseAndValidateQueryParams(
|
|
269
269
|
filter,
|
|
270
270
|
pagination
|
|
271
271
|
);
|
|
272
|
-
logMessage(`[handleUrlParams][${renderingEnv}] isDefaultStateParams`, isDefaultStateParams);
|
|
273
272
|
filter = newFilter;
|
|
274
|
-
logMessage(`[handleUrlParams][${renderingEnv}] filter`, JSON.stringify(filter));
|
|
275
273
|
await applyFilterToUI(isDefaultStateParams);
|
|
276
274
|
}
|
|
277
275
|
|
|
278
276
|
async function applyFilterToUI(isDefaultStateParams) {
|
|
279
|
-
const renderingEnv = await rendering.env();
|
|
280
|
-
logMessage(`[applyFilterToUI][${renderingEnv}] isDefaultStateParams`, isDefaultStateParams);
|
|
281
277
|
const setFilterFromParams = async (isInitializeValue = true) => {
|
|
282
278
|
const params = await wixLocation.query();
|
|
283
|
-
logMessage(`[setFilterFromParams][${renderingEnv}] params`, JSON.stringify(params));
|
|
284
279
|
console.log('params inside setFilterFromParams ', params);
|
|
285
280
|
const paramsMapping = getParamsMapping(filter, pagination);
|
|
286
281
|
for (const [param, { setValue, setUI }] of Object.entries(paramsMapping)) {
|
|
@@ -312,12 +307,10 @@ const homePageOnReady = async ({
|
|
|
312
307
|
await setFilterFromParams(true);
|
|
313
308
|
if (isDefaultStateParams) {
|
|
314
309
|
console.log('default state set for nearby');
|
|
315
|
-
logMessage(`[applyFilterToUI][${renderingEnv}] default state set for nearby`);
|
|
316
310
|
await Promise.all([fetchFilterData(), nearByHandler(true)]);
|
|
317
311
|
return;
|
|
318
312
|
}
|
|
319
313
|
console.log('not default state');
|
|
320
|
-
logMessage(`[applyFilterToUI][${renderingEnv}] not default state`);
|
|
321
314
|
const searchPromise =
|
|
322
315
|
filter.searchText && filter.searchText.length > 0
|
|
323
316
|
? () =>
|
|
@@ -338,7 +331,6 @@ const homePageOnReady = async ({
|
|
|
338
331
|
searchPromise(),
|
|
339
332
|
]);
|
|
340
333
|
} catch (error) {
|
|
341
|
-
logMessage(`[applyFilterToUI][${renderingEnv}] failed with error:`, error);
|
|
342
334
|
console.error('[applyFilterToUI] failed with error:', error);
|
|
343
335
|
multiStateBoxSelector.changeState('errorState');
|
|
344
336
|
}
|
|
@@ -348,11 +340,7 @@ const homePageOnReady = async ({
|
|
|
348
340
|
* UPDATE PROFILES BASED ON APPLIED/DEFAULT FILTER
|
|
349
341
|
*/
|
|
350
342
|
async function updateResults(timeoutType, preservePagination = false) {
|
|
351
|
-
const renderingEnv = await rendering.env();
|
|
352
|
-
logMessage(`[updateResults][${renderingEnv}] timeoutType`, timeoutType);
|
|
353
|
-
logMessage(`[updateResults][${renderingEnv}] preservePagination`, preservePagination);
|
|
354
343
|
if (debounceTimeout[timeoutType]) {
|
|
355
|
-
logMessage(`[updateResults][${renderingEnv}] clearing timeout type ${timeoutType}`);
|
|
356
344
|
clearTimeout(debounceTimeout[timeoutType]);
|
|
357
345
|
}
|
|
358
346
|
searchResults = await search({
|
|
@@ -363,7 +351,6 @@ const homePageOnReady = async ({
|
|
|
363
351
|
isSearchingNearby: _$w('#nearBy').checked,
|
|
364
352
|
preservePagination,
|
|
365
353
|
});
|
|
366
|
-
logMessage(`[updateResults][${renderingEnv}] searchResults`, JSON.stringify(searchResults));
|
|
367
354
|
!preservePagination && (await updateUrlParams(filter, pagination));
|
|
368
355
|
return searchResults;
|
|
369
356
|
}
|
|
@@ -423,8 +410,7 @@ const homePageOnReady = async ({
|
|
|
423
410
|
// NEAR BY FILTER
|
|
424
411
|
async function nearByHandler(preservePagination = false) {
|
|
425
412
|
const isSearchingNearby = _$w('#nearBy').checked;
|
|
426
|
-
|
|
427
|
-
logMessage(`[nearByHandler][${renderingEnv}] isSearchingNearby`, isSearchingNearby);
|
|
413
|
+
|
|
428
414
|
// 1. Disable nearby input while processing
|
|
429
415
|
_$w('#nearBy').disable();
|
|
430
416
|
|
|
@@ -434,10 +420,8 @@ const homePageOnReady = async ({
|
|
|
434
420
|
// 3. Do the query
|
|
435
421
|
const { success, filter: newFilter } = await getAndSetUserLocation(isSearchingNearby, filter);
|
|
436
422
|
filter = newFilter;
|
|
437
|
-
|
|
438
|
-
console.log('filter inside nearByHandler', filter);
|
|
423
|
+
const renderingEnv = await rendering.env();
|
|
439
424
|
if (!success) {
|
|
440
|
-
logMessage(`[nearByHandler][${renderingEnv}] failed to get user location`);
|
|
441
425
|
if (renderingEnv !== 'backend') {
|
|
442
426
|
//on Backend environment, geolocation API don't work, so makes no sense to change state for near by
|
|
443
427
|
multiStateBoxSelector.changeState('nearByState');
|
|
@@ -451,9 +435,8 @@ const homePageOnReady = async ({
|
|
|
451
435
|
|
|
452
436
|
// If location is not selected, change state to "resultsState"
|
|
453
437
|
if (!isSearchingNearby) {
|
|
454
|
-
logMessage(`[nearByHandler][${renderingEnv}] !isSearchingNearby, is`);
|
|
455
438
|
if (await noSearchCriteria()) {
|
|
456
|
-
|
|
439
|
+
console.log('no search criteria and no near by');
|
|
457
440
|
multiStateBoxSelector.changeState('noSearchCriteria');
|
|
458
441
|
// 4. Re-enable nearby input
|
|
459
442
|
_$w('#nearBy').enable();
|
|
@@ -461,7 +444,7 @@ const homePageOnReady = async ({
|
|
|
461
444
|
}
|
|
462
445
|
multiStateBoxSelector.changeState('resultsState');
|
|
463
446
|
}
|
|
464
|
-
|
|
447
|
+
|
|
465
448
|
await updateResults('zeroTimeout', preservePagination);
|
|
466
449
|
|
|
467
450
|
// 4. Re-enable nearby input when done
|
|
@@ -479,20 +462,14 @@ const homePageOnReady = async ({
|
|
|
479
462
|
await withWarmUpData(
|
|
480
463
|
'getCompiledFiltersOptions',
|
|
481
464
|
() => getCompiledFiltersOptions(),
|
|
482
|
-
|
|
465
|
+
console.log
|
|
483
466
|
);
|
|
484
|
-
const renderingEnv = await rendering.env();
|
|
485
|
-
logMessage(`[fetchFilterData][${renderingEnv}] fetched compiled filters`);
|
|
486
467
|
completeStateList = COMPILED_STATE_LIST;
|
|
487
468
|
areasOfPracticesList = COMPILED_AREAS_OF_PRACTICES;
|
|
488
469
|
stateCityMapList = COMPILED_STATE_CITY_MAP;
|
|
489
470
|
} catch (error) {
|
|
490
|
-
const renderingEnv = await rendering.env();
|
|
491
|
-
logMessage(
|
|
492
|
-
`[fetchFilterData][${renderingEnv}] failed to get compiled filters list, falling back to non compiled version with error: ${error}`
|
|
493
|
-
);
|
|
494
471
|
console.error(
|
|
495
|
-
`Failed to get compiled filters list, falling back to non compiled version
|
|
472
|
+
`Failed to get compiled filters list, falling back to non compiled version: ${error}`
|
|
496
473
|
);
|
|
497
474
|
const {
|
|
498
475
|
completeStateList: _completeStateList,
|
|
@@ -507,7 +484,7 @@ const homePageOnReady = async ({
|
|
|
507
484
|
areasOfPracticesList = _areasOfPracticesList;
|
|
508
485
|
stateCityMapList = _stateCityMapList;
|
|
509
486
|
}
|
|
510
|
-
sidePanelFilterData.set('state', completeStateList);
|
|
487
|
+
await sidePanelFilterData.set('state', completeStateList);
|
|
511
488
|
multiSelectFilter('state');
|
|
512
489
|
sidePanelFilterData.set('practiceAreas', areasOfPracticesList);
|
|
513
490
|
multiSelectFilter('practiceAreas');
|
|
@@ -767,9 +744,7 @@ const homePageOnReady = async ({
|
|
|
767
744
|
await updateResults('filterTimeout');
|
|
768
745
|
}
|
|
769
746
|
} catch (error) {
|
|
770
|
-
|
|
771
|
-
console.error(`[handleFilterChanged][${renderingEnv}] failed with error:`, error);
|
|
772
|
-
logMessage(`[handleFilterChanged][${renderingEnv}] failed with error:`, error);
|
|
747
|
+
console.error('Error in multiSelectFilter:', error);
|
|
773
748
|
multiStateBoxSelector.changeState('errorState');
|
|
774
749
|
}
|
|
775
750
|
}
|
|
@@ -785,7 +760,6 @@ const homePageOnReady = async ({
|
|
|
785
760
|
filter[`${filterName}Search`] = '';
|
|
786
761
|
}
|
|
787
762
|
};
|
|
788
|
-
|
|
789
763
|
module.exports = {
|
|
790
764
|
homePageOnReady,
|
|
791
765
|
};
|
package/public/Utils/homePage.js
CHANGED
|
@@ -536,13 +536,13 @@ const createHomepageUtils = (_$w, filterProfiles, logMessage) => {
|
|
|
536
536
|
`[parseAndValidateQueryParams][${renderingEnv}] isNoParams`,
|
|
537
537
|
JSON.stringify(params)
|
|
538
538
|
);
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
539
|
+
search({
|
|
540
|
+
filter,
|
|
541
|
+
pagination,
|
|
542
|
+
debounceTimeout: 0,
|
|
543
|
+
timeoutType: 'search',
|
|
544
|
+
isSearchingNearby: false,
|
|
545
|
+
});
|
|
546
546
|
// Don't search yet - let the caller decide what to do
|
|
547
547
|
// The search will be handled in applyFilterToUI
|
|
548
548
|
return { isDefaultStateParams: true, filter: newFilter };
|