@timardex/cluemart-shared 1.5.503 → 1.5.504

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.
@@ -1,4 +1,4 @@
1
- import "../chunk-KEUG6IHV.mjs";
1
+ import "../chunk-A3BCQJII.mjs";
2
2
  import "../chunk-RQDZX76B.mjs";
3
3
  import "../chunk-DWO35OY4.mjs";
4
4
  import "../chunk-I7WE3EBR.mjs";
@@ -14,7 +14,7 @@ import {
14
14
  dateFormat,
15
15
  normalizeUrl,
16
16
  timeFormat
17
- } from "../chunk-P7FGPPWG.mjs";
17
+ } from "../chunk-XNMKWMNF.mjs";
18
18
  import {
19
19
  EnumEventDateStatus,
20
20
  EnumEventType,
package/dist/index.cjs CHANGED
@@ -102,6 +102,7 @@ __export(index_exports, {
102
102
  getCurrentAndFutureDates: () => getCurrentAndFutureDates,
103
103
  globalDefaultValues: () => globalDefaultValues,
104
104
  isFutureDatesBeforeThreshold: () => isFutureDatesBeforeThreshold,
105
+ isIsoDateString: () => isIsoDateString,
105
106
  licenseNiceNames: () => licenseNiceNames,
106
107
  lightColors: () => lightColors,
107
108
  loginFields: () => loginFields,
@@ -728,9 +729,6 @@ var priceUnits = [
728
729
  { label: "Half dozen", value: "HALF_DOZEN" }
729
730
  ];
730
731
 
731
- // src/utils/dailyClueGame.ts
732
- var import_dayjs = __toESM(require("dayjs"));
733
-
734
732
  // src/types/game.ts
735
733
  var gameScreenIdentifierList = [
736
734
  {
@@ -843,6 +841,75 @@ var EnumGameStatus = /* @__PURE__ */ ((EnumGameStatus2) => {
843
841
  return EnumGameStatus2;
844
842
  })(EnumGameStatus || {});
845
843
 
844
+ // src/utils/date.ts
845
+ var import_dayjs = __toESM(require("dayjs"));
846
+ var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat.js"));
847
+ var import_isSameOrAfter = __toESM(require("dayjs/plugin/isSameOrAfter.js"));
848
+ var import_timezone = __toESM(require("dayjs/plugin/timezone.js"));
849
+ var import_utc = __toESM(require("dayjs/plugin/utc.js"));
850
+ var dateFormat = "DD-MM-YYYY";
851
+ var timeFormat = "HH:mm";
852
+ import_dayjs.default.extend(import_customParseFormat.default);
853
+ import_dayjs.default.extend(import_utc.default);
854
+ import_dayjs.default.extend(import_timezone.default);
855
+ import_dayjs.default.extend(import_isSameOrAfter.default);
856
+ var NZ_TZ = "Pacific/Auckland";
857
+ function toNZTime(date3) {
858
+ return date3 ? (0, import_dayjs.default)(date3).tz(NZ_TZ) : (0, import_dayjs.default)().tz(NZ_TZ);
859
+ }
860
+ var formatDate = (dateStr, display = "datetime", timeStr) => {
861
+ const dateTimeStr = timeStr ? `${dateStr} ${timeStr}` : dateStr;
862
+ const dateTime = timeStr ? (0, import_dayjs.default)(dateTimeStr, `${dateFormat} ${timeFormat}`) : (0, import_dayjs.default)(dateStr, dateFormat);
863
+ const formattedDate = dateTime.format("dddd, D MMMM, YYYY");
864
+ const formattedTime = dateTime.format("h:mm a");
865
+ switch (display) {
866
+ case "date":
867
+ return formattedDate;
868
+ case "time":
869
+ return formattedTime;
870
+ case "datetime":
871
+ return `${formattedDate} at ${formattedTime}`;
872
+ default:
873
+ return formattedDate;
874
+ }
875
+ };
876
+ var getCurrentAndFutureDates = (dates) => {
877
+ const now = (0, import_dayjs.default)();
878
+ return dates.filter((dateObj) => {
879
+ const dateTime = (0, import_dayjs.default)(
880
+ `${dateObj.startDate} ${dateObj.startTime}`,
881
+ `${dateFormat} ${timeFormat}`
882
+ );
883
+ return dateTime.isSameOrAfter(now);
884
+ });
885
+ };
886
+ var isFutureDatesBeforeThreshold = (date3, minHoursFromNow) => {
887
+ const threshold = minHoursFromNow ? (0, import_dayjs.default)().add(minHoursFromNow, "hour") : (0, import_dayjs.default)().startOf("day");
888
+ const dateTime = (0, import_dayjs.default)(
889
+ `${date3.startDate} ${date3.startTime}`,
890
+ `${dateFormat} ${timeFormat}`
891
+ );
892
+ return dateTime.isSameOrAfter(threshold);
893
+ };
894
+ var formatTimestamp = (timestamp) => {
895
+ const formattedDate = toNZTime(timestamp).format(dateFormat);
896
+ return formatDate(formattedDate, "date");
897
+ };
898
+ var isIsoDateString = (value) => {
899
+ return typeof value === "string" && !isNaN(Date.parse(value));
900
+ };
901
+ function sortDatesChronologically(dates) {
902
+ if (!dates || !dates.length) {
903
+ return [];
904
+ }
905
+ return [...dates].sort((a, b) => {
906
+ const dateTimeFormat = `${dateFormat} ${timeFormat}`;
907
+ const dateA = (0, import_dayjs.default)(`${a.startDate} ${a.startTime}`, dateTimeFormat);
908
+ const dateB = (0, import_dayjs.default)(`${b.startDate} ${b.startTime}`, dateTimeFormat);
909
+ return dateA.valueOf() - dateB.valueOf();
910
+ });
911
+ }
912
+
846
913
  // src/utils/dailyClueGame.ts
847
914
  function createSeededRng(seed) {
848
915
  let t = seed >>> 0;
@@ -877,9 +944,9 @@ function getDayIndex(start, today) {
877
944
  function computeDailyClueState(dailyClue) {
878
945
  const { startDate, endDate } = dailyClue.gameFields.gameDate;
879
946
  const { shuffled, collected } = dailyClue.letterInfo;
880
- const today = (0, import_dayjs.default)().startOf("day");
881
- const start = (0, import_dayjs.default)(startDate).startOf("day");
882
- const end = (0, import_dayjs.default)(endDate).startOf("day");
947
+ const today = toNZTime().startOf("day");
948
+ const start = toNZTime(startDate).startOf("day");
949
+ const end = toNZTime(endDate).startOf("day");
883
950
  const shuffledPlacements = seededShuffle(
884
951
  gameScreenIdentifierList,
885
952
  start.toISOString()
@@ -913,63 +980,7 @@ function computeDailyClueState(dailyClue) {
913
980
  };
914
981
  }
915
982
 
916
- // src/utils/index.ts
917
- var import_dayjs2 = __toESM(require("dayjs"));
918
- var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat.js"));
919
- var import_isSameOrAfter = __toESM(require("dayjs/plugin/isSameOrAfter.js"));
920
- var import_timezone = __toESM(require("dayjs/plugin/timezone.js"));
921
- var import_utc = __toESM(require("dayjs/plugin/utc.js"));
922
- var dateFormat = "DD-MM-YYYY";
923
- var timeFormat = "HH:mm";
924
- import_dayjs2.default.extend(import_customParseFormat.default);
925
- import_dayjs2.default.extend(import_utc.default);
926
- import_dayjs2.default.extend(import_timezone.default);
927
- import_dayjs2.default.extend(import_isSameOrAfter.default);
928
- var NZ_TZ = "Pacific/Auckland";
929
- function toNZTime(date3) {
930
- return (0, import_dayjs2.default)(date3).tz(NZ_TZ).format();
931
- }
932
- var formatDate = (dateStr, display = "datetime", timeStr) => {
933
- const dateTimeStr = timeStr ? `${dateStr} ${timeStr}` : dateStr;
934
- const dateTime = timeStr ? (0, import_dayjs2.default)(dateTimeStr, `${dateFormat} ${timeFormat}`) : (0, import_dayjs2.default)(dateStr, dateFormat);
935
- const formattedDate = dateTime.format("dddd, D MMMM, YYYY");
936
- const formattedTime = dateTime.format("h:mm a");
937
- switch (display) {
938
- case "date":
939
- return formattedDate;
940
- case "time":
941
- return formattedTime;
942
- case "datetime":
943
- return `${formattedDate} at ${formattedTime}`;
944
- default:
945
- return formattedDate;
946
- }
947
- };
948
- var getCurrentAndFutureDates = (dates) => {
949
- const now = (0, import_dayjs2.default)();
950
- return dates.filter((dateObj) => {
951
- const dateTime = (0, import_dayjs2.default)(
952
- `${dateObj.startDate} ${dateObj.startTime}`,
953
- `${dateFormat} ${timeFormat}`
954
- );
955
- return dateTime.isSameOrAfter(now);
956
- });
957
- };
958
- var isFutureDatesBeforeThreshold = (date3, minHoursFromNow) => {
959
- const threshold = minHoursFromNow ? (0, import_dayjs2.default)().add(minHoursFromNow, "hour") : (0, import_dayjs2.default)().startOf("day");
960
- const dateTime = (0, import_dayjs2.default)(
961
- `${date3.startDate} ${date3.startTime}`,
962
- `${dateFormat} ${timeFormat}`
963
- );
964
- return dateTime.isSameOrAfter(threshold);
965
- };
966
- var formatTimestamp = (timestamp) => {
967
- const formattedDate = (0, import_dayjs2.default)(timestamp).tz("Pacific/Auckland").format(dateFormat);
968
- return formatDate(formattedDate, "date");
969
- };
970
- var isIsoDateString = (value) => {
971
- return typeof value === "string" && !isNaN(Date.parse(value));
972
- };
983
+ // src/utils/utils.ts
973
984
  var removeTypename = (obj) => {
974
985
  if (obj instanceof Date) {
975
986
  return obj;
@@ -1009,17 +1020,6 @@ var statusOptions = [
1009
1020
  })).sort((a, b) => a.label.localeCompare(b.label))
1010
1021
  // Sort the options alphabetically
1011
1022
  ];
1012
- function sortDatesChronologically(dates) {
1013
- if (!dates || !dates.length) {
1014
- return [];
1015
- }
1016
- return [...dates].sort((a, b) => {
1017
- const dateTimeFormat = `${dateFormat} ${timeFormat}`;
1018
- const dateA = (0, import_dayjs2.default)(`${a.startDate} ${a.startTime}`, dateTimeFormat);
1019
- const dateB = (0, import_dayjs2.default)(`${b.startDate} ${b.startTime}`, dateTimeFormat);
1020
- return dateA.valueOf() - dateB.valueOf();
1021
- });
1022
- }
1023
1023
  var availableRegionTypes = Object.values(EnumRegions);
1024
1024
  var availableRegionOptions = mapArrayToOptions(availableRegionTypes);
1025
1025
  var paymentMethodOptions = mapArrayToOptions(
@@ -6503,7 +6503,7 @@ var React = __toESM(require("react"));
6503
6503
  var import_react_hook_form = require("react-hook-form");
6504
6504
 
6505
6505
  // src/yupSchema/global.ts
6506
- var import_dayjs3 = __toESM(require("dayjs"));
6506
+ var import_dayjs2 = __toESM(require("dayjs"));
6507
6507
  var import_customParseFormat2 = __toESM(require("dayjs/plugin/customParseFormat.js"));
6508
6508
  var import_isSameOrAfter2 = __toESM(require("dayjs/plugin/isSameOrAfter.js"));
6509
6509
  var yup = __toESM(require("yup"));
@@ -6532,8 +6532,8 @@ var noLeadingZeros = (fieldName, options = {}) => {
6532
6532
  return true;
6533
6533
  };
6534
6534
  };
6535
- import_dayjs3.default.extend(import_isSameOrAfter2.default);
6536
- import_dayjs3.default.extend(import_customParseFormat2.default);
6535
+ import_dayjs2.default.extend(import_isSameOrAfter2.default);
6536
+ import_dayjs2.default.extend(import_customParseFormat2.default);
6537
6537
  var emailRequiredSchema = yup.string().email("Invalid email address").required("Email is required").label("Email").transform(
6538
6538
  (value) => typeof value === "string" ? value.trim().toLowerCase() : value
6539
6539
  );
@@ -6564,12 +6564,12 @@ var contactDetailsSchema = yup.object({
6564
6564
  landlinePhone: landlinePhoneSchema
6565
6565
  }).nullable().default(void 0);
6566
6566
  var endDateNotInPastTest = yup.string().test("not-in-past", "End date cannot be in the past", (value) => {
6567
- const now = (0, import_dayjs3.default)();
6568
- return value ? (0, import_dayjs3.default)(value, dateFormat, true).isSameOrAfter(now, "day") : false;
6567
+ const now = (0, import_dayjs2.default)();
6568
+ return value ? (0, import_dayjs2.default)(value, dateFormat, true).isSameOrAfter(now, "day") : false;
6569
6569
  });
6570
6570
  var startDateNotInPastTest = yup.string().test("not-in-past", "Start date cannot be in the past", (value) => {
6571
- const now = (0, import_dayjs3.default)();
6572
- return value ? (0, import_dayjs3.default)(value, dateFormat, true).isSameOrAfter(now, "day") : false;
6571
+ const now = (0, import_dayjs2.default)();
6572
+ return value ? (0, import_dayjs2.default)(value, dateFormat, true).isSameOrAfter(now, "day") : false;
6573
6573
  });
6574
6574
  var endDateAfterStartDateTest = yup.string().test(
6575
6575
  "end-after-start",
@@ -6577,8 +6577,8 @@ var endDateAfterStartDateTest = yup.string().test(
6577
6577
  function(value) {
6578
6578
  const { startDate } = this.parent;
6579
6579
  if (!startDate || !value) return false;
6580
- return (0, import_dayjs3.default)(value, dateFormat, true).isSameOrAfter(
6581
- (0, import_dayjs3.default)(startDate, dateFormat, true),
6580
+ return (0, import_dayjs2.default)(value, dateFormat, true).isSameOrAfter(
6581
+ (0, import_dayjs2.default)(startDate, dateFormat, true),
6582
6582
  "day"
6583
6583
  );
6584
6584
  }
@@ -6589,12 +6589,12 @@ var endTimeMustBeAfterStartTimeTest = yup.string().test(
6589
6589
  function(value) {
6590
6590
  const { startDate, endDate, startTime } = this.parent;
6591
6591
  if (!startDate || !endDate || !startTime || !value) return false;
6592
- const startDateTime = (0, import_dayjs3.default)(
6592
+ const startDateTime = (0, import_dayjs2.default)(
6593
6593
  `${startDate} ${startTime}`,
6594
6594
  `${dateFormat} ${timeFormat}`,
6595
6595
  true
6596
6596
  );
6597
- const endDateTime = (0, import_dayjs3.default)(
6597
+ const endDateTime = (0, import_dayjs2.default)(
6598
6598
  `${endDate} ${value}`,
6599
6599
  `${dateFormat} ${timeFormat}`,
6600
6600
  true
@@ -6606,10 +6606,10 @@ var startTimeCannotBeInPastTest = yup.string().test(
6606
6606
  "valid-start-time",
6607
6607
  "Start time cannot be in the past",
6608
6608
  function(value) {
6609
- const now = (0, import_dayjs3.default)();
6609
+ const now = (0, import_dayjs2.default)();
6610
6610
  const { startDate } = this.parent;
6611
6611
  if (!startDate || !value) return false;
6612
- const startDateTime = (0, import_dayjs3.default)(
6612
+ const startDateTime = (0, import_dayjs2.default)(
6613
6613
  `${startDate} ${value}`,
6614
6614
  `${dateFormat} ${timeFormat}`,
6615
6615
  true
@@ -8289,6 +8289,7 @@ var EnumActivity = /* @__PURE__ */ ((EnumActivity2) => {
8289
8289
  getCurrentAndFutureDates,
8290
8290
  globalDefaultValues,
8291
8291
  isFutureDatesBeforeThreshold,
8292
+ isIsoDateString,
8292
8293
  licenseNiceNames,
8293
8294
  lightColors,
8294
8295
  loginFields,