@bash-app/bash-common 30.466.0 → 30.469.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 (62) hide show
  1. package/dist/__tests__/audienceImport.test.js +3 -1
  2. package/dist/__tests__/audienceImport.test.js.map +1 -1
  3. package/dist/__tests__/promoCodeScope.test.js +62 -1
  4. package/dist/__tests__/promoCodeScope.test.js.map +1 -1
  5. package/dist/audienceImport.d.ts +1 -1
  6. package/dist/audienceImport.d.ts.map +1 -1
  7. package/dist/audienceImport.js +1 -0
  8. package/dist/audienceImport.js.map +1 -1
  9. package/dist/extendedSchemas.d.ts +36 -0
  10. package/dist/extendedSchemas.d.ts.map +1 -1
  11. package/dist/extendedSchemas.js +3 -0
  12. package/dist/extendedSchemas.js.map +1 -1
  13. package/dist/index.d.ts +1 -0
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +1 -0
  16. package/dist/index.js.map +1 -1
  17. package/dist/membershipDefinitions.js +2 -2
  18. package/dist/membershipDefinitions.js.map +1 -1
  19. package/dist/promoCodeScope.d.ts +27 -0
  20. package/dist/promoCodeScope.d.ts.map +1 -1
  21. package/dist/promoCodeScope.js +38 -3
  22. package/dist/promoCodeScope.js.map +1 -1
  23. package/dist/utils/__tests__/addressUtils.test.js +3 -0
  24. package/dist/utils/__tests__/addressUtils.test.js.map +1 -1
  25. package/dist/utils/__tests__/crowdSizeValidation.test.js +1 -1
  26. package/dist/utils/__tests__/crowdSizeValidation.test.js.map +1 -1
  27. package/dist/utils/__tests__/eventTaskVolunteerRewardUtils.test.js +6 -0
  28. package/dist/utils/__tests__/eventTaskVolunteerRewardUtils.test.js.map +1 -1
  29. package/dist/utils/addressUtils.d.ts.map +1 -1
  30. package/dist/utils/addressUtils.js +28 -10
  31. package/dist/utils/addressUtils.js.map +1 -1
  32. package/dist/utils/crowdSizeValidation.d.ts.map +1 -1
  33. package/dist/utils/crowdSizeValidation.js +10 -0
  34. package/dist/utils/crowdSizeValidation.js.map +1 -1
  35. package/dist/utils/eventTimezoneIana.d.ts.map +1 -1
  36. package/dist/utils/eventTimezoneIana.js +16 -5
  37. package/dist/utils/eventTimezoneIana.js.map +1 -1
  38. package/dist/utils/service/__tests__/vendorPaymentWays.test.d.ts +2 -0
  39. package/dist/utils/service/__tests__/vendorPaymentWays.test.d.ts.map +1 -0
  40. package/dist/utils/service/__tests__/vendorPaymentWays.test.js +61 -0
  41. package/dist/utils/service/__tests__/vendorPaymentWays.test.js.map +1 -0
  42. package/dist/utils/service/vendorPaymentWays.d.ts +83 -0
  43. package/dist/utils/service/vendorPaymentWays.d.ts.map +1 -0
  44. package/dist/utils/service/vendorPaymentWays.js +306 -0
  45. package/dist/utils/service/vendorPaymentWays.js.map +1 -0
  46. package/package.json +1 -1
  47. package/prisma/schema.prisma +77 -0
  48. package/src/__tests__/audienceImport.test.ts +3 -0
  49. package/src/__tests__/promoCodeScope.test.ts +74 -0
  50. package/src/audienceImport.ts +1 -0
  51. package/src/extendedSchemas.ts +6 -0
  52. package/src/index.ts +1 -0
  53. package/src/membershipDefinitions.ts +2 -2
  54. package/src/promoCodeScope.ts +56 -4
  55. package/src/utils/__tests__/addressUtils.test.ts +6 -0
  56. package/src/utils/__tests__/crowdSizeValidation.test.ts +1 -1
  57. package/src/utils/__tests__/eventTaskVolunteerRewardUtils.test.ts +8 -0
  58. package/src/utils/addressUtils.ts +26 -10
  59. package/src/utils/crowdSizeValidation.ts +14 -0
  60. package/src/utils/eventTimezoneIana.ts +22 -10
  61. package/src/utils/service/__tests__/vendorPaymentWays.test.ts +87 -0
  62. package/src/utils/service/vendorPaymentWays.ts +384 -0
