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
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
const { location:
|
|
2
|
-
const {
|
|
3
|
-
const { window: wixWindowModule } = require('@wix/site-window');
|
|
1
|
+
const { location: wixLocation } = require('@wix/site-location');
|
|
2
|
+
const { window: wixWindow } = require('@wix/site-window');
|
|
4
3
|
const _ = require('lodash');
|
|
5
4
|
|
|
6
5
|
const {
|
|
6
|
+
ABMP_MEMBERS_HOME_URL,
|
|
7
7
|
ADDRESS_STATUS_TYPES,
|
|
8
8
|
DEFAULT_BUSINESS_NAME_TEXT,
|
|
9
9
|
FREE_WEBSITE_TEXT_STATES,
|
|
10
10
|
LIGHTBOX_NAMES,
|
|
11
|
-
ABMP_MEMBERS_HOME_URL,
|
|
12
11
|
} = require('../public/consts');
|
|
13
|
-
const { handleOnCustomValidation, isNotValidUrl } = require('../public/Utils/
|
|
12
|
+
const { handleOnCustomValidation, isNotValidUrl } = require('../public/Utils/profilePageUtils');
|
|
14
13
|
const { generateId } = require('../public/Utils/sharedUtils');
|
|
15
14
|
|
|
16
15
|
const MAX_PHONES_COUNT = 10;
|
|
@@ -37,37 +36,25 @@ const MAIN_STATE_BOX_STATES = {
|
|
|
37
36
|
ERROR_STATE: 'errorState',
|
|
38
37
|
};
|
|
39
38
|
|
|
39
|
+
const FALLBACK_ADDRESS_STATUS = ADDRESS_STATUS_TYPES.STATE_CITY_ZIP;
|
|
40
|
+
|
|
40
41
|
const FORM_SECTION_HANDLER_MAP = {
|
|
41
|
-
PERSONAL: { section: 'personal', handler: null }, // will be set in init
|
|
42
|
+
PERSONAL: { section: 'personal', handler: null }, // handler will be set in init
|
|
42
43
|
BUSINESS_SERVICES: { section: 'businessServices', handler: null },
|
|
43
44
|
CONTACT_BOOKING: { section: 'contactBooking', handler: null },
|
|
44
45
|
DIRECTORY_OPT_OUT: { section: 'directoryOptOut', handler: null },
|
|
45
46
|
WEBSITE_OPT_OUT: { section: 'websiteOptOut', handler: null },
|
|
46
47
|
};
|
|
47
48
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const SLUG_MESSAGES = {
|
|
54
|
-
INVALID_FORMAT: 'Enter a valid URL. You can use letters, numbers or dashes.',
|
|
55
|
-
TAKEN: 'Enter a new URL slug. This one is already taken.',
|
|
56
|
-
ERROR: 'There was an error. Please try again.',
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
async function personalDetailsFormOnReady({
|
|
60
|
-
$w,
|
|
49
|
+
async function personalDetailsOnReady({
|
|
50
|
+
$w: _$w,
|
|
51
|
+
memberTokenId,
|
|
52
|
+
baseUrl,
|
|
61
53
|
getInterestAll,
|
|
62
54
|
saveRegistrationData,
|
|
63
55
|
validateMemberToken,
|
|
64
56
|
checkUrlUniqueness,
|
|
65
|
-
query = {}, // Query params passed from host page
|
|
66
57
|
}) {
|
|
67
|
-
// Initialize Wix SDK modules
|
|
68
|
-
const wixStorage = wixStorageModule();
|
|
69
|
-
const wixWindow = wixWindowModule();
|
|
70
|
-
|
|
71
58
|
let itemMemberObj = {};
|
|
72
59
|
let originalMemberData = {};
|
|
73
60
|
let selectedServices = [];
|
|
@@ -77,8 +64,6 @@ async function personalDetailsFormOnReady({
|
|
|
77
64
|
bannerImage: '',
|
|
78
65
|
};
|
|
79
66
|
|
|
80
|
-
const FALLBACK_ADDRESS_STATUS = ADDRESS_STATUS_TYPES.STATE_CITY_ZIP;
|
|
81
|
-
|
|
82
67
|
const formHasUnsavedChanges = {
|
|
83
68
|
[FORM_SECTION_HANDLER_MAP.PERSONAL.section]: false,
|
|
84
69
|
[FORM_SECTION_HANDLER_MAP.BUSINESS_SERVICES.section]: false,
|
|
@@ -90,33 +75,43 @@ async function personalDetailsFormOnReady({
|
|
|
90
75
|
const slugValidationTimeout = {};
|
|
91
76
|
let isSlugValid = true;
|
|
92
77
|
let currentSlugValidationId = 0;
|
|
93
|
-
let memberData, isValid, isStudent;
|
|
94
78
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
79
|
+
const SLUG_FLAGS = {
|
|
80
|
+
VALID: '#validSlugFlag',
|
|
81
|
+
INVALID: '#invalidSlugFlag',
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const SLUG_MESSAGES = {
|
|
85
|
+
INVALID_FORMAT: 'Enter a valid URL. You can use letters, numbers or dashes.',
|
|
86
|
+
TAKEN: 'Enter a new URL slug. This one is already taken.',
|
|
87
|
+
ERROR: 'There was an error. Please try again.',
|
|
102
88
|
};
|
|
103
89
|
|
|
90
|
+
// Set up handler functions with access to closures
|
|
91
|
+
FORM_SECTION_HANDLER_MAP.PERSONAL.handler = () => checkPersonalDataChanged();
|
|
92
|
+
FORM_SECTION_HANDLER_MAP.BUSINESS_SERVICES.handler = () => checkBusinessDataChanged();
|
|
93
|
+
FORM_SECTION_HANDLER_MAP.CONTACT_BOOKING.handler = () => checkContactDataChanged();
|
|
94
|
+
FORM_SECTION_HANDLER_MAP.DIRECTORY_OPT_OUT.handler = () => checkDirectoryOptOutDataChanged();
|
|
95
|
+
FORM_SECTION_HANDLER_MAP.WEBSITE_OPT_OUT.handler = () => checkWebsiteOptOutDataChanged();
|
|
96
|
+
|
|
104
97
|
const showUnauthorizedState = () => {
|
|
105
98
|
console.log('❌ Unauthorized');
|
|
106
|
-
$w('#mainMultiStateBox').changeState(MAIN_STATE_BOX_STATES.UNAUTHORIZED_STATE);
|
|
99
|
+
_$w('#mainMultiStateBox').changeState(MAIN_STATE_BOX_STATES.UNAUTHORIZED_STATE);
|
|
107
100
|
};
|
|
108
101
|
|
|
102
|
+
let memberData, isValid, isStudent;
|
|
103
|
+
|
|
109
104
|
// Main initialization
|
|
110
|
-
console.log('query', query);
|
|
111
|
-
const memberTokenId = query.token;
|
|
112
105
|
console.log('memberTokenId', memberTokenId);
|
|
106
|
+
|
|
113
107
|
if (!memberTokenId) {
|
|
114
108
|
showUnauthorizedState();
|
|
115
109
|
return;
|
|
116
110
|
}
|
|
111
|
+
|
|
117
112
|
try {
|
|
118
113
|
const {
|
|
119
|
-
memberData: { isStudent: _isStudent, ...memberDataResponse },
|
|
114
|
+
memberData: { isStudent: _isStudent, ...memberDataResponse },
|
|
120
115
|
isValid: isValidResponse,
|
|
121
116
|
} = await validateMemberToken(memberTokenId);
|
|
122
117
|
memberData = memberDataResponse;
|
|
@@ -124,9 +119,10 @@ async function personalDetailsFormOnReady({
|
|
|
124
119
|
isStudent = _isStudent;
|
|
125
120
|
} catch (error) {
|
|
126
121
|
console.error(`Error in validateMemberToken memberTokenId : ${memberTokenId}`, error);
|
|
127
|
-
$w('#mainMultiStateBox').changeState(MAIN_STATE_BOX_STATES.ERROR_STATE);
|
|
122
|
+
_$w('#mainMultiStateBox').changeState(MAIN_STATE_BOX_STATES.ERROR_STATE);
|
|
128
123
|
return;
|
|
129
124
|
}
|
|
125
|
+
|
|
130
126
|
console.log('memberData frontend', memberData);
|
|
131
127
|
if (!isValid) {
|
|
132
128
|
showUnauthorizedState();
|
|
@@ -134,16 +130,16 @@ async function personalDetailsFormOnReady({
|
|
|
134
130
|
}
|
|
135
131
|
|
|
136
132
|
console.log('✅ Authorized 2', { memberTokenId });
|
|
137
|
-
$w('#loginButton2').hide();
|
|
138
|
-
$w('#goBackButton').show();
|
|
133
|
+
_$w('#loginButton2').hide();
|
|
134
|
+
_$w('#goBackButton').show();
|
|
139
135
|
|
|
140
|
-
$w('#goBackButton').onClick(() => {
|
|
136
|
+
_$w('#goBackButton').onClick(async () => {
|
|
141
137
|
try {
|
|
142
138
|
const isFormHasUnsavedChanges = Object.values(formHasUnsavedChanges).some(Boolean);
|
|
143
139
|
if (isFormHasUnsavedChanges) {
|
|
144
140
|
wixWindow.openLightbox(LIGHTBOX_NAMES.SAVE_ALERT);
|
|
145
141
|
} else {
|
|
146
|
-
wixLocation.to(ABMP_MEMBERS_HOME_URL);
|
|
142
|
+
await wixLocation.to(ABMP_MEMBERS_HOME_URL);
|
|
147
143
|
}
|
|
148
144
|
} catch (error) {
|
|
149
145
|
console.error('Logout failed:', error);
|
|
@@ -157,15 +153,13 @@ async function personalDetailsFormOnReady({
|
|
|
157
153
|
? itemMemberObj.areasOfPractices.map(label => ({ _id: generateId(), label: String(label) }))
|
|
158
154
|
: [];
|
|
159
155
|
|
|
160
|
-
$w('#mainMultiStateBox').changeState(MAIN_STATE_BOX_STATES.FORM_STATE);
|
|
161
|
-
|
|
162
|
-
setupHandlerReferences();
|
|
156
|
+
_$w('#mainMultiStateBox').changeState(MAIN_STATE_BOX_STATES.FORM_STATE);
|
|
163
157
|
init();
|
|
164
158
|
setupStepTrackingWrapper();
|
|
165
159
|
//initially disable save buttons
|
|
166
|
-
$w('#savePersonalButton').disable();
|
|
167
|
-
$w('#saveBusinessButton').disable();
|
|
168
|
-
$w('#saveContactBookingButton').disable();
|
|
160
|
+
_$w('#savePersonalButton').disable();
|
|
161
|
+
_$w('#saveBusinessButton').disable();
|
|
162
|
+
_$w('#saveContactBookingButton').disable();
|
|
169
163
|
onFormDataChanged();
|
|
170
164
|
|
|
171
165
|
function setupStepTrackingWrapper() {
|
|
@@ -209,36 +203,37 @@ async function personalDetailsFormOnReady({
|
|
|
209
203
|
|
|
210
204
|
function setupStepTracking(stepPairs) {
|
|
211
205
|
stepPairs.forEach(({ mark, sing, step, text, css, vector }) => {
|
|
212
|
-
$w(mark).onViewportEnter(() => {
|
|
213
|
-
$w(sing).customClassList.add('current-step');
|
|
214
|
-
$w(step).customClassList.add('highlighted-text');
|
|
215
|
-
$w(text).customClassList.add('highlighted-text');
|
|
216
|
-
$w(vector).customClassList.add('disabeld-step');
|
|
217
|
-
$w('#accordion').customClassList.add(css);
|
|
218
|
-
$w(mark).scrollTo();
|
|
206
|
+
_$w(mark).onViewportEnter(() => {
|
|
207
|
+
_$w(sing).customClassList.add('current-step');
|
|
208
|
+
_$w(step).customClassList.add('highlighted-text');
|
|
209
|
+
_$w(text).customClassList.add('highlighted-text');
|
|
210
|
+
_$w(vector).customClassList.add('disabeld-step');
|
|
211
|
+
_$w('#accordion').customClassList.add(css);
|
|
212
|
+
_$w(mark).scrollTo();
|
|
219
213
|
});
|
|
220
214
|
|
|
221
|
-
$w(mark).onViewportLeave(() => {
|
|
222
|
-
$w(sing).customClassList.remove('current-step');
|
|
223
|
-
$w(step).customClassList.remove('highlighted-text');
|
|
224
|
-
$w(text).customClassList.remove('highlighted-text');
|
|
225
|
-
$w(vector).customClassList.remove('disabeld-step');
|
|
226
|
-
$w('#accordion').customClassList.remove(css);
|
|
215
|
+
_$w(mark).onViewportLeave(() => {
|
|
216
|
+
_$w(sing).customClassList.remove('current-step');
|
|
217
|
+
_$w(step).customClassList.remove('highlighted-text');
|
|
218
|
+
_$w(text).customClassList.remove('highlighted-text');
|
|
219
|
+
_$w(vector).customClassList.remove('disabeld-step');
|
|
220
|
+
_$w('#accordion').customClassList.remove(css);
|
|
227
221
|
});
|
|
228
222
|
});
|
|
229
223
|
}
|
|
230
224
|
|
|
231
225
|
function init() {
|
|
232
|
-
const fullProfilePageLink = `${
|
|
226
|
+
const fullProfilePageLink = `${baseUrl}/profile/${itemMemberObj.url}`;
|
|
233
227
|
setPersonalDetails(fullProfilePageLink);
|
|
234
228
|
setBusinessServices();
|
|
235
229
|
setContactBooking(fullProfilePageLink);
|
|
236
230
|
initGallery();
|
|
237
231
|
}
|
|
232
|
+
|
|
238
233
|
function initGallery() {
|
|
239
|
-
$w('#galleryRepeater').onItemReady(handleGalleryItem);
|
|
240
|
-
$w('#uploadGalleryImageButton').onChange(async event => {
|
|
241
|
-
const $item = $w.at(event.context);
|
|
234
|
+
_$w('#galleryRepeater').onItemReady(handleGalleryItem);
|
|
235
|
+
_$w('#uploadGalleryImageButton').onChange(async event => {
|
|
236
|
+
const $item = _$w.at(event.context);
|
|
242
237
|
const uploadButton = $item('#uploadGalleryImageButton');
|
|
243
238
|
if (uploadButton.value.length === 0) return;
|
|
244
239
|
try {
|
|
@@ -255,16 +250,16 @@ async function personalDetailsFormOnReady({
|
|
|
255
250
|
await saveGalleryToCMS();
|
|
256
251
|
setGallery();
|
|
257
252
|
} catch (error) {
|
|
258
|
-
$w('#uploadFailedText').expand();
|
|
253
|
+
_$w('#uploadFailedText').expand();
|
|
259
254
|
setTimeout(() => {
|
|
260
|
-
$w('#uploadFailedText').collapse();
|
|
255
|
+
_$w('#uploadFailedText').collapse();
|
|
261
256
|
}, 5000);
|
|
262
257
|
console.error('Upload failed:', error);
|
|
263
258
|
}
|
|
264
259
|
});
|
|
265
|
-
$w('#deleteImageButton').onClick(async event => {
|
|
260
|
+
_$w('#deleteImageButton').onClick(async event => {
|
|
266
261
|
const itemId = event.context.itemId;
|
|
267
|
-
const itemData = $w('#galleryRepeater').data.find(item => item._id === itemId);
|
|
262
|
+
const itemData = _$w('#galleryRepeater').data.find(item => item._id === itemId);
|
|
268
263
|
const result = await wixWindow.openLightbox(LIGHTBOX_NAMES.DELETE_CONFIRM);
|
|
269
264
|
if (result && result.toDelete) {
|
|
270
265
|
itemMemberObj.gallery = itemMemberObj.gallery.filter(img => img.src !== itemData.image.src);
|
|
@@ -277,35 +272,40 @@ async function personalDetailsFormOnReady({
|
|
|
277
272
|
}
|
|
278
273
|
|
|
279
274
|
function setPersonalDetails(fullProfilePageLink) {
|
|
280
|
-
$w('#firstNameInput').value = itemMemberObj.firstName || '';
|
|
281
|
-
$w('#lastNameInput').value = itemMemberObj.lastName || '';
|
|
275
|
+
_$w('#firstNameInput').value = itemMemberObj.firstName || '';
|
|
276
|
+
_$w('#lastNameInput').value = itemMemberObj.lastName || '';
|
|
277
|
+
|
|
278
|
+
_$w('#slugInput').value = itemMemberObj.url || '';
|
|
282
279
|
|
|
283
|
-
|
|
280
|
+
isSlugValid = true;
|
|
284
281
|
|
|
285
|
-
$w(SLUG_FLAGS.VALID).collapse();
|
|
286
|
-
$w(SLUG_FLAGS.INVALID).collapse();
|
|
282
|
+
_$w(SLUG_FLAGS.VALID).collapse();
|
|
283
|
+
_$w(SLUG_FLAGS.INVALID).collapse();
|
|
287
284
|
|
|
288
|
-
$w('#profileLink').text = fullProfilePageLink;
|
|
289
|
-
$w('#profileLink').link = fullProfilePageLink;
|
|
290
|
-
$w('#profileLink').target = '_blank';
|
|
291
|
-
$w('#licenceNoText').text = (itemMemberObj.licenses || [])
|
|
285
|
+
_$w('#profileLink').text = fullProfilePageLink;
|
|
286
|
+
_$w('#profileLink').link = fullProfilePageLink;
|
|
287
|
+
_$w('#profileLink').target = '_blank';
|
|
288
|
+
_$w('#licenceNoText').text = (itemMemberObj.licenses || [])
|
|
292
289
|
.map(val => val.license)
|
|
293
290
|
.filter(Boolean)
|
|
294
291
|
.join(', ');
|
|
292
|
+
|
|
295
293
|
const handleIsStudent = () => {
|
|
296
294
|
if (isStudent) {
|
|
297
|
-
$w('#optCheckbox').disable();
|
|
298
|
-
$w('#optCheckbox').checked = false;
|
|
299
|
-
$w('#optCheckbox').customClassList.add('disabled-text');
|
|
300
|
-
$w('#optCheckbox').customClassList.add('disabled-checkbox');
|
|
295
|
+
_$w('#optCheckbox').disable();
|
|
296
|
+
_$w('#optCheckbox').checked = false;
|
|
297
|
+
_$w('#optCheckbox').customClassList.add('disabled-text');
|
|
298
|
+
_$w('#optCheckbox').customClassList.add('disabled-checkbox');
|
|
301
299
|
} else {
|
|
302
|
-
$w('#optCheckbox').enable();
|
|
303
|
-
$w('#optCheckbox').checked = !itemMemberObj.optOut;
|
|
300
|
+
_$w('#optCheckbox').enable();
|
|
301
|
+
_$w('#optCheckbox').checked = !itemMemberObj.optOut;
|
|
304
302
|
}
|
|
305
303
|
};
|
|
304
|
+
|
|
306
305
|
handleIsStudent();
|
|
307
|
-
$w('#optWebsiteCheckbox').checked = itemMemberObj.showWixUrl;
|
|
306
|
+
_$w('#optWebsiteCheckbox').checked = itemMemberObj.showWixUrl;
|
|
308
307
|
toggleFreeWebsiteText(itemMemberObj.showWixUrl);
|
|
308
|
+
|
|
309
309
|
setupOptOutCheckbox(
|
|
310
310
|
'#optCheckbox',
|
|
311
311
|
'#optConfirmationBox',
|
|
@@ -336,8 +336,8 @@ async function personalDetailsFormOnReady({
|
|
|
336
336
|
cancelBtnId,
|
|
337
337
|
confirmCallback
|
|
338
338
|
) {
|
|
339
|
-
const checkbox = $w(checkboxId);
|
|
340
|
-
const box = $w(confirmationBoxId);
|
|
339
|
+
const checkbox = _$w(checkboxId);
|
|
340
|
+
const box = _$w(confirmationBoxId);
|
|
341
341
|
|
|
342
342
|
checkbox.onChange(e => {
|
|
343
343
|
if (!e.target.checked) {
|
|
@@ -356,20 +356,21 @@ async function personalDetailsFormOnReady({
|
|
|
356
356
|
checkFormChanges(sectionHandlerType);
|
|
357
357
|
});
|
|
358
358
|
|
|
359
|
-
$w(confirmBtnId).onClick(() => confirmCallback(true));
|
|
360
|
-
$w(cancelBtnId).onClick(() => confirmCallback(false));
|
|
359
|
+
_$w(confirmBtnId).onClick(() => confirmCallback(true));
|
|
360
|
+
_$w(cancelBtnId).onClick(() => confirmCallback(false));
|
|
361
361
|
}
|
|
362
362
|
|
|
363
363
|
function toggleFreeWebsiteText(isFreeWebsiteEnabled) {
|
|
364
364
|
if (isFreeWebsiteEnabled) {
|
|
365
|
-
$w('#freeWebsiteText').text = FREE_WEBSITE_TEXT_STATES.ENABLED;
|
|
365
|
+
_$w('#freeWebsiteText').text = FREE_WEBSITE_TEXT_STATES.ENABLED;
|
|
366
366
|
} else {
|
|
367
|
-
$w('#freeWebsiteText').text = FREE_WEBSITE_TEXT_STATES.DISABLED;
|
|
367
|
+
_$w('#freeWebsiteText').text = FREE_WEBSITE_TEXT_STATES.DISABLED;
|
|
368
368
|
}
|
|
369
369
|
}
|
|
370
|
+
|
|
370
371
|
async function handleOptConfirmation(confirmed, optCheckbox, optConfirmationBox, field) {
|
|
371
|
-
const checkbox = $w(optCheckbox);
|
|
372
|
-
const box = $w(optConfirmationBox);
|
|
372
|
+
const checkbox = _$w(optCheckbox);
|
|
373
|
+
const box = _$w(optConfirmationBox);
|
|
373
374
|
if (confirmed) {
|
|
374
375
|
const toSaveOptValue = optCheckbox === '#optCheckbox' ? !checkbox.checked : checkbox.checked;
|
|
375
376
|
const formData = {
|
|
@@ -379,15 +380,15 @@ async function personalDetailsFormOnReady({
|
|
|
379
380
|
|
|
380
381
|
await saveData(formData);
|
|
381
382
|
if (field === 'showWixUrl') {
|
|
382
|
-
const showExistingUrl = $w('#showExsistingUrlCheckbox').checked;
|
|
383
|
+
const showExistingUrl = _$w('#showExsistingUrlCheckbox').checked;
|
|
383
384
|
if (toSaveOptValue) {
|
|
384
385
|
if (!showExistingUrl) {
|
|
385
|
-
$w('#showUrlWixCheckbox').checked = true;
|
|
386
|
+
_$w('#showUrlWixCheckbox').checked = true;
|
|
386
387
|
}
|
|
387
|
-
$w('#showUrlWixCheckbox').enable();
|
|
388
|
+
_$w('#showUrlWixCheckbox').enable();
|
|
388
389
|
} else {
|
|
389
|
-
$w('#showUrlWixCheckbox').checked = false;
|
|
390
|
-
$w('#showUrlWixCheckbox').disable();
|
|
390
|
+
_$w('#showUrlWixCheckbox').checked = false;
|
|
391
|
+
_$w('#showUrlWixCheckbox').disable();
|
|
391
392
|
}
|
|
392
393
|
toggleFreeWebsiteText(toSaveOptValue);
|
|
393
394
|
}
|
|
@@ -413,21 +414,22 @@ async function personalDetailsFormOnReady({
|
|
|
413
414
|
ON_INPUT: 'onInput',
|
|
414
415
|
};
|
|
415
416
|
const elements = {
|
|
416
|
-
$firstNameInput: $w('#firstNameInput'),
|
|
417
|
-
$lastNameInput: $w('#lastNameInput'),
|
|
418
|
-
$businessNameCheckbox: $w('#businessNameCheckbox'),
|
|
419
|
-
$yearJoinedcheckbox: $w('#yearJoinedcheckbox'),
|
|
420
|
-
$aboutInput: $w('#aboutInput'),
|
|
421
|
-
$businessNameInput: $w('#businessNameInput'),
|
|
422
|
-
$uploadProfileButton: $w('#uploadProfileButton'),
|
|
423
|
-
$uploadLogoButton: $w('#uploadLogoButton'),
|
|
424
|
-
$uploadBannerButton: $w('#uploadBannerButton'),
|
|
425
|
-
$showContactFormCheckbox: $w('#showCotactFormCheckbox'),
|
|
426
|
-
$contactFormEmailInput: $w('#contactFormEmailInput'),
|
|
427
|
-
$schedulingLinkInput: $w('#schedulingLinkInput'),
|
|
428
|
-
$UrlInput: $w('#UrlInput'),
|
|
429
|
-
$slugInput: $w('#slugInput'),
|
|
417
|
+
$firstNameInput: _$w('#firstNameInput'),
|
|
418
|
+
$lastNameInput: _$w('#lastNameInput'),
|
|
419
|
+
$businessNameCheckbox: _$w('#businessNameCheckbox'),
|
|
420
|
+
$yearJoinedcheckbox: _$w('#yearJoinedcheckbox'),
|
|
421
|
+
$aboutInput: _$w('#aboutInput'),
|
|
422
|
+
$businessNameInput: _$w('#businessNameInput'),
|
|
423
|
+
$uploadProfileButton: _$w('#uploadProfileButton'),
|
|
424
|
+
$uploadLogoButton: _$w('#uploadLogoButton'),
|
|
425
|
+
$uploadBannerButton: _$w('#uploadBannerButton'),
|
|
426
|
+
$showContactFormCheckbox: _$w('#showCotactFormCheckbox'),
|
|
427
|
+
$contactFormEmailInput: _$w('#contactFormEmailInput'),
|
|
428
|
+
$schedulingLinkInput: _$w('#schedulingLinkInput'),
|
|
429
|
+
$UrlInput: _$w('#UrlInput'),
|
|
430
|
+
$slugInput: _$w('#slugInput'),
|
|
430
431
|
};
|
|
432
|
+
|
|
431
433
|
const formChangeEventBindings = {
|
|
432
434
|
[FORM_SECTION_HANDLER_MAP.PERSONAL.section]: [
|
|
433
435
|
{ $elem: elements.$firstNameInput, changeEvent: CHANGE_EVENTS.ON_INPUT },
|
|
@@ -450,6 +452,7 @@ async function personalDetailsFormOnReady({
|
|
|
450
452
|
{ $elem: elements.$UrlInput, changeEvent: CHANGE_EVENTS.ON_INPUT },
|
|
451
453
|
],
|
|
452
454
|
};
|
|
455
|
+
|
|
453
456
|
Object.keys(formChangeEventBindings).forEach(section => {
|
|
454
457
|
formChangeEventBindings[section].forEach(({ $elem, changeEvent }) => {
|
|
455
458
|
$elem[changeEvent](() => {
|
|
@@ -461,8 +464,8 @@ async function personalDetailsFormOnReady({
|
|
|
461
464
|
});
|
|
462
465
|
});
|
|
463
466
|
|
|
464
|
-
$w('#slugInput').onInput(event => {
|
|
465
|
-
$w('#savePersonalButton').disable();
|
|
467
|
+
_$w('#slugInput').onInput(event => {
|
|
468
|
+
_$w('#savePersonalButton').disable();
|
|
466
469
|
const slug = event.target.value;
|
|
467
470
|
|
|
468
471
|
isSlugValid = false;
|
|
@@ -509,27 +512,30 @@ async function personalDetailsFormOnReady({
|
|
|
509
512
|
if (!buttonSelector) {
|
|
510
513
|
throw new Error(`No save button defined for form section: ${formDataType}`);
|
|
511
514
|
}
|
|
512
|
-
const $saveDataButton = $w(buttonSelector);
|
|
513
|
-
|
|
514
|
-
let isUrlValid = true;
|
|
515
|
-
let isEmailValid = true;
|
|
516
|
-
let isNameValid = true;
|
|
515
|
+
const $saveDataButton = _$w(buttonSelector);
|
|
517
516
|
|
|
517
|
+
let isUrlValid = true,
|
|
518
|
+
isEmailValid = true,
|
|
519
|
+
isNameValid = true,
|
|
520
|
+
isSlugValidLocal = true;
|
|
518
521
|
if (formDataType === FORM_SECTION_HANDLER_MAP.CONTACT_BOOKING.section) {
|
|
519
|
-
isEmailValid = $w('#contactFormEmailInput').valid;
|
|
522
|
+
isEmailValid = _$w('#contactFormEmailInput').valid;
|
|
520
523
|
isUrlValid =
|
|
521
|
-
!isNotValidUrl($w('#UrlInput').value) &&
|
|
524
|
+
!isNotValidUrl(_$w('#UrlInput').value) &&
|
|
525
|
+
!isNotValidUrl(_$w('#schedulingLinkInput').value);
|
|
522
526
|
}
|
|
523
527
|
if (formDataType === FORM_SECTION_HANDLER_MAP.PERSONAL.section) {
|
|
524
|
-
isNameValid = $w('#firstNameInput').valid && $w('#lastNameInput').valid;
|
|
528
|
+
isNameValid = _$w('#firstNameInput').valid && _$w('#lastNameInput').valid;
|
|
529
|
+
isSlugValidLocal = isSlugValid;
|
|
525
530
|
}
|
|
526
531
|
|
|
527
|
-
if (isFormDataChanged && isUrlValid && isEmailValid && isNameValid &&
|
|
532
|
+
if (isFormDataChanged && isUrlValid && isEmailValid && isNameValid && isSlugValidLocal) {
|
|
528
533
|
$saveDataButton.enable();
|
|
529
534
|
} else {
|
|
530
535
|
$saveDataButton.disable();
|
|
531
536
|
}
|
|
532
537
|
};
|
|
538
|
+
|
|
533
539
|
if (formSectionHandler) {
|
|
534
540
|
const { section, handler } = formSectionHandler;
|
|
535
541
|
isFormDataChanged = handler();
|
|
@@ -549,16 +555,19 @@ async function personalDetailsFormOnReady({
|
|
|
549
555
|
});
|
|
550
556
|
}
|
|
551
557
|
}
|
|
558
|
+
|
|
552
559
|
function checkWebsiteOptOutDataChanged() {
|
|
553
|
-
const currentWebsiteOptInData = $w('#optWebsiteCheckbox').checked;
|
|
560
|
+
const currentWebsiteOptInData = _$w('#optWebsiteCheckbox').checked;
|
|
554
561
|
const originalWebsiteOptInData = originalMemberData.showWixUrl;
|
|
555
562
|
return !_.isEqual(currentWebsiteOptInData, originalWebsiteOptInData);
|
|
556
563
|
}
|
|
564
|
+
|
|
557
565
|
function checkDirectoryOptOutDataChanged() {
|
|
558
|
-
const currentDirectoryOptOutData = $w('#optCheckbox').checked;
|
|
566
|
+
const currentDirectoryOptOutData = _$w('#optCheckbox').checked;
|
|
559
567
|
const originalDirectoryOptOutData = !originalMemberData.optOut;
|
|
560
568
|
return !_.isEqual(currentDirectoryOptOutData, originalDirectoryOptOutData);
|
|
561
569
|
}
|
|
570
|
+
|
|
562
571
|
function checkBusinessDataChanged() {
|
|
563
572
|
const currentBusinessData = getBusinessAndServicesData();
|
|
564
573
|
const originalBusinessData = {
|
|
@@ -592,13 +601,13 @@ async function personalDetailsFormOnReady({
|
|
|
592
601
|
}
|
|
593
602
|
|
|
594
603
|
function setBusinessServices() {
|
|
595
|
-
$w('#businessNameText').text = itemMemberObj.businessName || DEFAULT_BUSINESS_NAME_TEXT;
|
|
596
|
-
$w('#businessNameCheckbox').checked = itemMemberObj.showBusinessName;
|
|
597
|
-
$w('#yearJoinedcheckbox').checked = itemMemberObj.showABMP;
|
|
598
|
-
$w('#aboutInput').value = itemMemberObj.aboutService;
|
|
599
|
-
$w('#businessNameInput').value = itemMemberObj.businessName;
|
|
600
|
-
$w('#clearBusinessNameBtn').onClick(() => {
|
|
601
|
-
$w('#businessNameInput').value = '';
|
|
604
|
+
_$w('#businessNameText').text = itemMemberObj.businessName || DEFAULT_BUSINESS_NAME_TEXT;
|
|
605
|
+
_$w('#businessNameCheckbox').checked = itemMemberObj.showBusinessName;
|
|
606
|
+
_$w('#yearJoinedcheckbox').checked = itemMemberObj.showABMP;
|
|
607
|
+
_$w('#aboutInput').value = itemMemberObj.aboutService;
|
|
608
|
+
_$w('#businessNameInput').value = itemMemberObj.businessName;
|
|
609
|
+
_$w('#clearBusinessNameBtn').onClick(() => {
|
|
610
|
+
_$w('#businessNameInput').value = '';
|
|
602
611
|
checkFormChanges(FORM_SECTION_HANDLER_MAP.BUSINESS_SERVICES);
|
|
603
612
|
});
|
|
604
613
|
|
|
@@ -608,9 +617,9 @@ async function personalDetailsFormOnReady({
|
|
|
608
617
|
const abmp = memberships.find(m => m.association === 'ABMP');
|
|
609
618
|
// Set yearJoinedText
|
|
610
619
|
if (abmp && abmp.membersince) {
|
|
611
|
-
$w('#yearJoinedText').text = abmp.membersince;
|
|
620
|
+
_$w('#yearJoinedText').text = abmp.membersince;
|
|
612
621
|
} else {
|
|
613
|
-
$w('#yearJoinedText').text = 'Year joined not provided';
|
|
622
|
+
_$w('#yearJoinedText').text = 'Year joined not provided';
|
|
614
623
|
}
|
|
615
624
|
|
|
616
625
|
uploadImageFromLightbox();
|
|
@@ -634,18 +643,18 @@ async function personalDetailsFormOnReady({
|
|
|
634
643
|
|
|
635
644
|
displayExistingImagesFromCMS();
|
|
636
645
|
|
|
637
|
-
$w('#savePersonalButton').onClick(savePersonalDetails);
|
|
638
|
-
$w('#saveBusinessButton').onClick(saveBusinessServices);
|
|
639
|
-
$w('#servicesRepeater').onItemReady(($item, itemData) => {
|
|
646
|
+
_$w('#savePersonalButton').onClick(savePersonalDetails);
|
|
647
|
+
_$w('#saveBusinessButton').onClick(saveBusinessServices);
|
|
648
|
+
_$w('#servicesRepeater').onItemReady(($item, itemData) => {
|
|
640
649
|
$item('#serviceNameText').text = itemData.label;
|
|
641
650
|
});
|
|
642
651
|
}
|
|
643
652
|
|
|
644
653
|
function uploadImage(uploadButton, imageKey, updateUI) {
|
|
645
|
-
$w(uploadButton).onChange(async () => {
|
|
646
|
-
if ($w(uploadButton).value?.length > 0) {
|
|
654
|
+
_$w(uploadButton).onChange(async () => {
|
|
655
|
+
if (_$w(uploadButton).value?.length > 0) {
|
|
647
656
|
try {
|
|
648
|
-
const uploadedFiles = await $w(uploadButton).uploadFiles();
|
|
657
|
+
const uploadedFiles = await _$w(uploadButton).uploadFiles();
|
|
649
658
|
uploadedFiles.forEach(file => {
|
|
650
659
|
uploadedImages[imageKey] = file.fileUrl;
|
|
651
660
|
updateUI(file);
|
|
@@ -659,7 +668,7 @@ async function personalDetailsFormOnReady({
|
|
|
659
668
|
}
|
|
660
669
|
|
|
661
670
|
function uploadImageFromLightbox() {
|
|
662
|
-
$w('#bannerLightboxButton').onClick(async () => {
|
|
671
|
+
_$w('#bannerLightboxButton').onClick(async () => {
|
|
663
672
|
const returnedImage = await wixWindow.openLightbox(LIGHTBOX_NAMES.SELECT_BANNER_IMAGES);
|
|
664
673
|
console.log('uploadedImages', returnedImage);
|
|
665
674
|
|
|
@@ -669,9 +678,9 @@ async function personalDetailsFormOnReady({
|
|
|
669
678
|
// Update stored image
|
|
670
679
|
uploadedImages.bannerImage = returnedImage.image;
|
|
671
680
|
checkFormChanges(FORM_SECTION_HANDLER_MAP.BUSINESS_SERVICES);
|
|
672
|
-
$w('#bannerImage').src = returnedImage.image;
|
|
673
|
-
$w('#bannerImageName').text = extractFileName(returnedImage.image);
|
|
674
|
-
$w('#bannerImageContainer').expand();
|
|
681
|
+
_$w('#bannerImage').src = returnedImage.image;
|
|
682
|
+
_$w('#bannerImageName').text = extractFileName(returnedImage.image);
|
|
683
|
+
_$w('#bannerImageContainer').expand();
|
|
675
684
|
}
|
|
676
685
|
});
|
|
677
686
|
}
|
|
@@ -688,21 +697,21 @@ async function personalDetailsFormOnReady({
|
|
|
688
697
|
|
|
689
698
|
function setupImageUploadAndDeleteHandlers() {
|
|
690
699
|
uploadImage('#uploadProfileButton', 'profileImage', file => {
|
|
691
|
-
$w('#profileImage').src = file.fileUrl;
|
|
692
|
-
$w('#profileImageName').text = formatFileName(file.fileName);
|
|
693
|
-
$w('#profileImageContainer').expand();
|
|
700
|
+
_$w('#profileImage').src = file.fileUrl;
|
|
701
|
+
_$w('#profileImageName').text = formatFileName(file.fileName);
|
|
702
|
+
_$w('#profileImageContainer').expand();
|
|
694
703
|
});
|
|
695
704
|
|
|
696
705
|
uploadImage('#uploadLogoButton', 'logoImage', file => {
|
|
697
|
-
$w('#logoImage').src = file.fileUrl;
|
|
698
|
-
$w('#logoImageName').text = file.fileName;
|
|
699
|
-
$w('#logoImageContainer').expand();
|
|
706
|
+
_$w('#logoImage').src = file.fileUrl;
|
|
707
|
+
_$w('#logoImageName').text = file.fileName;
|
|
708
|
+
_$w('#logoImageContainer').expand();
|
|
700
709
|
});
|
|
701
710
|
|
|
702
711
|
uploadImage('#uploadBannerButton', 'bannerImage', file => {
|
|
703
|
-
$w('#bannerImage').src = file.fileUrl;
|
|
704
|
-
$w('#bannerImageName').text = file.fileName;
|
|
705
|
-
$w('#bannerImageContainer').expand();
|
|
712
|
+
_$w('#bannerImage').src = file.fileUrl;
|
|
713
|
+
_$w('#bannerImageName').text = file.fileName;
|
|
714
|
+
_$w('#bannerImageContainer').expand();
|
|
706
715
|
});
|
|
707
716
|
|
|
708
717
|
setupDeleteHandler(
|
|
@@ -732,16 +741,16 @@ async function personalDetailsFormOnReady({
|
|
|
732
741
|
}
|
|
733
742
|
|
|
734
743
|
function setupDeleteHandler(deleteBtn, imgId, nameId, containerId, imageKey, uploadBtnId) {
|
|
735
|
-
$w(deleteBtn).onClick(async () => {
|
|
744
|
+
_$w(deleteBtn).onClick(async () => {
|
|
736
745
|
const result = await wixWindow.openLightbox(LIGHTBOX_NAMES.DELETE_CONFIRM);
|
|
737
746
|
|
|
738
747
|
if (result && result.toDelete) {
|
|
739
|
-
$w(imgId).src = '';
|
|
740
|
-
$w(nameId).text = '';
|
|
741
|
-
$w(containerId).collapse();
|
|
748
|
+
_$w(imgId).src = '';
|
|
749
|
+
_$w(nameId).text = '';
|
|
750
|
+
_$w(containerId).collapse();
|
|
742
751
|
uploadedImages[imageKey] = '';
|
|
743
752
|
checkFormChanges(FORM_SECTION_HANDLER_MAP.BUSINESS_SERVICES);
|
|
744
|
-
$w(uploadBtnId).reset();
|
|
753
|
+
_$w(uploadBtnId).reset();
|
|
745
754
|
}
|
|
746
755
|
});
|
|
747
756
|
}
|
|
@@ -777,9 +786,9 @@ async function personalDetailsFormOnReady({
|
|
|
777
786
|
: itemMemberObj[key];
|
|
778
787
|
|
|
779
788
|
if (imageValue) {
|
|
780
|
-
$w(imageSelector).src = imageValue;
|
|
781
|
-
$w(nameSelector).text = formatFileName(extractFileName(imageValue));
|
|
782
|
-
$w(containerSelector).expand();
|
|
789
|
+
_$w(imageSelector).src = imageValue;
|
|
790
|
+
_$w(nameSelector).text = formatFileName(extractFileName(imageValue));
|
|
791
|
+
_$w(containerSelector).expand();
|
|
783
792
|
uploadedImages[key === 'bannerImages' ? 'bannerImage' : key] = imageValue;
|
|
784
793
|
}
|
|
785
794
|
});
|
|
@@ -789,7 +798,7 @@ async function personalDetailsFormOnReady({
|
|
|
789
798
|
const result = await wixWindow.openLightbox(LIGHTBOX_NAMES.DELETE_CONFIRM);
|
|
790
799
|
|
|
791
800
|
if (result && result.toDelete) {
|
|
792
|
-
const $clickedItem = $w.at(event.context);
|
|
801
|
+
const $clickedItem = _$w.at(event.context);
|
|
793
802
|
const textToRemove = $clickedItem(getTextSelector).text;
|
|
794
803
|
|
|
795
804
|
arrayRef.splice(
|
|
@@ -808,7 +817,7 @@ async function personalDetailsFormOnReady({
|
|
|
808
817
|
async function setInterestData() {
|
|
809
818
|
const interestsData = await getInterestAll();
|
|
810
819
|
|
|
811
|
-
$w('#removeServiceButton').onClick(event => {
|
|
820
|
+
_$w('#removeServiceButton').onClick(event => {
|
|
812
821
|
handleItemDelete(event, '#serviceNameText', selectedServices, 'label', renderServices);
|
|
813
822
|
});
|
|
814
823
|
|
|
@@ -818,40 +827,21 @@ async function personalDetailsFormOnReady({
|
|
|
818
827
|
value: val,
|
|
819
828
|
}));
|
|
820
829
|
|
|
821
|
-
$w('#repeaterInterest').data = formattedData;
|
|
822
|
-
$w('#repeaterInterest').onItemReady(($item, itemData, _index) => {
|
|
830
|
+
_$w('#repeaterInterest').data = formattedData;
|
|
831
|
+
_$w('#repeaterInterest').onItemReady(($item, itemData, _index) => {
|
|
823
832
|
$item('#interestText').text = itemData.value;
|
|
824
833
|
});
|
|
825
834
|
}
|
|
826
835
|
}
|
|
827
836
|
|
|
828
|
-
async function filterInterests(searchValue) {
|
|
829
|
-
const container = $w('#containerRepeaterInterest');
|
|
830
|
-
const repeater = $w('#repeaterInterest');
|
|
831
|
-
|
|
832
|
-
const allInterests = await getInterestAll();
|
|
833
|
-
const filtered = allInterests
|
|
834
|
-
.filter(val => val.toLowerCase().includes(searchValue))
|
|
835
|
-
.map(val => ({ _id: generateId(), value: val }));
|
|
836
|
-
|
|
837
|
-
if (filtered.length > 0) {
|
|
838
|
-
repeater.data = filtered;
|
|
839
|
-
container.expand();
|
|
840
|
-
} else {
|
|
841
|
-
repeater.data = [];
|
|
842
|
-
container.collapse();
|
|
843
|
-
}
|
|
844
|
-
|
|
845
|
-
return filtered;
|
|
846
|
-
}
|
|
847
|
-
|
|
848
837
|
const debounce_fun = _.debounce(async () => {
|
|
849
|
-
const searchValue = $w('#intrestInput').value.trim().toLowerCase();
|
|
838
|
+
const searchValue = _$w('#intrestInput').value.trim().toLowerCase();
|
|
850
839
|
await filterInterests(searchValue);
|
|
851
840
|
}, 250);
|
|
852
841
|
|
|
853
842
|
function setupServiceSelection() {
|
|
854
|
-
const intrestInput = $w('#intrestInput');
|
|
843
|
+
const intrestInput = _$w('#intrestInput');
|
|
844
|
+
|
|
855
845
|
intrestInput.onClick(() => {
|
|
856
846
|
if (intrestInput.value) {
|
|
857
847
|
intrestInput.onClick(async () => {
|
|
@@ -860,7 +850,7 @@ async function personalDetailsFormOnReady({
|
|
|
860
850
|
} else {
|
|
861
851
|
setInterestData();
|
|
862
852
|
}
|
|
863
|
-
$w('#containerRepeaterInterest').expand();
|
|
853
|
+
_$w('#containerRepeaterInterest').expand();
|
|
864
854
|
});
|
|
865
855
|
|
|
866
856
|
intrestInput.onKeyPress(event => {
|
|
@@ -882,12 +872,12 @@ async function personalDetailsFormOnReady({
|
|
|
882
872
|
checkFormChanges(FORM_SECTION_HANDLER_MAP.BUSINESS_SERVICES);
|
|
883
873
|
renderServices();
|
|
884
874
|
intrestInput.value = '';
|
|
885
|
-
$w('#containerRepeaterInterest').collapse();
|
|
875
|
+
_$w('#containerRepeaterInterest').collapse();
|
|
886
876
|
}
|
|
887
877
|
}
|
|
888
878
|
});
|
|
889
879
|
|
|
890
|
-
$w('#repeaterInterest').onItemReady(($item, itemData) => {
|
|
880
|
+
_$w('#repeaterInterest').onItemReady(($item, itemData) => {
|
|
891
881
|
$item('#interestText').text = itemData.value;
|
|
892
882
|
|
|
893
883
|
$item('#intrestItem').onClick(() => {
|
|
@@ -898,8 +888,8 @@ async function personalDetailsFormOnReady({
|
|
|
898
888
|
});
|
|
899
889
|
checkFormChanges(FORM_SECTION_HANDLER_MAP.BUSINESS_SERVICES);
|
|
900
890
|
renderServices();
|
|
901
|
-
$w('#intrestInput').value = '';
|
|
902
|
-
$w('#containerRepeaterInterest').collapse();
|
|
891
|
+
_$w('#intrestInput').value = '';
|
|
892
|
+
_$w('#containerRepeaterInterest').collapse();
|
|
903
893
|
}
|
|
904
894
|
});
|
|
905
895
|
});
|
|
@@ -910,7 +900,7 @@ async function personalDetailsFormOnReady({
|
|
|
910
900
|
}
|
|
911
901
|
|
|
912
902
|
function setupRepeater(repeaterId, data) {
|
|
913
|
-
const repeater = $w(repeaterId);
|
|
903
|
+
const repeater = _$w(repeaterId);
|
|
914
904
|
repeater.data = data;
|
|
915
905
|
}
|
|
916
906
|
|
|
@@ -922,14 +912,12 @@ async function personalDetailsFormOnReady({
|
|
|
922
912
|
* @param {boolean} success - Whether the save was successful
|
|
923
913
|
*/
|
|
924
914
|
function logUserDataChanges(saveType, beforeData, afterData, success) {
|
|
925
|
-
const memberId = wixStorage.local.getItem('memberId');
|
|
926
915
|
const timestamp = new Date().toISOString();
|
|
927
916
|
|
|
928
917
|
console.group(
|
|
929
918
|
`User Data Change Log - ${saveType.toUpperCase()} - ${success ? 'SUCCESS' : 'FAILED'}`
|
|
930
919
|
);
|
|
931
920
|
console.log('Change Details:', {
|
|
932
|
-
memberId,
|
|
933
921
|
timestamp,
|
|
934
922
|
saveType,
|
|
935
923
|
success,
|
|
@@ -959,12 +947,10 @@ async function personalDetailsFormOnReady({
|
|
|
959
947
|
}
|
|
960
948
|
|
|
961
949
|
async function saveData(formData) {
|
|
962
|
-
const memberId = wixStorage.local.getItem('memberId');
|
|
963
|
-
|
|
964
950
|
// Capture data before save for logging
|
|
965
951
|
const beforeSaveData = JSON.parse(JSON.stringify(itemMemberObj));
|
|
966
952
|
|
|
967
|
-
const { type, saveData: saved } = await saveRegistrationData(formData, memberId);
|
|
953
|
+
const { type, saveData: saved } = await saveRegistrationData(formData, itemMemberObj.memberId);
|
|
968
954
|
|
|
969
955
|
if (type === 'success') {
|
|
970
956
|
// Log the successful change
|
|
@@ -997,20 +983,20 @@ async function personalDetailsFormOnReady({
|
|
|
997
983
|
}
|
|
998
984
|
|
|
999
985
|
async function validateSlugRealTime(slug) {
|
|
1000
|
-
$w(SLUG_FLAGS.VALID).collapse();
|
|
1001
|
-
$w(SLUG_FLAGS.INVALID).collapse();
|
|
986
|
+
_$w(SLUG_FLAGS.VALID).collapse();
|
|
987
|
+
_$w(SLUG_FLAGS.INVALID).collapse();
|
|
1002
988
|
|
|
1003
989
|
const trimmedSlug = slug.trim();
|
|
1004
990
|
|
|
1005
991
|
if (!isValidSlugFormat(trimmedSlug)) {
|
|
1006
|
-
$w('#invalidSlugMessage').text = SLUG_MESSAGES.INVALID_FORMAT;
|
|
1007
|
-
$w(SLUG_FLAGS.INVALID).expand();
|
|
992
|
+
_$w('#invalidSlugMessage').text = SLUG_MESSAGES.INVALID_FORMAT;
|
|
993
|
+
_$w(SLUG_FLAGS.INVALID).expand();
|
|
1008
994
|
return { isValid: false };
|
|
1009
995
|
}
|
|
1010
996
|
|
|
1011
997
|
if (trimmedSlug === (originalMemberData.url || '')) {
|
|
1012
|
-
$w(SLUG_FLAGS.VALID).collapse();
|
|
1013
|
-
$w(SLUG_FLAGS.INVALID).collapse();
|
|
998
|
+
_$w(SLUG_FLAGS.VALID).collapse();
|
|
999
|
+
_$w(SLUG_FLAGS.INVALID).collapse();
|
|
1014
1000
|
return { isValid: true };
|
|
1015
1001
|
}
|
|
1016
1002
|
|
|
@@ -1019,29 +1005,29 @@ async function personalDetailsFormOnReady({
|
|
|
1019
1005
|
const isUnique = result.isUnique;
|
|
1020
1006
|
|
|
1021
1007
|
if (isUnique) {
|
|
1022
|
-
$w(SLUG_FLAGS.VALID).expand();
|
|
1023
|
-
$w(SLUG_FLAGS.INVALID).collapse();
|
|
1008
|
+
_$w(SLUG_FLAGS.VALID).expand();
|
|
1009
|
+
_$w(SLUG_FLAGS.INVALID).collapse();
|
|
1024
1010
|
return { isValid: true };
|
|
1025
1011
|
} else {
|
|
1026
|
-
$w('#invalidSlugMessage').text = SLUG_MESSAGES.TAKEN;
|
|
1027
|
-
$w(SLUG_FLAGS.INVALID).expand();
|
|
1028
|
-
$w(SLUG_FLAGS.VALID).collapse();
|
|
1012
|
+
_$w('#invalidSlugMessage').text = SLUG_MESSAGES.TAKEN;
|
|
1013
|
+
_$w(SLUG_FLAGS.INVALID).expand();
|
|
1014
|
+
_$w(SLUG_FLAGS.VALID).collapse();
|
|
1029
1015
|
return { isValid: false };
|
|
1030
1016
|
}
|
|
1031
1017
|
} catch (error) {
|
|
1032
1018
|
console.error('Error checking slug uniqueness:', error);
|
|
1033
|
-
$w('#invalidSlugMessage').text = SLUG_MESSAGES.ERROR;
|
|
1034
|
-
$w(SLUG_FLAGS.INVALID).expand();
|
|
1035
|
-
$w(SLUG_FLAGS.VALID).collapse();
|
|
1019
|
+
_$w('#invalidSlugMessage').text = SLUG_MESSAGES.ERROR;
|
|
1020
|
+
_$w(SLUG_FLAGS.INVALID).expand();
|
|
1021
|
+
_$w(SLUG_FLAGS.VALID).collapse();
|
|
1036
1022
|
return { isValid: false };
|
|
1037
1023
|
}
|
|
1038
1024
|
}
|
|
1039
1025
|
|
|
1040
1026
|
function getPersonalData() {
|
|
1041
|
-
const firstName = $w('#firstNameInput').value.trim();
|
|
1042
|
-
const lastName = $w('#lastNameInput').value.trim();
|
|
1027
|
+
const firstName = _$w('#firstNameInput').value.trim();
|
|
1028
|
+
const lastName = _$w('#lastNameInput').value.trim();
|
|
1043
1029
|
const fullName = `${firstName} ${lastName}`.trim();
|
|
1044
|
-
const url = $w('#slugInput').value.trim();
|
|
1030
|
+
const url = _$w('#slugInput').value.trim();
|
|
1045
1031
|
|
|
1046
1032
|
return {
|
|
1047
1033
|
firstName,
|
|
@@ -1064,23 +1050,24 @@ async function personalDetailsFormOnReady({
|
|
|
1064
1050
|
|
|
1065
1051
|
function getBusinessAndServicesData() {
|
|
1066
1052
|
const getCurrentTestimonials = () =>
|
|
1067
|
-
$w('#testimonialRepeater')
|
|
1053
|
+
_$w('#testimonialRepeater')
|
|
1068
1054
|
.data.filter(item => item.isAdd === false)
|
|
1069
1055
|
.map(item => item.text)
|
|
1070
1056
|
.filter(Boolean) || itemMemberObj.testimonial;
|
|
1071
1057
|
|
|
1072
1058
|
return {
|
|
1073
|
-
showBusinessName: $w('#businessNameCheckbox').checked,
|
|
1074
|
-
businessName: $w('#businessNameInput').value,
|
|
1075
|
-
showABMP: $w('#yearJoinedcheckbox').checked,
|
|
1059
|
+
showBusinessName: _$w('#businessNameCheckbox').checked,
|
|
1060
|
+
businessName: _$w('#businessNameInput').value,
|
|
1061
|
+
showABMP: _$w('#yearJoinedcheckbox').checked,
|
|
1076
1062
|
profileImage: uploadedImages.profileImage,
|
|
1077
1063
|
logoImage: uploadedImages.logoImage,
|
|
1078
1064
|
bannerImages: uploadedImages.bannerImage ? [uploadedImages.bannerImage] : [],
|
|
1079
1065
|
areasOfPractices: selectedServices.map(service => service.label),
|
|
1080
|
-
aboutService: $w('#aboutInput').value,
|
|
1066
|
+
aboutService: _$w('#aboutInput').value,
|
|
1081
1067
|
testimonial: getCurrentTestimonials(),
|
|
1082
1068
|
};
|
|
1083
1069
|
}
|
|
1070
|
+
|
|
1084
1071
|
async function savePersonalDetails() {
|
|
1085
1072
|
const beforeData = JSON.parse(JSON.stringify(itemMemberObj));
|
|
1086
1073
|
const personalChanges = getPersonalData();
|
|
@@ -1103,23 +1090,23 @@ async function personalDetailsFormOnReady({
|
|
|
1103
1090
|
|
|
1104
1091
|
if (result.success) {
|
|
1105
1092
|
if (personalChanges.url && personalChanges.url !== originalUrl) {
|
|
1106
|
-
const newProfileLink = `${
|
|
1093
|
+
const newProfileLink = `${baseUrl}/profile/${personalChanges.url}`;
|
|
1107
1094
|
console.log('🔗 Updating profile link:', {
|
|
1108
1095
|
originalUrl,
|
|
1109
1096
|
newUrl: personalChanges.url,
|
|
1110
1097
|
newProfileLink,
|
|
1111
1098
|
});
|
|
1112
|
-
$w('#profileLink').text = newProfileLink;
|
|
1113
|
-
$w('#profileLink').link = newProfileLink;
|
|
1099
|
+
_$w('#profileLink').text = newProfileLink;
|
|
1100
|
+
_$w('#profileLink').link = newProfileLink;
|
|
1114
1101
|
|
|
1115
|
-
$w(SLUG_FLAGS.VALID).collapse();
|
|
1116
|
-
$w(SLUG_FLAGS.INVALID).collapse();
|
|
1102
|
+
_$w(SLUG_FLAGS.VALID).collapse();
|
|
1103
|
+
_$w(SLUG_FLAGS.INVALID).collapse();
|
|
1117
1104
|
}
|
|
1118
1105
|
|
|
1119
|
-
$w('#savePersonalButton').disable();
|
|
1106
|
+
_$w('#savePersonalButton').disable();
|
|
1120
1107
|
}
|
|
1121
1108
|
|
|
1122
|
-
handleSaveDataFeedback($w('#personalMessage'), result.message);
|
|
1109
|
+
handleSaveDataFeedback(_$w('#personalMessage'), result.message);
|
|
1123
1110
|
}
|
|
1124
1111
|
|
|
1125
1112
|
async function saveBusinessServices() {
|
|
@@ -1146,15 +1133,15 @@ async function personalDetailsFormOnReady({
|
|
|
1146
1133
|
|
|
1147
1134
|
const result = await saveData(formData);
|
|
1148
1135
|
formHasUnsavedChanges[FORM_SECTION_HANDLER_MAP.BUSINESS_SERVICES.section] = false;
|
|
1149
|
-
handleSaveDataFeedback($w('#businessMessage'), result.message);
|
|
1150
|
-
$w('#businessNameText').text = formData.businessName || DEFAULT_BUSINESS_NAME_TEXT;
|
|
1136
|
+
handleSaveDataFeedback(_$w('#businessMessage'), result.message);
|
|
1137
|
+
_$w('#businessNameText').text = formData.businessName || DEFAULT_BUSINESS_NAME_TEXT;
|
|
1151
1138
|
}
|
|
1152
1139
|
|
|
1153
1140
|
function setupTestimonials() {
|
|
1154
|
-
const addTestimonialButton = $w('#addTestimonialButton');
|
|
1141
|
+
const addTestimonialButton = _$w('#addTestimonialButton');
|
|
1155
1142
|
|
|
1156
1143
|
addTestimonialButton.onClick(handleAddTestimonial);
|
|
1157
|
-
$w('#deleteTestimonialButton').onClick(event => {
|
|
1144
|
+
_$w('#deleteTestimonialButton').onClick(event => {
|
|
1158
1145
|
handleItemDelete(
|
|
1159
1146
|
event,
|
|
1160
1147
|
'#testimonialText',
|
|
@@ -1165,7 +1152,7 @@ async function personalDetailsFormOnReady({
|
|
|
1165
1152
|
});
|
|
1166
1153
|
|
|
1167
1154
|
renderTestimonials();
|
|
1168
|
-
$w('#testimonialRepeater').onItemReady(($item, itemData) => {
|
|
1155
|
+
_$w('#testimonialRepeater').onItemReady(($item, itemData) => {
|
|
1169
1156
|
const msb = $item('#testimonialMSB');
|
|
1170
1157
|
if (itemData.isAdd) {
|
|
1171
1158
|
msb.changeState(TESTIMONIAL_STATES.ADD);
|
|
@@ -1193,7 +1180,7 @@ async function personalDetailsFormOnReady({
|
|
|
1193
1180
|
}
|
|
1194
1181
|
|
|
1195
1182
|
function handleAddTestimonial(event) {
|
|
1196
|
-
const $clickedItem = $w.at(event.context);
|
|
1183
|
+
const $clickedItem = _$w.at(event.context);
|
|
1197
1184
|
const input = $clickedItem('#testimonialsInput');
|
|
1198
1185
|
const newText = input.value;
|
|
1199
1186
|
|
|
@@ -1215,70 +1202,68 @@ async function personalDetailsFormOnReady({
|
|
|
1215
1202
|
const showExistingUrlCheckbox = itemMemberObj.showWebsite;
|
|
1216
1203
|
|
|
1217
1204
|
// basic fields
|
|
1218
|
-
$w('#showCotactFormCheckbox').checked = itemMemberObj.showContactForm;
|
|
1219
|
-
$w('#contactFormEmailInput').value = itemMemberObj.contactFormEmail;
|
|
1220
|
-
$w('#schedulingLinkInput').value = itemMemberObj.bookingUrl;
|
|
1205
|
+
_$w('#showCotactFormCheckbox').checked = itemMemberObj.showContactForm;
|
|
1206
|
+
_$w('#contactFormEmailInput').value = itemMemberObj.contactFormEmail;
|
|
1207
|
+
_$w('#schedulingLinkInput').value = itemMemberObj.bookingUrl;
|
|
1221
1208
|
|
|
1222
1209
|
// URL part
|
|
1223
|
-
$w('#UrlInput').value = itemMemberObj.website || '';
|
|
1224
|
-
$w('#showUrlWixCheckbox').checked = showWixUrlCheckbox;
|
|
1225
|
-
$w('#showExsistingUrlCheckbox').checked = showExistingUrlCheckbox;
|
|
1226
|
-
$w('#urlWebsiteText').text = fullProfilePageLink;
|
|
1210
|
+
_$w('#UrlInput').value = itemMemberObj.website || '';
|
|
1211
|
+
_$w('#showUrlWixCheckbox').checked = showWixUrlCheckbox;
|
|
1212
|
+
_$w('#showExsistingUrlCheckbox').checked = showExistingUrlCheckbox;
|
|
1213
|
+
_$w('#urlWebsiteText').text = fullProfilePageLink;
|
|
1227
1214
|
|
|
1228
1215
|
// custom validation for url inputs and email
|
|
1229
|
-
handleOnCustomValidation($w('#UrlInput'));
|
|
1230
|
-
handleOnCustomValidation($w('#schedulingLinkInput'));
|
|
1216
|
+
handleOnCustomValidation(_$w('#UrlInput'));
|
|
1217
|
+
handleOnCustomValidation(_$w('#schedulingLinkInput'));
|
|
1231
1218
|
|
|
1232
1219
|
// enable/disable & styling in one pass
|
|
1233
1220
|
if (showWixUrlCheckbox) {
|
|
1234
|
-
$w('#UrlInput').disable();
|
|
1235
|
-
$w('#urlWebsiteText').customClassList.add('highlighted-text');
|
|
1221
|
+
_$w('#UrlInput').disable();
|
|
1222
|
+
_$w('#urlWebsiteText').customClassList.add('highlighted-text');
|
|
1236
1223
|
} else if (showExistingUrlCheckbox) {
|
|
1237
|
-
$w('#UrlInput').enable();
|
|
1238
|
-
$w('#urlWebsiteText').customClassList.remove('highlighted-text');
|
|
1224
|
+
_$w('#UrlInput').enable();
|
|
1225
|
+
_$w('#urlWebsiteText').customClassList.remove('highlighted-text');
|
|
1239
1226
|
} else {
|
|
1240
1227
|
// neither checked: disable input & remove highlight
|
|
1241
|
-
$w('#UrlInput').disable();
|
|
1242
|
-
$w('#urlWebsiteText').customClassList.remove('highlighted-text');
|
|
1228
|
+
_$w('#UrlInput').disable();
|
|
1229
|
+
_$w('#urlWebsiteText').customClassList.remove('highlighted-text');
|
|
1243
1230
|
}
|
|
1244
1231
|
|
|
1245
1232
|
// clear buttons
|
|
1246
|
-
$w('#clearSchedulingLinkInput').onClick(() => {
|
|
1247
|
-
$w('#schedulingLinkInput').value = '';
|
|
1233
|
+
_$w('#clearSchedulingLinkInput').onClick(() => {
|
|
1234
|
+
_$w('#schedulingLinkInput').value = '';
|
|
1248
1235
|
checkFormChanges(FORM_SECTION_HANDLER_MAP.CONTACT_BOOKING);
|
|
1249
1236
|
});
|
|
1250
|
-
$w('#clearExistingUrlLinkInput').onClick(() => {
|
|
1251
|
-
$w('#UrlInput').value = '';
|
|
1237
|
+
_$w('#clearExistingUrlLinkInput').onClick(() => {
|
|
1238
|
+
_$w('#UrlInput').value = '';
|
|
1252
1239
|
checkFormChanges(FORM_SECTION_HANDLER_MAP.CONTACT_BOOKING);
|
|
1253
1240
|
});
|
|
1254
1241
|
|
|
1255
1242
|
// toggle handlers
|
|
1256
|
-
$w('#showUrlWixCheckbox').onChange(e => {
|
|
1243
|
+
_$w('#showUrlWixCheckbox').onChange(e => {
|
|
1257
1244
|
if (e.target.checked) {
|
|
1258
|
-
$w('#showExsistingUrlCheckbox').checked = false;
|
|
1259
|
-
$w('#UrlInput').disable();
|
|
1260
|
-
$w('#urlWebsiteText').customClassList.add('highlighted-text');
|
|
1245
|
+
_$w('#showExsistingUrlCheckbox').checked = false;
|
|
1246
|
+
_$w('#UrlInput').disable();
|
|
1247
|
+
_$w('#urlWebsiteText').customClassList.add('highlighted-text');
|
|
1261
1248
|
}
|
|
1262
1249
|
checkFormChanges(FORM_SECTION_HANDLER_MAP.CONTACT_BOOKING);
|
|
1263
1250
|
});
|
|
1264
|
-
$w('#showExsistingUrlCheckbox').onChange(e => {
|
|
1251
|
+
_$w('#showExsistingUrlCheckbox').onChange(e => {
|
|
1265
1252
|
if (e.target.checked) {
|
|
1266
|
-
$w('#showUrlWixCheckbox').checked = false;
|
|
1267
|
-
$w('#UrlInput').enable();
|
|
1268
|
-
$w('#urlWebsiteText').customClassList.remove('highlighted-text');
|
|
1253
|
+
_$w('#showUrlWixCheckbox').checked = false;
|
|
1254
|
+
_$w('#UrlInput').enable();
|
|
1255
|
+
_$w('#urlWebsiteText').customClassList.remove('highlighted-text');
|
|
1269
1256
|
}
|
|
1270
1257
|
checkFormChanges(FORM_SECTION_HANDLER_MAP.CONTACT_BOOKING);
|
|
1271
1258
|
});
|
|
1272
1259
|
|
|
1273
1260
|
setupAddressRepeater();
|
|
1274
1261
|
setupPhoneRepeater();
|
|
1275
|
-
$w('#saveContactBookingButton').onClick(saveContactBooking);
|
|
1262
|
+
_$w('#saveContactBookingButton').onClick(saveContactBooking);
|
|
1276
1263
|
}
|
|
1277
1264
|
|
|
1278
1265
|
/**
|
|
1279
1266
|
* Converts our internal address format to AddressInput component format
|
|
1280
|
-
* @param {Object} address - Our internal address object with line1, city, state, postalcode, latitude, longitude
|
|
1281
|
-
* @returns {Object} AddressInput compatible object
|
|
1282
1267
|
*/
|
|
1283
1268
|
function convertToAddressInputFormat(address) {
|
|
1284
1269
|
if (!address) return null;
|
|
@@ -1310,9 +1295,6 @@ async function personalDetailsFormOnReady({
|
|
|
1310
1295
|
|
|
1311
1296
|
/**
|
|
1312
1297
|
* Converts AddressInput format back to our internal address format
|
|
1313
|
-
* @param {Object} addressInputValue - AddressInput value object
|
|
1314
|
-
* @param {Object} existingAddress - Existing address data to preserve key and other fields
|
|
1315
|
-
* @returns {Object} Our internal address format
|
|
1316
1298
|
*/
|
|
1317
1299
|
function parseAddressInput(addressInputValue, existingAddress = null) {
|
|
1318
1300
|
if (!addressInputValue) return null;
|
|
@@ -1343,23 +1325,23 @@ async function personalDetailsFormOnReady({
|
|
|
1343
1325
|
}
|
|
1344
1326
|
|
|
1345
1327
|
function setupAddressRepeater() {
|
|
1346
|
-
$w('#addressesList').onItemReady(($item, itemData,
|
|
1347
|
-
handleAddressItem($item, itemData,
|
|
1328
|
+
_$w('#addressesList').onItemReady(($item, itemData, index) =>
|
|
1329
|
+
handleAddressItem($item, itemData, index)
|
|
1348
1330
|
);
|
|
1349
1331
|
renderAddressesList();
|
|
1350
1332
|
|
|
1351
|
-
$w('#newAddressButton').onClick(addNewAddress);
|
|
1333
|
+
_$w('#newAddressButton').onClick(addNewAddress);
|
|
1352
1334
|
|
|
1353
1335
|
setupAddressRepeaterEventListeners();
|
|
1354
1336
|
}
|
|
1355
1337
|
|
|
1356
1338
|
function setupAddressRepeaterEventListeners() {
|
|
1357
|
-
$w('#mainAddressCheckbox').onChange(event => {
|
|
1358
|
-
const data = $w('#addressesList').data;
|
|
1339
|
+
_$w('#mainAddressCheckbox').onChange(event => {
|
|
1340
|
+
const data = _$w('#addressesList').data;
|
|
1359
1341
|
const clickedItemData = data.find(item => item._id === event.context.itemId);
|
|
1360
|
-
const $item = $w.at(event.context);
|
|
1342
|
+
const $item = _$w.at(event.context);
|
|
1361
1343
|
|
|
1362
|
-
$w('#mainAddressCheckbox').checked = false;
|
|
1344
|
+
_$w('#mainAddressCheckbox').checked = false;
|
|
1363
1345
|
$item('#mainAddressCheckbox').checked = true;
|
|
1364
1346
|
|
|
1365
1347
|
if (clickedItemData.address.addressStatus === ADDRESS_STATUS_TYPES.DONT_SHOW) {
|
|
@@ -1371,11 +1353,11 @@ async function personalDetailsFormOnReady({
|
|
|
1371
1353
|
checkFormChanges(FORM_SECTION_HANDLER_MAP.CONTACT_BOOKING);
|
|
1372
1354
|
});
|
|
1373
1355
|
|
|
1374
|
-
$w('#addressStatusOptions').onChange(event => {
|
|
1375
|
-
const data = $w('#addressesList').data;
|
|
1356
|
+
_$w('#addressStatusOptions').onChange(event => {
|
|
1357
|
+
const data = _$w('#addressesList').data;
|
|
1376
1358
|
const clickedItemData = data.find(item => item._id === event.context.itemId);
|
|
1377
1359
|
const newStatus = event.target.value;
|
|
1378
|
-
const $item = $w.at(event.context);
|
|
1360
|
+
const $item = _$w.at(event.context);
|
|
1379
1361
|
const isMain = $item('#mainAddressCheckbox').checked;
|
|
1380
1362
|
|
|
1381
1363
|
if (isMain && newStatus === ADDRESS_STATUS_TYPES.DONT_SHOW) {
|
|
@@ -1387,17 +1369,17 @@ async function personalDetailsFormOnReady({
|
|
|
1387
1369
|
checkFormChanges(FORM_SECTION_HANDLER_MAP.CONTACT_BOOKING);
|
|
1388
1370
|
});
|
|
1389
1371
|
|
|
1390
|
-
$w('#addressItemEditBtn').onClick(event => {
|
|
1391
|
-
const data = $w('#addressesList').data;
|
|
1372
|
+
_$w('#addressItemEditBtn').onClick(event => {
|
|
1373
|
+
const data = _$w('#addressesList').data;
|
|
1392
1374
|
const clickedItemData = data.find(item => item._id === event.context.itemId);
|
|
1393
|
-
const $item = $w.at(event.context);
|
|
1375
|
+
const $item = _$w.at(event.context);
|
|
1394
1376
|
$item('#addressItemStates').changeState(ADDRESS_STATES.EDIT);
|
|
1395
1377
|
const addressInputValue = convertToAddressInputFormat(clickedItemData.address);
|
|
1396
1378
|
$item('#addressEditInput').value = addressInputValue;
|
|
1397
1379
|
});
|
|
1398
1380
|
|
|
1399
|
-
$w('#addressItemRemoveBtn').onClick(async event => {
|
|
1400
|
-
const data = $w('#addressesList').data;
|
|
1381
|
+
_$w('#addressItemRemoveBtn').onClick(async event => {
|
|
1382
|
+
const data = _$w('#addressesList').data;
|
|
1401
1383
|
const clickedItemData = data.find(item => item._id === event.context.itemId);
|
|
1402
1384
|
const result = await wixWindow.openLightbox(LIGHTBOX_NAMES.DELETE_CONFIRM);
|
|
1403
1385
|
if (result && result.toDelete) {
|
|
@@ -1405,15 +1387,15 @@ async function personalDetailsFormOnReady({
|
|
|
1405
1387
|
}
|
|
1406
1388
|
});
|
|
1407
1389
|
|
|
1408
|
-
$w('#addressEditInput').onChange(event => {
|
|
1409
|
-
const $item = $w.at(event.context);
|
|
1390
|
+
_$w('#addressEditInput').onChange(event => {
|
|
1391
|
+
const $item = _$w.at(event.context);
|
|
1410
1392
|
validateAddressCompleteness($item);
|
|
1411
1393
|
});
|
|
1412
1394
|
|
|
1413
|
-
$w('#addressEditCancelBtn').onClick(event => {
|
|
1414
|
-
const data = $w('#addressesList').data;
|
|
1395
|
+
_$w('#addressEditCancelBtn').onClick(event => {
|
|
1396
|
+
const data = _$w('#addressesList').data;
|
|
1415
1397
|
const clickedItemData = data.find(item => item._id === event.context.itemId);
|
|
1416
|
-
const $item = $w.at(event.context);
|
|
1398
|
+
const $item = _$w.at(event.context);
|
|
1417
1399
|
if (clickedItemData.isNewAddress) {
|
|
1418
1400
|
removeNewAddressFromRepeater(clickedItemData._id);
|
|
1419
1401
|
} else {
|
|
@@ -1422,16 +1404,16 @@ async function personalDetailsFormOnReady({
|
|
|
1422
1404
|
}
|
|
1423
1405
|
});
|
|
1424
1406
|
|
|
1425
|
-
$w('#addressEditSaveBtn').onClick(event => {
|
|
1426
|
-
const data = $w('#addressesList').data;
|
|
1407
|
+
_$w('#addressEditSaveBtn').onClick(event => {
|
|
1408
|
+
const data = _$w('#addressesList').data;
|
|
1427
1409
|
const clickedItemData = data.find(item => item._id === event.context.itemId);
|
|
1428
|
-
const $item = $w.at(event.context);
|
|
1410
|
+
const $item = _$w.at(event.context);
|
|
1429
1411
|
saveAddressFromSingleInput($item, clickedItemData);
|
|
1430
1412
|
});
|
|
1431
1413
|
}
|
|
1432
1414
|
|
|
1433
1415
|
function addNewAddress() {
|
|
1434
|
-
const currentData = $w('#addressesList').data || [];
|
|
1416
|
+
const currentData = _$w('#addressesList').data || [];
|
|
1435
1417
|
|
|
1436
1418
|
if (currentData.length >= MAX_ADDRESSES_COUNT) {
|
|
1437
1419
|
return;
|
|
@@ -1483,7 +1465,6 @@ async function personalDetailsFormOnReady({
|
|
|
1483
1465
|
$item('#addressItemNumber').text = `Location ${index + 1}`;
|
|
1484
1466
|
$item('#mainAddressCheckbox').checked = itemData.isMain || false;
|
|
1485
1467
|
|
|
1486
|
-
// TO DO: Ask client what should be the default address status
|
|
1487
1468
|
const addressStatus = itemData.address.addressStatus || ADDRESS_STATUS_TYPES.STATE_CITY_ZIP;
|
|
1488
1469
|
$item('#addressStatusOptions').value = addressStatus;
|
|
1489
1470
|
}
|
|
@@ -1580,9 +1561,9 @@ async function personalDetailsFormOnReady({
|
|
|
1580
1561
|
}
|
|
1581
1562
|
|
|
1582
1563
|
function removeNewAddressFromRepeater(addressId) {
|
|
1583
|
-
const currentData = $w('#addressesList').data || [];
|
|
1564
|
+
const currentData = _$w('#addressesList').data || [];
|
|
1584
1565
|
const updatedData = currentData.filter(item => item._id !== addressId);
|
|
1585
|
-
$w('#addressesList').data = updatedData;
|
|
1566
|
+
_$w('#addressesList').data = updatedData;
|
|
1586
1567
|
}
|
|
1587
1568
|
|
|
1588
1569
|
function setNewAddress(addressId, addressData) {
|
|
@@ -1634,15 +1615,15 @@ async function personalDetailsFormOnReady({
|
|
|
1634
1615
|
});
|
|
1635
1616
|
}
|
|
1636
1617
|
|
|
1637
|
-
const repeater = $w('#addressesList');
|
|
1618
|
+
const repeater = _$w('#addressesList');
|
|
1638
1619
|
repeater.data = addressData;
|
|
1639
1620
|
|
|
1640
1621
|
updateAddressAddButtonState();
|
|
1641
1622
|
}
|
|
1642
1623
|
|
|
1643
1624
|
function updateAddressAddButtonState() {
|
|
1644
|
-
const currentData = $w('#addressesList').data || [];
|
|
1645
|
-
const newAddressButton = $w('#newAddressButton');
|
|
1625
|
+
const currentData = _$w('#addressesList').data || [];
|
|
1626
|
+
const newAddressButton = _$w('#newAddressButton');
|
|
1646
1627
|
|
|
1647
1628
|
if (currentData.length >= MAX_ADDRESSES_COUNT) {
|
|
1648
1629
|
newAddressButton.disable();
|
|
@@ -1728,17 +1709,17 @@ async function personalDetailsFormOnReady({
|
|
|
1728
1709
|
}
|
|
1729
1710
|
|
|
1730
1711
|
function setupPhoneRepeater() {
|
|
1731
|
-
$w('#phoneNumbersList').onItemReady(handlePhoneItem);
|
|
1712
|
+
_$w('#phoneNumbersList').onItemReady(handlePhoneItem);
|
|
1732
1713
|
renderPhonesList();
|
|
1733
1714
|
|
|
1734
|
-
$w('#addPhoneButton').onClick(addNewPhone);
|
|
1715
|
+
_$w('#addPhoneButton').onClick(addNewPhone);
|
|
1735
1716
|
|
|
1736
1717
|
setupPhoneRepeaterEventListeners();
|
|
1737
1718
|
}
|
|
1738
1719
|
|
|
1739
1720
|
function setupPhoneRepeaterEventListeners() {
|
|
1740
|
-
$w('#phoneInput').onInput(event => {
|
|
1741
|
-
const data = $w('#phoneNumbersList').data;
|
|
1721
|
+
_$w('#phoneInput').onInput(event => {
|
|
1722
|
+
const data = _$w('#phoneNumbersList').data;
|
|
1742
1723
|
const clickedItemData = data.find(item => item._id === event.context.itemId);
|
|
1743
1724
|
const phoneValue = event.target.value;
|
|
1744
1725
|
|
|
@@ -1752,20 +1733,20 @@ async function personalDetailsFormOnReady({
|
|
|
1752
1733
|
checkFormChanges(FORM_SECTION_HANDLER_MAP.CONTACT_BOOKING);
|
|
1753
1734
|
});
|
|
1754
1735
|
|
|
1755
|
-
$w('#showPhoneCheckbox').onChange(event => {
|
|
1756
|
-
const data = $w('#phoneNumbersList').data;
|
|
1736
|
+
_$w('#showPhoneCheckbox').onChange(event => {
|
|
1737
|
+
const data = _$w('#phoneNumbersList').data;
|
|
1757
1738
|
const clickedItemData = data.find(item => item._id === event.context.itemId);
|
|
1758
|
-
const $item = $w.at(event.context);
|
|
1739
|
+
const $item = _$w.at(event.context);
|
|
1759
1740
|
|
|
1760
|
-
$w('#showPhoneCheckbox').checked = false;
|
|
1741
|
+
_$w('#showPhoneCheckbox').checked = false;
|
|
1761
1742
|
$item('#showPhoneCheckbox').checked = true;
|
|
1762
1743
|
|
|
1763
1744
|
updateShowPhoneSelection(clickedItemData._id, event.target.checked);
|
|
1764
1745
|
checkFormChanges(FORM_SECTION_HANDLER_MAP.CONTACT_BOOKING);
|
|
1765
1746
|
});
|
|
1766
1747
|
|
|
1767
|
-
$w('#removePhoneBtn').onClick(async event => {
|
|
1768
|
-
const data = $w('#phoneNumbersList').data;
|
|
1748
|
+
_$w('#removePhoneBtn').onClick(async event => {
|
|
1749
|
+
const data = _$w('#phoneNumbersList').data;
|
|
1769
1750
|
const clickedItemData = data.find(item => item._id === event.context.itemId);
|
|
1770
1751
|
const result = await wixWindow.openLightbox(LIGHTBOX_NAMES.DELETE_CONFIRM);
|
|
1771
1752
|
if (result && result.toDelete) {
|
|
@@ -1775,7 +1756,7 @@ async function personalDetailsFormOnReady({
|
|
|
1775
1756
|
}
|
|
1776
1757
|
|
|
1777
1758
|
function addNewPhone() {
|
|
1778
|
-
const currentData = $w('#phoneNumbersList').data || [];
|
|
1759
|
+
const currentData = _$w('#phoneNumbersList').data || [];
|
|
1779
1760
|
|
|
1780
1761
|
if (currentData.length >= MAX_PHONES_COUNT) {
|
|
1781
1762
|
return;
|
|
@@ -1814,15 +1795,15 @@ async function personalDetailsFormOnReady({
|
|
|
1814
1795
|
}));
|
|
1815
1796
|
}
|
|
1816
1797
|
|
|
1817
|
-
const repeater = $w('#phoneNumbersList');
|
|
1798
|
+
const repeater = _$w('#phoneNumbersList');
|
|
1818
1799
|
|
|
1819
1800
|
repeater.data = phoneData;
|
|
1820
1801
|
updatePhoneAddButtonState();
|
|
1821
1802
|
}
|
|
1822
1803
|
|
|
1823
1804
|
function updatePhoneAddButtonState() {
|
|
1824
|
-
const currentData = $w('#phoneNumbersList').data || [];
|
|
1825
|
-
const addPhoneButton = $w('#addPhoneButton');
|
|
1805
|
+
const currentData = _$w('#phoneNumbersList').data || [];
|
|
1806
|
+
const addPhoneButton = _$w('#addPhoneButton');
|
|
1826
1807
|
|
|
1827
1808
|
if (currentData.length >= MAX_PHONES_COUNT) {
|
|
1828
1809
|
addPhoneButton.disable();
|
|
@@ -1832,7 +1813,7 @@ async function personalDetailsFormOnReady({
|
|
|
1832
1813
|
}
|
|
1833
1814
|
|
|
1834
1815
|
function updatePhoneNumber(phoneId, newPhoneNumber) {
|
|
1835
|
-
const currentData = $w('#phoneNumbersList').data || [];
|
|
1816
|
+
const currentData = _$w('#phoneNumbersList').data || [];
|
|
1836
1817
|
const itemIndex = currentData.findIndex(item => item._id === phoneId);
|
|
1837
1818
|
|
|
1838
1819
|
if (itemIndex !== -1) {
|
|
@@ -1844,7 +1825,7 @@ async function personalDetailsFormOnReady({
|
|
|
1844
1825
|
}
|
|
1845
1826
|
|
|
1846
1827
|
function syncPhonesFromRepeater() {
|
|
1847
|
-
const phoneData = $w('#phoneNumbersList').data || [];
|
|
1828
|
+
const phoneData = _$w('#phoneNumbersList').data || [];
|
|
1848
1829
|
itemMemberObj.phones = phoneData
|
|
1849
1830
|
.filter(item => !item.isNewPhone && item.phoneNumber.trim())
|
|
1850
1831
|
.map(item => item.phoneNumber);
|
|
@@ -1861,7 +1842,7 @@ async function personalDetailsFormOnReady({
|
|
|
1861
1842
|
}
|
|
1862
1843
|
|
|
1863
1844
|
function removePhone(phoneId) {
|
|
1864
|
-
const currentData = $w('#phoneNumbersList').data || [];
|
|
1845
|
+
const currentData = _$w('#phoneNumbersList').data || [];
|
|
1865
1846
|
const phoneToRemove = currentData.find(item => item._id === phoneId);
|
|
1866
1847
|
|
|
1867
1848
|
if (phoneToRemove) {
|
|
@@ -1875,7 +1856,7 @@ async function personalDetailsFormOnReady({
|
|
|
1875
1856
|
}
|
|
1876
1857
|
|
|
1877
1858
|
function updateShowPhoneSelection(phoneId, isVisible) {
|
|
1878
|
-
const currentData = $w('#phoneNumbersList').data || [];
|
|
1859
|
+
const currentData = _$w('#phoneNumbersList').data || [];
|
|
1879
1860
|
const selectedItem = currentData.find(item => item._id === phoneId);
|
|
1880
1861
|
|
|
1881
1862
|
if (selectedItem && selectedItem.phoneNumber) {
|
|
@@ -1892,18 +1873,18 @@ async function personalDetailsFormOnReady({
|
|
|
1892
1873
|
}
|
|
1893
1874
|
|
|
1894
1875
|
function getContactAndBookingData() {
|
|
1895
|
-
const showWixUrl = $w('#showUrlWixCheckbox').checked;
|
|
1896
|
-
const showExistingUrl = $w('#showExsistingUrlCheckbox').checked;
|
|
1876
|
+
const showWixUrl = _$w('#showUrlWixCheckbox').checked;
|
|
1877
|
+
const showExistingUrl = _$w('#showExsistingUrlCheckbox').checked;
|
|
1897
1878
|
|
|
1898
1879
|
const addresses = Array.isArray(itemMemberObj.addresses) ? itemMemberObj.addresses : [];
|
|
1899
1880
|
const phones = Array.isArray(itemMemberObj.phones) ? itemMemberObj.phones : [];
|
|
1900
1881
|
|
|
1901
1882
|
return {
|
|
1902
|
-
showContactForm: $w('#showCotactFormCheckbox').checked,
|
|
1903
|
-
contactFormEmail: $w('#contactFormEmailInput').value,
|
|
1883
|
+
showContactForm: _$w('#showCotactFormCheckbox').checked,
|
|
1884
|
+
contactFormEmail: _$w('#contactFormEmailInput').value,
|
|
1904
1885
|
toShowPhone: getToShowPhone(),
|
|
1905
|
-
bookingUrl: $w('#schedulingLinkInput').value,
|
|
1906
|
-
website: $w('#UrlInput').value,
|
|
1886
|
+
bookingUrl: _$w('#schedulingLinkInput').value,
|
|
1887
|
+
website: _$w('#UrlInput').value,
|
|
1907
1888
|
showWebsite: showExistingUrl,
|
|
1908
1889
|
showWixUrl,
|
|
1909
1890
|
addresses,
|
|
@@ -1911,9 +1892,10 @@ async function personalDetailsFormOnReady({
|
|
|
1911
1892
|
phones,
|
|
1912
1893
|
};
|
|
1913
1894
|
}
|
|
1895
|
+
|
|
1914
1896
|
async function saveContactBooking() {
|
|
1915
1897
|
// if showWixUrl value changes then update optWebsiteCheckbox value
|
|
1916
|
-
$w('#optWebsiteCheckbox').checked = itemMemberObj.showWixUrl;
|
|
1898
|
+
_$w('#optWebsiteCheckbox').checked = itemMemberObj.showWixUrl;
|
|
1917
1899
|
|
|
1918
1900
|
const beforeData = JSON.parse(JSON.stringify(itemMemberObj));
|
|
1919
1901
|
const contactChanges = getContactAndBookingData();
|
|
@@ -1937,7 +1919,7 @@ async function personalDetailsFormOnReady({
|
|
|
1937
1919
|
|
|
1938
1920
|
const result = await saveData(formData);
|
|
1939
1921
|
formHasUnsavedChanges[FORM_SECTION_HANDLER_MAP.CONTACT_BOOKING.section] = false;
|
|
1940
|
-
handleSaveDataFeedback($w('#contactMessage'), result.message);
|
|
1922
|
+
handleSaveDataFeedback(_$w('#contactMessage'), result.message);
|
|
1941
1923
|
}
|
|
1942
1924
|
|
|
1943
1925
|
function handleSaveDataFeedback($messageElement, message) {
|
|
@@ -1957,7 +1939,7 @@ async function personalDetailsFormOnReady({
|
|
|
1957
1939
|
|
|
1958
1940
|
const galleryData = buildGalleryData(gallery);
|
|
1959
1941
|
|
|
1960
|
-
$w('#galleryRepeater').data = galleryData;
|
|
1942
|
+
_$w('#galleryRepeater').data = galleryData;
|
|
1961
1943
|
}
|
|
1962
1944
|
|
|
1963
1945
|
function buildGalleryData(gallery) {
|
|
@@ -2007,8 +1989,28 @@ async function personalDetailsFormOnReady({
|
|
|
2007
1989
|
const ext = fullName.slice(dotIndex);
|
|
2008
1990
|
return `${name.slice(0, maxBaseLength)}...${ext}`;
|
|
2009
1991
|
}
|
|
1992
|
+
|
|
1993
|
+
async function filterInterests(searchValue) {
|
|
1994
|
+
const container = _$w('#containerRepeaterInterest');
|
|
1995
|
+
const repeater = _$w('#repeaterInterest');
|
|
1996
|
+
|
|
1997
|
+
const allInterests = await getInterestAll();
|
|
1998
|
+
const filtered = allInterests
|
|
1999
|
+
.filter(val => val.toLowerCase().includes(searchValue))
|
|
2000
|
+
.map(val => ({ _id: generateId(), value: val }));
|
|
2001
|
+
|
|
2002
|
+
if (filtered.length > 0) {
|
|
2003
|
+
repeater.data = filtered;
|
|
2004
|
+
container.expand();
|
|
2005
|
+
} else {
|
|
2006
|
+
repeater.data = [];
|
|
2007
|
+
container.collapse();
|
|
2008
|
+
}
|
|
2009
|
+
|
|
2010
|
+
return filtered;
|
|
2011
|
+
}
|
|
2010
2012
|
}
|
|
2011
2013
|
|
|
2012
2014
|
module.exports = {
|
|
2013
|
-
|
|
2015
|
+
personalDetailsOnReady,
|
|
2014
2016
|
};
|