Add group tickets with named attendees

Events can take a name (and optional email/phone) for each main-ticket
place. Each named person gets their own quantity-1 ticket and attendee
form; unnamed places share one ticket. Tickets go to the payer or to each
person, attendees matching one existing account are linked to it, and
the payer can edit names and send form links from My Events. Ticket
generation is now planned per line (utils/attendees.js), free
registrations use the same generator, and guest registration matches
accounts by phone too, refusing conflicting email/phone pairs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-19 12:12:33 +02:00
co-authored by Claude Opus 5.5
parent 4b413788ac
commit df0bf09a0e
31 changed files with 1323 additions and 113 deletions
@@ -7,6 +7,7 @@ import { apiFetch, fetchAllUsers } from "@/lib/api";
import { scoreUser } from "@/lib/fuzzyMatch";
import { useDismissingState } from "@/hooks/useDismissingState";
import { CouponCodeField, AppliedCoupon } from "@/components/shared/CouponCodeField";
import { AttendeeNamesEditor, AttendeeEntries, TicketDelivery, attendeesPayload } from "@/components/shared/AttendeeNamesEditor";
import { UserPlus, CreditCard } from "lucide-react";
// ─── Pricing helpers ─────────────────────────────────────────────────────────
@@ -218,6 +219,12 @@ export default function ManualRegistrationPage() {
// Discount code, checked against the picked account (or a walk-in when none is picked).
const [coupon, setCoupon] = useState<AppliedCoupon | null>(null);
// Named attendees (group tickets), when the event takes them.
const [namingOthers, setNamingOthers] = useState(false);
const [attendeeEntries, setAttendeeEntries] = useState<AttendeeEntries>({});
const [delivery, setDelivery] = useState<TicketDelivery>("payer");
const manualQtyFor = (optionId: string, variantId: string | null) => quantities[variantId ? `${optionId}::${variantId}` : optionId] || 0;
const selectedEventAllowsNames = !!events.find(ev => ev.id === selectedEventId)?.allowNamedAttendees;
const [pickedUserId, setPickedUserId] = useState<string | null>(null);
const selectUser = (u: any) => {
@@ -315,6 +322,9 @@ export default function ManualRegistrationPage() {
user: guest,
notificationPreference: resolvedPref,
...(coupon ? { couponCode: coupon.code } : {}),
...(selectedEventAllowsNames && namingOthers && attendeesPayload(options, manualQtyFor, attendeeEntries).length > 0
? { attendees: attendeesPayload(options, manualQtyFor, attendeeEntries), ticketDelivery: delivery }
: {}),
}
});
setMessage(res?.couponError
@@ -336,6 +346,9 @@ export default function ManualRegistrationPage() {
setDropdownOpen(false);
setCoupon(null);
setPickedUserId(null);
setNamingOthers(false);
setAttendeeEntries({});
setDelivery("payer");
setQuantities(prev => Object.fromEntries(Object.keys(prev).map(k => [k, 0])));
} catch (e: any) {
setError(e?.message || "Failed to create manual registration");
@@ -592,6 +605,22 @@ export default function ManualRegistrationPage() {
)}
</div>
{selectedEventAllowsNames && (
<div className="mt-6">
<AttendeeNamesEditor
options={options}
qtyFor={manualQtyFor}
enabled={namingOthers}
onEnabledChange={setNamingOthers}
entries={attendeeEntries}
onEntriesChange={setAttendeeEntries}
delivery={delivery}
onDeliveryChange={setDelivery}
payerLabel="the person registering"
/>
</div>
)}
{selectedEventId && totalDue > 0 && (
<div className="mt-6 max-w-md">
<CouponCodeField