abmp-npm 1.8.26 → 1.8.28

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.
@@ -1,4 +1,5 @@
1
1
  const { contacts } = require('@wix/crm');
2
+ const { auth } = require('@wix/essentials');
2
3
 
3
4
  const { COLLECTIONS } = require('../public/consts');
4
5
 
@@ -13,6 +14,8 @@ const {
13
14
  urlExists,
14
15
  } = require('./utils');
15
16
 
17
+ const elevatedUpdateContact = auth.elevate(contacts.updateContact);
18
+
16
19
  /**
17
20
  * Retrieves member data by member ID
18
21
  * @param {string} memberId - The member ID to search for
@@ -145,10 +148,11 @@ async function updateContactInfo(contactId, updateInfoCallback, operationName) {
145
148
 
146
149
  try {
147
150
  const contact = await contacts.getContact(contactId);
151
+ console.log('contact from updateContactInfo', contact);
148
152
  const currentInfo = contact.info;
149
153
  const updatedInfo = updateInfoCallback(currentInfo);
150
154
 
151
- await contacts.updateContact(contactId, { info: updatedInfo });
155
+ await elevatedUpdateContact(contactId, { info: updatedInfo });
152
156
  } catch (error) {
153
157
  console.error(`Error in ${operationName}:`, error);
154
158
  throw new Error(`Failed to ${operationName}: ${error.message}`);
@@ -165,7 +169,7 @@ async function updateContactEmail(contactId, newEmail) {
165
169
  throw new Error('New email is required');
166
170
  }
167
171
 
168
- return updateContactInfo(
172
+ return await updateContactInfo(
169
173
  contactId,
170
174
  currentInfo => ({
171
175
  ...currentInfo,
@@ -193,7 +197,7 @@ async function updateContactNames(contactId, firstName, lastName) {
193
197
  throw new Error('At least one name field is required');
194
198
  }
195
199
 
196
- return updateContactInfo(
200
+ return await updateContactInfo(
197
201
  contactId,
198
202
  currentInfo => ({
199
203
  ...currentInfo,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "abmp-npm",
3
- "version": "1.8.26",
3
+ "version": "1.8.28",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",
@@ -952,7 +952,7 @@ async function personalDetailsOnReady({
952
952
  // Capture data before save for logging
953
953
  const beforeSaveData = JSON.parse(JSON.stringify(itemMemberObj));
954
954
 
955
- const { type, saveData: saved } = await saveRegistrationData(formData, itemMemberObj.memberId);
955
+ const { type, saveData: saved } = await saveRegistrationData(formData, itemMemberObj._id);
956
956
 
957
957
  if (type === 'success') {
958
958
  // Log the successful change