@@ -1075,7 +1075,17 @@ model BashEvent {
1075
1075
  tags String[]
1076
1076
  coverPhoto String?
1077
1077
  dateTimePublished DateTime?
1078
+ /// First Published transition after the wedge cohort shipped. Stays null for older bashes.
1079
+ publishedAt DateTime?
1080
+ /// First audience import that added at least one person to this bash.
1081
+ audienceImportedAt DateTime?
1082
+ audienceImportSource AudienceImportSource?
1083
+ /// First paid, mixed, or BashPoints ticket fulfilled for this bash.
1084
+ firstPaidTicketAt DateTime?
1078
1085
  includedItems String[]
1086
+
1087
+ @@index([publishedAt])
1088
+ @@index([firstPaidTicketAt])
1079
1089
  videoLink String?
1080
1090
  /// Optional mood track URL (YouTube Music preferred; Spotify / Apple Music / SoundCloud also OK).
1081
1091
  moodTrackUrl String?
@@ -1108,6 +1118,13 @@ model BashEvent {
1108
1118
  /// host's BP balance; `BashBpPool` taps a per-bash pool funded by
1109
1119
  /// BashPoints-priced ticket sales before falling back to the host wallet.
1110
1120
  bashPointsPayoutSource BashPointsPayoutSource @default(HostWallet)
1121
+ /// Ways this bash will accept vendor payment. Empty means the host has not
1122
+ /// said yet, and vendor requests keep today's fee dropdown.
1123
+ vendorPaymentWays String[] @default([])
1124
+ /// Booth fee the host lists when `flat` is one of `vendorPaymentWays`.
1125
+ vendorPaymentFlatFeeCents Int?
1126
+ /// Percent of vendor sales (0..100) when `percentage` is one of the ways.
1127
+ vendorPaymentPercentage Int?
1111
1128
  /// When true, attendees may request a refund from the app/email (host approves in Tickets → Refunds). When false, self-serve refund CTAs are hidden.
1112
1129
  allowAttendeeRefundRequests Boolean @default(true)
1113
1130
  /// Free-text cancellation / refund policy shown at checkout and on the guest's ticket.
@@ -1381,6 +1398,7 @@ model BashEvent {
1381
1398
  requireExpenseApproval Boolean @default(false)
1382
1399
 
1383
1400
  associatedBashesReferencingMe AssociatedBash[]
1401
+ loyaltyPerks BashEventLoyaltyPerk[]
1384
1402
  eventStaffAudits EventStaffAudit[]
1385
1403
  comments BashComment[]
1386
1404
  amountOfGuests AmountOfGuests? @relation(fields: [amountOfGuestsId], references: [id], onDelete: Cascade)
@@ -4687,6 +4705,10 @@ model User {
4687
4705
  stripeAccountId String? @unique
4688
4706
  /// Preferred processor for dual-rail onboarding (optional; legacy Stripe fields remain source of truth until fully migrated).
4689
4707
  paymentProvider PaymentProvider @default(STRIPE)
4708
+ /// Saved default for the next bash: ways this host will accept vendor payment.
4709
+ defaultVendorPaymentWays String[] @default([])
4710
+ defaultVendorPaymentFlatFeeCents Int?
4711
+ defaultVendorPaymentPercentage Int?
4690
4712
  isSuperUser Boolean @default(false)
4691
4713
  /// Enterprise: super-users may set event feeHandling to GuestPays/Split for this host.
4692
4714
  allowGuestFeePassThrough Boolean @default(false)
@@ -6645,6 +6667,26 @@ model Vendor {
6645
6667
  permits VendorPermit[]
6646
6668
  preferences VendorPreferences?
6647
6669
  spaceRequirements VendorSpaceRequirements?
6670
+ paymentOptions VendorPaymentOption[]
6671
+ }
6672
+
6673
+ /// One way a vendor will pay a host. A booth fee plus a percent of sales is
6674
+ /// one row (`ways` contains both), not two listings.
6675
+ model VendorPaymentOption {
6676
+ id String @id @default(cuid())
6677
+ vendorId String
6678
+ /// free | flat | hourly | daily | percentage | negotiable. A combo lists more than one.
6679
+ ways String[] @default([])
6680
+ /// Booth, hourly, or daily amount in cents. Null when the option has no cash rate.
6681
+ amountCents Int?
6682
+ /// 0..100 when the option includes a percent of sales.
6683
+ percentage Int?
6684
+ sortOrder Int @default(0)
6685
+ createdAt DateTime @default(now())
6686
+ updatedAt DateTime @updatedAt
6687
+ vendor Vendor @relation(fields: [vendorId], references: [id], onDelete: Cascade)
6688
+
6689
+ @@index([vendorId])
6648
6690
  }
6649
6691
 
6650
6692
  model VendorSpaceRequirements {
@@ -7041,6 +7083,23 @@ model VenueLoyaltyOffer {
7041
7083
  @@index([venueId, enabled])
7042
7084
  }
7043
7085
 
7086
+ /// Host-defined repeat-guest perk for one bash. Shown on the event. Not a venue BashPoints claim.
7087
+ model BashEventLoyaltyPerk {
7088
+ id String @id @default(cuid())
7089
+ bashEventId String
7090
+ title String
7091
+ description String?
7092
+ /// Guests qualify after this many of the host's published bashes. Null = no minimum.
7093
+ minEventsAttended Int?
7094
+ enabled Boolean @default(true)
7095
+ createdAt DateTime @default(now())
7096
+ updatedAt DateTime @updatedAt
7097
+
7098
+ bashEvent BashEvent @relation(fields: [bashEventId], references: [id], onDelete: Cascade)
7099
+
7100
+ @@index([bashEventId, enabled])
7101
+ }
7102
+
7044
7103
  /// Guest claim against a VenueLoyaltyOffer. BashPoints are escrowed at claim time
7045
7104
  /// (when bashPointsCost > 0), credited to the venue owner on redemption, or refunded
7046
7105
  /// to the guest on decline/expire. Every transition writes a BashCreditTransaction
@@ -8842,6 +8901,22 @@ model VendorBookingRequest {
8842
8901
  vendorFee Float?
8843
8902
  feeStructure String
8844
8903
  percentageRate Float?
8904
+ /// Snapshot of the chosen payment option, copied when the vendor accepts.
8905
+ paymentOptionWays String[] @default([])
8906
+ paymentOptionAmountCents Int?
8907
+ paymentOptionPercentage Int?
8908
+ /// ALL_SALES when the chosen option includes a percent of sales.
8909
+ paymentOptionBasis String?
8910
+ paymentOptionSnapshottedAt DateTime?
8911
+ /// Vendor-reported gross booth sales, in cents. Not charged until the host confirms.
8912
+ grossSalesCents Int?
8913
+ salesReportedAt DateTime?
8914
+ salesConfirmedCents Int?
8915
+ salesConfirmedAt DateTime?
8916
+ /// Percent of confirmed sales, minus any booth fee already paid on this option.
8917
+ salesCutCents Int?
8918
+ /// confirmed | marked_paid. Null until the host confirms the sales number.
8919
+ salesCutStatus String?
8845
8920
  eventDescription String
8846
8921
  specialRequests String
8847
8922
  contactPreference String @default("email")
@@ -13926,6 +14001,8 @@ model BashEventPageView {
13926
14001
  bashEventId String
13927
14002
  sessionHash String // hashed IP+UA for dedup
13928
14003
  viewedAt DateTime @default(now())
14004
+ /// 1 for a recorded view. 10 on the 10% anonymous sample so SUM(sampleWeight) estimates views.
14005
+ sampleWeight Int @default(1)
13929
14006
 
13930
14007
  bashEvent BashEvent @relation(fields: [bashEventId], references: [id], onDelete: Cascade)
13931
14008
 
@@ -1,4 +1,5 @@
1
1
  import {
2
+ AUDIENCE_IMPORT_DESTINATIONS,
2
3
  compareBashVsPartifulTicketFees,
3
4
  importGuestDedupeKey,
4
5
  isAudienceImportDestination,
@@ -53,6 +54,8 @@ describe("audienceImport", () => {
53
54
  expect(isAudienceImportSource("Eventbrite")).toBe(true);
54
55
  expect(isAudienceImportSource("Dice")).toBe(false);
55
56
  expect(isAudienceImportDestination("crm")).toBe(true);
57
+ expect(isAudienceImportDestination("invite")).toBe(true);
58
+ expect(AUDIENCE_IMPORT_DESTINATIONS).toContain("invite");
56
59
  expect(isAudienceImportDestination("sms")).toBe(false);
57
60
  });
58
61
  });
@@ -5,6 +5,8 @@ import {
5
5
  promoCodeBashEventId,
6
6
  promoCodeDiscountKind,
7
7
  promoCodeEligibleTierIds,
8
+ buildBashOfferShareUrl,
9
+ chooseSharerPromoCode,
8
10
  getPromoterShareUrl,
9
11
  promoterCodeInputErrors,
10
12
  } from "../promoCodeScope.js";
@@ -103,6 +105,78 @@ describe("getPromoterShareUrl", () => {
103
105
  });
104
106
  });
105
107
 
108
+ describe("buildBashOfferShareUrl", () => {
109
+ const base = {
110
+ bashEventId: "evt_1",
111
+ slug: "summer-bash",
112
+ origin: "https://bash.community",
113
+ };
114
+
115
+ it("keeps promo, ref, and tierId on the public bash path", () => {
116
+ expect(
117
+ buildBashOfferShareUrl({
118
+ ...base,
119
+ promo: "crew",
120
+ ref: "crew",
121
+ tierId: "tier_ga",
122
+ })
123
+ ).toBe("https://bash.community/bash/evt_1-summer-bash?promo=CREW&ref=crew&tierId=tier_ga");
124
+ });
125
+
126
+ it("includes a bash-wide code with no tierId", () => {
127
+ expect(buildBashOfferShareUrl({ ...base, promo: "crew", ref: "REF1" })).toBe(
128
+ "https://bash.community/bash/evt_1-summer-bash?promo=CREW&ref=REF1"
129
+ );
130
+ });
131
+
132
+ it("omits promo when the code does not apply to the shared tier", () => {
133
+ const codes = [
134
+ {
135
+ id: "b",
136
+ code: "VIPONLY",
137
+ discountType: "PERCENT" as const,
138
+ discountAmountPercentage: 20,
139
+ eligibilityMode: "SELECTED_TIERS" as const,
140
+ eligibleTiers: [{ ticketTierId: "vip" }],
141
+ },
142
+ ];
143
+ expect(chooseSharerPromoCode(codes, "ga")).toBeUndefined();
144
+ expect(
145
+ buildBashOfferShareUrl({
146
+ ...base,
147
+ ref: "GLOBAL",
148
+ tierId: "ga",
149
+ })
150
+ ).toBe("https://bash.community/bash/evt_1-summer-bash?ref=GLOBAL&tierId=ga");
151
+ expect(buildBashOfferShareUrl({ ...base, tierId: "ga" })).not.toContain("promo=");
152
+ });
153
+
154
+ it("picks the newest discount assigned to the sharer", () => {
155
+ const older = {
156
+ id: "a",
157
+ code: "OLD",
158
+ discountType: "PERCENT" as const,
159
+ discountAmountPercentage: 10,
160
+ eligibilityMode: "ALL_TIERS" as const,
161
+ };
162
+ const newer = {
163
+ id: "c",
164
+ code: "NEW",
165
+ discountType: "FIXED_CASH" as const,
166
+ discountAmountInCents: 500,
167
+ eligibilityMode: "ALL_TIERS" as const,
168
+ };
169
+ const tracking = {
170
+ id: "d",
171
+ code: "TRACK",
172
+ discountType: "NONE" as const,
173
+ eligibilityMode: "ALL_TIERS" as const,
174
+ };
175
+ expect(chooseSharerPromoCode([older, tracking, newer])?.code).toBe("NEW");
176
+ expect(chooseSharerPromoCode([tracking])?.code).toBe("TRACK");
177
+ });
178
+ });
179
+
106
180
  describe("promoterCodeInputErrors", () => {
107
181
  const ok = {
108
182
  code: "CREW",
@@ -16,6 +16,7 @@ export const AUDIENCE_IMPORT_SOURCES = [
16
16
  export type AudienceImportSource = (typeof AUDIENCE_IMPORT_SOURCES)[number];
17
17
 
18
18
  export const AUDIENCE_IMPORT_DESTINATIONS = [
19
+ "invite",
19
20
  "admission",
20
21
  "crm",
21
22
  "standingGuestlist",
@@ -792,6 +792,9 @@ export type BashEventExt = Omit<
792
792
  | "postponeResponseDeadline"
793
793
  > & {
794
794
  icebreakerPrompt: string | null;
795
+ vanityPaths?: ReadonlyArray<
796
+ Pick<import("@prisma/client").EventVanityPath, "segment" | "status">
797
+ > | null;
795
798
  /** Free-text cancellation / refund policy shown at checkout and on tickets. */
796
799
  cancellationPolicy: string | null;
797
800
  /** When true (default), cancelling auto-refunds paid ticket holders. */
@@ -1053,6 +1056,9 @@ export const VENDOR_DATA_TO_INCLUDE = {
1053
1056
  spaceRequirements: true,
1054
1057
  insurance: true,
1055
1058
  permits: true,
1059
+ paymentOptions: {
1060
+ orderBy: { sortOrder: "asc" as const },
1061
+ },
1056
1062
  preferences: {
1057
1063
  include: {
1058
1064
  socialMediaExpectations: true,
package/src/index.ts CHANGED
@@ -427,6 +427,7 @@ export * from "./utils/service/partnerRevenueShareOptIn.js";
427
427
  export * from "./utils/service/partnerDealflow.js";
428
428
  export * from "./utils/service/serviceListingDealPreferences.js";
429
429
  export * from "./utils/service/offerAllowListUtils.js";
430
+ export * from "./utils/service/vendorPaymentWays.js";
430
431
  export * from "./utils/service/offerComparisonUtils.js";
431
432
  export * from "./utils/service/unifiedPricingResolver.js";
432
433
  export * from "./utils/service/defaultOfferAmountUtils.js";
@@ -736,7 +736,7 @@ export const MEMBERSHIP_LIMITS: Record<MembershipTier, {
736
736
  canCreateEvents: true,
737
737
  minimumTicketPriceCents: null, // No minimum
738
738
  maxEventsPerMonth: -1, // Unlimited
739
- featuredEventsPerMonth: -1, // ✅ Unlimited featured events!
739
+ featuredEventsPerMonth: 5, // 5 free featured events per month
740
740
 
741
741
  // Analytics & Insights
742
742
  analyticsAccess: true,
@@ -1036,7 +1036,7 @@ export const MEMBERSHIP_TIER_INFO: Record<MembershipTier, MembershipTierInfo> =
1036
1036
  'VIP concierge & brand manager access'
1037
1037
  ],
1038
1038
  limits: {
1039
- featuredEventsPerMonth: -1,
1039
+ featuredEventsPerMonth: 5,
1040
1040
  analyticsAccess: true,
1041
1041
  vendorDirectoryAccess: true,
1042
1042
  prioritySupport: true,
@@ -141,21 +141,73 @@ export function promoRejectMessageFromPublicStatus(
141
141
  : PROMO_CODE_REJECT_MESSAGES.invalid;
142
142
  }
143
143
 
144
- export function getPromoterShareUrl(args: {
144
+ export type BashOfferShareCode = PromoScopeFields & {
145
+ id: string;
146
+ code: string;
147
+ disabledAt?: Date | string | null;
148
+ };
149
+
150
+ /**
151
+ * The sharer's own code for this link. Prefer a discount assigned to them,
152
+ * newest id first. A tracking-only code is returned when nothing discounts.
153
+ */
154
+ export function chooseSharerPromoCode<T extends BashOfferShareCode>(
155
+ codes: readonly T[],
156
+ tierId?: string | null
157
+ ): T | undefined {
158
+ const active = codes.filter((code) => !code.disabledAt && code.code.trim());
159
+ const applicable = tierId
160
+ ? active.filter((code) => promoCodeAppliesToTier(code, tierId))
161
+ : active;
162
+ const discounted = applicable.filter((code) => promoCodeDiscountKind(code) !== "NONE");
163
+ const pool = discounted.length > 0 ? discounted : applicable;
164
+ return [...pool].sort((a, b) => (a.id < b.id ? 1 : a.id > b.id ? -1 : 0))[0];
165
+ }
166
+
167
+ /**
168
+ * Public bash path plus the offer query. `promo` only when there is a code,
169
+ * `ref` for promoter or referral attribution, `tierId` when one tier is shared.
170
+ */
171
+ export function buildBashOfferShareUrl(args: {
145
172
  bashEventId: string;
146
173
  slug?: string | null;
147
174
  vanityPaths?: ReadonlyArray<{ segment: string; status: string }> | null;
148
- code: string;
149
175
  /** Absolute origin, e.g. "https://bash.community". Omit for a relative path. */
150
176
  origin?: string;
177
+ promo?: string | null;
178
+ ref?: string | null;
179
+ tierId?: string | null;
151
180
  }): string {
152
181
  const active = args.vanityPaths?.find((v) => v.status === "Active" && v.segment.trim());
153
182
  const path = active
154
183
  ? `/bash/${encodeURIComponent(active.segment.trim().toLowerCase())}`
155
184
  : getPublicBashDetailPath(args.bashEventId, args.slug);
156
- const query = `?promo=${encodeURIComponent(args.code.trim().toUpperCase())}`;
185
+ const parts: string[] = [];
186
+ const promo = args.promo?.trim();
187
+ const ref = args.ref?.trim();
188
+ const tierId = args.tierId?.trim();
189
+ if (promo) parts.push(`promo=${encodeURIComponent(promo.toUpperCase())}`);
190
+ if (ref) parts.push(`ref=${encodeURIComponent(ref)}`);
191
+ if (tierId) parts.push(`tierId=${encodeURIComponent(tierId)}`);
157
192
  const origin = args.origin?.replace(/\/$/, "") ?? "";
158
- return `${origin}${path}${query}`;
193
+ return parts.length > 0 ? `${origin}${path}?${parts.join("&")}` : `${origin}${path}`;
194
+ }
195
+
196
+ export function getPromoterShareUrl(args: {
197
+ bashEventId: string;
198
+ slug?: string | null;
199
+ vanityPaths?: ReadonlyArray<{ segment: string; status: string }> | null;
200
+ code: string;
201
+ /** Absolute origin, e.g. "https://bash.community". Omit for a relative path. */
202
+ origin?: string;
203
+ }): string {
204
+ return buildBashOfferShareUrl({
205
+ bashEventId: args.bashEventId,
206
+ slug: args.slug,
207
+ vanityPaths: args.vanityPaths,
208
+ origin: args.origin,
209
+ promo: args.code,
210
+ });
159
211
  }
160
212
 
161
213
  /** Host form payload for a bash-level promoter or promo code. */
@@ -110,6 +110,12 @@ describe("addressUtils", () => {
110
110
  test("skips empty parts", () => {
111
111
  expect(formatLocalityForCardDisplay("Austin", null, "USA")).toBe("Austin, USA");
112
112
  });
113
+
114
+ test("drops a city name that was stored twice", () => {
115
+ expect(formatLocalityForCardDisplay("Salt Lake City, Salt Lake City", "UT")).toBe(
116
+ "Salt Lake City, UT"
117
+ );
118
+ });
113
119
  });
114
120
 
115
121
  describe("databaseAddressStringToOneLineString", () => {
@@ -1,3 +1,3 @@
1
1
  import { validateCrowdSize } from "../crowdSizeValidation";
2
- it.each([{ minimum: -5 }, { expected: 1e22 }, { expected: 999999999 }, { expected: 100001 }, { ideal: 2.5 }, { minimum: 10, maximum: 5 }, { expected: 25, maximum: 10 }, { maximum: 0 }])("rejects invalid crowd sizes: %j", values => expect(validateCrowdSize(values)).not.toBeNull());
2
+ it.each([{ minimum: -5 }, { expected: 1e22 }, { expected: 999999999 }, { expected: 100001 }, { ideal: 2.5 }, { minimum: 10, maximum: 5 }, { expected: 25, maximum: 10 }, { maximum: 0 }, { minimum: 30, expected: 25 }, { minimum: 40, ideal: 20 }])("rejects invalid crowd sizes: %j", values => expect(validateCrowdSize(values)).not.toBeNull());
3
3
  it.each([{}, { minimum: null, maximum: null }, { minimum: 10, expected: 25, ideal: 35, maximum: 35 }, { expected: 100000 }])("accepts optional or consistent counts: %j", values => expect(validateCrowdSize(values)).toBeNull());
@@ -39,12 +39,20 @@ describe("eventTaskVolunteerRewardUtils", () => {
39
39
  { id: "t2", neededCount: 1, bashPointsReward: 50 },
40
40
  ];
41
41
  expect(totalEventTaskBashPointsOffer({ tasks })).toBe(70);
42
+ // 2 * 10 + 1 * 80 = 100. Matching the balance is allowed; one point over is not.
42
43
  expect(
43
44
  validateHostTaskBashPointsOffer({
44
45
  hostBashPointsBalance: 100,
45
46
  tasks,
46
47
  patch: { taskId: "t2", bashPointsReward: 80 },
47
48
  }).ok
49
+ ).toBe(true);
50
+ expect(
51
+ validateHostTaskBashPointsOffer({
52
+ hostBashPointsBalance: 100,
53
+ tasks,
54
+ patch: { taskId: "t2", bashPointsReward: 81 },
55
+ }).ok
48
56
  ).toBe(false);
49
57
  expect(
50
58
  validateHostTaskBashPointsOffer({
@@ -111,6 +111,24 @@ export function databaseAddressStringToAddressValues(addressString: string | und
111
111
  }
112
112
 
113
113
 
114
+ /** Drop repeated place names ("Salt Lake City, Salt Lake City, UT"). */
115
+ function uniqueAddressParts(parts: Array<string | null | undefined>): string[] {
116
+ const out: string[] = [];
117
+ const seen = new Set<string>();
118
+ for (const part of parts) {
119
+ if (!part) continue;
120
+ for (const segment of part.split(",")) {
121
+ const trimmed = segment.trim();
122
+ if (!trimmed || trimmed === "undefined") continue;
123
+ const key = trimmed.toLowerCase();
124
+ if (seen.has(key)) continue;
125
+ seen.add(key);
126
+ out.push(trimmed);
127
+ }
128
+ }
129
+ return out;
130
+ }
131
+
114
132
  /**
115
133
  * City, state/region, and country for compact card/list UIs (no street or full formatted address).
116
134
  * Detail pages should use {@link databaseAddressStringToOneLineString} or full address fields.
@@ -120,10 +138,7 @@ export function formatLocalityForCardDisplay(
120
138
  state?: string | null,
121
139
  country?: string | null
122
140
  ): string {
123
- const parts = [city?.trim(), state?.trim(), country?.trim()].filter(
124
- (p): p is string => !!p && p.length > 0
125
- );
126
- return parts.join(", ");
141
+ return uniqueAddressParts([city, state, country]).join(", ");
127
142
  }
128
143
 
129
144
  export function databaseAddressStringToOneLineString(addressString: string | undefined | null): string {
@@ -142,13 +157,14 @@ export function databaseAddressStringToOneLineString(addressString: string | und
142
157
  return address.place.trim();
143
158
  }
144
159
 
145
- let addressArr = address.place ? [address.place] : [];
146
-
147
- if (address.street && address.street !== 'undefined') addressArr.push(address.street);
148
- if (address.city && address.city !== 'undefined') addressArr.push(address.city);
149
- if (address.state && address.state !== 'undefined') addressArr.push(address.state);
160
+ const addressArr = uniqueAddressParts([
161
+ address.place,
162
+ address.street,
163
+ address.city,
164
+ address.state,
165
+ ]);
150
166
 
151
- const addressStr = addressArr.filter((str) => !!str && str !== 'undefined').join(', ');
167
+ const addressStr = addressArr.join(', ');
152
168
 
153
169
  return address.zipCode && address.zipCode !== 'undefined'
154
170
  ? `${addressStr} ${address.zipCode}`
@@ -17,5 +17,19 @@ export function validateCrowdSize(values: CrowdSizeValues): string | null {
17
17
  if (value != null && value > values.maximum) return `Maximum capacity cannot be lower than ${key} guests.`;
18
18
  }
19
19
  }
20
+ if (
21
+ values.minimum != null &&
22
+ values.expected != null &&
23
+ values.minimum > values.expected
24
+ ) {
25
+ return "Minimum guests cannot be higher than expected guests.";
26
+ }
27
+ if (
28
+ values.minimum != null &&
29
+ values.ideal != null &&
30
+ values.minimum > values.ideal
31
+ ) {
32
+ return "Minimum guests cannot be higher than ideal guests.";
33
+ }
20
34
  return null;
21
35
  }
@@ -338,6 +338,7 @@ function eventHasLocationHint(args: InferEventTimezoneArgs): boolean {
338
338
  return !!(
339
339
  args.location?.trim() ||
340
340
  args.city?.trim() ||
341
+ args.state?.trim() ||
341
342
  (args.latitude != null && args.longitude != null)
342
343
  );
343
344
  }
@@ -384,17 +385,28 @@ export function formatEventTimezoneAbbrev(
384
385
  const zoned = dt.setZone(zone);
385
386
  if (!zoned.isValid) return "";
386
387
 
387
- const short = zoned.toFormat("z");
388
- if (short && short !== "GMT" && short !== "UTC") return short;
388
+ // Luxon 3: "z" is the IANA id. "ZZZZ" is the short name (EST, MDT).
389
+ const named = zoned.toFormat("ZZZZ");
390
+ if (isShortZoneLabel(named, zone)) return named;
389
391
 
390
- return (
391
- new Intl.DateTimeFormat("en-US", {
392
- timeZone: zone,
393
- timeZoneName: "short",
394
- })
395
- .formatToParts(zoned.toJSDate())
396
- .find((part) => part.type === "timeZoneName")?.value ?? short
397
- );
392
+ const fromIntl = new Intl.DateTimeFormat("en-US", {
393
+ timeZone: zone,
394
+ timeZoneName: "short",
395
+ })
396
+ .formatToParts(zoned.toJSDate())
397
+ .find((part) => part.type === "timeZoneName")?.value;
398
+
399
+ if (isShortZoneLabel(fromIntl, zone)) return fromIntl;
400
+ return "";
401
+ }
402
+
403
+ function isShortZoneLabel(
404
+ label: string | null | undefined,
405
+ zone: string
406
+ ): label is string {
407
+ if (!label || label === "GMT" || label.includes("/")) return false;
408
+ // "z" used to return the IANA id. Keep that out of the UI, but UTC is a real label.
409
+ return label !== zone || zone === "UTC";
398
410
  }
399
411
 
400
412
  /** Curated list for the event wizard timezone picker (full IANA set is huge). */
@@ -0,0 +1,87 @@
1
+ import { describe, expect, it } from "@jest/globals";
2
+
3
+ import {
4
+ computeSalesCut,
5
+ overlappingPaymentOptions,
6
+ snapshotFromBookingRequest,
7
+ vendorFitsHostPayment,
8
+ } from "../vendorPaymentWays.js";
9
+
10
+ const flat = { ways: ["flat"], amountCents: 20000 };
11
+ const percent = { ways: ["percentage"], percentage: 10 };
12
+ const both = { ways: ["flat", "percentage"], amountCents: 10000, percentage: 10 };
13
+
14
+ describe("vendor payment overlap", () => {
15
+ it("offers both flat and percent when the host accepts both", () => {
16
+ const overlap = overlappingPaymentOptions(
17
+ [flat, percent, both],
18
+ ["flat", "percentage"]
19
+ );
20
+ expect(overlap).toEqual([flat, percent, both]);
21
+ });
22
+
23
+ it("does not match a percent-only vendor to a flat-only bash", () => {
24
+ expect(vendorFitsHostPayment([percent], ["flat"])).toBe(false);
25
+ expect(overlappingPaymentOptions([percent], ["flat"])).toEqual([]);
26
+ });
27
+
28
+ it("keeps today's requests when the host has not listed ways", () => {
29
+ expect(overlappingPaymentOptions([percent], [])).toBeNull();
30
+ expect(vendorFitsHostPayment([percent], [])).toBe(true);
31
+ });
32
+
33
+ it("hides a booth-plus-percent option when the host only accepts a percent", () => {
34
+ expect(overlappingPaymentOptions([both, percent], ["percentage"])).toEqual([
35
+ percent,
36
+ ]);
37
+ });
38
+ });
39
+
40
+ describe("sales cut", () => {
41
+ it("takes 10 percent of $1,000", () => {
42
+ expect(
43
+ computeSalesCut({
44
+ confirmedSalesCents: 100_000,
45
+ percentage: 10,
46
+ boothFeeAlreadyPaidCents: 0,
47
+ })
48
+ ).toEqual({ owedCents: 10_000, remainingCents: 10_000 });
49
+ });
50
+
51
+ it("reduces what is still due by a booth fee already paid", () => {
52
+ expect(
53
+ computeSalesCut({
54
+ confirmedSalesCents: 100_000,
55
+ percentage: 10,
56
+ boothFeeAlreadyPaidCents: 4_000,
57
+ })
58
+ ).toEqual({ owedCents: 10_000, remainingCents: 6_000 });
59
+ });
60
+
61
+ it("owes nothing on a $0 night", () => {
62
+ expect(
63
+ computeSalesCut({
64
+ confirmedSalesCents: 0,
65
+ percentage: 10,
66
+ boothFeeAlreadyPaidCents: 0,
67
+ })
68
+ ).toEqual({ owedCents: 0, remainingCents: 0 });
69
+ });
70
+
71
+ it("does not charge before the host confirms", () => {
72
+ expect(
73
+ computeSalesCut({ confirmedSalesCents: null, percentage: 10 })
74
+ ).toBeNull();
75
+ });
76
+
77
+ it("keeps the percent from the booking after the listing changes", () => {
78
+ const booked = snapshotFromBookingRequest({
79
+ feeStructure: "percentage",
80
+ percentageRate: 10,
81
+ });
82
+ const listingPercentAfterward = 25;
83
+ expect(booked.paymentOptionPercentage).toBe(10);
84
+ expect(booked.paymentOptionBasis).toBe("ALL_SALES");
85
+ expect(booked.paymentOptionPercentage).not.toBe(listingPercentAfterward);
86
+ });
87
+ });