@timardex/cluemart-shared 2.2.11 → 2.2.13

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.
Files changed (36) hide show
  1. package/dist/{chunk-576YBZYO.mjs → chunk-4DFWOUOT.mjs} +2 -2
  2. package/dist/{chunk-UIG4A4U3.mjs → chunk-KGYLNZQW.mjs} +2 -2
  3. package/dist/{chunk-2DTCLBHT.mjs → chunk-MTBH5LMV.mjs} +95 -21
  4. package/dist/chunk-MTBH5LMV.mjs.map +1 -0
  5. package/dist/{chunk-GOWIY4NZ.mjs → chunk-QSBAN3V5.mjs} +9 -1
  6. package/dist/chunk-QSBAN3V5.mjs.map +1 -0
  7. package/dist/{chunk-VWGCXGEL.mjs → chunk-YKJAOTF7.mjs} +2 -2
  8. package/dist/formFields/index.cjs +16 -7
  9. package/dist/formFields/index.cjs.map +1 -1
  10. package/dist/formFields/index.mjs +3 -3
  11. package/dist/graphql/index.cjs +8 -0
  12. package/dist/graphql/index.cjs.map +1 -1
  13. package/dist/graphql/index.mjs +1 -1
  14. package/dist/hooks/index.cjs +36 -25
  15. package/dist/hooks/index.cjs.map +1 -1
  16. package/dist/hooks/index.mjs +5 -5
  17. package/dist/index.cjs +106 -22
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.mts +17 -1
  20. package/dist/index.d.ts +17 -1
  21. package/dist/index.mjs +104 -22
  22. package/dist/index.mjs.map +1 -1
  23. package/dist/sharing/index.cjs +20 -9
  24. package/dist/sharing/index.cjs.map +1 -1
  25. package/dist/sharing/index.mjs +2 -2
  26. package/dist/utils/index.cjs +98 -22
  27. package/dist/utils/index.cjs.map +1 -1
  28. package/dist/utils/index.d.mts +17 -1
  29. package/dist/utils/index.d.ts +17 -1
  30. package/dist/utils/index.mjs +7 -3
  31. package/package.json +1 -1
  32. package/dist/chunk-2DTCLBHT.mjs.map +0 -1
  33. package/dist/chunk-GOWIY4NZ.mjs.map +0 -1
  34. /package/dist/{chunk-576YBZYO.mjs.map → chunk-4DFWOUOT.mjs.map} +0 -0
  35. /package/dist/{chunk-UIG4A4U3.mjs.map → chunk-KGYLNZQW.mjs.map} +0 -0
  36. /package/dist/{chunk-VWGCXGEL.mjs.map → chunk-YKJAOTF7.mjs.map} +0 -0
@@ -1,18 +1,18 @@
1
- import "../chunk-VWGCXGEL.mjs";
1
+ import "../chunk-YKJAOTF7.mjs";
2
2
  import "../chunk-VA5YN2K3.mjs";
3
3
  import "../chunk-VPANTTZI.mjs";
4
4
  import "../chunk-DWO35OY4.mjs";
5
- import "../chunk-576YBZYO.mjs";
5
+ import "../chunk-4DFWOUOT.mjs";
6
6
  import {
7
7
  SCHOOL_MIN_STUDENT_COUNT,
8
8
  isValidIrdNumber,
9
9
  normalizeUrl
10
- } from "../chunk-UIG4A4U3.mjs";
10
+ } from "../chunk-KGYLNZQW.mjs";
11
11
  import "../chunk-RE4NZPYY.mjs";
