@timardex/cluemart-server-shared 1.0.207 → 1.0.208

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
@@ -78,6 +78,7 @@ __export(index_exports, {
78
78
  termsAgreementSchema: () => termsAgreementSchema,
79
79
  updateAdStatuses: () => updateAdStatuses,
80
80
  updateRelationDatesToUnavailable: () => updateRelationDatesToUnavailable,
81
+ updateSingleDateTimeStatus: () => updateSingleDateTimeStatus,
81
82
  updateVendorBasedOnUserLicense: () => updateVendorBasedOnUserLicense,
82
83
  userLicenseSchema: () => userLicenseSchema
83
84
  });
@@ -3562,6 +3563,8 @@ var gameScreenIdentifierList = [
3562
3563
  match: "/visitors"
3563
3564
  }
3564
3565
  ];
3566
+ var dateFormat = "DD-MM-YYYY";
3567
+ var timeFormat = "HH:mm";
3565
3568
  import_dayjs.default.extend(import_customParseFormat.default);
3566
3569
  import_dayjs.default.extend(import_utc.default);
3567
3570
  import_dayjs.default.extend(import_timezone.default);
@@ -9171,6 +9174,15 @@ function convertObjectIdsToStrings(obj) {
9171
9174
  }
9172
9175
 
9173
9176
  // src/service/event.ts
9177
+ var import_dayjs2 = __toESM(require("dayjs"));
9178
+ var import_customParseFormat2 = __toESM(require("dayjs/plugin/customParseFormat"));
9179
+ var import_isoWeek = __toESM(require("dayjs/plugin/isoWeek"));
9180
+ var import_isToday = __toESM(require("dayjs/plugin/isToday"));
9181
+ var import_isTomorrow = __toESM(require("dayjs/plugin/isTomorrow"));
9182
+ import_dayjs2.default.extend(import_customParseFormat2.default);
9183
+ import_dayjs2.default.extend(import_isToday.default);
9184
+ import_dayjs2.default.extend(import_isTomorrow.default);
9185
+ import_dayjs2.default.extend(import_isoWeek.default);
9174
9186
  async function findEventOrImportedMarketById(resourceId) {
9175
9187
  if (!resourceId) {
9176
9188
  return null;
@@ -9182,6 +9194,54 @@ async function findEventOrImportedMarketById(resourceId) {
9182
9194
  ]);
9183
9195
  return eventDoc ?? googleImportedDoc;
9184
9196
  }
9197
+ function getFutureEventStatus(startDateTime, now) {
9198
+ if (startDateTime.isToday()) {
9199
+ return EnumEventDateStatus.TODAY;
9200
+ }
9201
+ if (startDateTime.isTomorrow()) {
9202
+ return EnumEventDateStatus.TOMORROW;
9203
+ }
9204
+ if (startDateTime.isSame(now, "isoWeek")) {
9205
+ return EnumEventDateStatus.THIS_WEEK;
9206
+ }
9207
+ if (startDateTime.isSame(now.add(1, "week"), "isoWeek")) {
9208
+ return EnumEventDateStatus.NEXT_WEEK;
9209
+ }
9210
+ const hoursUntilStart = startDateTime.diff(now, "hour", true);
9211
+ if (hoursUntilStart > 0 && hoursUntilStart <= 4) {
9212
+ return EnumEventDateStatus.STARTING_SOON;
9213
+ }
9214
+ return EnumEventDateStatus.UPCOMING;
9215
+ }
9216
+ function updateSingleDateTimeStatus(dateTime) {
9217
+ const now = (0, import_dayjs2.default)();
9218
+ const startDateTime = (0, import_dayjs2.default)(
9219
+ `${dateTime.startDate} ${dateTime.startTime}`,
9220
+ `${dateFormat} ${timeFormat}`
9221
+ );
9222
+ const endDateTime = (0, import_dayjs2.default)(
9223
+ `${dateTime.endDate} ${dateTime.endTime}`,
9224
+ `${dateFormat} ${timeFormat}`
9225
+ );
9226
+ if (!startDateTime.isValid() || !endDateTime.isValid()) {
9227
+ return {
9228
+ ...dateTime,
9229
+ dateStatus: null
9230
+ };
9231
+ }
9232
+ let dateStatus = null;
9233
+ if (endDateTime.isBefore(now)) {
9234
+ dateStatus = EnumEventDateStatus.ENDED;
9235
+ } else if (startDateTime.isBefore(now) && endDateTime.isAfter(now)) {
9236
+ dateStatus = EnumEventDateStatus.STARTED;
9237
+ } else {
9238
+ dateStatus = getFutureEventStatus(startDateTime, now);
9239
+ }
9240
+ return {
9241
+ ...dateTime,
9242
+ dateStatus
9243
+ };
9244
+ }
9185
9245
 
9186
9246
  // src/service/relations.ts
9187
9247
  function didRemoveAnyEventDates(previousDateTime, nextDateTime) {
@@ -9266,6 +9326,7 @@ var EnumPubSubEvents = /* @__PURE__ */ ((EnumPubSubEvents2) => {
9266
9326
  termsAgreementSchema,
9267
9327
  updateAdStatuses,
9268
9328
  updateRelationDatesToUnavailable,
9329
+ updateSingleDateTimeStatus,
9269
9330
  updateVendorBasedOnUserLicense,
9270
9331
  userLicenseSchema
9271
9332
  });