@timardex/cluemart-shared 1.0.29 → 1.0.31

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.cjs CHANGED
@@ -68,6 +68,7 @@ __export(index_exports, {
68
68
  marketInfoPaymentTarget: () => marketInfoPaymentTarget,
69
69
  marketPriceByDateFields: () => marketPriceByDateFields,
70
70
  marketStartDateFields: () => marketStartDateFields,
71
+ normalizeUrl: () => normalizeUrl,
71
72
  packagingOptions: () => packagingOptions,
72
73
  paymentMethodOptions: () => paymentMethodOptions,
73
74
  producedIngOptions: () => producedIngOptions,
@@ -77,6 +78,7 @@ __export(index_exports, {
77
78
  requestPasswordResetFields: () => requestPasswordResetFields,
78
79
  requirementsOptions: () => requirementsOptions,
79
80
  resetPasswordFields: () => resetPasswordFields,
81
+ siteTypeOptions: () => siteTypeOptions,
80
82
  socialMediaFields: () => socialMediaFields,
81
83
  sortDatesByProximity: () => sortDatesByProximity,
82
84
  stallholderBasicInfoFields: () => stallholderBasicInfoFields,
@@ -364,6 +366,12 @@ var availableRegionOptions = mapArrayToOptions(availableRegionTypes);
364
366
  var paymentMethodOptions = mapArrayToOptions(
365
367
  Object.values(EnumPaymentMethod)
366
368
  );
369
+ function normalizeUrl(url) {
370
+ if (!url.startsWith("http://") && !url.startsWith("https://")) {
371
+ return `https://${url}`;
372
+ }
373
+ return url;
374
+ }
367
375
 
368
376
  // src/hooks/useLocationSearch.ts
369
377
  var handleApiError = (error, message) => {
@@ -449,6 +457,11 @@ var import_dayjs2 = __toESM(require("dayjs"));
449
457
  var import_customParseFormat2 = __toESM(require("dayjs/plugin/customParseFormat"));
450
458
  var import_isSameOrAfter2 = __toESM(require("dayjs/plugin/isSameOrAfter"));
451
459
  var yup = __toESM(require("yup"));
460
+ var normalizedUrlTransform = () => yup.string().trim().transform(
461
+ (value) => typeof value === "string" ? value.toLowerCase() : value
462
+ ).transform(
463
+ (value) => typeof value === "string" ? normalizeUrl(value) : value
464
+ );
452
465
  var noLeadingZeros = (fieldName, options = {}) => {
453
466
  return function(value, context) {
454
467
  const original = context.originalValue?.toString() ?? "";
@@ -521,12 +534,25 @@ var dateTimeSchema = yup.object().shape({
521
534
  startDate: yup.string().concat(startDateNotInPastTest).required("Start date is required"),
522
535
  startTime: yup.string().concat(startTimeCannotBeInPastTest).required("Start time is required")
523
536
  });
537
+ var siteTypesSchema = yup.object({
538
+ label: yup.string().trim().optional(),
539
+ price: yup.number().when("label", {
540
+ is: (label) => !!label,
541
+ then: (schema) => schema.typeError("Site price must be a number").min(0.1, "Site price must be at least 0.1").required("Site price is required").test(
542
+ "no-leading-zeros",
543
+ "",
544
+ noLeadingZeros("Site price", { allowDecimal: true })
545
+ ),
546
+ otherwise: (schema) => schema.notRequired()
547
+ })
548
+ });
524
549
  var dateTimeWithPriceSchema = dateTimeSchema.shape({
525
550
  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(
526
551
  "no-leading-zeros",
527
552
  "",
528
553
  noLeadingZeros("Market price", { allowDecimal: true })
529
- )
554
+ ),
555
+ siteTypes: yup.array().of(siteTypesSchema).nullable().optional()
530
556
  });
531
557
  var locationSchema = yup.object().shape({
532
558
  city: yup.string().required("City is required"),
@@ -545,6 +571,15 @@ var emailSchema = yup.string().email("Invalid email address").required("Email is
545
571
  (value) => typeof value === "string" ? value.toLowerCase() : value
546
572
  );
547
573
  var passwordSchema = yup.string().trim().min(8, "Password must be at least 8 characters long").required("Password is required");
574
+ var socialMediaSchema = yup.object({
575
+ name: yup.mixed().oneOf(Object.values(EnumSocialMedia)).optional(),
576
+ link: yup.string().when("name", {
577
+ is: (name) => !!name,
578
+ // If name has a value
579
+ then: () => normalizedUrlTransform().required("Link is required when name is set").url("Link must be a valid URL"),
580
+ otherwise: (schema) => schema.notRequired()
581
+ })
582
+ });
548
583
  var globalResourceSchema = yup.object().shape({
549
584
  active: yup.boolean().required("Active is required"),
550
585
  cover: yup.object({
@@ -553,7 +588,8 @@ var globalResourceSchema = yup.object().shape({
553
588
  }),
554
589
  description: yup.string().trim().min(3).required("Description is required"),
555
590
  name: yup.string().trim().min(3).required("Name is required"),
556
- region: yup.string().required("Region is required")
591
+ region: yup.string().required("Region is required"),
592
+ socialMedia: yup.array().of(socialMediaSchema).nullable().optional()
557
593
  });
558
594
 
559
595
  // src/yupSchema/market.ts
@@ -582,9 +618,7 @@ var paymentTargetSchema = yup2.object({
582
618
  }),
583
619
  link: yup2.string().when("paymentMethod", {
584
620
  is: (val) => val !== "bank_transfer" /* BANK_TRANSFER */,
585
- then: (schema) => schema.trim().url("Link must be a valid URL").required("Link is required for PayPal/Stripe").transform(
586
- (value) => typeof value === "string" ? value.toLowerCase() : value
587
- ),
621
+ then: () => normalizedUrlTransform().url("Link must be a valid URL").required("Link is required for PayPal/Stripe"),
588
622
  otherwise: (schema) => schema.notRequired()
589
623
  })
590
624
  });
@@ -594,22 +628,6 @@ var marketInfoSchema = yup2.object().shape({
594
628
  marketId: yup2.string().trim().required("Market ID is required"),
595
629
  packInTime: yup2.number().typeError("Pack in time must be a number").min(1, "Pack in time must be at least 1").required("Pack in time is required").test("no-leading-zeros", "", noLeadingZeros("Pack in time")),
596
630
  packOutTime: yup2.number().typeError("Pack out time must be a number").min(1, "Pack out time must be at least 1").required("Pack out time is required").test("no-leading-zeros", "", noLeadingZeros("Pack out time")),
597
- /* requirements: yup
598
- .array()
599
- .of(
600
- yup.object({
601
- category: yup
602
- .mixed<
603
- "Food Safety" | "Environment" | "Operations" | "Legal & Safety"
604
- >()
605
- .oneOf(["Food Safety", "Environment", "Operations", "Legal & Safety"])
606
- .required("Category is required"),
607
- label: yup.string().trim().required("Label is required"),
608
- value: yup.string().trim().required("Value is required"),
609
- }),
610
- )
611
- .min(1, "At least one requirement is required")
612
- .required("Requirements are required"), */
613
631
  paymentDueHours: yup2.number().typeError("Payment due hours must be a number").min(1, "Payment due hours must be at least 1").required("Payment due hours is required").test("no-leading-zeros", "", noLeadingZeros("Payment due hours")),
614
632
  paymentTarget: yup2.array().of(paymentTargetSchema).min(1, "At least one payment target is required").required("Payment target is required"),
615
633
  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("no-leading-zeros", "", noLeadingZeros("Stall capacity"))
@@ -777,6 +795,7 @@ var defaultMarketInfoFormValues = {
777
795
  endDate: "04-05-2025",
778
796
  endTime: "15:00",
779
797
  marketPrice: 0,
798
+ siteTypes: [],
780
799
  startDate: "04-05-2025",
781
800
  startTime: "09:00"
782
801
  },
@@ -784,6 +803,7 @@ var defaultMarketInfoFormValues = {
784
803
  endDate: "05-05-2025",
785
804
  endTime: "15:00",
786
805
  marketPrice: 0,
806
+ siteTypes: [],
787
807
  startDate: "05-05-2025",
788
808
  startTime: "09:00"
789
809
  }
@@ -1766,6 +1786,10 @@ var MARKET_INFO = import_client8.gql`
1766
1786
  endDate
1767
1787
  endTime
1768
1788
  marketPrice
1789
+ siteTypes {
1790
+ label
1791
+ price
1792
+ }
1769
1793
  startDate
1770
1794
  startTime
1771
1795
  }
@@ -3321,80 +3345,206 @@ var marketPriceByDateFields = [
3321
3345
  }
3322
3346
  ];
3323
3347
  var requirementsOptions = [
3348
+ {
3349
+ category: "Environment",
3350
+ label: "All packaging must be eco-friendly or recyclable where possible.",
3351
+ value: false
3352
+ },
3353
+ {
3354
+ category: "Environment",
3355
+ label: "No single-use plastic bags are to be handed out.",
3356
+ value: false
3357
+ },
3358
+ {
3359
+ category: "Environment",
3360
+ label: "Stall area must be left clean with no trace of activity after pack-down.",
3361
+ value: false
3362
+ },
3363
+ {
3364
+ category: "Environment",
3365
+ label: "No disposal of oils, fats, or chemicals in public drains or on grassed areas.",
3366
+ value: false
3367
+ },
3368
+ {
3369
+ category: "Environment",
3370
+ label: "You must provide bins at your site for rubbish and recycling, and take away all bins including rubbish, to dispose of outside of the town centre.",
3371
+ value: false
3372
+ },
3373
+ {
3374
+ category: "Food Safety",
3375
+ label: "Food must be prepared and stored according to your food regulation.",
3376
+ value: false
3377
+ },
3378
+ {
3379
+ category: "Food Safety",
3380
+ label: "The stallholder must display a current food grade certificate.",
3381
+ value: false
3382
+ },
3383
+ {
3384
+ category: "Food Safety",
3385
+ label: "Only licensed food vendors may sell ready-to-eat food items.",
3386
+ value: false
3387
+ },
3324
3388
  {
3325
3389
  category: "Food Safety",
3326
- label: "The stallholder must display a current food grade certificate",
3327
- value: "food_grade_certificate"
3390
+ label: "Handwashing facilities must be available at your stall if preparing food.",
3391
+ value: false
3328
3392
  },
3329
3393
  {
3330
3394
  category: "Food Safety",
3331
- label: "Food must be prepared and stored according to your food regulation",
3332
- value: "food_preparation_regulations"
3395
+ label: "You must have a food safety plan in place for your stall.",
3396
+ value: false
3397
+ },
3398
+ {
3399
+ category: "Food Safety",
3400
+ label: "Allergens must be clearly listed on packaged and unpackaged food items.",
3401
+ value: false
3333
3402
  },
3334
3403
  {
3335
3404
  category: "Legal & Safety",
3336
- label: "All electrical equipment must be tested and tagged",
3337
- value: "electrical_safety"
3405
+ label: "All stallholders must comply with local council regulations.",
3406
+ value: false
3338
3407
  },
3339
3408
  {
3340
- category: "Operations",
3341
- label: "You must be self-sufficient in all operations",
3342
- value: "self_sufficient_operations"
3409
+ category: "Legal & Safety",
3410
+ label: "No unauthorised subletting of stall space to other vendors.",
3411
+ value: false
3343
3412
  },
3344
3413
  {
3345
- category: "Environment",
3346
- label: "You must provide bins at your site for rubbish and recycling, and take away all bins including rubbish, to dispose of outside of the town centre",
3347
- value: "rubbish_and_recycling_responsibility"
3414
+ category: "Legal & Safety",
3415
+ label: "Gas bottles and fuel containers must be secured and in good condition if applicable.",
3416
+ value: false
3348
3417
  },
3349
3418
  {
3350
3419
  category: "Legal & Safety",
3351
- label: "You must secure your gazebo and equipment to withstand wind or bad weather",
3352
- value: "stall_safety_and_weather_protection"
3420
+ label: "Fire extinguishers must be available for stalls using cooking or heating equipment.",
3421
+ value: false
3353
3422
  },
3354
3423
  {
3355
3424
  category: "Legal & Safety",
3356
- label: "You are responsible for the safety of your setup and any potential hazards",
3357
- value: "stallholder_safety_responsibility"
3425
+ label: "Stallholders must not sell items that are illegal or prohibited by law.",
3426
+ value: false
3358
3427
  },
3359
3428
  {
3360
- category: "Operations",
3361
- label: "Stallholders must arrive and be fully set up by the designated opening time",
3362
- value: "setup_on_time"
3429
+ category: "Legal & Safety",
3430
+ label: "All electrical equipment must be tested and tagged.",
3431
+ value: false
3363
3432
  },
3364
3433
  {
3365
- category: "Operations",
3366
- label: "You may not pack down your stall before the event officially ends",
3367
- value: "no_early_packdown"
3434
+ category: "Legal & Safety",
3435
+ label: "Noise levels must be kept to a minimum unless part of a permitted performance.",
3436
+ value: false
3368
3437
  },
3369
3438
  {
3370
- category: "Environment",
3371
- label: "All packaging must be eco-friendly or recyclable where possible",
3372
- value: "eco_friendly_packaging"
3439
+ category: "Legal & Safety",
3440
+ label: "Pets at the stall must be secured and well-behaved at all times.",
3441
+ value: false
3373
3442
  },
3374
3443
  {
3375
3444
  category: "Legal & Safety",
3376
- label: "Stallholders must hold valid liability insurance where required",
3377
- value: "liability_insurance_required"
3445
+ label: "Cables must be secured and not create tripping hazards.",
3446
+ value: false
3378
3447
  },
3379
3448
  {
3380
- category: "Environment",
3381
- label: "No single-use plastic bags are to be handed out",
3382
- value: "no_single_use_plastics"
3449
+ category: "Legal & Safety",
3450
+ label: "Stalls must not obstruct emergency access routes.",
3451
+ value: false
3383
3452
  },
3384
3453
  {
3385
3454
  category: "Legal & Safety",
3386
- label: "Noise levels must be kept to a minimum unless part of a permitted performance",
3387
- value: "noise_restrictions"
3455
+ label: "First aid kit must be available at the stall for minor injuries.",
3456
+ value: false
3388
3457
  },
3389
3458
  {
3390
- category: "Operations",
3391
- label: "Generators must be quiet and pre-approved by the event organiser",
3392
- value: "generator_policy"
3459
+ category: "Legal & Safety",
3460
+ label: "Stallholders must hold valid liability insurance where required.",
3461
+ value: false
3393
3462
  },
3394
3463
  {
3395
3464
  category: "Legal & Safety",
3396
- label: "Pets at the stall must be secured and well-behaved at all times",
3397
- value: "pets_policy"
3465
+ label: "You must secure your gazebo and equipment to withstand wind or bad weather.",
3466
+ value: false
3467
+ },
3468
+ {
3469
+ category: "Legal & Safety",
3470
+ label: "You are responsible for the safety of your setup and any potential hazards.",
3471
+ value: false
3472
+ },
3473
+ {
3474
+ category: "Operations",
3475
+ label: "Generators must be quiet and pre-approved by the event organiser.",
3476
+ value: false
3477
+ },
3478
+ {
3479
+ category: "Operations",
3480
+ label: "Only approved products or services may be sold \u2014 no last-minute changes.",
3481
+ value: false
3482
+ },
3483
+ {
3484
+ category: "Operations",
3485
+ label: "Stallholders must arrive and be fully set up by the designated opening time.",
3486
+ value: false
3487
+ },
3488
+ {
3489
+ category: "Operations",
3490
+ label: "You may not pack down your stall before the event officially ends.",
3491
+ value: false
3492
+ },
3493
+ {
3494
+ category: "Operations",
3495
+ label: "You must be self-sufficient in all operations.",
3496
+ value: false
3497
+ },
3498
+ {
3499
+ category: "Operations",
3500
+ label: "Stall layout must be kept within your allocated space.",
3501
+ value: false
3502
+ }
3503
+ ];
3504
+ var siteTypeOptions = [
3505
+ {
3506
+ label: "3x3m tent site",
3507
+ price: 0
3508
+ },
3509
+ {
3510
+ label: "2x2m mini stall",
3511
+ price: 0
3512
+ },
3513
+ {
3514
+ label: "1.8m table only",
3515
+ price: 0
3516
+ },
3517
+ {
3518
+ label: "Food truck site",
3519
+ price: 0
3520
+ },
3521
+ {
3522
+ label: "Wall-based vendor",
3523
+ price: 0
3524
+ },
3525
+ {
3526
+ label: "Workshop/seating area",
3527
+ price: 0
3528
+ },
3529
+ {
3530
+ label: "Shared table space",
3531
+ price: 0
3532
+ },
3533
+ {
3534
+ label: "Corner stall",
3535
+ price: 0
3536
+ },
3537
+ {
3538
+ label: "Double stall (6x3m)",
3539
+ price: 0
3540
+ },
3541
+ {
3542
+ label: "Inside hall stall",
3543
+ price: 0
3544
+ },
3545
+ {
3546
+ label: "Outdoor open area",
3547
+ price: 0
3398
3548
  }
3399
3549
  ];
3400
3550
 
@@ -3899,6 +4049,7 @@ var socialMediaFields = socialMedia.map((link) => ({
3899
4049
  marketInfoPaymentTarget,
3900
4050
  marketPriceByDateFields,
3901
4051
  marketStartDateFields,
4052
+ normalizeUrl,
3902
4053
  packagingOptions,
3903
4054
  paymentMethodOptions,
3904
4055
  producedIngOptions,
@@ -3908,6 +4059,7 @@ var socialMediaFields = socialMedia.map((link) => ({
3908
4059
  requestPasswordResetFields,
3909
4060
  requirementsOptions,
3910
4061
  resetPasswordFields,
4062
+ siteTypeOptions,
3911
4063
  socialMediaFields,
3912
4064
  sortDatesByProximity,
3913
4065
  stallholderBasicInfoFields,