@timardex/cluemart-shared 1.0.14 → 1.0.15

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
@@ -9,23 +9,23 @@ var EnumInviteStatus = /* @__PURE__ */ ((EnumInviteStatus2) => {
9
9
  EnumInviteStatus2["ACCEPTED"] = "Accepted";
10
10
  EnumInviteStatus2["COMPLETED"] = "Completed";
11
11
  EnumInviteStatus2["EXPIRED"] = "Expired";
12
- EnumInviteStatus2["NO_STATUS"] = "No Status";
12
+ EnumInviteStatus2["NO_STATUS"] = "No_Status";
13
13
  EnumInviteStatus2["PENDING"] = "Pending";
14
14
  EnumInviteStatus2["REJECTED"] = "Rejected";
15
- EnumInviteStatus2["WAITING"] = "waiting";
15
+ EnumInviteStatus2["WAITING"] = "Waiting";
16
16
  return EnumInviteStatus2;
17
17
  })(EnumInviteStatus || {});
18
18
  var EnumRejectionPolicy = /* @__PURE__ */ ((EnumRejectionPolicy2) => {
19
- EnumRejectionPolicy2["SINGLE_DATE_ALLOWED"] = "Single date allowed";
20
- EnumRejectionPolicy2["MULTI_DATE_ALLOWED"] = "Multi date allowed";
19
+ EnumRejectionPolicy2["SINGLE_DATE_ALLOWED"] = "single_date_allowed";
20
+ EnumRejectionPolicy2["MULTI_DATE_ALLOWED"] = "multi_date_allowed";
21
21
  return EnumRejectionPolicy2;
22
22
  })(EnumRejectionPolicy || {});
23
23
  var EnumPaymentMethod = /* @__PURE__ */ ((EnumPaymentMethod3) => {
24
- EnumPaymentMethod3["CASH"] = "Cash";
25
- EnumPaymentMethod3["EFTPOS"] = "Eftpos";
26
- EnumPaymentMethod3["BANK_TRANSFER"] = "Bank Transfer";
27
- EnumPaymentMethod3["PAYPAL"] = "PayPal";
28
- EnumPaymentMethod3["STRIPE"] = "Stripe";
24
+ EnumPaymentMethod3["CASH"] = "cash";
25
+ EnumPaymentMethod3["EFTPOS"] = "eftpos";
26
+ EnumPaymentMethod3["BANK_TRANSFER"] = "bank_transfer";
27
+ EnumPaymentMethod3["PAYPAL"] = "paypal";
28
+ EnumPaymentMethod3["STRIPE"] = "stripe";
29
29
  return EnumPaymentMethod3;
30
30
  })(EnumPaymentMethod || {});