12
12
  import {
13
13
  dateFormat,
14
14
  timeFormat
15
- } from "../chunk-2DTCLBHT.mjs";
15
+ } from "../chunk-MTBH5LMV.mjs";
16
16
  import {
17
17
  EnumAdShowOn,
18
18
  EnumAdStatus,
@@ -24,7 +24,7 @@ import {
24
24
  } from "../chunk-MRBTCICB.mjs";
25
25
  import "../chunk-RAYUJODN.mjs";
26
26
  import "../chunk-DQ7ZHIXW.mjs";
27
- import "../chunk-GOWIY4NZ.mjs";
27
+ import "../chunk-QSBAN3V5.mjs";
28
28
  import "../chunk-OSSBKFNH.mjs";
29
29
  import "../chunk-7DQBUZXY.mjs";
30
30
  import {
package/dist/index.cjs CHANGED
@@ -271,6 +271,7 @@ __export(index_exports, {
271
271
  getEventScheduleStatusPresentation: () => getEventScheduleStatusPresentation,
272
272
  getEventScheduleStatusTone: () => getEventScheduleStatusTone,
273
273
  getEventStallholderEmptyMessage: () => getEventStallholderEmptyMessage,
274
+ getFutureEventStatus: () => getFutureEventStatus,
274
275
  getPermissionsForRoles: () => getPermissionsForRoles,
275
276
  getRegisteredVendorCategoryNames: () => getRegisteredVendorCategoryNames,
276
277
  getRegisteredVendorStartDates: () => getRegisteredVendorStartDates,
@@ -361,6 +362,7 @@ __export(index_exports, {
361
362
  toShareSocialImageCacheVersion: () => toShareSocialImageCacheVersion,
362
363
  toUserFacingErrorMessage: () => toUserFacingErrorMessage,
363
364
  truncateText: () => truncateText,
365
+ updateSingleDateTimeStatus: () => updateSingleDateTimeStatus,
364
366
  useActivateVendorClaim: () => useActivateVendorClaim,
365
367
  useAddParticipantToChat: () => useAddParticipantToChat,
366
368
  useAddUserFavouriteResource: () => useAddUserFavouriteResource,
@@ -1125,13 +1127,22 @@ var gameScreenIdentifierList = [
1125
1127
  ];
1126
1128
 
1127
1129
  // src/utils/date.ts
1128
- var import_dayjs = __toESM(require("dayjs"));
1129
- var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat.js"));
1130
+ var import_dayjs2 = __toESM(require("dayjs"));
1131
+ var import_customParseFormat2 = __toESM(require("dayjs/plugin/customParseFormat.js"));
1130
1132
  var import_isSameOrAfter = __toESM(require("dayjs/plugin/isSameOrAfter.js"));
1131
1133
  var import_timezone = __toESM(require("dayjs/plugin/timezone.js"));
1132
1134
  var import_utc = __toESM(require("dayjs/plugin/utc.js"));
1133
1135
 
1136
+ // src/utils/dateFormats.ts
1137
+ var dateFormat = "DD-MM-YYYY";
1138
+ var timeFormat = "HH:mm";
1139
+
1134
1140
  // src/utils/eventDateStatus.ts
1141
+ var import_dayjs = __toESM(require("dayjs"));
1142
+ var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat.js"));
1143
+ var import_isoWeek = __toESM(require("dayjs/plugin/isoWeek.js"));
1144
+ import_dayjs.default.extend(import_customParseFormat.default);
1145
+ import_dayjs.default.extend(import_isoWeek.default);
1135
1146
  var EVENT_DATE_STATUS_PERIOD_MAP = {
1136
1147
  ["Today" /* TODAY */]: [
1137
1148
  "Started" /* STARTED */,
@@ -1172,27 +1183,90 @@ function isFutureEventDateStatus(dateStatus) {
1172
1183
  function filterDatesByFutureStatus(dates) {
1173
1184
  return dates.filter((date) => isFutureEventDateStatus(date.dateStatus));
1174
1185
  }
1186
+ var MANUAL_DATE_STATUSES = /* @__PURE__ */ new Set([
1187
+ "Canceled" /* CANCELED */,
1188
+ "Rescheduled" /* RE_SCHEDULED */
1189
+ ]);
1190
+ function getFutureEventStatus(startDateTime, now) {
1191
+ const hoursUntilStart = startDateTime.diff(now, "hour", true);
1192
+ if (hoursUntilStart > 0 && hoursUntilStart <= 4) {
1193
+ return "Starting_Soon" /* STARTING_SOON */;
1194
+ }
1195
+ if (startDateTime.isSame(now, "day")) {
1196
+ return "Today" /* TODAY */;
1197
+ }
1198
+ if (startDateTime.isSame(now.add(1, "day"), "day")) {
1199
+ return "Tomorrow" /* TOMORROW */;
1200
+ }
1201
+ if (startDateTime.isSame(now, "isoWeek")) {
1202
+ return "This_Week" /* THIS_WEEK */;
1203
+ }
1204
+ if (startDateTime.isSame(now.add(1, "week"), "isoWeek")) {
1205
+ return "Next_Week" /* NEXT_WEEK */;
1206
+ }
1207
+ return "Upcoming" /* UPCOMING */;
1208
+ }
1209
+ function updateSingleDateTimeStatus(dateTime, now = (0, import_dayjs.default)()) {
1210
+ if (MANUAL_DATE_STATUSES.has(dateTime.dateStatus)) {
1211
+ return dateTime;
1212
+ }
1213
+ const dateTimeFormat = `${dateFormat} ${timeFormat}`;
1214
+ const startDateTime = (0, import_dayjs.default)(
1215
+ `${dateTime.startDate} ${dateTime.startTime}`,
1216
+ dateTimeFormat,
1217
+ true
1218
+ );
1219
+ const endDateTime = (0, import_dayjs.default)(
1220
+ `${dateTime.endDate} ${dateTime.endTime}`,
1221
+ dateTimeFormat,
1222
+ true
1223
+ );
1224
+ if (!startDateTime.isValid() || !endDateTime.isValid()) {
1225
+ return {
1226
+ ...dateTime,
1227
+ dateStatus: "Invalid" /* INVALID */
1228
+ };
1229
+ }
1230
+ if (endDateTime.isBefore(startDateTime)) {
1231
+ return {
1232
+ ...dateTime,
1233
+ dateStatus: "Invalid" /* INVALID */
1234
+ };
1235
+ }
1236
+ let dateStatus;
1237
+ if (endDateTime.isAfter(now)) {
1238
+ if (startDateTime.isAfter(now)) {
1239
+ dateStatus = getFutureEventStatus(startDateTime, now);
1240
+ } else {
1241
+ dateStatus = "Started" /* STARTED */;
1242
+ }
1243
+ } else {
1244
+ dateStatus = "Ended" /* ENDED */;
1245
+ }
1246
+ return {
1247
+ ...dateTime,
1248
+ dateStatus
1249
+ };
1250
+ }
1175
1251
 
1176
1252
  // src/utils/date.ts
1177
- var dateFormat = "DD-MM-YYYY";
1178
- var timeFormat = "HH:mm";
1179
- import_dayjs.default.extend(import_customParseFormat.default);
1180
- import_dayjs.default.extend(import_utc.default);
1181
- import_dayjs.default.extend(import_timezone.default);
1182
- import_dayjs.default.extend(import_isSameOrAfter.default);
1253
+ import_dayjs2.default.extend(import_customParseFormat2.default);
1254
+ import_dayjs2.default.extend(import_utc.default);
1255
+ import_dayjs2.default.extend(import_timezone.default);
1256
+ import_dayjs2.default.extend(import_isSameOrAfter.default);
1183
1257
  var NZ_TZ = "Pacific/Auckland";
1184
1258
  function toNZTime(date) {
1185
- return date ? (0, import_dayjs.default)(date).tz(NZ_TZ) : (0, import_dayjs.default)().tz(NZ_TZ);
1259
+ return date ? (0, import_dayjs2.default)(date).tz(NZ_TZ) : (0, import_dayjs2.default)().tz(NZ_TZ);
1186
1260
  }
1187
1261
  function nzStartOfDay(input) {
1188
1262
  if (input == null) {
1189
- return (0, import_dayjs.default)().tz(NZ_TZ).startOf("day");
1263
+ return (0, import_dayjs2.default)().tz(NZ_TZ).startOf("day");
1190
1264
  }
1191
- return import_dayjs.default.tz(input, NZ_TZ).startOf("day");
1265
+ return import_dayjs2.default.tz(input, NZ_TZ).startOf("day");
1192
1266
  }
1193
1267
  var formatDate = (dateStr, display = "datetime", timeStr) => {
1194
1268
  const dateTimeStr = timeStr ? `${dateStr} ${timeStr}` : dateStr;
1195
- const dateTime = timeStr ? (0, import_dayjs.default)(dateTimeStr, `${dateFormat} ${timeFormat}`) : (0, import_dayjs.default)(dateStr, dateFormat);
1269
+ const dateTime = timeStr ? (0, import_dayjs2.default)(dateTimeStr, `${dateFormat} ${timeFormat}`) : (0, import_dayjs2.default)(dateStr, dateFormat);
1196
1270
  const formattedDate = dateTime.format("dddd, D MMMM, YYYY");
1197
1271
  const formattedTime = dateTime.format("h:mm a");
1198
1272
  switch (display) {
@@ -1207,12 +1281,12 @@ var formatDate = (dateStr, display = "datetime", timeStr) => {
1207
1281
  }
1208
1282
  };
1209
1283
  var getCurrentAndFutureDates = (dates) => {
1210
- const now = (0, import_dayjs.default)();
1284
+ const now = (0, import_dayjs2.default)();
1211
1285
  return dates.filter((dateObj) => {
1212
1286
  if (!dateObj.startDate || !dateObj.startTime) {
1213
1287
  return false;
1214
1288
  }
1215
- const dateTime = (0, import_dayjs.default)(
1289
+ const dateTime = (0, import_dayjs2.default)(
1216
1290
  `${dateObj.startDate} ${dateObj.startTime}`,
1217
1291
  `${dateFormat} ${timeFormat}`
1218
1292
  );
@@ -1223,8 +1297,8 @@ var isFutureDatesBeforeThreshold = (date, minHoursFromNow) => {
1223
1297
  if (!date.startDate || !date.startTime) {
1224
1298
  return false;
1225
1299
  }
1226
- const threshold = minHoursFromNow ? (0, import_dayjs.default)().add(minHoursFromNow, "hour") : (0, import_dayjs.default)().startOf("day");
1227
- const dateTime = (0, import_dayjs.default)(
1300
+ const threshold = minHoursFromNow ? (0, import_dayjs2.default)().add(minHoursFromNow, "hour") : (0, import_dayjs2.default)().startOf("day");
1301
+ const dateTime = (0, import_dayjs2.default)(
1228
1302
  `${date.startDate} ${date.startTime}`,
1229
1303
  `${dateFormat} ${timeFormat}`
1230
1304
  );
@@ -1243,8 +1317,8 @@ function sortDatesChronologically(dates) {
1243
1317
  }
1244
1318
  return [...dates].sort((a, b) => {
1245
1319
  const dateTimeFormat = `${dateFormat} ${timeFormat}`;
1246
- const dateA = a.startDate && a.startTime ? (0, import_dayjs.default)(`${a.startDate} ${a.startTime}`, dateTimeFormat) : null;
1247
- const dateB = b.startDate && b.startTime ? (0, import_dayjs.default)(`${b.startDate} ${b.startTime}`, dateTimeFormat) : null;
1320
+ const dateA = a.startDate && a.startTime ? (0, import_dayjs2.default)(`${a.startDate} ${a.startTime}`, dateTimeFormat) : null;
1321
+ const dateB = b.startDate && b.startTime ? (0, import_dayjs2.default)(`${b.startDate} ${b.startTime}`, dateTimeFormat) : null;
1248
1322
  if (dateA && dateB) {
1249
1323
  return dateA.valueOf() - dateB.valueOf();
1250
1324
  }
@@ -1873,13 +1947,13 @@ var SCHOOL_MIN_STUDENT_COUNT = 300;
1873
1947
  var SCHOOL_MAX_STUDENT_COUNT = 0;
1874
1948
 
1875
1949
  // src/calendar/eventCalendar.ts
1876
- var import_dayjs2 = __toESM(require("dayjs"));
1950
+ var import_dayjs3 = __toESM(require("dayjs"));
1877
1951
  function toCalendarIsoDate(startDate) {
1878
- const formatted = (0, import_dayjs2.default)(startDate, dateFormat).format("YYYY-MM-DD");
1879
- return (0, import_dayjs2.default)(formatted, "YYYY-MM-DD", true).isValid() ? formatted : null;
1952
+ const formatted = (0, import_dayjs3.default)(startDate, dateFormat).format("YYYY-MM-DD");
1953
+ return (0, import_dayjs3.default)(formatted, "YYYY-MM-DD", true).isValid() ? formatted : null;
1880
1954
  }
1881
1955
  function fromCalendarIsoDate(isoDate) {
1882
- return (0, import_dayjs2.default)(isoDate, "YYYY-MM-DD").format(dateFormat);
1956
+ return (0, import_dayjs3.default)(isoDate, "YYYY-MM-DD").format(dateFormat);
1883
1957
  }
1884
1958
  function getEventCalendarIsoDates(dateTimes) {
1885
1959
  return dateTimes?.map(
@@ -6202,14 +6276,22 @@ var UPDATE_EVENT_INFO_MUTATION = import_client23.gql`
6202
6276
  // src/graphql/hooks/event/hooksMutation.ts
6203
6277
  var useCreateEvent = () => {
6204
6278
  const [createEvent, { loading, error }] = (0, import_client24.useMutation)(CREATE_EVENT_MUTATION, {
6279
+ // The mutation response is a live-only view of EventType. Don't write it
6280
+ // into the normalized EventType cache, where it would overwrite the full
6281
+ // (live + archived) `dateTime` that `getEvent` fetches for the detail page.
6205
6282
  awaitRefetchQueries: true,
6283
+ fetchPolicy: "no-cache",
6206
6284
  refetchQueries: [{ query: GET_USER_EVENTS }]
6207
6285
  });
6208
6286
  return { createEvent, error, loading };
6209
6287
  };
6210
6288
  var useUpdateEvent = () => {
6211
6289
  const [updateEvent, { loading, error }] = (0, import_client24.useMutation)(UPDATE_EVENT_MUTATION, {
6290
+ // See useCreateEvent: the update response only carries the live schedule,
6291
+ // so keep it out of the normalized EventType cache to avoid clobbering the
6292
+ // archived dates merged by `getEvent`.
6212
6293
  awaitRefetchQueries: true,
6294
+ fetchPolicy: "no-cache",
6213
6295
  refetchQueries: (mutationResult) => {
6214
6296
  const eventId = mutationResult?.data?.updateEvent?.data?._id;
6215
6297
  if (!eventId) return [];
@@ -10259,6 +10341,7 @@ function canAccessAdminPath(roles, pathname) {
10259
10341
  getEventScheduleStatusPresentation,
10260
10342
  getEventScheduleStatusTone,
10261
10343
  getEventStallholderEmptyMessage,
10344
+ getFutureEventStatus,
10262
10345
  getPermissionsForRoles,
10263
10346
  getRegisteredVendorCategoryNames,
10264
10347
  getRegisteredVendorStartDates,
@@ -10349,6 +10432,7 @@ function canAccessAdminPath(roles, pathname) {
10349
10432
  toShareSocialImageCacheVersion,
10350
10433
  toUserFacingErrorMessage,
10351
10434
  truncateText,
10435
+ updateSingleDateTimeStatus,
10352
10436
  useActivateVendorClaim,
10353
10437
  useAddParticipantToChat,
10354
10438
  useAddUserFavouriteResource,