@timardex/cluemart-shared 1.0.9 → 1.0.12

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.mjs CHANGED
@@ -41,22 +41,22 @@ var EnumResourceTypeIcon = /* @__PURE__ */ ((EnumResourceTypeIcon2) => {
41
41
  EnumResourceTypeIcon2["STALLHOLDER"] = "store";
42
42
  return EnumResourceTypeIcon2;
43
43
  })(EnumResourceTypeIcon || {});
44
- var EnumRegions = /* @__PURE__ */ ((EnumRegions2) => {
45
- EnumRegions2["Auckland"] = "Auckland";
46
- EnumRegions2["BayOfPlenty"] = "Bay of Plenty";
47
- EnumRegions2["Canterbury"] = "Canterbury";
48
- EnumRegions2["Gisborne"] = "Gisborne";
49
- EnumRegions2["HawkesBay"] = "Hawke's Bay";
50
- EnumRegions2["ManawatuWanganui"] = "Manawatu-Wanganui";
51
- EnumRegions2["Marlborough"] = "Marlborough";
52
- EnumRegions2["Nelson"] = "Nelson";
53
- EnumRegions2["Northland"] = "Northland";
54
- EnumRegions2["Otago"] = "Otago";
55
- EnumRegions2["Southland"] = "Southland";
56
- EnumRegions2["Taranaki"] = "Taranaki";
57
- EnumRegions2["Waikato"] = "Waikato";
58
- EnumRegions2["Wellington"] = "Wellington";
59
- return EnumRegions2;
44
+ var EnumRegions = /* @__PURE__ */ ((EnumRegions3) => {
45
+ EnumRegions3["Auckland"] = "Auckland";
46
+ EnumRegions3["BayOfPlenty"] = "Bay of Plenty";
47
+ EnumRegions3["Canterbury"] = "Canterbury";
48
+ EnumRegions3["Gisborne"] = "Gisborne";
49
+ EnumRegions3["HawkesBay"] = "Hawke's Bay";
50
+ EnumRegions3["ManawatuWanganui"] = "Manawatu-Wanganui";
51
+ EnumRegions3["Marlborough"] = "Marlborough";
52
+ EnumRegions3["Nelson"] = "Nelson";
53
+ EnumRegions3["Northland"] = "Northland";
54
+ EnumRegions3["Otago"] = "Otago";
55
+ EnumRegions3["Southland"] = "Southland";
56
+ EnumRegions3["Taranaki"] = "Taranaki";
57
+ EnumRegions3["Waikato"] = "Waikato";
58
+ EnumRegions3["Wellington"] = "Wellington";
59
+ return EnumRegions3;
60
60
  })(EnumRegions || {});
61
61
  var ImageTypeEnum = /* @__PURE__ */ ((ImageTypeEnum2) => {
62
62
  ImageTypeEnum2["AVATAR"] = "avatar";
@@ -176,6 +176,8 @@ function sortDatesByProximity(dates) {
176
176
  return diffA - diffB;
177
177
  });
178
178
  }
179
+ var availableRegionTypes = Object.values(EnumRegions);
180
+ var availableRegionOptions = mapArrayToOptions(availableRegionTypes);
179
181
 
180
182
  // src/hooks/useLocationSearch.ts
181
183
  var handleApiError = (error, message) => {
@@ -318,6 +320,14 @@ var startTimeCannotBeInPastTest = yup.string().test(
318
320
  var dateTimeSchema = yup.object().shape({
319
321
  endDate: yup.string().concat(endDateNotInPastTest).concat(endDateAfterStartDateTest).required("End date is required"),
320
322
  endTime: yup.string().concat(endTimeMustBeAfterStartTimeTest).required("End time is required"),
323
+ marketPrice: yup.number().typeError("Market price must be a number").min(0.1, "Market price must be at least 0.1").required("Market price is required").test(
324
+ "no-leading-zeros",
325
+ "Market price must not have leading zeros",
326
+ (value, context) => {
327
+ const original = context.originalValue?.toString() ?? "";
328
+ return !/^0\d+(\.\d+)?$/.test(original);
329
+ }
330
+ ),
321
331
  startDate: yup.string().concat(startDateNotInPastTest).required("Start date is required"),
322
332
  startTime: yup.string().concat(startTimeCannotBeInPastTest).required("Start time is required")
323
333
  });
@@ -356,9 +366,23 @@ var marketSchema = globalResourceSchema.shape({
356
366
  location: locationSchema,
357
367
  provider: yup2.string().trim().min(3).required("Provider is required"),
358
368
  stallApplicationInfo: yup2.object().shape({
359
- applicationDeadlineHours: yup2.number().min(1).required("Application deadline hours is required"),
369
+ applicationDeadlineHours: yup2.number().typeError("Application deadline hours must be a number").min(1, "Application deadline hours must be at least 1").required("Application deadline hours is required").test(
370
+ "no-leading-zeros",
371
+ "Application deadline hours must not start with leading zeros",
372
+ (value, context) => {
373
+ const original = context.originalValue?.toString() ?? "";
374
+ return !/^0\d+$/.test(original);
375
+ }
376
+ ),
360
377
  rejectionPolicy: yup2.mixed().oneOf(Object.values(EnumRejectionPolicy)).required("Rejection policy is required"),
361
- stallCapacity: yup2.number().min(1).required("Stall capacity is required")
378
+ stallCapacity: yup2.number().typeError("Stall capacity must be a number").min(1, "Stall capacity must be at least 1").integer("Stall capacity must be a whole number").required("Stall capacity is required").test(
379
+ "no-leading-zeros",
380
+ "Stall capacity must not have leading zeros",
381
+ (value, context) => {
382
+ const original = context.originalValue?.toString() ?? "";
383
+ return !/^0\d+$/.test(original);
384
+ }
385
+ )
362
386
  }),
363
387
  tags: yup2.array().of(yup2.string().defined()).nullable()
364
388
  });
@@ -432,6 +456,7 @@ var userSchema = yup4.object().shape({
432
456
  firstName: yup4.string().required("First name is required"),
433
457
  lastName: yup4.string().required("Last name is required"),
434
458
  password: passwordSchema,
459
+ preferredRegion: yup4.string().required("Preferred region is required"),
435
460
  // eslint-disable-next-line sort-keys
436
461
  confirmPassword: yup4.string().oneOf([yup4.ref("password")], "Passwords must match").required("Confirm Password is required"),
437
462
  role: yup4.mixed().oneOf(Object.values(EnumUserRole)).required("Role is required")
@@ -448,6 +473,7 @@ var registerSchema = yup5.object().shape({
448
473
  firstName: yup5.string().required("First Name is required"),
449
474
  lastName: yup5.string().required("Last Name is required"),
450
475
  password: passwordSchema,
476
+ preferredRegion: yup5.string().required("Preferred Region is required"),
451
477
  role: yup5.mixed().oneOf(Object.values(EnumUserRole)).required("Role is required")
452
478
  });
453
479
  var requestPasswordResetSchema = yup5.object().shape({
@@ -490,12 +516,14 @@ var defaultMarketFormValues = {
490
516
  {
491
517
  endDate: "04-05-2025",
492
518
  endTime: "15:00",
519
+ marketPrice: 0,
493
520
  startDate: "04-05-2025",
494
521
  startTime: "09:00"
495
522
  },
496
523
  {
497
524
  endDate: "05-05-2025",
498
525
  endTime: "15:00",
526
+ marketPrice: 0,
499
527
  startDate: "05-05-2025",
500
528
  startTime: "09:00"
501
529
  }
@@ -514,9 +542,9 @@ var defaultMarketFormValues = {
514
542
  },
515
543
  provider: "Provider name",
516
544
  stallApplicationInfo: {
517
- applicationDeadlineHours: 72,
545
+ applicationDeadlineHours: 0,
518
546
  rejectionPolicy: "multi_date_allowed" /* MULTI_DATE_ALLOWED */,
519
- stallCapacity: 4
547
+ stallCapacity: 0
520
548
  },
521
549
  tags: null
522
550
  };
@@ -805,6 +833,7 @@ var defaultValues = {
805
833
  firstName: "",
806
834
  lastName: "",
807
835
  password: "",
836
+ preferredRegion: "",
808
837
  role: "customer" /* CUSTOMER */
809
838
  };
810
839
  function useUserForm(data) {
@@ -832,6 +861,7 @@ function useUserForm(data) {
832
861
  firstName: data.firstName,
833
862
  lastName: data.lastName,
834
863
  password: data.password,
864
+ preferredRegion: data.preferredRegion,
835
865
  role: data.role
836
866
  });
837
867
  } else {
@@ -848,6 +878,7 @@ function useUserForm(data) {
848
878
  firstName,
849
879
  lastName,
850
880
  password,
881
+ preferredRegion,
851
882
  role
852
883
  } = getValues();
853
884
  return {
@@ -862,6 +893,7 @@ function useUserForm(data) {
862
893
  firstName,
863
894
  lastName,
864
895
  password,
896
+ preferredRegion,
865
897
  role
866
898
  },
867
899
  formState: { errors },
@@ -915,6 +947,7 @@ var defaultValues3 = {
915
947
  firstName: "",
916
948
  lastName: "",
917
949
  password: "",
950
+ preferredRegion: "",
918
951
  role: "customer" /* CUSTOMER */
919
952
  };
920
953
  function useRegisterForm() {
@@ -930,7 +963,7 @@ function useRegisterForm() {
930
963
  defaultValues: defaultValues3,
931
964
  resolver: yupResolver6(registerSchema)
932
965
  });
933
- const { email, firstName, lastName, password, role } = getValues();
966
+ const { email, firstName, lastName, password, preferredRegion, role } = getValues();
934
967
  return {
935
968
  control,
936
969
  fields: {
@@ -938,6 +971,7 @@ function useRegisterForm() {
938
971
  firstName,
939
972
  lastName,
940
973
  password,
974
+ preferredRegion,
941
975
  role
942
976
  },
943
977
  formState: { errors },
@@ -1102,6 +1136,7 @@ var USER_FIELDS_FRAGMENT = gql`
1102
1136
  lastName
1103
1137
  licences
1104
1138
  markets
1139
+ preferredRegion
1105
1140
  role
1106
1141
  stallholder
1107
1142
  updatedAt
@@ -1384,6 +1419,7 @@ var MARKET_DATETIME_FIELDS_FRAGMENT = gql5`
1384
1419
  fragment MarketDateTimeFields on MarketDateTimeType {
1385
1420
  endDate
1386
1421
  endTime
1422
+ marketPrice
1387
1423
  startDate
1388
1424
  startTime
1389
1425
  }
@@ -1807,6 +1843,7 @@ var RELATION_LOGS_FRAGMENT = gql9`
1807
1843
  var RELATION_DATES_FRAGMENT = gql9`
1808
1844
  fragment RelationDates on RelationDateType {
1809
1845
  lastUpdateBy
1846
+ marketPrice
1810
1847
  startDate
1811
1848
  status
1812
1849
  }
@@ -2584,9 +2621,7 @@ var availableCityTypes = [
2584
2621
  "Hamilton",
2585
2622
  "Wellington"
2586
2623
  ];
2587
- var availableRegionTypes = Object.values(EnumRegions);
2588
2624
  var availableCityOptions = mapArrayToOptions(availableCityTypes);
2589
- var availableRegionOptions = mapArrayToOptions(availableRegionTypes);
2590
2625
 
2591
2626
  // src/formFields/stallholder/stallholderApplyForm.ts
2592
2627
  var stallholderElectricity = {
@@ -2740,6 +2775,14 @@ var marketStartDateFields = [
2740
2775
  placeholder: "Start Time"
2741
2776
  }
2742
2777
  ];
2778
+ var marketPriceByDateFields = [
2779
+ {
2780
+ helperText: "Market Price for this date *",
2781
+ keyboardType: "number-pad",
2782
+ name: "marketPrice",
2783
+ placeholder: "Market Price"
2784
+ }
2785
+ ];
2743
2786
  var marketEndDateFields = [
2744
2787
  {
2745
2788
  dateMode: "date",
@@ -3237,6 +3280,7 @@ export {
3237
3280
  mapArrayToOptions,
3238
3281
  marketBasicInfoFields,
3239
3282
  marketEndDateFields,
3283
+ marketPriceByDateFields,
3240
3284
  marketSchema,
3241
3285
  marketStartDateFields,
3242
3286
  packagingOptions,