abmp-npm 1.8.10 → 1.8.12
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 +0 -1
- package/package.json +1 -3
- package/pages/Profile.js +348 -0
- package/pages/index.js +2 -1
- package/pages/{PersonalDetailsForm.js → personalDetails.js} +327 -325
- package/public/Utils/{formValidation.js → profilePageUtils.js} +3 -10
- package/public/Utils/sharedUtils.js +9 -0
- package/public/index.js +0 -1
- package/backend/personal-details-form-methods.js +0 -399
package/backend/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "abmp-npm",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.12",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
@@ -32,9 +32,7 @@
|
|
|
32
32
|
"@wix/essentials": "^0.1.28",
|
|
33
33
|
"@wix/members": "^1.0.330",
|
|
34
34
|
"@wix/site-location": "^1.31.0",
|
|
35
|
-
"@wix/site-storage": "^1.22.0",
|
|
36
35
|
"@wix/site-window": "^1.44.0",
|
|
37
|
-
"lodash": "^4.17.21",
|
|
38
36
|
"ngeohash": "^0.6.3",
|
|
39
37
|
"phone": "^3.1.67",
|
|
40
38
|
"psdev-utils": "1.1.1"
|
package/pages/Profile.js
ADDED
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
const { location: wixLocation } = require('@wix/site-location');
|
|
2
|
+
const { window: wixWindow } = require('@wix/site-window');
|
|
3
|
+
|
|
4
|
+
const { generateId, formatPracticeAreasForDisplay } = require('../public/Utils/sharedUtils');
|
|
5
|
+
|
|
6
|
+
const TESTIMONIALS_PER_PAGE_CONFIG = {
|
|
7
|
+
DESKTOP: 4,
|
|
8
|
+
TABLET: 2,
|
|
9
|
+
MOBILE: 1,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const BREAKPOINTS = {
|
|
13
|
+
DESKTOP: 1301,
|
|
14
|
+
TABLET: 750,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
async function profileOnReady({ $w: _$w }) {
|
|
18
|
+
const profileData = await wixWindow.getRouterData();
|
|
19
|
+
console.log('profileData', profileData);
|
|
20
|
+
|
|
21
|
+
let testimonialsPerPage = TESTIMONIALS_PER_PAGE_CONFIG.TABLET;
|
|
22
|
+
let currentTestimonialPage = 0;
|
|
23
|
+
|
|
24
|
+
if (!profileData) {
|
|
25
|
+
wixLocation.to(`${wixLocation.baseUrl}/404`);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
initializePage();
|
|
30
|
+
|
|
31
|
+
function initializePage() {
|
|
32
|
+
bindProfileData();
|
|
33
|
+
setupAddressToggle();
|
|
34
|
+
setupResponsiveTestimonials();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Profile data binding
|
|
38
|
+
function bindProfileData() {
|
|
39
|
+
bindAddressData();
|
|
40
|
+
bindMemberInfo();
|
|
41
|
+
bindContactInfo();
|
|
42
|
+
bindBusinessInfo();
|
|
43
|
+
bindGalleryData();
|
|
44
|
+
bindTestimonialsData();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function bindAddressData() {
|
|
48
|
+
if (profileData.mainAddress) {
|
|
49
|
+
setTextForElements(
|
|
50
|
+
['#LocationText', '#LocationText2', '#LocationText3'],
|
|
51
|
+
profileData.mainAddress
|
|
52
|
+
);
|
|
53
|
+
} else {
|
|
54
|
+
collapseElements(['#locationContainer', '#location1Container', '#locationContainer2']);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
setupAdditionalAddresses();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function setupAdditionalAddresses() {
|
|
61
|
+
_$w('#moreAdressesRepeater').data = profileData.processedAddresses;
|
|
62
|
+
|
|
63
|
+
if (profileData.processedAddresses.length > 0) {
|
|
64
|
+
_$w('#moreLocationButton').expand();
|
|
65
|
+
_$w('#addressTitle').collapse();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
_$w('#moreAdressesRepeater').onItemReady(($item, itemData) => {
|
|
69
|
+
console.log('Item Data:', itemData);
|
|
70
|
+
$item('#adressText').text = itemData.address || '';
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function setupAddressToggle() {
|
|
75
|
+
toggleContainer('#moreLocationButton', '#addressContainer');
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function toggleContainer(buttonId, containerId) {
|
|
79
|
+
const $button = _$w(buttonId);
|
|
80
|
+
const $container = _$w(containerId);
|
|
81
|
+
|
|
82
|
+
$button.onClick(() => {
|
|
83
|
+
const isCollapsed = $container.collapsed;
|
|
84
|
+
$container[isCollapsed ? 'expand' : 'collapse']();
|
|
85
|
+
$button.label = isCollapsed ? 'Less Locations -' : 'More Locations +';
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function bindMemberInfo() {
|
|
90
|
+
bindMemberSince();
|
|
91
|
+
bindStudentBadge();
|
|
92
|
+
bindProfileImages();
|
|
93
|
+
bindFullName();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function bindMemberSince() {
|
|
97
|
+
if (profileData.memberSince) {
|
|
98
|
+
_$w('#sinceYearText').text = profileData.memberSince;
|
|
99
|
+
} else {
|
|
100
|
+
_$w('#memberSinceBox').collapse();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function bindStudentBadge() {
|
|
105
|
+
if (profileData.shouldHaveStudentBadge) {
|
|
106
|
+
_$w('#studentContainer, #studentContainerMobile').expand();
|
|
107
|
+
} else {
|
|
108
|
+
_$w('#studentContainer, #studentContainerMobile').collapse();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function bindProfileImages() {
|
|
113
|
+
if (profileData.logoImage) {
|
|
114
|
+
_$w('#logoImage').src = profileData.logoImage;
|
|
115
|
+
} else {
|
|
116
|
+
_$w('#logoImage').collapse();
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (profileData.profileImage) {
|
|
120
|
+
_$w('#profileImage').src = profileData.profileImage;
|
|
121
|
+
} else {
|
|
122
|
+
_$w('#profileImage').src =
|
|
123
|
+
'https://static.wixstatic.com/media/1d7134_e052e9b1d0a543d0980650e16dd6d374~mv2.jpg';
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function bindFullName() {
|
|
128
|
+
if (profileData.fullName) {
|
|
129
|
+
setTextForElements(
|
|
130
|
+
['#fullNameText', '#fullNameText2', '#fullNameTextFoter'],
|
|
131
|
+
profileData.fullName
|
|
132
|
+
);
|
|
133
|
+
} else {
|
|
134
|
+
collapseElements(['#fullNameText', '#fullNameText2', '#fullNameTextFoter']);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Contact information binding
|
|
139
|
+
function bindContactInfo() {
|
|
140
|
+
bindContactForm();
|
|
141
|
+
bindBookingUrl();
|
|
142
|
+
bindPhoneNumber();
|
|
143
|
+
bindLicenseNumber();
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function bindContactForm() {
|
|
147
|
+
if (profileData.showContactForm) {
|
|
148
|
+
_$w('#contactButton').onClick(() => wixWindow.openLightbox('Contact Us', profileData));
|
|
149
|
+
} else {
|
|
150
|
+
_$w('#contactButton').collapse();
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function bindBookingUrl() {
|
|
155
|
+
if (profileData.bookingUrl) {
|
|
156
|
+
_$w('#bookNowButton').link = profileData.bookingUrl;
|
|
157
|
+
} else {
|
|
158
|
+
_$w('#bookNowButton').collapse();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function bindPhoneNumber() {
|
|
163
|
+
if (profileData.phone) {
|
|
164
|
+
const formattedPhoneNumber = profileData.phone.replace(/[^\d+]/g, '');
|
|
165
|
+
const getPhoneHTML = $phoneSelector =>
|
|
166
|
+
$phoneSelector.html.replace(
|
|
167
|
+
$phoneSelector.text,
|
|
168
|
+
`<a href="${`tel:${formattedPhoneNumber}`}">${profileData.phone}</a>`
|
|
169
|
+
);
|
|
170
|
+
_$w('#phoneText').html = getPhoneHTML(_$w('#phoneText'));
|
|
171
|
+
_$w('#phoneText2').html = getPhoneHTML(_$w('#phoneText2'));
|
|
172
|
+
} else {
|
|
173
|
+
collapseElements(['#phoneContainer', '#phoneContainer2']);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function bindLicenseNumber() {
|
|
178
|
+
if (profileData.licenceNo) {
|
|
179
|
+
_$w('#licenceNoText').text = profileData.licenceNo;
|
|
180
|
+
} else {
|
|
181
|
+
_$w('#licensesContainer').collapse();
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function bindBusinessInfo() {
|
|
186
|
+
bindAboutService();
|
|
187
|
+
bindBusinessName();
|
|
188
|
+
bindAreasOfPractice();
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function bindAboutService() {
|
|
192
|
+
if (profileData.aboutService) {
|
|
193
|
+
_$w('#aboutYouText').html = profileData.aboutService;
|
|
194
|
+
} else {
|
|
195
|
+
_$w('#aboutSection').collapse();
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function bindBusinessName() {
|
|
200
|
+
if (profileData.businessName) {
|
|
201
|
+
_$w('#businessName').text = profileData.businessName;
|
|
202
|
+
_$w('#businessName').expand();
|
|
203
|
+
} else {
|
|
204
|
+
_$w('#businessName').collapse();
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function bindAreasOfPractice() {
|
|
209
|
+
const areasText = formatPracticeAreasForDisplay(profileData.areasOfPractices);
|
|
210
|
+
|
|
211
|
+
if (areasText) {
|
|
212
|
+
_$w('#areaOfPracticesText').text = areasText;
|
|
213
|
+
} else {
|
|
214
|
+
_$w('#areaOfPracticesText').collapse();
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if (Array.isArray(profileData.areasOfPractices) && profileData.areasOfPractices.length > 0) {
|
|
218
|
+
populateRepeater(profileData.areasOfPractices, '#areaOfPracticesRepeater', '#practiceText');
|
|
219
|
+
} else {
|
|
220
|
+
_$w('#servicesSection').collapse();
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function bindGalleryData() {
|
|
225
|
+
if (profileData.bannerImages && profileData.bannerImages.length > 0) {
|
|
226
|
+
_$w('#bannerImage').src = profileData.bannerImages[0];
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
if (!profileData.gallery?.length) {
|
|
230
|
+
_$w('#gallerySection').collapse();
|
|
231
|
+
} else {
|
|
232
|
+
_$w('#gallery').items = profileData.gallery;
|
|
233
|
+
_$w('#gallerySection').expand();
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function bindTestimonialsData() {
|
|
238
|
+
if (!profileData.testimonials?.length) {
|
|
239
|
+
_$w('#testimonialsSection').collapse();
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// Responsive testimonials setup
|
|
244
|
+
async function setupResponsiveTestimonials() {
|
|
245
|
+
const { window } = await wixWindow.getBoundingRect();
|
|
246
|
+
testimonialsPerPage = getTestimonialsPerPage(window.width);
|
|
247
|
+
|
|
248
|
+
// Monitor window resize
|
|
249
|
+
setInterval(async () => {
|
|
250
|
+
const { window: win } = await wixWindow.getBoundingRect();
|
|
251
|
+
const newTestimonialsPerPage = getTestimonialsPerPage(win.width);
|
|
252
|
+
|
|
253
|
+
if (newTestimonialsPerPage !== testimonialsPerPage) {
|
|
254
|
+
testimonialsPerPage = newTestimonialsPerPage;
|
|
255
|
+
currentTestimonialPage = 0;
|
|
256
|
+
displayTestimonialsPage(profileData.testimonials);
|
|
257
|
+
}
|
|
258
|
+
}, 500);
|
|
259
|
+
|
|
260
|
+
setupTestimonialsIfAvailable();
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
function setupTestimonialsIfAvailable() {
|
|
264
|
+
if (profileData.testimonials.length > 0) {
|
|
265
|
+
setupTestimonialsPagination(profileData.testimonials);
|
|
266
|
+
_$w('#testimonialsSection').expand();
|
|
267
|
+
} else {
|
|
268
|
+
_$w('#testimonialsSection').collapse();
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
function getTestimonialsPerPage(width) {
|
|
273
|
+
if (width >= BREAKPOINTS.DESKTOP) return TESTIMONIALS_PER_PAGE_CONFIG.DESKTOP;
|
|
274
|
+
if (width >= BREAKPOINTS.TABLET) return TESTIMONIALS_PER_PAGE_CONFIG.TABLET;
|
|
275
|
+
return TESTIMONIALS_PER_PAGE_CONFIG.MOBILE;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function setTextForElements(elementIds, text) {
|
|
279
|
+
elementIds.forEach(id => {
|
|
280
|
+
_$w(id).text = text;
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
function collapseElements(elementIds) {
|
|
285
|
+
elementIds.forEach(id => {
|
|
286
|
+
_$w(id).collapse();
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
function populateRepeater(data, repeaterId, textElementId) {
|
|
291
|
+
const repeaterData = data.map(item => ({
|
|
292
|
+
_id: generateId(),
|
|
293
|
+
text: item.trim(),
|
|
294
|
+
}));
|
|
295
|
+
_$w(repeaterId).data = repeaterData;
|
|
296
|
+
_$w(repeaterId).onItemReady(($item, itemData) => {
|
|
297
|
+
$item(textElementId).text = itemData.text;
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// Testimonials pagination
|
|
302
|
+
function setupTestimonialsPagination(allTestimonials) {
|
|
303
|
+
currentTestimonialPage = 0;
|
|
304
|
+
|
|
305
|
+
_$w('#prevTestimonialBtn').onClick(() => {
|
|
306
|
+
if (currentTestimonialPage > 0) {
|
|
307
|
+
currentTestimonialPage--;
|
|
308
|
+
displayTestimonialsPage(allTestimonials);
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
_$w('#nextTestimonialBtn').onClick(() => {
|
|
313
|
+
const maxPage = Math.floor((allTestimonials.length - 1) / testimonialsPerPage);
|
|
314
|
+
if (currentTestimonialPage < maxPage) {
|
|
315
|
+
currentTestimonialPage++;
|
|
316
|
+
displayTestimonialsPage(allTestimonials);
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
displayTestimonialsPage(allTestimonials);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
function displayTestimonialsPage(allTestimonials) {
|
|
324
|
+
const start = currentTestimonialPage * testimonialsPerPage;
|
|
325
|
+
const end = start + testimonialsPerPage;
|
|
326
|
+
const currentBatch = allTestimonials.slice(start, end);
|
|
327
|
+
|
|
328
|
+
populateRepeater(currentBatch, '#testimonialsrepeater', '#testimonialText');
|
|
329
|
+
updateTestimonialNavigation(end, allTestimonials.length);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
function updateTestimonialNavigation(end, totalLength) {
|
|
333
|
+
_$w('#prevTestimonialBtn').hide();
|
|
334
|
+
_$w('#nextTestimonialBtn').hide();
|
|
335
|
+
|
|
336
|
+
if (currentTestimonialPage > 0) {
|
|
337
|
+
_$w('#prevTestimonialBtn').show();
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
if (end < totalLength) {
|
|
341
|
+
_$w('#nextTestimonialBtn').show();
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
module.exports = {
|
|
347
|
+
profileOnReady,
|
|
348
|
+
};
|