31
31
  var EnumResourceType = /* @__PURE__ */ ((EnumResourceType2) => {
@@ -160,8 +160,8 @@ var truncateText = (text, maxLength = 30) => {
160
160
  return text.length > maxLength ? text.substring(0, maxLength) + "..." : text;
161
161
  };
162
162
  var mapArrayToOptions = (items) => items.map((item) => ({
163
- label: item,
164
- value: item
163
+ label: item.replace(/_/g, " "),
164
+ value: item.replace(/\s+/g, "_").toLowerCase()
165
165
  }));
166
166
  var capitalizeFirstLetter = (str) => {
167
167
  return str.split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
@@ -383,6 +383,7 @@ var globalResourceSchema = yup.object().shape({
383
383
 
384
384
  // src/yupSchema/market.ts
385
385
  import * as yup2 from "yup";
386
+ var nzBankAccountRegex = /^\d{2}-\d{4}-\d{7}-\d{2}$/;
386
387
  var marketSchema = globalResourceSchema.shape({
387
388
  dateTime: yup2.array().of(dateTimeSchema).required("DateTime is required"),
388
389
  location: locationSchema,
@@ -395,7 +396,33 @@ var marketSchema = globalResourceSchema.shape({
395
396
  ),
396
397
  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")),
397
398
  paymentMethod: yup2.mixed().oneOf(Object.values(EnumPaymentMethod)).required("Please select a Payment method"),
398
- paymentTarget: yup2.string().trim().required("Payment target is required"),
399
+ paymentTarget: yup2.object().when("paymentMethod", (paymentMethod, schema) => {
400
+ const isBankTransfer = paymentMethod.includes(
401
+ "bank_transfer" /* BANK_TRANSFER */
402
+ );
403
+ if (!isBankTransfer) {
404
+ return schema.shape({
405
+ accountHolderName: yup2.string().notRequired(),
406
+ accountNumber: yup2.string().notRequired(),
407
+ link: yup2.string().trim().required("Link is required for PayPal/Stripe")
408
+ });
409
+ } else if (isBankTransfer) {
410
+ return schema.shape({
411
+ accountHolderName: yup2.string().trim().required("Account holder name is required for bank transfer"),
412
+ accountNumber: yup2.string().trim().required("Account number is required for bank transfer").matches(
413
+ nzBankAccountRegex,
414
+ "Account number must be in format: XX-XXXX-XXXXXXX-XX"
415
+ ),
416
+ link: yup2.string().notRequired()
417
+ });
418
+ } else {
419
+ return schema.shape({
420
+ accountHolderName: yup2.string().notRequired(),
421
+ accountNumber: yup2.string().notRequired(),
422
+ link: yup2.string().notRequired()
423
+ });
424
+ }
425
+ }),
399
426
  rejectionPolicy: yup2.mixed().oneOf(Object.values(EnumRejectionPolicy)).required("Rejection policy is required"),
400
427
  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"))
401
428
  }),
@@ -560,8 +587,12 @@ var defaultMarketFormValues = {
560
587
  applicationDeadlineHours: 0,
561
588
  paymentDueHours: 0,
562
589
  paymentMethod: "",
563
- paymentTarget: "",
564
- rejectionPolicy: "Multi date allowed" /* MULTI_DATE_ALLOWED */,
590
+ paymentTarget: {
591
+ accountHolderName: "",
592
+ accountNumber: "",
593
+ link: ""
594
+ },
595
+ rejectionPolicy: "multi_date_allowed" /* MULTI_DATE_ALLOWED */,
565
596
  stallCapacity: 0
566
597
  },
567
598
  tags: null
@@ -1454,6 +1485,26 @@ var MARKET_LOCATION_FIELDS_FRAGMENT = gql5`
1454
1485
  type
1455
1486
  }
1456
1487
  `;
1488
+ var PAYMENT_TARGET_FIELDS_FRAGMENT = gql5`
1489
+ fragment PaymentTargetFields on PaymentTargetType {
1490
+ accountHolderName
1491
+ accountNumber
1492
+ link
1493
+ }
1494
+ `;
1495
+ var STALL_APPLICATION_INFO_FIELDS_FRAGMENT = gql5`
1496
+ fragment StallApplicationInfoFields on StallApplicationInfoType {
1497
+ applicationDeadlineHours
1498
+ paymentDueHours
1499
+ paymentMethod
1500
+ paymentTarget {
1501
+ ...PaymentTargetFields
1502
+ }
1503
+ rejectionPolicy
1504
+ stallCapacity
1505
+ }
1506
+ ${PAYMENT_TARGET_FIELDS_FRAGMENT}
1507
+ `;
1457
1508
  var MARKET = gql5`
1458
1509
  fragment MarketFields on MarketType {
1459
1510
  _id
@@ -1484,12 +1535,7 @@ var MARKET = gql5`
1484
1535
  region
1485
1536
  relationIds
1486
1537
  stallApplicationInfo {
1487
- applicationDeadlineHours
1488
- paymentDueHours
1489
- paymentMethod
1490
- paymentTarget
1491
- rejectionPolicy
1492
- stallCapacity
1538
+ ...StallApplicationInfoFields
1493
1539
  }
1494
1540
  tags
1495
1541
  updatedAt
@@ -1498,6 +1544,7 @@ var MARKET = gql5`
1498
1544
  ${MARKET_LOCATION_FIELDS_FRAGMENT}
1499
1545
  ${OWNER_FIELDS_FRAGMENT}
1500
1546
  ${RESOURCE_IMAGE_FIELDS_FRAGMENT}
1547
+ ${STALL_APPLICATION_INFO_FIELDS_FRAGMENT}
1501
1548
  `;
1502
1549
  var GET_MARKETS = gql5`
1503
1550
  query getMarkets {
@@ -2808,22 +2855,21 @@ var stallApplicationInfo = [
2808
2855
  placeholder: "Payment Due Hours"
2809
2856
  }
2810
2857
  ];
2811
- var stallApplicationInfoPaymentTarget = {
2812
- helperText: "Payment Target of the Market *",
2813
- isTextArea: true,
2814
- name: "stallApplicationInfo.paymentTarget",
2815
- placeholder: "Payment Target"
2816
- };
2817
- var stallApplicationInfoDropdowns = [
2858
+ var stallApplicationInfoPaymentTarget = [
2859
+ {
2860
+ helperText: "Account holder name *",
2861
+ name: "stallApplicationInfo.paymentTarget.accountHolderName",
2862
+ placeholder: "Account holder name"
2863
+ },
2818
2864
  {
2819
- helperText: "Select payment method *",
2820
- name: "stallApplicationInfo.paymentMethod",
2821
- placeholder: "Choose Payment Method"
2865
+ helperText: "Account number *",
2866
+ name: "stallApplicationInfo.paymentTarget.accountNumber",
2867
+ placeholder: "Account number"
2822
2868
  },
2823
2869
  {
2824
- helperText: "Rejection Policy *",
2825
- name: "stallApplicationInfo.rejectionPolicy",
2826
- placeholder: "Choose Rejection Policy"
2870
+ helperText: "Link to payment target *",
2871
+ name: "stallApplicationInfo.paymentTarget.link",
2872
+ placeholder: "Link to payment target"
2827
2873
  }
2828
2874
  ];
2829
2875
  var marketStartDateFields = [
@@ -3366,7 +3412,6 @@ export {
3366
3412
  resetPasswordSchema,
3367
3413
  sortDatesByProximity,
3368
3414
  stallApplicationInfo,
3369
- stallApplicationInfoDropdowns,
3370
3415
  stallApplicationInfoPaymentTarget,
3371
3416
  stallHolderSchema,
3372
3417
  stallholderApplyFormSchema,