@bash-app/bash-common 30.466.0 → 30.467.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 (46) hide show
  1. package/dist/extendedSchemas.d.ts +35 -0
  2. package/dist/extendedSchemas.d.ts.map +1 -1
  3. package/dist/extendedSchemas.js +3 -0
  4. package/dist/extendedSchemas.js.map +1 -1
  5. package/dist/index.d.ts +1 -0
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +1 -0
  8. package/dist/index.js.map +1 -1
  9. package/dist/membershipDefinitions.js +2 -2
  10. package/dist/membershipDefinitions.js.map +1 -1
  11. package/dist/utils/__tests__/addressUtils.test.js +3 -0
  12. package/dist/utils/__tests__/addressUtils.test.js.map +1 -1
  13. package/dist/utils/__tests__/crowdSizeValidation.test.js +1 -1
  14. package/dist/utils/__tests__/crowdSizeValidation.test.js.map +1 -1
  15. package/dist/utils/__tests__/eventTaskVolunteerRewardUtils.test.js +6 -0
  16. package/dist/utils/__tests__/eventTaskVolunteerRewardUtils.test.js.map +1 -1
  17. package/dist/utils/addressUtils.d.ts.map +1 -1
  18. package/dist/utils/addressUtils.js +28 -10
  19. package/dist/utils/addressUtils.js.map +1 -1
  20. package/dist/utils/crowdSizeValidation.d.ts.map +1 -1
  21. package/dist/utils/crowdSizeValidation.js +10 -0
  22. package/dist/utils/crowdSizeValidation.js.map +1 -1
  23. package/dist/utils/eventTimezoneIana.d.ts.map +1 -1
  24. package/dist/utils/eventTimezoneIana.js +16 -5
  25. package/dist/utils/eventTimezoneIana.js.map +1 -1
  26. package/dist/utils/service/__tests__/vendorPaymentWays.test.d.ts +2 -0
  27. package/dist/utils/service/__tests__/vendorPaymentWays.test.d.ts.map +1 -0
  28. package/dist/utils/service/__tests__/vendorPaymentWays.test.js +61 -0
  29. package/dist/utils/service/__tests__/vendorPaymentWays.test.js.map +1 -0
  30. package/dist/utils/service/vendorPaymentWays.d.ts +83 -0
  31. package/dist/utils/service/vendorPaymentWays.d.ts.map +1 -0
  32. package/dist/utils/service/vendorPaymentWays.js +306 -0
  33. package/dist/utils/service/vendorPaymentWays.js.map +1 -0
  34. package/package.json +1 -1
  35. package/prisma/schema.prisma +47 -0
  36. package/src/extendedSchemas.ts +3 -0
  37. package/src/index.ts +1 -0
  38. package/src/membershipDefinitions.ts +2 -2
  39. package/src/utils/__tests__/addressUtils.test.ts +6 -0
  40. package/src/utils/__tests__/crowdSizeValidation.test.ts +1 -1
  41. package/src/utils/__tests__/eventTaskVolunteerRewardUtils.test.ts +8 -0
  42. package/src/utils/addressUtils.ts +26 -10
  43. package/src/utils/crowdSizeValidation.ts +14 -0
  44. package/src/utils/eventTimezoneIana.ts +22 -10
  45. package/src/utils/service/__tests__/vendorPaymentWays.test.ts +87 -0
  46. package/src/utils/service/vendorPaymentWays.ts +384 -0
