@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.
@@ -11809,6 +11809,7 @@ var AppSettingSchema = new MongooseSchema18(
11809
11809
  var AppSettingModel = mongoose18.models.AppSetting || mongoose18.model("AppSetting", AppSettingSchema);
11810
11810
 
11811
11811
  export {
11812
+ EnumUserLicence,
11812
11813
  EnumAdStatus,
11813
11814
  StallTypeSchema,
11814
11815
  refundPolicySchema,
@@ -11869,4 +11870,4 @@ react/cjs/react.development.js:
11869
11870
  * LICENSE file in the root directory of this source tree.
11870
11871
  *)
11871
11872
  */
11872
- //# sourceMappingURL=chunk-EIX3V4IW.mjs.map
11873
+ //# sourceMappingURL=chunk-GEP7O5RI.mjs.map
package/dist/index.cjs CHANGED
@@ -1705,7 +1705,7 @@ __export(index_exports, {
1705
1705
  express: () => import_express.default,
1706
1706
  locationGeoSchema: () => locationGeoSchema,
1707
1707
  locationsSchema: () => locationsSchema,
1708
- mongoose: () => import_mongoose21.default,
1708
+ mongoose: () => import_mongoose22.default,
1709
1709
  refundPolicySchema: () => refundPolicySchema,
1710
1710
  relationDatesSchema: () => relationDatesSchema,
1711
1711
  resourceRelationsSchema: () => resourceRelationsSchema,
@@ -1713,6 +1713,7 @@ __export(index_exports, {
1713
1713
  sendPushNotifications: () => sendPushNotifications,
1714
1714
  termsAgreementSchema: () => termsAgreementSchema,
1715
1715
  updateAdStatuses: () => updateAdStatuses,
1716
+ updateVendorBasedOnUserLicense: () => updateVendorBasedOnUserLicense,
1716
1717
  userLicenseSchema: () => userLicenseSchema
1717
1718
  });
1718
1719
  module.exports = __toCommonJS(index_exports);
@@ -12073,9 +12074,66 @@ async function updateAdStatuses() {
12073
12074
  );
12074
12075
  }
12075
12076
 
12077
+ // src/service/vendor.ts
12078
+ async function updateVendorBasedOnUserLicense(userId, licenceObject) {
12079
+ try {
12080
+ const user = await UserModel.findById(userId).exec();
12081
+ if (!user) {
12082
+ return null;
12083
+ }
12084
+ const userVendor = await VendorModel.findById(user.vendor).exec();
12085
+ if (!userVendor) {
12086
+ return null;
12087
+ }
12088
+ const selectedLicence = licenceObject.licenceType;
12089
+ if (selectedLicence === void 0) {
12090
+ return null;
12091
+ }
12092
+ const vendorUpdateData = {
12093
+ owner: {
12094
+ email: user.email,
12095
+ userId
12096
+ }
12097
+ };
12098
+ if (selectedLicence === EnumUserLicence.STANDARD_VENDOR) {
12099
+ vendorUpdateData.associates = [];
12100
+ vendorUpdateData.availability = {
12101
+ corporate: false,
12102
+ private: false,
12103
+ school: false
12104
+ };
12105
+ vendorUpdateData.products = {
12106
+ active: false,
12107
+ productsList: userVendor.products?.productsList || []
12108
+ };
12109
+ vendorUpdateData.calendar = {
12110
+ active: false,
12111
+ calendarData: userVendor.calendar?.calendarData || []
12112
+ };
12113
+ vendorUpdateData.images = (userVendor.images || []).map((img, index) => ({
12114
+ active: index < 6,
12115
+ // first 6 will be true, the rest false
12116
+ source: img.source,
12117
+ title: img.title
12118
+ }));
12119
+ }
12120
+ await VendorModel.findByIdAndUpdate(
12121
+ userVendor._id,
12122
+ {
12123
+ $set: vendorUpdateData
12124
+ },
12125
+ { new: true }
12126
+ );
12127
+ return null;
12128
+ } catch (error) {
12129
+ console.error("Error updating vendor based on user license:", error);
12130
+ return null;
12131
+ }
12132
+ }
12133
+
12076
12134
  // src/types/index.ts
12077
12135
  var import_express = __toESM(require("express"));
12078
- var import_mongoose21 = __toESM(require("mongoose"));
12136
+ var import_mongoose22 = __toESM(require("mongoose"));
12079
12137
  var EnumPubSubEvents = /* @__PURE__ */ ((EnumPubSubEvents2) => {
12080
12138
  EnumPubSubEvents2["GET_CHAT_MESSAGE"] = "GET_CHAT_MESSAGE";
12081
12139
  EnumPubSubEvents2["GET_NOTIFICATIONS"] = "GET_NOTIFICATIONS";
@@ -12125,6 +12183,7 @@ var EnumPubSubEvents = /* @__PURE__ */ ((EnumPubSubEvents2) => {
12125
12183
  sendPushNotifications,
12126
12184
  termsAgreementSchema,
12127
12185
  updateAdStatuses,
12186
+ updateVendorBasedOnUserLicense,
12128
12187
  userLicenseSchema
12129
12188
  });
12130
12189
  /*! Bundled license information: