@timardex/cluemart-shared 2.2.40 → 2.3.0

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 (38) hide show
  1. package/dist/{chunk-BCMBTEGJ.mjs → chunk-DV3K3JDE.mjs} +26 -33
  2. package/dist/{chunk-BCMBTEGJ.mjs.map → chunk-DV3K3JDE.mjs.map} +1 -1
  3. package/dist/{chunk-T5ZOYS3L.mjs → chunk-HKTBJOB7.mjs} +40 -11
  4. package/dist/chunk-HKTBJOB7.mjs.map +1 -0
  5. package/dist/{chunk-NMJ2CR2F.mjs → chunk-KMS64DE2.mjs} +2 -2
  6. package/dist/{chunk-VL275KFW.mjs → chunk-PBW5K54C.mjs} +2 -2
  7. package/dist/{chunk-MKHXXZWF.mjs → chunk-YTRRTC2S.mjs} +11 -6
  8. package/dist/chunk-YTRRTC2S.mjs.map +1 -0
  9. package/dist/formFields/index.cjs +10 -0
  10. package/dist/formFields/index.cjs.map +1 -1
  11. package/dist/formFields/index.mjs +3 -3
  12. package/dist/graphql/index.cjs +10 -5
  13. package/dist/graphql/index.cjs.map +1 -1
  14. package/dist/graphql/index.d.mts +3 -1
  15. package/dist/graphql/index.d.ts +3 -1
  16. package/dist/graphql/index.mjs +1 -1
  17. package/dist/hooks/index.cjs +8 -2
  18. package/dist/hooks/index.cjs.map +1 -1
  19. package/dist/hooks/index.mjs +5 -5
  20. package/dist/index.cjs +76 -47
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.mts +33 -5
  23. package/dist/index.d.ts +33 -5
  24. package/dist/index.mjs +72 -45
  25. package/dist/index.mjs.map +1 -1
  26. package/dist/sharing/index.cjs +6 -0
  27. package/dist/sharing/index.cjs.map +1 -1
  28. package/dist/sharing/index.mjs +2 -2
  29. package/dist/utils/index.cjs +66 -42
  30. package/dist/utils/index.cjs.map +1 -1
  31. package/dist/utils/index.d.mts +30 -4
  32. package/dist/utils/index.d.ts +30 -4
  33. package/dist/utils/index.mjs +10 -6
  34. package/package.json +1 -1
  35. package/dist/chunk-MKHXXZWF.mjs.map +0 -1
  36. package/dist/chunk-T5ZOYS3L.mjs.map +0 -1
  37. /package/dist/{chunk-NMJ2CR2F.mjs.map → chunk-KMS64DE2.mjs.map} +0 -0
  38. /package/dist/{chunk-VL275KFW.mjs.map → chunk-PBW5K54C.mjs.map} +0 -0
@@ -1,18 +1,18 @@
1
- import "../chunk-NMJ2CR2F.mjs";
1
+ import "../chunk-KMS64DE2.mjs";
2
2
  import "../chunk-VA5YN2K3.mjs";
3
3
  import "../chunk-VPANTTZI.mjs";
4
4
  import "../chunk-DWO35OY4.mjs";
5
- import "../chunk-VL275KFW.mjs";
5
+ import "../chunk-PBW5K54C.mjs";
6
6
  import {
7
7
  SCHOOL_MIN_STUDENT_COUNT,
8
8
  isValidIrdNumber,
9
9
  normalizeUrl
10
- } from "../chunk-BCMBTEGJ.mjs";
10
+ } from "../chunk-DV3K3JDE.mjs";
11
11
  import "../chunk-RE4NZPYY.mjs";
12
12
  import {
13
13
  dateFormat,
14
14
  timeFormat
15
- } from "../chunk-T5ZOYS3L.mjs";
15
+ } from "../chunk-HKTBJOB7.mjs";
16
16
  import {
17
17
  EnumAdShowOn,
18
18
  EnumAdStatus,
@@ -24,7 +24,7 @@ import {
24
24
  } from "../chunk-5AAYX364.mjs";
25
25
  import "../chunk-RAYUJODN.mjs";
26
26
  import "../chunk-DQ7ZHIXW.mjs";
27
- import "../chunk-MKHXXZWF.mjs";
27
+ import "../chunk-YTRRTC2S.mjs";
28
28
  import "../chunk-TKSBCN3N.mjs";
29
29
  import "../chunk-7DQBUZXY.mjs";
30
30
  import {
package/dist/index.cjs CHANGED
@@ -209,7 +209,7 @@ __export(index_exports, {
209
209
  cluiFiles: () => cluiFiles,
210
210
  cluiIds: () => cluiIds,
211
211
  cluiImages: () => cluiImages,
212
- collectStallholderStartDates: () => collectStallholderStartDates,
212
+ collectStallholderDateTimes: () => collectStallholderDateTimes,
213
213
  collectVendorEventRelationDateTimes: () => collectVendorEventRelationDateTimes,
214
214
  companyContactFields: () => companyContactFields,
215
215
  computeDailyClueState: () => computeDailyClueState,
@@ -272,7 +272,6 @@ __export(index_exports, {
272
272
  getDistanceInMeters: () => getDistanceInMeters,
273
273
  getErrorMessage: () => getErrorMessage,
274
274
  getEventCalendarIsoDates: () => getEventCalendarIsoDates,
275
- getEventDatesWithStallholders: () => getEventDatesWithStallholders,
276
275
  getEventScheduleStatusLabel: () => getEventScheduleStatusLabel,
277
276
  getEventScheduleStatusPresentation: () => getEventScheduleStatusPresentation,
278
277
  getEventScheduleStatusTone: () => getEventScheduleStatusTone,
@@ -284,6 +283,8 @@ __export(index_exports, {
284
283
  getRegisteredVendorStartDates: () => getRegisteredVendorStartDates,
285
284
  getStallholderCategoryNames: () => getStallholderCategoryNames,
286
285
  getStallholderCategoryOptions: () => getStallholderCategoryOptions,
286
+ getUniqueStallholderStartDates: () => getUniqueStallholderStartDates,
287
+ getUniqueStartDates: () => getUniqueStartDates,
287
288
  getUnregisteredVendorCategoryNames: () => getUnregisteredVendorCategoryNames,
288
289
  getUnregisteredVendorStartDates: () => getUnregisteredVendorStartDates,
289
290
  getUsableAdminContexts: () => getUsableAdminContexts,
@@ -302,6 +303,7 @@ __export(index_exports, {
302
303
  icons: () => icons,
303
304
  isFutureDatesBeforeThreshold: () => isFutureDatesBeforeThreshold,
304
305
  isFutureEventDateStatus: () => isFutureEventDateStatus,
306
+ isFutureStartDate: () => isFutureStartDate,
305
307
  isInternalErrorMessage: () => isInternalErrorMessage,
306
308
  isIsoDateString: () => isIsoDateString,
307
309
  isNonVisitorResourceType: () => isNonVisitorResourceType,
@@ -1320,19 +1322,34 @@ var formatDate = (dateStr, display = "datetime", timeStr) => {
1320
1322
  return formattedDate;
1321
1323
  }
1322
1324
  };
1325
+ var SLOT_FORMATS = [
1326
+ `${dateFormat} ${timeFormat}`,
1327
+ `${dateFormat} H:mm`,
1328
+ `${dateFormat} ${timeFormat}:ss`,
1329
+ `${dateFormat} H:mm:ss`
1330
+ ];
1331
+ var parseSlot = (date) => {
1332
+ if (!date.startDate || !date.startTime) {
1333
+ return null;
1334
+ }
1335
+ const value = `${date.startDate} ${date.startTime}`;
1336
+ for (const format of SLOT_FORMATS) {
1337
+ const parsed = (0, import_dayjs2.default)(value, format, true);
1338
+ if (parsed.isValid()) {
1339
+ return parsed;
1340
+ }
1341
+ }
1342
+ return null;
1343
+ };
1344
+ var isFutureDateTime = (date, now) => {
1345
+ const slot = parseSlot(date);
1346
+ return slot ? slot.isSameOrAfter(now) : false;
1347
+ };
1323
1348
  var getCurrentAndFutureDates = (dates) => {
1324
1349
  const now = (0, import_dayjs2.default)();
1325
- return dates.filter((dateObj) => {
1326
- if (!dateObj.startDate || !dateObj.startTime) {
1327
- return false;
1328
- }
1329
- const dateTime = (0, import_dayjs2.default)(
1330
- `${dateObj.startDate} ${dateObj.startTime}`,
1331
- `${dateFormat} ${timeFormat}`
1332
- );
1333
- return dateTime.isSameOrAfter(now);
1334
- });
1350
+ return dates.filter((dateObj) => isFutureDateTime(dateObj, now));
1335
1351
  };
1352
+ var isFutureStartDate = (date) => isFutureDateTime(date, (0, import_dayjs2.default)());
1336
1353
  var isFutureDatesBeforeThreshold = (date, minHoursFromNow) => {
1337
1354
  if (!date.startDate || !date.startTime) {
1338
1355
  return false;
@@ -1371,6 +1388,18 @@ function sortDatesChronologically(dates) {
1371
1388
  return 0;
1372
1389
  });
1373
1390
  }
1391
+ function getUniqueStartDates(dates) {
1392
+ const seenStartDates = /* @__PURE__ */ new Set();
1393
+ const uniqueStartDates = [];
1394
+ for (const { startDate } of sortDatesChronologically(dates ?? [])) {
1395
+ if (!startDate || seenStartDates.has(startDate)) {
1396
+ continue;
1397
+ }
1398
+ seenStartDates.add(startDate);
1399
+ uniqueStartDates.push(startDate);
1400
+ }
1401
+ return uniqueStartDates;
1402
+ }
1374
1403
  var futureTimePeriods = FUTURE_EVENT_DATE_STATUSES.filter(
1375
1404
  (status) => status !== "Starting_Soon" /* STARTING_SOON */
1376
1405
  ).map((status) => ({
@@ -3184,21 +3213,23 @@ function filterUnregisteredVendorsByEventDatesOnly(vendors, eventStartDates) {
3184
3213
  )
3185
3214
  );
3186
3215
  }
3187
- function collectStallholderStartDates(registeredVendors, unregisteredVendors = []) {
3216
+ function collectStallholderDateTimes(registeredVendors, unregisteredVendors = []) {
3188
3217
  return [
3189
- ...registeredVendors.flatMap(getRegisteredVendorStartDates),
3190
- ...unregisteredVendors.flatMap(getUnregisteredVendorStartDates)
3218
+ ...registeredVendors.flatMap(
3219
+ (vendor) => (vendor.relations ?? []).flatMap(
3220
+ (relation) => (relation.relationDates ?? []).map(
3221
+ (relationDate) => relationDate.dateTime
3222
+ )
3223
+ )
3224
+ ),
3225
+ ...unregisteredVendors.flatMap(
3226
+ (vendor) => (vendor.invitations ?? []).flatMap((invitation) => invitation.dateTime)
3227
+ )
3191
3228
  ];
3192
3229
  }
3193
- function getEventDatesWithStallholders(eventDateTime, stallholderStartDates) {
3194
- if (!eventDateTime?.length) {
3195
- return [];
3196
- }
3197
- const startDates = new Set(stallholderStartDates);
3198
- return sortDatesChronologically(
3199
- eventDateTime.filter(
3200
- (date) => Boolean(date.startDate) && startDates.has(date.startDate)
3201
- )
3230
+ function getUniqueStallholderStartDates(registeredVendors, unregisteredVendors = []) {
3231
+ return getUniqueStartDates(
3232
+ collectStallholderDateTimes(registeredVendors, unregisteredVendors)
3202
3233
  );
3203
3234
  }
3204
3235
  function getStallholderCategoryNames(registeredVendors, unregisteredVendors = []) {
@@ -3254,16 +3285,7 @@ function collectVendorEventRelationDateTimes(events) {
3254
3285
  );
3255
3286
  }
3256
3287
  function getVendorEventRelationStartDates(events) {
3257
- const sortedDates = sortDatesChronologically(
3258
- collectVendorEventRelationDateTimes(events)
3259
- );
3260
- const uniqueStartDates = [];
3261
- for (const dateTime of sortedDates) {
3262
- if (dateTime.startDate && !uniqueStartDates.includes(dateTime.startDate)) {
3263
- uniqueStartDates.push(dateTime.startDate);
3264
- }
3265
- }
3266
- return uniqueStartDates;
3288
+ return getUniqueStartDates(collectVendorEventRelationDateTimes(events));
3267
3289
  }
3268
3290
  function getVendorEventRelationDateOptions(events) {
3269
3291
  return getVendorEventRelationStartDates(events).map((startDate) => ({
@@ -3528,12 +3550,12 @@ function getEventStallholdersData({
3528
3550
  registeredForSelectedDate,
3529
3551
  unregisteredForSelectedDate
3530
3552
  );
3531
- const futureEventStartDates = getEventDatesWithStallholders(
3532
- eventDateTime,
3533
- collectStallholderStartDates(registeredForEvent, unregisteredForEvent)
3534
- ).map((date) => ({
3535
- label: formatDate(date.startDate, "date"),
3536
- value: date.startDate
3553
+ const futureEventStartDates = getUniqueStallholderStartDates(
3554
+ registeredForEvent,
3555
+ unregisteredForEvent
3556
+ ).map((startDate) => ({
3557
+ label: formatDate(startDate, "date"),
3558
+ value: startDate
3537
3559
  }));
3538
3560
  const hasDatePills = futureEventStartDates.length > 0;
3539
3561
  const hasStallholders = vendorList.length > 0 || unregisteredVendorList.length > 0;
@@ -5740,8 +5762,8 @@ var RELATION_FIELDS_FRAGMENT = import_client11.gql`
5740
5762
  ${RELATION_DATES_FRAGMENT}
5741
5763
  `;
5742
5764
  var GET_RELATION = import_client11.gql`
5743
- query getRelation($_id: ID!) {
5744
- relation(_id: $_id) {
5765
+ query getRelation($_id: ID!, $futureOnly: Boolean = false) {
5766
+ relation(_id: $_id, futureOnly: $futureOnly) {
5745
5767
  ...RelationFields
5746
5768
  }
5747
5769
  }
@@ -7116,11 +7138,16 @@ var useDeleteRelation = () => {
7116
7138
 
7117
7139
  // src/graphql/hooks/relation/hooksQuery.ts
7118
7140
  var import_client38 = require("@apollo/client");
7119
- var useGetRelation = (_id) => {
7141
+ var useGetRelation = (_id, options) => {
7120
7142
  const { loading, error, data, refetch } = (0, import_client38.useQuery)(GET_RELATION, {
7121
- fetchPolicy: "network-only",
7143
+ // `relation(futureOnly)` is a projection-specific view of RelationType.
7144
+ // If this writes into the normalized RelationType cache, a full-history
7145
+ // read (e.g. the statistics screen's `futureOnly: false`) and this one can
7146
+ // overwrite each other's `relationDates` for the same entity id. Keep it
7147
+ // uncached.
7148
+ fetchPolicy: "no-cache",
7122
7149
  skip: !_id,
7123
- variables: _id ? { _id } : void 0
7150
+ variables: _id ? { _id, futureOnly: options?.futureOnly ?? false } : void 0
7124
7151
  });
7125
7152
  const relation = data?.relation;
7126
7153
  return { error, loading, refetch, relation };
@@ -10483,7 +10510,7 @@ function canAccessAdminPath(roles, pathname) {
10483
10510
  cluiFiles,
10484
10511
  cluiIds,
10485
10512
  cluiImages,
10486
- collectStallholderStartDates,
10513
+ collectStallholderDateTimes,
10487
10514
  collectVendorEventRelationDateTimes,
10488
10515
  companyContactFields,
10489
10516
  computeDailyClueState,
@@ -10546,7 +10573,6 @@ function canAccessAdminPath(roles, pathname) {
10546
10573
  getDistanceInMeters,
10547
10574
  getErrorMessage,
10548
10575
  getEventCalendarIsoDates,
10549
- getEventDatesWithStallholders,
10550
10576
  getEventScheduleStatusLabel,
10551
10577
  getEventScheduleStatusPresentation,
10552
10578
  getEventScheduleStatusTone,
@@ -10558,6 +10584,8 @@ function canAccessAdminPath(roles, pathname) {
10558
10584
  getRegisteredVendorStartDates,
10559
10585
  getStallholderCategoryNames,
10560
10586
  getStallholderCategoryOptions,
10587
+ getUniqueStallholderStartDates,
10588
+ getUniqueStartDates,
10561
10589
  getUnregisteredVendorCategoryNames,
10562
10590
  getUnregisteredVendorStartDates,
10563
10591
  getUsableAdminContexts,
@@ -10576,6 +10604,7 @@ function canAccessAdminPath(roles, pathname) {
10576
10604
  icons,
10577
10605
  isFutureDatesBeforeThreshold,
10578
10606
  isFutureEventDateStatus,
10607
+ isFutureStartDate,
10579
10608
  isInternalErrorMessage,
10580
10609
  isIsoDateString,
10581
10610
  isNonVisitorResourceType,