@timardex/cluemart-server-shared 1.0.97 → 1.0.98

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/dist/index.cjs CHANGED
@@ -12079,22 +12079,17 @@ async function updateVendorBasedOnUserLicense(userId, licenceObject) {
12079
12079
  try {
12080
12080
  const user = await UserModel.findById(userId).exec();
12081
12081
  if (!user) {
12082
- return null;
12082
+ return;
12083
12083
  }
12084
12084
  const userVendor = await VendorModel.findById(user.vendor).exec();
12085
12085
  if (!userVendor) {
12086
- return null;
12086
+ return;
12087
12087
  }
12088
12088
  const selectedLicence = licenceObject.licenceType;
12089
12089
  if (selectedLicence === void 0) {
12090
- return null;
12090
+ return;
12091
12091
  }
12092
- const vendorUpdateData = {
12093
- owner: {
12094
- email: user.email,
12095
- userId
12096
- }
12097
- };
12092
+ const vendorUpdateData = {};
12098
12093
  if (selectedLicence === EnumUserLicence.STANDARD_VENDOR) {
12099
12094
  vendorUpdateData.associates = [];
12100
12095
  vendorUpdateData.availability = {
@@ -12116,6 +12111,13 @@ async function updateVendorBasedOnUserLicense(userId, licenceObject) {
12116
12111
  source: img.source,
12117
12112
  title: img.title
12118
12113
  }));
12114
+ } else {
12115
+ vendorUpdateData.images = (userVendor.images || []).map((img) => ({
12116
+ active: true,
12117
+ // all images will be true
12118
+ source: img.source,
12119
+ title: img.title
12120
+ }));
12119
12121
  }
12120
12122
  await VendorModel.findByIdAndUpdate(
12121
12123
  userVendor._id,
@@ -12124,10 +12126,8 @@ async function updateVendorBasedOnUserLicense(userId, licenceObject) {
12124
12126
  },
12125
12127
  { new: true }
12126
12128
  );
12127
- return null;
12128
12129
  } catch (error) {
12129
12130
  console.error("Error updating vendor based on user license:", error);
12130
- return null;
12131
12131
  }
12132
12132
  }
12133
12133