abmp-npm 10.0.64 → 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 -12
- package/backend/public-profile-methods.js +45 -0
- package/backend/routers/utils.js +1 -0
- package/backend/tasks/consts.js +0 -1
- package/backend/tasks/index.js +0 -1
- package/backend/tasks/tasks-configs.js +0 -8
- 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-check-methods.js +0 -88
package/backend/index.js
CHANGED
package/backend/jobs.js
CHANGED
|
@@ -2,7 +2,6 @@ const { taskManager } = require('psdev-task-manager');
|
|
|
2
2
|
|
|
3
3
|
const { MEMBER_ACTIONS } = require('./daily-pull/consts');
|
|
4
4
|
const { TASKS_NAMES } = require('./tasks/consts');
|
|
5
|
-
const { dailyPullExecutionCheck } = require('./tasks/daily-pull-check-methods');
|
|
6
5
|
const { TASKS } = require('./tasks/tasks-configs');
|
|
7
6
|
|
|
8
7
|
async function runScheduledTasks() {
|
|
@@ -97,16 +96,6 @@ async function scheduleFixUrlsWithSpacesTask() {
|
|
|
97
96
|
}
|
|
98
97
|
}
|
|
99
98
|
|
|
100
|
-
async function runDailyPullExecutionCheck() {
|
|
101
|
-
try {
|
|
102
|
-
console.log('runDailyPullExecutionCheck started!');
|
|
103
|
-
return await dailyPullExecutionCheck({});
|
|
104
|
-
} catch (error) {
|
|
105
|
-
console.error(`Failed to runDailyPullExecutionCheck: ${error.message}`);
|
|
106
|
-
throw new Error(`Failed to runDailyPullExecutionCheck: ${error.message}`);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
99
|
async function updateSiteMapS3() {
|
|
111
100
|
try {
|
|
112
101
|
return await taskManager().schedule({
|
|
@@ -126,5 +115,4 @@ module.exports = {
|
|
|
126
115
|
scheduleCreateContactsFromMembersTask,
|
|
127
116
|
scheduleFixPrimaryAddressForMembersTask,
|
|
128
117
|
scheduleFixUrlsWithSpacesTask,
|
|
129
|
-
runDailyPullExecutionCheck,
|
|
130
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,7 +22,6 @@ const TASKS_NAMES = {
|
|
|
22
22
|
fixPrimaryAddressChunk: 'fixPrimaryAddressChunk',
|
|
23
23
|
scheduleFixUrlsWithSpaces: 'scheduleFixUrlsWithSpaces',
|
|
24
24
|
fixUrlsWithSpacesChunk: 'fixUrlsWithSpacesChunk',
|
|
25
|
-
dailyPullExecutionCheck: 'dailyPullExecutionCheck',
|
|
26
25
|
};
|
|
27
26
|
|
|
28
27
|
module.exports = {
|
package/backend/tasks/index.js
CHANGED
|
@@ -9,7 +9,6 @@ const {
|
|
|
9
9
|
fixPrimaryAddressChunk,
|
|
10
10
|
} = require('./address-primary-methods');
|
|
11
11
|
const { TASKS_NAMES } = require('./consts');
|
|
12
|
-
const { dailyPullExecutionCheck } = require('./daily-pull-check-methods');
|
|
13
12
|
const {
|
|
14
13
|
scheduleTaskForEmptyAboutYouMembers,
|
|
15
14
|
convertAboutYouHtmlToRichContent,
|
|
@@ -203,13 +202,6 @@ const TASKS = {
|
|
|
203
202
|
shouldSkipCheck: () => false,
|
|
204
203
|
estimatedDurationSec: 80,
|
|
205
204
|
},
|
|
206
|
-
[TASKS_NAMES.dailyPullExecutionCheck]: {
|
|
207
|
-
name: TASKS_NAMES.dailyPullExecutionCheck,
|
|
208
|
-
getIdentifier: task => task.data,
|
|
209
|
-
process: dailyPullExecutionCheck,
|
|
210
|
-
shouldSkipCheck: () => false,
|
|
211
|
-
estimatedDurationSec: 30,
|
|
212
|
-
},
|
|
213
205
|
};
|
|
214
206
|
|
|
215
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,88 +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
|
-
* Verifies ScheduleMembersDataPerAction tasks exist and succeeded per action.
|
|
19
|
-
*/
|
|
20
|
-
async function dailyPullExecutionCheck(taskData) {
|
|
21
|
-
const hoursBack =
|
|
22
|
-
taskData?.hoursBack && Number.isFinite(taskData.hoursBack)
|
|
23
|
-
? taskData.hoursBack
|
|
24
|
-
: DEFAULT_HOURS_BACK;
|
|
25
|
-
const includeNone = Boolean(taskData?.includeNone);
|
|
26
|
-
const sinceDate = new Date(Date.now() - hoursBack * 60 * 60 * 1000);
|
|
27
|
-
|
|
28
|
-
console.log('dailyPullExecutionCheck started', { hoursBack, sinceDate });
|
|
29
|
-
|
|
30
|
-
const tasksQuery = wixData
|
|
31
|
-
.query(COLLECTIONS.TASKS)
|
|
32
|
-
.eq('name', TASKS_NAMES.ScheduleMembersDataPerAction)
|
|
33
|
-
.ge('_createdDate', sinceDate)
|
|
34
|
-
.limit(1000);
|
|
35
|
-
|
|
36
|
-
const tasks = await queryAllItems(tasksQuery);
|
|
37
|
-
const actionsToCheck = getActionsToCheck(includeNone);
|
|
38
|
-
|
|
39
|
-
const statusByAction = actionsToCheck.reduce((acc, action) => {
|
|
40
|
-
acc[action] = { success: 0, failed: 0, pending: 0, in_progress: 0, skipped: 0 };
|
|
41
|
-
return acc;
|
|
42
|
-
}, {});
|
|
43
|
-
|
|
44
|
-
tasks.forEach(task => {
|
|
45
|
-
const action = task?.data?.action;
|
|
46
|
-
if (!action || !(action in statusByAction)) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
const status = task?.status || 'unknown';
|
|
50
|
-
if (!statusByAction[action][status]) {
|
|
51
|
-
statusByAction[action][status] = 0;
|
|
52
|
-
}
|
|
53
|
-
statusByAction[action][status] += 1;
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
const missingActions = actionsToCheck.filter(
|
|
57
|
-
action => (statusByAction[action]?.success || 0) === 0
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
const result = {
|
|
61
|
-
success: missingActions.length === 0,
|
|
62
|
-
sinceDate: sinceDate.toISOString(),
|
|
63
|
-
actionsChecked: actionsToCheck,
|
|
64
|
-
missingActions,
|
|
65
|
-
statusByAction,
|
|
66
|
-
totalTasksFound: tasks.length,
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
if (missingActions.length > 0) {
|
|
70
|
-
console.log('Missing daily pull actions detected, scheduling fallback daily pull run', {
|
|
71
|
-
missingActions,
|
|
72
|
-
});
|
|
73
|
-
await taskManager().schedule({
|
|
74
|
-
name: TASKS_NAMES.ScheduleDailyMembersDataSync,
|
|
75
|
-
data: {},
|
|
76
|
-
type: 'scheduled',
|
|
77
|
-
});
|
|
78
|
-
result.fallbackScheduled = true;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
console.log('dailyPullExecutionCheck result', JSON.stringify(result, null, 2));
|
|
82
|
-
|
|
83
|
-
return result;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
module.exports = {
|
|
87
|
-
dailyPullExecutionCheck,
|
|
88
|
-
};
|