@timardex/cluemart-server-shared 1.0.96 → 1.0.97

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.
@@ -33,7 +33,7 @@ import {
33
33
  resourceRelationsSchema,
34
34
  termsAgreementSchema,
35
35
  userLicenseSchema
36
- } from "../chunk-EIX3V4IW.mjs";
36
+ } from "../chunk-GEP7O5RI.mjs";
37
37
  import "../chunk-3QS3WKRC.mjs";
38
38
  export {
39
39
  APP_SETTINGS_ID,
@@ -1676,7 +1676,8 @@ __export(service_exports, {
1676
1676
  connectToDatabase: () => connectToDatabase,
1677
1677
  saveNotificationsInDb: () => saveNotificationsInDb,
1678
1678
  sendPushNotifications: () => sendPushNotifications,
1679
- updateAdStatuses: () => updateAdStatuses
1679
+ updateAdStatuses: () => updateAdStatuses,
1680
+ updateVendorBasedOnUserLicense: () => updateVendorBasedOnUserLicense
1680
1681
  });
1681
1682
  module.exports = __toCommonJS(service_exports);
1682
1683
 
@@ -12037,12 +12038,70 @@ async function updateAdStatuses() {
12037
12038
  `\u2705 Ad statuses updated: invalid=${invalidResult.modifiedCount}, expired=${expiredResult.modifiedCount}, active=${activeResult.modifiedCount}, paused=${pausedResult.modifiedCount}`
12038
12039
  );
12039
12040
  }
12041
+
12042
+ // src/service/vendor.ts
12043
+ async function updateVendorBasedOnUserLicense(userId, licenceObject) {
12044
+ try {
12045
+ const user = await UserModel.findById(userId).exec();
12046
+ if (!user) {
12047
+ return null;
12048
+ }
12049
+ const userVendor = await VendorModel.findById(user.vendor).exec();
12050
+ if (!userVendor) {
12051
+ return null;
12052
+ }
12053
+ const selectedLicence = licenceObject.licenceType;
12054
+ if (selectedLicence === void 0) {
12055
+ return null;
12056
+ }
12057
+ const vendorUpdateData = {
12058
+ owner: {
12059
+ email: user.email,
12060
+ userId
12061
+ }
12062
+ };
12063
+ if (selectedLicence === EnumUserLicence.STANDARD_VENDOR) {
12064
+ vendorUpdateData.associates = [];
12065
+ vendorUpdateData.availability = {
12066
+ corporate: false,
12067
+ private: false,
12068
+ school: false
12069
+ };
12070
+ vendorUpdateData.products = {
12071
+ active: false,
12072
+ productsList: userVendor.products?.productsList || []
12073
+ };
12074
+ vendorUpdateData.calendar = {
12075
+ active: false,
12076
+ calendarData: userVendor.calendar?.calendarData || []
12077
+ };
12078
+ vendorUpdateData.images = (userVendor.images || []).map((img, index) => ({
12079
+ active: index < 6,
12080
+ // first 6 will be true, the rest false
12081
+ source: img.source,
12082
+ title: img.title
12083
+ }));
12084
+ }
12085
+ await VendorModel.findByIdAndUpdate(
12086
+ userVendor._id,
12087
+ {
12088
+ $set: vendorUpdateData
12089
+ },
12090
+ { new: true }
12091
+ );
12092
+ return null;
12093
+ } catch (error) {
12094
+ console.error("Error updating vendor based on user license:", error);
12095
+ return null;
12096
+ }
12097
+ }
12040
12098
  // Annotate the CommonJS export names for ESM import in node:
12041
12099
  0 && (module.exports = {
12042
12100
  connectToDatabase,
12043
12101
  saveNotificationsInDb,
12044
12102
  sendPushNotifications,
12045
- updateAdStatuses
12103
+ updateAdStatuses,
12104
+ updateVendorBasedOnUserLicense
12046
12105
  });
12047
12106
  /*! Bundled license information:
12048
12107