abmp-npm 1.1.45 → 1.1.46

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "abmp-npm",
3
- "version": "1.1.45",
3
+ "version": "1.1.46",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",
@@ -26,6 +26,7 @@
26
26
  "prettier": "^3.3.3"
27
27
  },
28
28
  "dependencies": {
29
+ "@hisense-staging/velo-npm": "3.0.24",
29
30
  "@wix/automations": "^1.0.261",
30
31
  "@wix/crm": "^1.0.1061",
31
32
  "@wix/data": "^1.0.303",
package/pages/Home.js CHANGED
@@ -1,7 +1,7 @@
1
1
  //home page code
2
+ const { withWarmUpData } = require('@hisense-staging/velo-npm');
2
3
  const { location: wixLocation } = require('@wix/site-location');
3
4
  const { window: wixWindow, rendering } = require('@wix/site-window');
4
- const { withWarmUpData } = require('psdev-utils/frontend');
5
5
 
6
6
  const { ADDRESS_STATUS_TYPES, DEFAULT_FILTER, DROPDOWN_OPTIONS } = require('../public/consts.js');
7
7
  const { createHomepageUtils } = require('../public/Utils/homePage.js');
@@ -77,7 +77,7 @@ const homePageOnReady = async ({
77
77
  showFiltersOnDesktop();
78
78
  }
79
79
 
80
- function attachEventListeners() {
80
+ async 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(async event => await searchProfilesOnSearchText(event));
112
- _$w('#searchTabletMobile').onInput(async event => await searchProfilesOnSearchText(event));
111
+ _$w('#searchDesktop').onInput(event => searchProfilesOnSearchText(event));
112
+ _$w('#searchTabletMobile').onInput(event => searchProfilesOnSearchText(event));
113
113
  // Use onChange for the switch and onClick for the retry button
114
114
  _$w('#nearBy').onChange(() => {
115
115
  updateFiltersState();
@@ -179,8 +179,8 @@ const homePageOnReady = async ({
179
179
 
180
180
  await updateResults('zeroTimeout');
181
181
  });
182
-
183
- _$w('#profileRepeater').onItemReady(async ($item, itemData) => {
182
+ const baseUrl = await wixLocation.baseUrl();
183
+ _$w('#profileRepeater').onItemReady(($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,7 +200,6 @@ const homePageOnReady = async ({
200
200
  if (itemData.showWebsite) {
201
201
  $item('#website').link = itemData.website;
202
202
  } else {
203
- const baseUrl = await wixLocation.baseUrl();
204
203
  $item('#website').link = `${baseUrl}/profile/${itemData.url}`;
205
204
  }
206
205
  $item('#website').target = '_blank';
@@ -265,17 +264,23 @@ const homePageOnReady = async ({
265
264
  }
266
265
 
267
266
  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);
272
273
  filter = newFilter;
274
+ logMessage(`[handleUrlParams][${renderingEnv}] filter`, JSON.stringify(filter));
273
275
  await applyFilterToUI(isDefaultStateParams);
274
276
  }
275
277
 
276
278
  async function applyFilterToUI(isDefaultStateParams) {
279
+ const renderingEnv = await rendering.env();
280
+ logMessage(`[applyFilterToUI][${renderingEnv}] isDefaultStateParams`, isDefaultStateParams);
277
281
  const setFilterFromParams = async (isInitializeValue = true) => {
278
282
  const params = await wixLocation.query();
283
+ logMessage(`[setFilterFromParams][${renderingEnv}] params`, JSON.stringify(params));
279
284
  console.log('params inside setFilterFromParams ', params);
280
285
  const paramsMapping = getParamsMapping(filter, pagination);
281
286
  for (const [param, { setValue, setUI }] of Object.entries(paramsMapping)) {
@@ -307,10 +312,12 @@ const homePageOnReady = async ({
307
312
  await setFilterFromParams(true);
308
313
  if (isDefaultStateParams) {
309
314
  console.log('default state set for nearby');
315
+ logMessage(`[applyFilterToUI][${renderingEnv}] default state set for nearby`);
310
316
  await Promise.all([fetchFilterData(), nearByHandler(true)]);
311
317
  return;
312
318
  }
313
319
  console.log('not default state');
320
+ logMessage(`[applyFilterToUI][${renderingEnv}] not default state`);
314
321
  const searchPromise =
315
322
  filter.searchText && filter.searchText.length > 0
316
323
  ? () =>
@@ -331,6 +338,7 @@ const homePageOnReady = async ({
331
338
  searchPromise(),
332
339
  ]);
333
340
  } catch (error) {
341
+ logMessage(`[applyFilterToUI][${renderingEnv}] failed with error:`, error);
334
342
  console.error('[applyFilterToUI] failed with error:', error);
335
343
  multiStateBoxSelector.changeState('errorState');
336
344
  }
@@ -340,7 +348,11 @@ const homePageOnReady = async ({
340
348
  * UPDATE PROFILES BASED ON APPLIED/DEFAULT FILTER
341
349
  */
342
350
  async function updateResults(timeoutType, preservePagination = false) {
351
+ const renderingEnv = await rendering.env();
352
+ logMessage(`[updateResults][${renderingEnv}] timeoutType`, timeoutType);
353
+ logMessage(`[updateResults][${renderingEnv}] preservePagination`, preservePagination);
343
354
  if (debounceTimeout[timeoutType]) {
355
+ logMessage(`[updateResults][${renderingEnv}] clearing timeout type ${timeoutType}`);
344
356
  clearTimeout(debounceTimeout[timeoutType]);
345
357
  }
346
358
  searchResults = await search({
@@ -351,6 +363,7 @@ const homePageOnReady = async ({
351
363
  isSearchingNearby: _$w('#nearBy').checked,
352
364
  preservePagination,
353
365
  });
366
+ logMessage(`[updateResults][${renderingEnv}] searchResults`, JSON.stringify(searchResults));
354
367
  !preservePagination && (await updateUrlParams(filter, pagination));
355
368
  return searchResults;
356
369
  }
@@ -410,7 +423,8 @@ const homePageOnReady = async ({
410
423
  // NEAR BY FILTER
411
424
  async function nearByHandler(preservePagination = false) {
412
425
  const isSearchingNearby = _$w('#nearBy').checked;
413
-
426
+ const renderingEnv = await rendering.env();
427
+ logMessage(`[nearByHandler][${renderingEnv}] isSearchingNearby`, isSearchingNearby);
414
428
  // 1. Disable nearby input while processing
415
429
  _$w('#nearBy').disable();
416
430
 
@@ -420,8 +434,10 @@ const homePageOnReady = async ({
420
434
  // 3. Do the query
421
435
  const { success, filter: newFilter } = await getAndSetUserLocation(isSearchingNearby, filter);
422
436
  filter = newFilter;
423
- const renderingEnv = await rendering.env();
437
+ logMessage(`[nearByHandler][${renderingEnv}] filter`, JSON.stringify(filter));
438
+ console.log('filter inside nearByHandler', filter);
424
439
  if (!success) {
440
+ logMessage(`[nearByHandler][${renderingEnv}] failed to get user location`);
425
441
  if (renderingEnv !== 'backend') {
426
442
  //on Backend environment, geolocation API don't work, so makes no sense to change state for near by
427
443
  multiStateBoxSelector.changeState('nearByState');
@@ -435,8 +451,9 @@ const homePageOnReady = async ({
435
451
 
436
452
  // If location is not selected, change state to "resultsState"
437
453
  if (!isSearchingNearby) {
454
+ logMessage(`[nearByHandler][${renderingEnv}] !isSearchingNearby, is`);
438
455
  if (await noSearchCriteria()) {
439
- console.log('no search criteria and no near by');
456
+ logMessage(`[nearByHandler][${renderingEnv}] no search criteria and no near by`);
440
457
  multiStateBoxSelector.changeState('noSearchCriteria');
441
458
  // 4. Re-enable nearby input
442
459
  _$w('#nearBy').enable();
@@ -444,7 +461,7 @@ const homePageOnReady = async ({
444
461
  }
445
462
  multiStateBoxSelector.changeState('resultsState');
446
463
  }
447
-
464
+ logMessage(`[nearByHandler][${renderingEnv}] !isSearchingNearby, isSearchingNearby is true`);
448
465
  await updateResults('zeroTimeout', preservePagination);
449
466
 
450
467
  // 4. Re-enable nearby input when done
@@ -462,14 +479,20 @@ const homePageOnReady = async ({
462
479
  await withWarmUpData(
463
480
  'getCompiledFiltersOptions',
464
481
  () => getCompiledFiltersOptions(),
465
- console.log
482
+ logMessage
466
483
  );
484
+ const renderingEnv = await rendering.env();
485
+ logMessage(`[fetchFilterData][${renderingEnv}] fetched compiled filters`);
467
486
  completeStateList = COMPILED_STATE_LIST;
468
487
  areasOfPracticesList = COMPILED_AREAS_OF_PRACTICES;
469
488
  stateCityMapList = COMPILED_STATE_CITY_MAP;
470
489
  } 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
+ );
471
494
  console.error(
472
- `Failed to get compiled filters list, falling back to non compiled version: ${error}`
495
+ `Failed to get compiled filters list, falling back to non compiled version with error: ${error}`
473
496
  );
474
497
  const {
475
498
  completeStateList: _completeStateList,
@@ -744,7 +767,9 @@ const homePageOnReady = async ({
744
767
  await updateResults('filterTimeout');
745
768
  }
746
769
  } catch (error) {
747
- console.error('Error in multiSelectFilter:', error);
770
+ const renderingEnv = await rendering.env();
771
+ console.error(`[handleFilterChanged][${renderingEnv}] failed with error:`, error);
772
+ logMessage(`[handleFilterChanged][${renderingEnv}] failed with error:`, error);
748
773
  multiStateBoxSelector.changeState('errorState');
749
774
  }
750
775
  }
@@ -511,6 +511,9 @@ const createHomepageUtils = (_$w, filterProfiles, logMessage) => {
511
511
  ssrOnly: _ssrOnly,
512
512
  ...withoutPreviewParams
513
513
  } = params || {};
514
+ logMessage(
515
+ `[parseAndValidateQueryParams][${renderingEnv}] nearby: ${params.nearby}, type of nearby: ${typeof params.nearby}`
516
+ );
514
517
  const isSearchingNearby = params.nearby === 'true';
515
518
  const isNoParams = !withoutPreviewParams || Object.keys(withoutPreviewParams).length === 0;
516
519
  const { success, filter: newFilter } = await getAndSetUserLocation(isSearchingNearby, filter);
@@ -536,13 +539,13 @@ const createHomepageUtils = (_$w, filterProfiles, logMessage) => {
536
539
  `[parseAndValidateQueryParams][${renderingEnv}] isNoParams`,
537
540
  JSON.stringify(params)
538
541
  );
539
- search({
540
- filter,
541
- pagination,
542
- debounceTimeout: 0,
543
- timeoutType: 'search',
544
- isSearchingNearby: false,
545
- });
542
+ // search({
543
+ // filter,
544
+ // pagination,
545
+ // debounceTimeout: 0,
546
+ // timeoutType: 'search',
547
+ // isSearchingNearby: false,
548
+ // });
546
549
  // Don't search yet - let the caller decide what to do
547
550
  // The search will be handled in applyFilterToUI
548
551
  return { isDefaultStateParams: true, filter: newFilter };