@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.
@@ -37,7 +37,7 @@ import {
37
37
  resourceRelationsSchema,
38
38
  termsAgreementSchema,
39
39
  userLicenseSchema
40
- } from "../chunk-AZS3BEZ3.mjs";
40
+ } from "../chunk-3BUXU7KR.mjs";
41
41
  export {
42
42
  APP_SETTINGS_ID,
43
43
  AdModel,
@@ -38,6 +38,7 @@ __export(service_exports, {
38
38
  sendPushNotifications: () => sendPushNotifications,
39
39
  updateAdStatuses: () => updateAdStatuses,
40
40
  updateRelationDatesToUnavailable: () => updateRelationDatesToUnavailable,
41
+ updateSingleDateTimeStatus: () => updateSingleDateTimeStatus,
41
42
  updateVendorBasedOnUserLicense: () => updateVendorBasedOnUserLicense
42
43
  });
43
44
  module.exports = __toCommonJS(service_exports);
@@ -3546,6 +3547,8 @@ var gameScreenIdentifierList = [
3546
3547
  match: "/visitors"
3547
3548
  }
3548
3549
  ];
3550
+ var dateFormat = "DD-MM-YYYY";
3551
+ var timeFormat = "HH:mm";
3549
3552
  import_dayjs.default.extend(import_customParseFormat.default);
3550
3553
  import_dayjs.default.extend(import_utc.default);
3551
3554
  import_dayjs.default.extend(import_timezone.default);
@@ -9132,6 +9135,15 @@ function convertObjectIdsToStrings(obj) {
9132
9135
  }
9133
9136
 
9134
9137
  // src/service/event.ts
9138
+ var import_dayjs2 = __toESM(require("dayjs"));
9139
+ var import_customParseFormat2 = __toESM(require("dayjs/plugin/customParseFormat"));
9140
+ var import_isoWeek = __toESM(require("dayjs/plugin/isoWeek"));
9141
+ var import_isToday = __toESM(require("dayjs/plugin/isToday"));
9142
+ var import_isTomorrow = __toESM(require("dayjs/plugin/isTomorrow"));
9143
+ import_dayjs2.default.extend(import_customParseFormat2.default);
9144
+ import_dayjs2.default.extend(import_isToday.default);
9145
+ import_dayjs2.default.extend(import_isTomorrow.default);
9146
+ import_dayjs2.default.extend(import_isoWeek.default);
9135
9147
  async function findEventOrImportedMarketById(resourceId) {
9136
9148
  if (!resourceId) {
9137
9149
  return null;
@@ -9143,6 +9155,54 @@ async function findEventOrImportedMarketById(resourceId) {
9143
9155
  ]);
9144
9156
  return eventDoc ?? googleImportedDoc;
9145
9157
  }
9158
+ function getFutureEventStatus(startDateTime, now) {
9159
+ if (startDateTime.isToday()) {
9160
+ return EnumEventDateStatus.TODAY;
9161
+ }
9162
+ if (startDateTime.isTomorrow()) {
9163
+ return EnumEventDateStatus.TOMORROW;
9164
+ }
9165
+ if (startDateTime.isSame(now, "isoWeek")) {
9166
+ return EnumEventDateStatus.THIS_WEEK;
9167
+ }
9168
+ if (startDateTime.isSame(now.add(1, "week"), "isoWeek")) {
9169
+ return EnumEventDateStatus.NEXT_WEEK;
9170
+ }
9171
+ const hoursUntilStart = startDateTime.diff(now, "hour", true);
9172
+ if (hoursUntilStart > 0 && hoursUntilStart <= 4) {
9173
+ return EnumEventDateStatus.STARTING_SOON;
9174
+ }
9175
+ return EnumEventDateStatus.UPCOMING;
9176
+ }
9177
+ function updateSingleDateTimeStatus(dateTime) {
9178
+ const now = (0, import_dayjs2.default)();
9179
+ const startDateTime = (0, import_dayjs2.default)(
9180
+ `${dateTime.startDate} ${dateTime.startTime}`,
9181
+ `${dateFormat} ${timeFormat}`
9182
+ );
9183
+ const endDateTime = (0, import_dayjs2.default)(
9184
+ `${dateTime.endDate} ${dateTime.endTime}`,
9185
+ `${dateFormat} ${timeFormat}`
9186
+ );
9187
+ if (!startDateTime.isValid() || !endDateTime.isValid()) {
9188
+ return {
9189
+ ...dateTime,
9190
+ dateStatus: null
9191
+ };
9192
+ }
9193
+ let dateStatus = null;
9194
+ if (endDateTime.isBefore(now)) {
9195
+ dateStatus = EnumEventDateStatus.ENDED;
9196
+ } else if (startDateTime.isBefore(now) && endDateTime.isAfter(now)) {
9197
+ dateStatus = EnumEventDateStatus.STARTED;
9198
+ } else {
9199
+ dateStatus = getFutureEventStatus(startDateTime, now);
9200
+ }
9201
+ return {
9202
+ ...dateTime,
9203
+ dateStatus
9204
+ };
9205
+ }
9146
9206
 
9147
9207
  // src/service/relations.ts
9148
9208
  function didRemoveAnyEventDates(previousDateTime, nextDateTime) {
@@ -9176,6 +9236,7 @@ function updateRelationDatesToUnavailable(relationDates, eventDateTime) {
9176
9236
  sendPushNotifications,
9177
9237
  updateAdStatuses,
9178
9238
  updateRelationDatesToUnavailable,
9239
+ updateSingleDateTimeStatus,
9179
9240
  updateVendorBasedOnUserLicense
9180
9241
  });
9181
9242
  //# sourceMappingURL=index.cjs.map