abmp-npm 10.0.64 → 10.0.66

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