@@ -0,0 +1,306 @@
1
+ /**
2
+ * Host and vendor payment ways, and the cut of booth sales.
3
+ * A combined booth fee plus a percent is one option (`ways` lists both).
4
+ */
5
+ export const VENDOR_PAYMENT_WAYS = [
6
+ "free",
7
+ "flat",
8
+ "hourly",
9
+ "daily",
10
+ "percentage",
11
+ "negotiable",
12
+ ];
13
+ export const VENDOR_PAYMENT_WAY_LABEL = {
14
+ free: "Free space",
15
+ flat: "Flat booth fee",
16
+ hourly: "Hourly",
17
+ daily: "Daily",
18
+ percentage: "Percentage of sales",
19
+ negotiable: "Open to negotiation",
20
+ };
21
+ const WAY_SET = new Set(VENDOR_PAYMENT_WAYS);
22
+ export function normalizeWays(raw) {
23
+ const list = Array.isArray(raw) ? raw : [];
24
+ const seen = new Set();
25
+ const out = [];
26
+ for (const item of list) {
27
+ if (typeof item !== "string" || !WAY_SET.has(item))
28
+ continue;
29
+ const way = item;
30
+ if (seen.has(way))
31
+ continue;
32
+ seen.add(way);
33
+ out.push(way);
34
+ }
35
+ return out;
36
+ }
37
+ export function clampPercent(raw) {
38
+ if (raw == null || raw === "")
39
+ return null;
40
+ const n = typeof raw === "number" ? raw : Number(raw);
41
+ if (!Number.isFinite(n))
42
+ return null;
43
+ return Math.min(100, Math.max(0, Math.round(n)));
44
+ }
45
+ export function clampCents(raw) {
46
+ if (raw == null || raw === "")
47
+ return null;
48
+ const n = typeof raw === "number" ? raw : Number(raw);
49
+ if (!Number.isFinite(n) || n < 0)
50
+ return null;
51
+ return Math.round(n);
52
+ }
53
+ export function sanitizeHostVendorPayment(input) {
54
+ const ways = normalizeWays(input.ways);
55
+ return {
56
+ ways,
57
+ flatFeeCents: ways.includes("flat") ? clampCents(input.flatFeeCents) : null,
58
+ percentage: ways.includes("percentage")
59
+ ? clampPercent(input.percentage)
60
+ : null,
61
+ };
62
+ }
63
+ export function sanitizePaymentOption(input) {
64
+ if (!input || typeof input !== "object")
65
+ return null;
66
+ const row = input;
67
+ const ways = normalizeWays(row.ways);
68
+ if (ways.length === 0)
69
+ return null;
70
+ const needsAmount = ways.includes("flat") || ways.includes("hourly") || ways.includes("daily");
71
+ const needsPercent = ways.includes("percentage");
72
+ return {
73
+ ways,
74
+ amountCents: needsAmount ? clampCents(row.amountCents) : null,
75
+ percentage: needsPercent ? clampPercent(row.percentage) : null,
76
+ };
77
+ }
78
+ export function sanitizePaymentOptions(raw) {
79
+ if (!Array.isArray(raw))
80
+ return [];
81
+ return raw
82
+ .map((row) => sanitizePaymentOption(row))
83
+ .filter((row) => row != null);
84
+ }
85
+ function sameWays(a, b) {
86
+ const left = normalizeWays(a).slice().sort();
87
+ const right = normalizeWays(b).slice().sort();
88
+ if (left.length !== right.length)
89
+ return false;
90
+ return left.every((way, i) => way === right[i]);
91
+ }
92
+ export function optionMatchesHost(option, hostWays) {
93
+ const ways = normalizeWays(option.ways);
94
+ const host = normalizeWays(hostWays);
95
+ if (ways.length === 0 || host.length === 0)
96
+ return false;
97
+ return ways.every((way) => host.includes(way));
98
+ }
99
+ /**
100
+ * Null means the host has not listed ways yet, so callers keep today's
101
+ * dropdown. An empty array means they listed ways and nothing overlaps.
102
+ */
103
+ export function overlappingPaymentOptions(options, hostWays) {
104
+ const host = normalizeWays(hostWays);
105
+ if (host.length === 0)
106
+ return null;
107
+ return options.filter((option) => optionMatchesHost(option, host));
108
+ }
109
+ export function vendorFitsHostPayment(options, hostWays) {
110
+ const overlap = overlappingPaymentOptions(options, hostWays);
111
+ if (overlap === null)
112
+ return true;
113
+ return overlap.length > 0;
114
+ }
115
+ export function derivePaymentOptionsFromListing(listing) {
116
+ const options = [];
117
+ const add = (option) => {
118
+ const cleaned = sanitizePaymentOption(option);
119
+ if (!cleaned)
120
+ return;
121
+ const exists = options.some((current) => sameWays(current.ways, cleaned.ways) &&
122
+ current.amountCents === cleaned.amountCents &&
123
+ current.percentage === cleaned.percentage);
124
+ if (!exists)
125
+ options.push(cleaned);
126
+ };
127
+ if ((listing.preferredBoothFeeCents ?? 0) > 0) {
128
+ add({ ways: ["flat"], amountCents: listing.preferredBoothFeeCents });
129
+ }
130
+ const base = listing.baseRateCents ?? null;
131
+ switch (listing.pricingModel) {
132
+ case "FLAT_FEE":
133
+ case "PER_ATTENDEE":
134
+ if ((base ?? 0) > 0)
135
+ add({ ways: ["flat"], amountCents: base });
136
+ break;
137
+ case "HOURLY":
138
+ if ((base ?? 0) > 0)
139
+ add({ ways: ["hourly"], amountCents: base });
140
+ break;
141
+ case "PER_DAY":
142
+ if ((base ?? 0) > 0)
143
+ add({ ways: ["daily"], amountCents: base });
144
+ break;
145
+ case "PRODUCT_SALES_PERCENTAGE":
146
+ add({
147
+ ways: ["percentage"],
148
+ percentage: base != null && base <= 100 ? base : null,
149
+ });
150
+ break;
151
+ case "TIERED":
152
+ case "CUSTOM":
153
+ add({ ways: ["negotiable"] });
154
+ break;
155
+ default:
156
+ break;
157
+ }
158
+ if ((listing.flatRateCents ?? 0) > 0) {
159
+ add({ ways: ["flat"], amountCents: listing.flatRateCents });
160
+ }
161
+ if ((listing.hourlyRateCents ?? 0) > 0) {
162
+ add({ ways: ["hourly"], amountCents: listing.hourlyRateCents });
163
+ }
164
+ if ((listing.dailyRateCents ?? 0) > 0) {
165
+ add({ ways: ["daily"], amountCents: listing.dailyRateCents });
166
+ }
167
+ const hasUnit = options.some((option) => {
168
+ const ways = normalizeWays(option.ways);
169
+ return (ways.includes("flat") ||
170
+ ways.includes("hourly") ||
171
+ ways.includes("daily") ||
172
+ ways.includes("percentage") ||
173
+ ways.includes("free"));
174
+ });
175
+ if (!hasUnit)
176
+ add({ ways: ["negotiable"] });
177
+ return options;
178
+ }
179
+ export function effectivePaymentOptions(explicit, listing) {
180
+ const cleaned = sanitizePaymentOptions(explicit ?? []);
181
+ if (cleaned.length > 0)
182
+ return cleaned;
183
+ return derivePaymentOptionsFromListing(listing);
184
+ }
185
+ export function feeStructureToWays(feeStructure, hasAmount) {
186
+ switch (feeStructure) {
187
+ case "free":
188
+ return ["free"];
189
+ case "flat":
190
+ case "fixed":
191
+ return ["flat"];
192
+ case "hourly":
193
+ return ["hourly"];
194
+ case "daily":
195
+ return ["daily"];
196
+ case "negotiable":
197
+ return ["negotiable"];
198
+ case "flat_plus_percentage":
199
+ return ["flat", "percentage"];
200
+ case "percentage":
201
+ return hasAmount ? ["flat", "percentage"] : ["percentage"];
202
+ default:
203
+ return [];
204
+ }
205
+ }
206
+ export function waysToFeeStructure(ways) {
207
+ const normalized = normalizeWays(ways);
208
+ if (normalized.includes("flat") && normalized.includes("percentage")) {
209
+ return "flat_plus_percentage";
210
+ }
211
+ if (normalized.length === 1)
212
+ return normalized[0];
213
+ return normalized[0] ?? "negotiable";
214
+ }
215
+ export function requestMatchesOverlap(args) {
216
+ const overlap = overlappingPaymentOptions(args.vendorOptions, args.hostWays);
217
+ if (overlap === null)
218
+ return { ok: true };
219
+ const requested = feeStructureToWays(args.feeStructure, args.hasAmount);
220
+ if (requested.length === 0) {
221
+ return {
222
+ ok: false,
223
+ reason: "Choose a way to pay that this bash accepts.",
224
+ };
225
+ }
226
+ const match = overlap.some((option) => sameWays(option.ways, requested));
227
+ if (!match) {
228
+ return {
229
+ ok: false,
230
+ reason: "That way to pay is not one you both accept.",
231
+ };
232
+ }
233
+ return { ok: true };
234
+ }
235
+ export function paymentOptionLabel(option) {
236
+ const ways = normalizeWays(option.ways);
237
+ const dollars = option.amountCents != null
238
+ ? `$${(option.amountCents / 100).toFixed(2)}`
239
+ : null;
240
+ if (ways.includes("flat") && ways.includes("percentage")) {
241
+ const pct = option.percentage ?? 0;
242
+ return dollars
243
+ ? `${dollars} plus ${pct}% of sales`
244
+ : `${pct}% of sales plus a booth fee`;
245
+ }
246
+ if (ways.length === 1 && ways[0] === "percentage") {
247
+ return `${option.percentage ?? 0}% of sales`;
248
+ }
249
+ if (ways.length === 1 && ways[0] === "flat") {
250
+ return dollars ? `${dollars} flat fee` : "Flat booth fee";
251
+ }
252
+ if (ways.length === 1 && ways[0] === "hourly") {
253
+ return dollars ? `${dollars} per hour` : "Hourly";
254
+ }
255
+ if (ways.length === 1 && ways[0] === "daily") {
256
+ return dollars ? `${dollars} per day` : "Daily";
257
+ }
258
+ if (ways.length === 1 && ways[0] === "free")
259
+ return "Free space";
260
+ if (ways.length === 1 && ways[0] === "negotiable")
261
+ return "Open to negotiation";
262
+ return ways.map((way) => VENDOR_PAYMENT_WAY_LABEL[way]).join(" + ");
263
+ }
264
+ export function snapshotFromBookingRequest(request) {
265
+ const hasAmount = request.vendorFee != null && request.vendorFee > 0;
266
+ const ways = feeStructureToWays(request.feeStructure, hasAmount);
267
+ const includesPercent = ways.includes("percentage");
268
+ return {
269
+ paymentOptionWays: ways,
270
+ paymentOptionAmountCents: hasAmount
271
+ ? Math.round(request.vendorFee * 100)
272
+ : null,
273
+ paymentOptionPercentage: includesPercent
274
+ ? clampPercent(request.percentageRate)
275
+ : null,
276
+ paymentOptionBasis: includesPercent ? "ALL_SALES" : null,
277
+ };
278
+ }
279
+ /**
280
+ * Null when sales are not confirmed yet. Nothing is owed until the host
281
+ * confirms the number the vendor reported.
282
+ */
283
+ export function computeSalesCut(input) {
284
+ if (input.confirmedSalesCents == null)
285
+ return null;
286
+ const sales = Math.max(0, Math.round(input.confirmedSalesCents));
287
+ const pct = clampPercent(input.percentage) ?? 0;
288
+ const owedCents = Math.round((sales * pct) / 100);
289
+ const paid = Math.max(0, Math.round(input.boothFeeAlreadyPaidCents ?? 0));
290
+ return {
291
+ owedCents,
292
+ remainingCents: Math.max(0, owedCents - paid),
293
+ };
294
+ }
295
+ export function readHostVendorPayment(source) {
296
+ if (!source || typeof source !== "object") {
297
+ return { ways: [], flatFeeCents: null, percentage: null };
298
+ }
299
+ const row = source;
300
+ return sanitizeHostVendorPayment({
301
+ ways: row.vendorPaymentWays ?? row.ways,
302
+ flatFeeCents: row.vendorPaymentFlatFeeCents ?? row.flatFeeCents,
303
+ percentage: row.vendorPaymentPercentage ?? row.percentage,
304
+ });
305
+ }
306
+ //# sourceMappingURL=vendorPaymentWays.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vendorPaymentWays.js","sourceRoot":"","sources":["../../../src/utils/service/vendorPaymentWays.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,MAAM;IACN,MAAM;IACN,QAAQ;IACR,OAAO;IACP,YAAY;IACZ,YAAY;CACJ,CAAC;AAIX,MAAM,CAAC,MAAM,wBAAwB,GAAqC;IACxE,IAAI,EAAE,YAAY;IAClB,IAAI,EAAE,gBAAgB;IACtB,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,OAAO;IACd,UAAU,EAAE,qBAAqB;IACjC,UAAU,EAAE,qBAAqB;CAClC,CAAC;AA4BF,MAAM,OAAO,GAAG,IAAI,GAAG,CAAS,mBAAmB,CAAC,CAAC;AAErD,MAAM,UAAU,aAAa,CAAC,GAAY;IACxC,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3C,MAAM,IAAI,GAAG,IAAI,GAAG,EAAoB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AAY,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;IAC5D,CAAC;IACD,MAAM,GAAG,GAAG,MAAiC,CAAC;IAC9C,OAAO,yBAAyB,CAAC;QAC/B,IAAI,EAAE,GAAG,CAAC,iBAAiB,IAAI,GAAG,CAAC,IAAI;QACvC,YAAY,EAAE,GAAG,CAAC,yBAAyB,IAAI,GAAG,CAAC,YAAY;QAC/D,UAAU,EAAE,GAAG,CAAC,uBAAuB,IAAI,GAAG,CAAC,UAAU;KAC1D,CAAC,CAAC;AACL,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bash-app/bash-common",
3
- "version": "30.466.0",
3
+ "version": "30.467.0",
4
4
  "description": "Common data and scripts to use on the frontend and backend",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1108,6 +1108,13 @@ model BashEvent {
1108
1108
  /// host's BP balance; `BashBpPool` taps a per-bash pool funded by
1109
1109
  /// BashPoints-priced ticket sales before falling back to the host wallet.
1110
1110
  bashPointsPayoutSource BashPointsPayoutSource @default(HostWallet)
1111
+ /// Ways this bash will accept vendor payment. Empty means the host has not
1112
+ /// said yet, and vendor requests keep today's fee dropdown.
1113
+ vendorPaymentWays String[] @default([])
1114
+ /// Booth fee the host lists when `flat` is one of `vendorPaymentWays`.
1115
+ vendorPaymentFlatFeeCents Int?
1116
+ /// Percent of vendor sales (0..100) when `percentage` is one of the ways.
1117
+ vendorPaymentPercentage Int?
1111
1118
  /// 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
1119
  allowAttendeeRefundRequests Boolean @default(true)
1113
1120
  /// Free-text cancellation / refund policy shown at checkout and on the guest's ticket.
@@ -4687,6 +4694,10 @@ model User {
4687
4694
  stripeAccountId String? @unique
4688
4695
  /// Preferred processor for dual-rail onboarding (optional; legacy Stripe fields remain source of truth until fully migrated).
4689
4696
  paymentProvider PaymentProvider @default(STRIPE)
4697
+ /// Saved default for the next bash: ways this host will accept vendor payment.
4698
+ defaultVendorPaymentWays String[] @default([])
4699
+ defaultVendorPaymentFlatFeeCents Int?
4700
+ defaultVendorPaymentPercentage Int?
4690
4701
  isSuperUser Boolean @default(false)
4691
4702
  /// Enterprise: super-users may set event feeHandling to GuestPays/Split for this host.
4692
4703
  allowGuestFeePassThrough Boolean @default(false)
@@ -6645,6 +6656,26 @@ model Vendor {
6645
6656
  permits VendorPermit[]
6646
6657
  preferences VendorPreferences?
6647
6658
  spaceRequirements VendorSpaceRequirements?
6659
+ paymentOptions VendorPaymentOption[]
6660
+ }
6661
+
6662
+ /// One way a vendor will pay a host. A booth fee plus a percent of sales is
6663
+ /// one row (`ways` contains both), not two listings.
6664
+ model VendorPaymentOption {
6665
+ id String @id @default(cuid())
6666
+ vendorId String
6667
+ /// free | flat | hourly | daily | percentage | negotiable. A combo lists more than one.
6668
+ ways String[] @default([])
6669
+ /// Booth, hourly, or daily amount in cents. Null when the option has no cash rate.
6670
+ amountCents Int?
6671
+ /// 0..100 when the option includes a percent of sales.
6672
+ percentage Int?
6673
+ sortOrder Int @default(0)
6674
+ createdAt DateTime @default(now())
6675
+ updatedAt DateTime @updatedAt
6676
+ vendor Vendor @relation(fields: [vendorId], references: [id], onDelete: Cascade)
6677
+
6678
+ @@index([vendorId])
6648
6679
  }
6649
6680
 
6650
6681
  model VendorSpaceRequirements {
@@ -8842,6 +8873,22 @@ model VendorBookingRequest {
8842
8873
  vendorFee Float?
8843
8874
  feeStructure String
8844
8875
  percentageRate Float?
8876
+ /// Snapshot of the chosen payment option, copied when the vendor accepts.
8877
+ paymentOptionWays String[] @default([])
8878
+ paymentOptionAmountCents Int?
8879
+ paymentOptionPercentage Int?
8880
+ /// ALL_SALES when the chosen option includes a percent of sales.
8881
+ paymentOptionBasis String?
8882
+ paymentOptionSnapshottedAt DateTime?
8883
+ /// Vendor-reported gross booth sales, in cents. Not charged until the host confirms.
8884
+ grossSalesCents Int?
8885
+ salesReportedAt DateTime?
8886
+ salesConfirmedCents Int?
8887
+ salesConfirmedAt DateTime?
8888
+ /// Percent of confirmed sales, minus any booth fee already paid on this option.
8889
+ salesCutCents Int?
8890
+ /// confirmed | marked_paid. Null until the host confirms the sales number.
8891
+ salesCutStatus String?
8845
8892
  eventDescription String
8846
8893
  specialRequests String
8847
8894
  contactPreference String @default("email")
@@ -1053,6 +1053,9 @@ export const VENDOR_DATA_TO_INCLUDE = {
1053
1053
  spaceRequirements: true,
1054
1054
  insurance: true,
1055
1055
  permits: true,
1056
+ paymentOptions: {
1057
+ orderBy: { sortOrder: "asc" as const },
1058
+ },
1056
1059
  preferences: {
1057
1060
  include: {
1058
1061
  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,
@@ -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). */