abmp-npm 10.0.63 → 10.0.65
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/backend/index.js +1 -0
- package/backend/jobs.js +0 -15
- package/backend/public-profile-methods.js +45 -0
- package/backend/routers/utils.js +1 -0
- package/backend/tasks/consts.js +0 -2
- package/backend/tasks/index.js +0 -1
- package/backend/tasks/tasks-configs.js +0 -18
- package/package.json +1 -1
- package/pages/index.js +1 -0
- package/pages/publicProfile.js +381 -0
- package/public/consts.js +1 -0
- package/backend/tasks/daily-pull-backup-check-methods.js +0 -106
package/backend/index.js
CHANGED
package/backend/jobs.js
CHANGED
|
@@ -96,20 +96,6 @@ async function scheduleFixUrlsWithSpacesTask() {
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
async function scheduleDailyPullExecutionCheckTask() {
|
|
100
|
-
try {
|
|
101
|
-
console.log('scheduleDailyPullExecutionCheck started!');
|
|
102
|
-
return await taskManager().schedule({
|
|
103
|
-
name: TASKS_NAMES.scheduleDailyPullExecutionCheck,
|
|
104
|
-
data: {},
|
|
105
|
-
type: 'scheduled',
|
|
106
|
-
});
|
|
107
|
-
} catch (error) {
|
|
108
|
-
console.error(`Failed to scheduleDailyPullExecutionCheck: ${error.message}`);
|
|
109
|
-
throw new Error(`Failed to scheduleDailyPullExecutionCheck: ${error.message}`);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
99
|
async function updateSiteMapS3() {
|
|
114
100
|
try {
|
|
115
101
|
return await taskManager().schedule({
|
|
@@ -129,5 +115,4 @@ module.exports = {
|
|
|
129
115
|
scheduleCreateContactsFromMembersTask,
|
|
130
116
|
scheduleFixPrimaryAddressForMembersTask,
|
|
131
117
|
scheduleFixUrlsWithSpacesTask,
|
|
132
|
-
scheduleDailyPullExecutionCheckTask,
|
|
133
118
|
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const { COLLECTIONS } = require('../public/consts');
|
|
2
|
+
|
|
3
|
+
const { CONFIG_KEYS } = require('./consts');
|
|
4
|
+
const { MEMBER_ACTIONS } = require('./daily-pull/consts');
|
|
5
|
+
const { wixData } = require('./elevated-modules');
|
|
6
|
+
const { findMemberByWixDataId } = require('./members-data-methods');
|
|
7
|
+
const { transformMemberToProfileData } = require('./routers/utils');
|
|
8
|
+
const { getSiteConfigs } = require('./utils');
|
|
9
|
+
|
|
10
|
+
const getPublicMemberRecord = memberDataId =>
|
|
11
|
+
wixData
|
|
12
|
+
.query(COLLECTIONS.MEMBERS_DATA_PUBLIC)
|
|
13
|
+
.eq('memberData', memberDataId)
|
|
14
|
+
.limit(1)
|
|
15
|
+
.find()
|
|
16
|
+
.then(res => res.items?.[0] || null);
|
|
17
|
+
|
|
18
|
+
async function getPublicMemberProfileData({ memberDataId }) {
|
|
19
|
+
if (!memberDataId) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const publicMember = await getPublicMemberRecord(memberDataId);
|
|
24
|
+
if (!publicMember || publicMember.showWixUrl !== true) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const member = await findMemberByWixDataId(memberDataId);
|
|
29
|
+
if (!member || member.action === MEMBER_ACTIONS.DROP || member.showWixUrl !== true) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const siteConfigs = await getSiteConfigs();
|
|
34
|
+
const siteAssociation = siteConfigs[CONFIG_KEYS.SITE_ASSOCIATION];
|
|
35
|
+
const defaultProfileImage = siteConfigs[CONFIG_KEYS.DEFAULT_PROFILE_IMAGE];
|
|
36
|
+
|
|
37
|
+
const profileData = transformMemberToProfileData(member, siteAssociation);
|
|
38
|
+
return {
|
|
39
|
+
profileData: { ...profileData, defaultProfileImage },
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
module.exports = {
|
|
44
|
+
getPublicMemberProfileData,
|
|
45
|
+
};
|
package/backend/routers/utils.js
CHANGED
package/backend/tasks/consts.js
CHANGED
|
@@ -22,8 +22,6 @@ const TASKS_NAMES = {
|
|
|
22
22
|
fixPrimaryAddressChunk: 'fixPrimaryAddressChunk',
|
|
23
23
|
scheduleFixUrlsWithSpaces: 'scheduleFixUrlsWithSpaces',
|
|
24
24
|
fixUrlsWithSpacesChunk: 'fixUrlsWithSpacesChunk',
|
|
25
|
-
scheduleDailyPullExecutionCheck: 'scheduleDailyPullExecutionCheck',
|
|
26
|
-
dailyPullExecutionCheck: 'dailyPullExecutionCheck',
|
|
27
25
|
};
|
|
28
26
|
|
|
29
27
|
module.exports = {
|
package/backend/tasks/index.js
CHANGED
|
@@ -9,10 +9,6 @@ const {
|
|
|
9
9
|
fixPrimaryAddressChunk,
|
|
10
10
|
} = require('./address-primary-methods');
|
|
11
11
|
const { TASKS_NAMES } = require('./consts');
|
|
12
|
-
const {
|
|
13
|
-
scheduleDailyPullExecutionCheck,
|
|
14
|
-
dailyPullExecutionCheck,
|
|
15
|
-
} = require('./daily-pull-backup-check-methods');
|
|
16
12
|
const {
|
|
17
13
|
scheduleTaskForEmptyAboutYouMembers,
|
|
18
14
|
convertAboutYouHtmlToRichContent,
|
|
@@ -206,20 +202,6 @@ const TASKS = {
|
|
|
206
202
|
shouldSkipCheck: () => false,
|
|
207
203
|
estimatedDurationSec: 80,
|
|
208
204
|
},
|
|
209
|
-
[TASKS_NAMES.scheduleDailyPullExecutionCheck]: {
|
|
210
|
-
name: TASKS_NAMES.scheduleDailyPullExecutionCheck,
|
|
211
|
-
getIdentifier: () => 'SHOULD_NEVER_SKIP',
|
|
212
|
-
process: scheduleDailyPullExecutionCheck,
|
|
213
|
-
shouldSkipCheck: () => false,
|
|
214
|
-
estimatedDurationSec: 30,
|
|
215
|
-
},
|
|
216
|
-
[TASKS_NAMES.dailyPullExecutionCheck]: {
|
|
217
|
-
name: TASKS_NAMES.dailyPullExecutionCheck,
|
|
218
|
-
getIdentifier: task => task.data,
|
|
219
|
-
process: dailyPullExecutionCheck,
|
|
220
|
-
shouldSkipCheck: () => false,
|
|
221
|
-
estimatedDurationSec: 30,
|
|
222
|
-
},
|
|
223
205
|
};
|
|
224
206
|
|
|
225
207
|
module.exports = { TASKS };
|
package/package.json
CHANGED
package/pages/index.js
CHANGED
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
const { location: wixLocation } = require('@wix/site-location');
|
|
2
|
+
const { window: wixWindow } = require('@wix/site-window');
|
|
3
|
+
|
|
4
|
+
const { getPublicMemberProfileData } = require('../backend');
|
|
5
|
+
const { LIGHTBOX_NAMES } = require('../public/consts');
|
|
6
|
+
const {
|
|
7
|
+
generateId,
|
|
8
|
+
formatPracticeAreasForDisplay,
|
|
9
|
+
isWixHostedImage,
|
|
10
|
+
} = require('../public/Utils/sharedUtils');
|
|
11
|
+
|
|
12
|
+
const TESTIMONIALS_PER_PAGE_CONFIG = {
|
|
13
|
+
DESKTOP: 4,
|
|
14
|
+
TABLET: 2,
|
|
15
|
+
MOBILE: 1,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const BREAKPOINTS = {
|
|
19
|
+
DESKTOP: 1301,
|
|
20
|
+
TABLET: 750,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const resolveMemberDataId = memberData => {
|
|
24
|
+
if (!memberData) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
if (typeof memberData === 'string') {
|
|
28
|
+
return memberData;
|
|
29
|
+
}
|
|
30
|
+
return memberData?._id || memberData?._ref || null;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
async function publicProfileOnReady({ $w: _$w }) {
|
|
34
|
+
const dataset = _$w('#dynamicDataset');
|
|
35
|
+
let profileData = null;
|
|
36
|
+
|
|
37
|
+
let testimonialsPerPage = TESTIMONIALS_PER_PAGE_CONFIG.TABLET;
|
|
38
|
+
let currentTestimonialPage = 0;
|
|
39
|
+
|
|
40
|
+
await dataset.onReadyAsync();
|
|
41
|
+
const item = dataset.getCurrentItem();
|
|
42
|
+
if (!item || item.showWixUrl !== true) {
|
|
43
|
+
wixLocation.to(`${wixLocation.baseUrl}/404`);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const memberDataId = resolveMemberDataId(item.memberData);
|
|
48
|
+
if (!memberDataId) {
|
|
49
|
+
wixLocation.to(`${wixLocation.baseUrl}/404`);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const result = await getPublicMemberProfileData({ memberDataId });
|
|
54
|
+
profileData = result?.profileData || null;
|
|
55
|
+
|
|
56
|
+
if (!profileData) {
|
|
57
|
+
wixLocation.to(`${wixLocation.baseUrl}/404`);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
initializePage();
|
|
62
|
+
|
|
63
|
+
function initializePage() {
|
|
64
|
+
bindProfileData();
|
|
65
|
+
setupAddressToggle();
|
|
66
|
+
setupResponsiveTestimonials();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Profile data binding
|
|
70
|
+
function bindProfileData() {
|
|
71
|
+
bindAddressData();
|
|
72
|
+
bindMemberInfo();
|
|
73
|
+
bindContactInfo();
|
|
74
|
+
bindBusinessInfo();
|
|
75
|
+
bindGalleryData();
|
|
76
|
+
bindTestimonialsData();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function bindAddressData() {
|
|
80
|
+
if (profileData.mainAddress) {
|
|
81
|
+
setTextForElements(
|
|
82
|
+
['#LocationText', '#LocationText2', '#LocationText3'],
|
|
83
|
+
profileData.mainAddress
|
|
84
|
+
);
|
|
85
|
+
} else {
|
|
86
|
+
deleteElements(['#locationContainer', '#location1Container', '#locationContainer2']);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
setupAdditionalAddresses();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function setupAdditionalAddresses() {
|
|
93
|
+
_$w('#moreAdressesRepeater').data = profileData.moreAddressesToDisplay;
|
|
94
|
+
|
|
95
|
+
if (profileData.moreAddressesToDisplay.length > 0) {
|
|
96
|
+
_$w('#moreLocationButton').expand();
|
|
97
|
+
_$w('#addressTitle').collapse();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
_$w('#moreAdressesRepeater').onItemReady(($item, itemData) => {
|
|
101
|
+
console.log('Item Data:', itemData);
|
|
102
|
+
$item('#adressText').text = itemData.address || '';
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function setupAddressToggle() {
|
|
107
|
+
toggleContainer('#moreLocationButton', '#addressContainer');
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function toggleContainer(buttonId, containerId) {
|
|
111
|
+
const $button = _$w(buttonId);
|
|
112
|
+
const $container = _$w(containerId);
|
|
113
|
+
|
|
114
|
+
$button.onClick(() => {
|
|
115
|
+
const isCollapsed = $container.collapsed;
|
|
116
|
+
$container[isCollapsed ? 'expand' : 'collapse']();
|
|
117
|
+
$button.label = isCollapsed ? 'Less Locations -' : 'More Locations +';
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function bindMemberInfo() {
|
|
122
|
+
bindMemberSince();
|
|
123
|
+
bindStudentBadge();
|
|
124
|
+
bindProfileImages();
|
|
125
|
+
bindFullName();
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function bindMemberSince() {
|
|
129
|
+
if (profileData.memberSince) {
|
|
130
|
+
_$w('#sinceYearText').text = profileData.memberSince;
|
|
131
|
+
} else {
|
|
132
|
+
_$w('#memberSinceBox').delete();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function bindStudentBadge() {
|
|
137
|
+
if (profileData.shouldHaveStudentBadge) {
|
|
138
|
+
_$w('#studentContainer, #studentContainerMobile').expand();
|
|
139
|
+
} else {
|
|
140
|
+
_$w('#studentContainer, #studentContainerMobile').delete();
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function bindProfileImages() {
|
|
145
|
+
if (profileData.logoImage) {
|
|
146
|
+
_$w('#logoImage').src = profileData.logoImage;
|
|
147
|
+
} else {
|
|
148
|
+
_$w('#logoImage').delete();
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (profileData.profileImage && isWixHostedImage(profileData.profileImage)) {
|
|
152
|
+
_$w('#profileImage').src = profileData.profileImage;
|
|
153
|
+
} else {
|
|
154
|
+
_$w('#profileImage').src = profileData.defaultProfileImage;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function bindFullName() {
|
|
159
|
+
if (profileData.fullName) {
|
|
160
|
+
setTextForElements(
|
|
161
|
+
['#fullNameText', '#fullNameText2', '#fullNameTextFoter'],
|
|
162
|
+
profileData.fullName
|
|
163
|
+
);
|
|
164
|
+
} else {
|
|
165
|
+
deleteElements(['#fullNameText', '#fullNameText2', '#fullNameTextFoter']);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Contact information binding
|
|
170
|
+
function bindContactInfo() {
|
|
171
|
+
bindContactForm();
|
|
172
|
+
bindBookingUrl();
|
|
173
|
+
bindPhoneNumber();
|
|
174
|
+
bindLicenseNumber();
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function bindContactForm() {
|
|
178
|
+
if (profileData.showContactForm) {
|
|
179
|
+
_$w('#contactButton').onClick(() =>
|
|
180
|
+
wixWindow.openLightbox(LIGHTBOX_NAMES.CONTACT_US, profileData)
|
|
181
|
+
);
|
|
182
|
+
} else {
|
|
183
|
+
_$w('#contactButton').delete();
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function bindBookingUrl() {
|
|
188
|
+
if (profileData.bookingUrl) {
|
|
189
|
+
_$w('#bookNowButton').link = profileData.bookingUrl;
|
|
190
|
+
} else {
|
|
191
|
+
_$w('#bookNowButton').delete();
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function bindPhoneNumber() {
|
|
196
|
+
if (profileData.phone) {
|
|
197
|
+
const formattedPhoneNumber = profileData.phone.replace(/[^\d+]/g, '');
|
|
198
|
+
const getPhoneHTML = $phoneSelector =>
|
|
199
|
+
$phoneSelector.html.replace(
|
|
200
|
+
$phoneSelector.text,
|
|
201
|
+
`<a href="${`tel:${formattedPhoneNumber}`}">${profileData.phone}</a>`
|
|
202
|
+
);
|
|
203
|
+
_$w('#phoneText').html = getPhoneHTML(_$w('#phoneText'));
|
|
204
|
+
_$w('#phoneText2').html = getPhoneHTML(_$w('#phoneText2'));
|
|
205
|
+
} else {
|
|
206
|
+
deleteElements(['#phoneContainer', '#phoneContainer2']);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function bindLicenseNumber() {
|
|
211
|
+
if (profileData.licenceNo) {
|
|
212
|
+
_$w('#licenceNoText').text = profileData.licenceNo;
|
|
213
|
+
} else {
|
|
214
|
+
_$w('#licensesContainer').delete();
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function bindBusinessInfo() {
|
|
219
|
+
bindAboutService();
|
|
220
|
+
bindBusinessName();
|
|
221
|
+
bindAreasOfPractice();
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function bindAboutService() {
|
|
225
|
+
if (profileData.aboutService) {
|
|
226
|
+
_$w('#aboutYouText').html = profileData.aboutService;
|
|
227
|
+
} else {
|
|
228
|
+
_$w('#aboutSection').delete();
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function bindBusinessName() {
|
|
233
|
+
if (profileData.businessName) {
|
|
234
|
+
_$w('#businessName').text = profileData.businessName;
|
|
235
|
+
_$w('#businessName').expand();
|
|
236
|
+
} else {
|
|
237
|
+
_$w('#businessName').delete();
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function bindAreasOfPractice() {
|
|
242
|
+
const areasText = formatPracticeAreasForDisplay(profileData.areasOfPractices);
|
|
243
|
+
|
|
244
|
+
if (areasText) {
|
|
245
|
+
_$w('#areaOfPracticesText').text = areasText;
|
|
246
|
+
} else {
|
|
247
|
+
_$w('#areaOfPracticesText').delete();
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (Array.isArray(profileData.areasOfPractices) && profileData.areasOfPractices.length > 0) {
|
|
251
|
+
populateRepeater(profileData.areasOfPractices, '#areaOfPracticesRepeater', '#practiceText');
|
|
252
|
+
} else {
|
|
253
|
+
_$w('#servicesSection').delete();
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function bindGalleryData() {
|
|
258
|
+
if (profileData.bannerImages && profileData.bannerImages.length > 0) {
|
|
259
|
+
_$w('#bannerImage').src = profileData.bannerImages[0];
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
if (!profileData.gallery?.length) {
|
|
263
|
+
_$w('#gallerySection').delete();
|
|
264
|
+
} else {
|
|
265
|
+
_$w('#gallery').items = profileData.gallery;
|
|
266
|
+
_$w('#gallerySection').restore();
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function bindTestimonialsData() {
|
|
271
|
+
if (!profileData.testimonials?.length) {
|
|
272
|
+
_$w('#testimonialsSection').delete();
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// Responsive testimonials setup
|
|
277
|
+
async function setupResponsiveTestimonials() {
|
|
278
|
+
const { window } = await wixWindow.getBoundingRect();
|
|
279
|
+
testimonialsPerPage = getTestimonialsPerPage(window.width);
|
|
280
|
+
|
|
281
|
+
// Monitor window resize
|
|
282
|
+
setInterval(async () => {
|
|
283
|
+
const { window: win } = await wixWindow.getBoundingRect();
|
|
284
|
+
const newTestimonialsPerPage = getTestimonialsPerPage(win.width);
|
|
285
|
+
|
|
286
|
+
if (newTestimonialsPerPage !== testimonialsPerPage) {
|
|
287
|
+
testimonialsPerPage = newTestimonialsPerPage;
|
|
288
|
+
currentTestimonialPage = 0;
|
|
289
|
+
displayTestimonialsPage(profileData.testimonials);
|
|
290
|
+
}
|
|
291
|
+
}, 500);
|
|
292
|
+
|
|
293
|
+
setupTestimonialsIfAvailable();
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
function setupTestimonialsIfAvailable() {
|
|
297
|
+
if (profileData.testimonials.length > 0) {
|
|
298
|
+
setupTestimonialsPagination(profileData.testimonials);
|
|
299
|
+
_$w('#testimonialsSection').expand();
|
|
300
|
+
} else {
|
|
301
|
+
_$w('#testimonialsSection').delete();
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
function getTestimonialsPerPage(width) {
|
|
306
|
+
if (width >= BREAKPOINTS.DESKTOP) return TESTIMONIALS_PER_PAGE_CONFIG.DESKTOP;
|
|
307
|
+
if (width >= BREAKPOINTS.TABLET) return TESTIMONIALS_PER_PAGE_CONFIG.TABLET;
|
|
308
|
+
return TESTIMONIALS_PER_PAGE_CONFIG.MOBILE;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
function setTextForElements(elementIds, text) {
|
|
312
|
+
elementIds.forEach(id => {
|
|
313
|
+
_$w(id).text = text;
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
function deleteElements(elementIds) {
|
|
318
|
+
elementIds.forEach(id => {
|
|
319
|
+
_$w(id).delete();
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
function populateRepeater(data, repeaterId, textElementId) {
|
|
324
|
+
const repeaterData = data.map(item => ({
|
|
325
|
+
_id: generateId(),
|
|
326
|
+
text: item.trim(),
|
|
327
|
+
}));
|
|
328
|
+
_$w(repeaterId).data = repeaterData;
|
|
329
|
+
_$w(repeaterId).onItemReady(($item, itemData) => {
|
|
330
|
+
$item(textElementId).text = itemData.text;
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// Testimonials pagination
|
|
335
|
+
function setupTestimonialsPagination(allTestimonials) {
|
|
336
|
+
currentTestimonialPage = 0;
|
|
337
|
+
|
|
338
|
+
_$w('#prevTestimonialBtn').onClick(() => {
|
|
339
|
+
if (currentTestimonialPage > 0) {
|
|
340
|
+
currentTestimonialPage--;
|
|
341
|
+
displayTestimonialsPage(allTestimonials);
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
_$w('#nextTestimonialBtn').onClick(() => {
|
|
346
|
+
const maxPage = Math.floor((allTestimonials.length - 1) / testimonialsPerPage);
|
|
347
|
+
if (currentTestimonialPage < maxPage) {
|
|
348
|
+
currentTestimonialPage++;
|
|
349
|
+
displayTestimonialsPage(allTestimonials);
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
displayTestimonialsPage(allTestimonials);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
function displayTestimonialsPage(allTestimonials) {
|
|
357
|
+
const start = currentTestimonialPage * testimonialsPerPage;
|
|
358
|
+
const end = start + testimonialsPerPage;
|
|
359
|
+
const currentBatch = allTestimonials.slice(start, end);
|
|
360
|
+
|
|
361
|
+
populateRepeater(currentBatch, '#testimonialsrepeater', '#testimonialText');
|
|
362
|
+
updateTestimonialNavigation(end, allTestimonials.length);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
function updateTestimonialNavigation(end, totalLength) {
|
|
366
|
+
_$w('#prevTestimonialBtn').hide();
|
|
367
|
+
_$w('#nextTestimonialBtn').hide();
|
|
368
|
+
|
|
369
|
+
if (currentTestimonialPage > 0) {
|
|
370
|
+
_$w('#prevTestimonialBtn').show();
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
if (end < totalLength) {
|
|
374
|
+
_$w('#nextTestimonialBtn').show();
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
module.exports = {
|
|
380
|
+
publicProfileOnReady,
|
|
381
|
+
};
|
package/public/consts.js
CHANGED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
const { taskManager } = require('psdev-task-manager');
|
|
2
|
-
const { COLLECTIONS } = require('psdev-task-manager/public/consts');
|
|
3
|
-
|
|
4
|
-
const { MEMBER_ACTIONS } = require('../daily-pull/consts');
|
|
5
|
-
const { wixData } = require('../elevated-modules');
|
|
6
|
-
const { queryAllItems } = require('../utils');
|
|
7
|
-
|
|
8
|
-
const { TASKS_NAMES } = require('./consts');
|
|
9
|
-
|
|
10
|
-
const DEFAULT_HOURS_BACK = 4;
|
|
11
|
-
|
|
12
|
-
const getActionsToCheck = includeNone =>
|
|
13
|
-
includeNone
|
|
14
|
-
? Object.values(MEMBER_ACTIONS)
|
|
15
|
-
: Object.values(MEMBER_ACTIONS).filter(action => action !== MEMBER_ACTIONS.NONE);
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Schedules an execution check for daily pull status.
|
|
19
|
-
*/
|
|
20
|
-
async function scheduleDailyPullExecutionCheck() {
|
|
21
|
-
try {
|
|
22
|
-
console.log('scheduleDailyPullExecutionCheck started!');
|
|
23
|
-
return await taskManager().schedule({
|
|
24
|
-
name: TASKS_NAMES.dailyPullExecutionCheck,
|
|
25
|
-
data: { hoursBack: DEFAULT_HOURS_BACK, includeNone: false },
|
|
26
|
-
type: 'scheduled',
|
|
27
|
-
});
|
|
28
|
-
} catch (error) {
|
|
29
|
-
console.error(`Failed to scheduleDailyPullExecutionCheck: ${error.message}`);
|
|
30
|
-
throw new Error(`Failed to scheduleDailyPullExecutionCheck: ${error.message}`);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Verifies ScheduleMembersDataPerAction tasks exist and succeeded per action.
|
|
36
|
-
*/
|
|
37
|
-
async function dailyPullExecutionCheck(taskData) {
|
|
38
|
-
const hoursBack =
|
|
39
|
-
taskData?.hoursBack && Number.isFinite(taskData.hoursBack)
|
|
40
|
-
? taskData.hoursBack
|
|
41
|
-
: DEFAULT_HOURS_BACK;
|
|
42
|
-
const includeNone = Boolean(taskData?.includeNone);
|
|
43
|
-
const sinceDate = new Date(Date.now() - hoursBack * 60 * 60 * 1000);
|
|
44
|
-
|
|
45
|
-
console.log('dailyPullExecutionCheck started', { hoursBack, sinceDate });
|
|
46
|
-
|
|
47
|
-
const tasksQuery = wixData
|
|
48
|
-
.query(COLLECTIONS.TASKS)
|
|
49
|
-
.eq('name', TASKS_NAMES.ScheduleMembersDataPerAction)
|
|
50
|
-
.ge('_createdDate', sinceDate)
|
|
51
|
-
.limit(1000);
|
|
52
|
-
|
|
53
|
-
const tasks = await queryAllItems(tasksQuery);
|
|
54
|
-
const actionsToCheck = getActionsToCheck(includeNone);
|
|
55
|
-
|
|
56
|
-
const statusByAction = actionsToCheck.reduce((acc, action) => {
|
|
57
|
-
acc[action] = { success: 0, failed: 0, pending: 0, in_progress: 0, skipped: 0 };
|
|
58
|
-
return acc;
|
|
59
|
-
}, {});
|
|
60
|
-
|
|
61
|
-
tasks.forEach(task => {
|
|
62
|
-
const action = task?.data?.action;
|
|
63
|
-
if (!action || !(action in statusByAction)) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
const status = task?.status || 'unknown';
|
|
67
|
-
if (!statusByAction[action][status]) {
|
|
68
|
-
statusByAction[action][status] = 0;
|
|
69
|
-
}
|
|
70
|
-
statusByAction[action][status] += 1;
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
const missingActions = actionsToCheck.filter(
|
|
74
|
-
action => (statusByAction[action]?.success || 0) === 0
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
const result = {
|
|
78
|
-
success: missingActions.length === 0,
|
|
79
|
-
sinceDate: sinceDate.toISOString(),
|
|
80
|
-
actionsChecked: actionsToCheck,
|
|
81
|
-
missingActions,
|
|
82
|
-
statusByAction,
|
|
83
|
-
totalTasksFound: tasks.length,
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
if (missingActions.length > 0) {
|
|
87
|
-
console.log('Missing daily pull actions detected, scheduling fallback daily pull run', {
|
|
88
|
-
missingActions,
|
|
89
|
-
});
|
|
90
|
-
await taskManager().schedule({
|
|
91
|
-
name: TASKS_NAMES.ScheduleDailyMembersDataSync,
|
|
92
|
-
data: {},
|
|
93
|
-
type: 'scheduled',
|
|
94
|
-
});
|
|
95
|
-
result.fallbackScheduled = true;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
console.log('dailyPullExecutionCheck result', JSON.stringify(result, null, 2));
|
|
99
|
-
|
|
100
|
-
return result;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
module.exports = {
|
|
104
|
-
scheduleDailyPullExecutionCheck,
|
|
105
|
-
dailyPullExecutionCheck,
|
|
106
|
-
};
|