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:
@@ -4,6 +4,7 @@ import React, { useCallback, useEffect, useMemo, useRef, useState } from "react"
|
||||
import { apiFetch } from "@/lib/api";
|
||||
import { TwoFactorChallenge, isTwoFactorChallenge } from "@/lib/auth";
|
||||
import { CouponCodeField, AppliedCoupon } from "@/components/shared/CouponCodeField";
|
||||
import { AttendeeNamesEditor, AttendeeEntries, TicketDelivery, attendeesPayload } from "@/components/shared/AttendeeNamesEditor";
|
||||
|
||||
// ─── Types ────────────────────────────────────────────────────────────────────
|
||||
type EarlyBirdTier = { deadline: string; price: number; order?: number; variantId?: string | null };
|
||||
@@ -39,6 +40,7 @@ type KioskEvent = {
|
||||
picture?: string;
|
||||
eventOptions?: EventOption[];
|
||||
form?: EventForm | null;
|
||||
allowNamedAttendees?: boolean;
|
||||
};
|
||||
|
||||
type Screen = "setup" | "form" | "eventform" | "confirmation";
|
||||
@@ -136,6 +138,9 @@ export default function SelfServicePage() {
|
||||
const [setupError, setSetupError] = useState<string | null>(null);
|
||||
const [supervisorToken, setSupervisorToken] = useState<string | null>(null);
|
||||
const [kioskCoupon, setKioskCoupon] = useState<AppliedCoupon | null>(null);
|
||||
const [namingOthers, setNamingOthers] = useState(false);
|
||||
const [attendeeEntries, setAttendeeEntries] = useState<AttendeeEntries>({});
|
||||
const [delivery, setDelivery] = useState<TicketDelivery>("payer");
|
||||
// Set while a supervisor with two-factor on still has to enter their code.
|
||||
const [setupChallenge, setSetupChallenge] = useState<TwoFactorChallenge | null>(null);
|
||||
const [setupCode, setSetupCode] = useState("");
|
||||
@@ -412,6 +417,13 @@ export default function SelfServicePage() {
|
||||
notificationPreference: notificationPref,
|
||||
...(kioskCoupon ? { couponCode: kioskCoupon.code } : {}),
|
||||
};
|
||||
const kioskNames = selectedEvent?.allowNamedAttendees && namingOthers
|
||||
? attendeesPayload(selectedEvent.eventOptions || [], (o, v) => quantities[v ? `${o}::${v}` : o] || 0, attendeeEntries)
|
||||
: [];
|
||||
if (kioskNames.length > 0) {
|
||||
payload.attendees = kioskNames;
|
||||
payload.ticketDelivery = delivery;
|
||||
}
|
||||
if (createAccount && visitorPassword) {
|
||||
payload.user.password = visitorPassword;
|
||||
}
|
||||
@@ -526,6 +538,9 @@ export default function SelfServicePage() {
|
||||
|
||||
function resetForm() {
|
||||
setKioskCoupon(null);
|
||||
setNamingOthers(false);
|
||||
setAttendeeEntries({});
|
||||
setDelivery("payer");
|
||||
setVisitorName("");
|
||||
setVisitorEmail("");
|
||||
setVisitorPhone("");
|
||||
@@ -993,6 +1008,20 @@ export default function SelfServicePage() {
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
{selectedEvent?.allowNamedAttendees && (
|
||||
<div className="mt-4">
|
||||
<AttendeeNamesEditor
|
||||
options={selectedEvent.eventOptions || []}
|
||||
qtyFor={(o, v) => quantities[v ? `${o}::${v}` : o] || 0}
|
||||
enabled={namingOthers}
|
||||
onEnabledChange={setNamingOthers}
|
||||
entries={attendeeEntries}
|
||||
onEntriesChange={setAttendeeEntries}
|
||||
delivery={delivery}
|
||||
onDeliveryChange={setDelivery}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
{total > 0 && selectedEventId && (
|
||||
<div className="mt-4">
|
||||
<CouponCodeField
|
||||
|
||||
Reference in New Issue
Block a user