abmp-npm 2.0.60 → 2.0.62
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 +1 -1
- package/pages/personalDetails.js +33 -11
- package/public/Utils/homePage.js +31 -90
package/package.json
CHANGED
package/pages/Home.js
CHANGED
|
@@ -366,7 +366,7 @@ const homePageOnReady = async ({
|
|
|
366
366
|
isSearchingNearby: _$w('#nearBy').checked,
|
|
367
367
|
preservePagination,
|
|
368
368
|
});
|
|
369
|
-
|
|
369
|
+
!preservePagination && (await updateUrlParams(filter, pagination));
|
|
370
370
|
return searchResults;
|
|
371
371
|
}
|
|
372
372
|
|
package/pages/personalDetails.js
CHANGED
|
@@ -2033,14 +2033,29 @@ async function personalDetailsOnReady({
|
|
|
2033
2033
|
});
|
|
2034
2034
|
|
|
2035
2035
|
_$w('#showPhoneCheckbox').onChange(event => {
|
|
2036
|
-
const data = _$w('#phoneNumbersList').data;
|
|
2036
|
+
const data = _$w('#phoneNumbersList').data || [];
|
|
2037
2037
|
const clickedItemData = data.find(item => item._id === event.context.itemId);
|
|
2038
|
-
|
|
2038
|
+
if (!clickedItemData) {
|
|
2039
|
+
return;
|
|
2040
|
+
}
|
|
2039
2041
|
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
+
const isChecked = event.target.checked;
|
|
2043
|
+
let updated;
|
|
2044
|
+
if (isChecked) {
|
|
2045
|
+
updated = data.map(item =>
|
|
2046
|
+
item._id === clickedItemData._id
|
|
2047
|
+
? { ...item, showPhone: true }
|
|
2048
|
+
: { ...item, showPhone: false }
|
|
2049
|
+
);
|
|
2050
|
+
updateShowPhoneSelection(clickedItemData._id, true);
|
|
2051
|
+
} else {
|
|
2052
|
+
updated = data.map(item =>
|
|
2053
|
+
item._id === clickedItemData._id ? { ...item, showPhone: false } : item
|
|
2054
|
+
);
|
|
2055
|
+
updateShowPhoneSelection(clickedItemData._id, false);
|
|
2056
|
+
}
|
|
2042
2057
|
|
|
2043
|
-
|
|
2058
|
+
renderPhonesList(updated);
|
|
2044
2059
|
checkFormChanges(FORM_SECTION_HANDLER_MAP.CONTACT_BOOKING);
|
|
2045
2060
|
});
|
|
2046
2061
|
|
|
@@ -2168,12 +2183,19 @@ async function personalDetailsOnReady({
|
|
|
2168
2183
|
const currentData = _$w('#phoneNumbersList').data || [];
|
|
2169
2184
|
const selectedItem = currentData.find(item => item._id === phoneId);
|
|
2170
2185
|
|
|
2171
|
-
if (selectedItem
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2186
|
+
if (!selectedItem) {
|
|
2187
|
+
return;
|
|
2188
|
+
}
|
|
2189
|
+
|
|
2190
|
+
if (isVisible) {
|
|
2191
|
+
itemMemberObj.toShowPhone = selectedItem.phoneNumber?.trim()
|
|
2192
|
+
? selectedItem.phoneNumber
|
|
2193
|
+
: null;
|
|
2194
|
+
return;
|
|
2195
|
+
}
|
|
2196
|
+
|
|
2197
|
+
if (selectedItem.phoneNumber) {
|
|
2198
|
+
itemMemberObj.toShowPhone = null;
|
|
2177
2199
|
}
|
|
2178
2200
|
}
|
|
2179
2201
|
|
package/public/Utils/homePage.js
CHANGED
|
@@ -1,24 +1,11 @@
|
|
|
1
1
|
const { location: wixLocation, queryParams: wixQueryParams } = require('@wix/site-location');
|
|
2
2
|
const { window: wixWindow, rendering } = require('@wix/site-window');
|
|
3
3
|
|
|
4
|
-
const { DEFAULT_FILTER
|
|
4
|
+
const { DEFAULT_FILTER } = require('../consts.js');
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
|
|
8
|
-
const r = (Math.random() * 16) | 0;
|
|
9
|
-
const v = c === 'x' ? r : (r & 0x3) | 0x8;
|
|
10
|
-
return v.toString(16);
|
|
11
|
-
});
|
|
12
|
-
}
|
|
6
|
+
const { debouncedFunction } = require('./sharedUtils.js');
|
|
13
7
|
|
|
14
8
|
const createHomepageUtils = (_$w, filterProfiles) => {
|
|
15
|
-
let currentSearchId = null;
|
|
16
|
-
let searchDebounceTimer = null;
|
|
17
|
-
let lastSearchFilter = null;
|
|
18
|
-
let lastSearchIsSearchingNearby = false;
|
|
19
|
-
let lastSearchPreservePagination = false;
|
|
20
|
-
let pendingSearchResolve = null;
|
|
21
|
-
|
|
22
9
|
const getFiltersSelectors = filterName => ({
|
|
23
10
|
checkBoxContainerSelector: _$w(`#${filterName}CheckBoxContainer`),
|
|
24
11
|
searchTextInputSelector: _$w(`#${filterName}TextInput`),
|
|
@@ -668,14 +655,13 @@ const createHomepageUtils = (_$w, filterProfiles) => {
|
|
|
668
655
|
async function search({
|
|
669
656
|
filter,
|
|
670
657
|
pagination,
|
|
671
|
-
debounceTimeout
|
|
658
|
+
debounceTimeout,
|
|
672
659
|
timeoutType,
|
|
673
660
|
isSearchingNearby,
|
|
674
661
|
preservePagination = false,
|
|
675
662
|
}) {
|
|
676
663
|
const multiStateBoxSelector = _$w('#resultsStateBox');
|
|
677
664
|
const renderingEnv = await rendering.env();
|
|
678
|
-
|
|
679
665
|
const initSearchResultsUI = () => {
|
|
680
666
|
JSON.stringify(filter) === JSON.stringify(DEFAULT_FILTER)
|
|
681
667
|
? _$w('#resetFilter').hide()
|
|
@@ -686,115 +672,70 @@ const createHomepageUtils = (_$w, filterProfiles) => {
|
|
|
686
672
|
_$w('#profileRepeater').data = [];
|
|
687
673
|
console.log({ filter });
|
|
688
674
|
};
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
filterToUse,
|
|
692
|
-
isSearchingNearbyToUse,
|
|
693
|
-
preservePaginationToUse
|
|
694
|
-
) => {
|
|
695
|
-
if (!isSearchingNearbyToUse) {
|
|
675
|
+
const runSearchAndUpdateUI = async (filter, isSearchingNearby) => {
|
|
676
|
+
if (!isSearchingNearby) {
|
|
696
677
|
if (
|
|
697
678
|
JSON.stringify({
|
|
698
|
-
...
|
|
679
|
+
...filter,
|
|
699
680
|
latitude: 0,
|
|
700
681
|
longitude: 0,
|
|
701
682
|
}) === JSON.stringify(DEFAULT_FILTER)
|
|
702
683
|
) {
|
|
703
684
|
multiStateBoxSelector.changeState('noSearchCriteria');
|
|
704
|
-
await updateUrlParams(filterToUse, pagination);
|
|
705
685
|
return [];
|
|
706
686
|
}
|
|
707
687
|
}
|
|
708
|
-
const
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
688
|
+
const nonDebouncedFilterProfiles = async () => {
|
|
689
|
+
try {
|
|
690
|
+
const result = await filterProfiles({ filter, isSearchingNearby });
|
|
691
|
+
return { success: true, response: result };
|
|
692
|
+
} catch (error) {
|
|
693
|
+
return { success: false, error };
|
|
694
|
+
}
|
|
695
|
+
};
|
|
696
|
+
//Don't run setTimeout on SSR
|
|
697
|
+
const funcPromise =
|
|
698
|
+
renderingEnv === 'backend'
|
|
699
|
+
? () => nonDebouncedFilterProfiles()
|
|
700
|
+
: () =>
|
|
701
|
+
debouncedFunction({
|
|
702
|
+
func: filterProfiles,
|
|
703
|
+
debounceTimeout,
|
|
704
|
+
timeoutType,
|
|
705
|
+
args: { filter, isSearchingNearby },
|
|
706
|
+
});
|
|
707
|
+
const { success, response, error } = await funcPromise();
|
|
708
|
+
if (!success) {
|
|
719
709
|
_$w('#numberOfResults').text = '';
|
|
720
710
|
console.error('[search] failed with error:', error);
|
|
721
711
|
multiStateBoxSelector.changeState('errorState');
|
|
722
|
-
await updateUrlParams(filterToUse, pagination);
|
|
723
712
|
return [];
|
|
724
713
|
}
|
|
725
|
-
|
|
726
|
-
if (thisSearchId !== currentSearchId) return [];
|
|
727
|
-
|
|
728
|
-
const response = result;
|
|
729
714
|
const totalCount = response.items.length;
|
|
730
715
|
if (!totalCount) {
|
|
731
716
|
_$w('#numberOfResults').text = 'Showing 0 results';
|
|
732
717
|
_$w('#noResultsMessage').text = `${
|
|
733
|
-
|
|
734
|
-
? `'${
|
|
718
|
+
filter.searchText && filter.searchText.length > 0
|
|
719
|
+
? `'${filter.searchText}' did not match any search. Please try again.`
|
|
735
720
|
: 'No results found for the selected filters. Please adjust your filters and try again'
|
|
736
721
|
}`;
|
|
737
722
|
multiStateBoxSelector.changeState('noResultsState');
|
|
738
|
-
await updateUrlParams(filterToUse, pagination);
|
|
739
723
|
return [];
|
|
740
724
|
}
|
|
741
725
|
console.log({ response });
|
|
742
726
|
handleNumberOfResults(pagination, totalCount);
|
|
743
727
|
_$w('#showingResult').show();
|
|
744
728
|
|
|
745
|
-
if (!
|
|
729
|
+
if (!preservePagination || pagination.currentPage >= pagination.totalPages) {
|
|
746
730
|
pagination.currentPage = 0;
|
|
747
731
|
}
|
|
748
732
|
pagination.totalPages = Math.ceil(totalCount / pagination.pageSize);
|
|
749
733
|
paginateSearchResults(response.items, pagination);
|
|
750
734
|
multiStateBoxSelector.changeState('resultsState');
|
|
751
|
-
await updateUrlParams(filterToUse, pagination);
|
|
752
735
|
return response.items;
|
|
753
736
|
};
|
|
754
|
-
|
|
755
|
-
// Always show loading as soon as user changes input
|
|
756
737
|
initSearchResultsUI();
|
|
757
|
-
|
|
758
|
-
// SSR: run immediately, no debounce
|
|
759
|
-
if (renderingEnv === 'backend') {
|
|
760
|
-
return await runSearchAndUpdateUI(filter, isSearchingNearby, preservePagination);
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
// Client: debounce the API call; loading is already shown above.
|
|
764
|
-
// Snapshot the filter so rapid clicks / URL sync can't mutate it before the debounced run.
|
|
765
|
-
lastSearchFilter = JSON.parse(JSON.stringify(filter));
|
|
766
|
-
lastSearchIsSearchingNearby = isSearchingNearby;
|
|
767
|
-
lastSearchPreservePagination = preservePagination;
|
|
768
|
-
|
|
769
|
-
if (pendingSearchResolve) {
|
|
770
|
-
pendingSearchResolve([]);
|
|
771
|
-
pendingSearchResolve = null;
|
|
772
|
-
}
|
|
773
|
-
|
|
774
|
-
if (searchDebounceTimer) {
|
|
775
|
-
clearTimeout(searchDebounceTimer);
|
|
776
|
-
searchDebounceTimer = null;
|
|
777
|
-
}
|
|
778
|
-
|
|
779
|
-
const delay = DEBOUNCE_DELAY[timeoutType] ?? 300;
|
|
780
|
-
return new Promise(resolve => {
|
|
781
|
-
pendingSearchResolve = resolve;
|
|
782
|
-
searchDebounceTimer = setTimeout(async () => {
|
|
783
|
-
searchDebounceTimer = null;
|
|
784
|
-
const filterToUse = lastSearchFilter;
|
|
785
|
-
const isSearchingNearbyToUse = lastSearchIsSearchingNearby;
|
|
786
|
-
const preservePaginationToUse = lastSearchPreservePagination;
|
|
787
|
-
const items = await runSearchAndUpdateUI(
|
|
788
|
-
filterToUse,
|
|
789
|
-
isSearchingNearbyToUse,
|
|
790
|
-
preservePaginationToUse
|
|
791
|
-
);
|
|
792
|
-
if (pendingSearchResolve) {
|
|
793
|
-
pendingSearchResolve(items);
|
|
794
|
-
pendingSearchResolve = null;
|
|
795
|
-
}
|
|
796
|
-
}, delay);
|
|
797
|
-
});
|
|
738
|
+
return await runSearchAndUpdateUI(filter, isSearchingNearby);
|
|
798
739
|
}
|
|
799
740
|
|
|
800
741
|
return {
|