Archived
Fix: door and manual registrations get their tickets; admin Corrections (1.52.0)
On events with a required attendee form, tickets waited for the forms, but
At the door and Manual registration never asked for them: payment was
recorded and nobody could be checked in.
- The form pops up at the door and in Manual registration; "Fill in later"
(any staff) issues the tickets once paid and sends the payer a link
(Registration.formWaivedAt, POST /api/v2/registrations/{id}/form-later).
- One form per person on picked-session bookings; a required form with no
questions no longer holds tickets back; every caller asks the ticket
generator (formsOutstanding).
- Kiosk asks for the forms the server says are missing; headings show as text.
- Admin Corrections page and /api/v2/corrections: issue missing tickets,
pay later (ticketsReleasedAt), make it free (complimentaryDiscount),
check in or undo after the event.
- Migration 20261102120000_corrections; unit and e2e tests.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -19,6 +19,7 @@ import { bookableSessions, choosesSessions, isPickOption, todaysSession } from "
|
||||
import { SessionPicker } from "@/components/events/SessionPicker";
|
||||
import type { Event, EventOption, PublicBundle, Registration, Ticket as TicketRecord, UserSummary } from "@/types";
|
||||
import { EventPicker } from "@/components/shared/EventPicker";
|
||||
import { AttendeeFormModal, formsStillNeeded } from "@/components/shared/AttendeeFormModal";
|
||||
import { apiV2, apiV2Data } from "@/lib/apiV2";
|
||||
|
||||
type NewAttendee = { name: string; email: string | null; phone: string | null; notifPref: "email" | "whatsapp" | "both" };
|
||||
@@ -198,12 +199,37 @@ export default function AtTheDoorPage() {
|
||||
const [info, setInfo] = useDismissingState<string | null>(null);
|
||||
const [error, setError] = useDismissingState<string | null>(null);
|
||||
|
||||
// A required attendee form holds the tickets back: it pops up to fill in now, or "Fill in
|
||||
// later" (tickets are issued anyway and the attendee gets a link).
|
||||
const [formPrompt, setFormPrompt] = useState<{ registration: Registration; needed: number } | null>(null);
|
||||
const loadFull = (id: string) => apiV2Data("get", "/registrations/{id}/full", { params: { id }, authToken: token }) as Promise<Registration>;
|
||||
const promptFormFor = (full: Registration) => {
|
||||
const needed = formsStillNeeded(doorEvent?.form, full);
|
||||
if (needed > 0 && full.status !== "cancelled") setFormPrompt({ registration: full, needed });
|
||||
return needed;
|
||||
};
|
||||
|
||||
const handleRegistrationCreated = (registration: Registration) => {
|
||||
setActiveRegistration(registration); // 🚀 Jump automatically (see effect below)
|
||||
if ((registration.formsNeeded || 0) > 0) setFormPrompt({ registration, needed: registration.formsNeeded || 0 });
|
||||
};
|
||||
|
||||
const handleRegistrationSelected = (registration: Registration) => {
|
||||
setActiveRegistration(registration);
|
||||
// The search list doesn't carry the forms, so look at the whole registration.
|
||||
loadFull(registration.id).then(promptFormFor).catch(() => {});
|
||||
};
|
||||
|
||||
const handleFormDone = async ({ later, ticketsIssued, sentTo }: { later: boolean; ticketsIssued: number; sentTo?: string[] }) => {
|
||||
const reg = formPrompt?.registration;
|
||||
setFormPrompt(null);
|
||||
const issued = ticketsIssued > 0 ? " Tickets issued." : "";
|
||||
setInfo(later
|
||||
? `Form left for later${sentTo && sentTo.length ? ` — a link was sent by ${sentTo.join(" and ")}` : ""}.${issued}`
|
||||
: `Attendee form saved.${issued}`);
|
||||
if (reg) {
|
||||
try { setActiveRegistration(await loadFull(reg.id)); } catch {}
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
@@ -404,9 +430,14 @@ export default function AtTheDoorPage() {
|
||||
// Tickets are generated and emailed/WhatsApped automatically server-side
|
||||
// once a registration reaches "paid" (see paymentController) — no need to
|
||||
// fetch/print them here, just move straight to checking the attendee in.
|
||||
// Unless a required attendee form holds them back: that pops up first.
|
||||
setActiveRegistration(reg);
|
||||
setInfo("Payment recorded — tickets sent. Ready to check in.");
|
||||
setMode("checkin");
|
||||
if (reg && promptFormFor(reg) > 0) {
|
||||
setInfo("Payment recorded — fill in the attendee form (or choose Fill in later) to issue the tickets.");
|
||||
return;
|
||||
}
|
||||
setInfo("Payment recorded — tickets sent. Ready to check in.");
|
||||
};
|
||||
|
||||
const handleDonation = (user?: UserSummary) => {
|
||||
@@ -499,7 +530,12 @@ export default function AtTheDoorPage() {
|
||||
)}
|
||||
|
||||
{mode === "checkin" && (
|
||||
<DoorCheckInPanel token={token} eventId={eventId} registration={activeRegistration} setError={setError} setInfo={setInfo} />
|
||||
<DoorCheckInPanel
|
||||
token={token} eventId={eventId} registration={activeRegistration} setError={setError} setInfo={setInfo}
|
||||
onFillForm={activeRegistration ? () => loadFull(activeRegistration.id).then(full => {
|
||||
if (promptFormFor(full) === 0) setError("No attendee form is outstanding. If the tickets are still missing, an admin can issue them in Corrections.");
|
||||
}).catch(e => setError(errorMessage(e) || "Couldn't load the registration")) : undefined}
|
||||
/>
|
||||
)}
|
||||
|
||||
{mode === "tickets" && (
|
||||
@@ -550,6 +586,17 @@ export default function AtTheDoorPage() {
|
||||
seed={newAttendeeSeed}
|
||||
onConfirm={handleNewAttendeeConfirm}
|
||||
/>
|
||||
{formPrompt && (
|
||||
<AttendeeFormModal
|
||||
key={formPrompt.registration.id}
|
||||
registrationId={formPrompt.registration.id}
|
||||
form={doorEvent?.form}
|
||||
needed={formPrompt.needed}
|
||||
token={token}
|
||||
attendeeName={formPrompt.registration.user?.name}
|
||||
onDone={handleFormDone}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1027,12 +1074,14 @@ function DoorTicketsPanel({ token, eventId }: { token: string | null; eventId: s
|
||||
);
|
||||
}
|
||||
|
||||
function DoorCheckInPanel({ token, eventId, registration, setError, setInfo }: {
|
||||
function DoorCheckInPanel({ token, eventId, registration, setError, setInfo, onFillForm }: {
|
||||
token: string | null;
|
||||
eventId: string;
|
||||
registration: Registration | null;
|
||||
setError: (e: string | null) => void;
|
||||
setInfo: (s: string | null) => void;
|
||||
/** No tickets yet: open the attendee form that holds them back. */
|
||||
onFillForm?: () => void;
|
||||
}) {
|
||||
const [ticketsForEvent, setTicketsForEvent] = useState<TicketRecord[]>([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
@@ -1053,7 +1102,8 @@ function DoorCheckInPanel({ token, eventId, registration, setError, setInfo }: {
|
||||
}
|
||||
}, [token, eventId]);
|
||||
|
||||
useEffect(() => { load(); }, [load]);
|
||||
// Again when the registration changes: its tickets may have just been issued.
|
||||
useEffect(() => { load(); }, [load, registration]);
|
||||
|
||||
if (!registration) {
|
||||
return (
|
||||
@@ -1117,9 +1167,18 @@ function DoorCheckInPanel({ token, eventId, registration, setError, setInfo }: {
|
||||
)}
|
||||
|
||||
{!loading && myTickets.length === 0 && (
|
||||
<div className="text-sm text-gray-500">
|
||||
No Main Tickets on this registration
|
||||
</div>
|
||||
registration.status === "paid" && onFillForm ? (
|
||||
<div className="text-sm border border-amber-200 bg-amber-50 rounded-lg p-3 text-amber-900">
|
||||
No tickets yet. If the event has an attendee form, it’s holding them back.
|
||||
<button type="button" onClick={onFillForm} className="block mt-2 px-3 py-1.5 rounded bg-amber-600 text-white text-xs font-medium">
|
||||
Fill in the attendee form
|
||||
</button>
|
||||
</div>
|
||||
) : (
|
||||
<div className="text-sm text-gray-500">
|
||||
{registration.status === "paid" ? "No Main Tickets on this registration" : "No tickets yet — they're issued once it's paid."}
|
||||
</div>
|
||||
)
|
||||
)}
|
||||
|
||||
<div className="space-y-4">
|
||||
|
||||
@@ -167,6 +167,21 @@ function AttendeeFormsSection({ registration, form, formsData, setFormsData }: {
|
||||
}
|
||||
};
|
||||
|
||||
// The tickets stop waiting for the form (issued now if it's paid); the attendee gets a link.
|
||||
const later = async () => {
|
||||
if (!token) return;
|
||||
try {
|
||||
setSubmitting(true);
|
||||
setError(null); setInfo(null);
|
||||
const res = await (apiV2Data("post", "/registrations/{id}/form-later", { params: { id: registration.id }, authToken: token, body: {} }) as Promise<{ ticketsIssued: number; sentTo: string[] }>);
|
||||
setInfo(`Form left for later${res?.sentTo?.length ? ` — a link was sent by ${res.sentTo.join(' and ')}` : ''}.${res?.ticketsIssued ? ' Tickets issued.' : ''}`);
|
||||
} catch (e) {
|
||||
setError(errorMessage(e) || 'Failed to leave the form for later');
|
||||
} finally {
|
||||
setSubmitting(false);
|
||||
}
|
||||
};
|
||||
|
||||
if (!form || !Array.isArray(form.fields) || count === 0) return null;
|
||||
return (
|
||||
<div className="mt-6 border rounded p-3 bg-gray-50">
|
||||
@@ -212,7 +227,10 @@ function AttendeeFormsSection({ registration, form, formsData, setFormsData }: {
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
<button className="mt-3 px-3 py-1.5 text-sm rounded bg-brand-600 text-white hover:bg-brand-700 disabled:opacity-50" disabled={submitting || !canSubmit} onClick={submit}>{submitting ? 'Submitting…' : 'Submit forms'}</button>
|
||||
<div className="mt-3 flex gap-2">
|
||||
<button className="px-3 py-1.5 text-sm rounded bg-brand-600 text-white hover:bg-brand-700 disabled:opacity-50" disabled={submitting || !canSubmit} onClick={submit}>{submitting ? 'Submitting…' : 'Submit forms'}</button>
|
||||
{form.isRequired && <button className="px-3 py-1.5 text-sm rounded border bg-white hover:bg-gray-50 disabled:opacity-50" disabled={submitting} onClick={later}>Fill in later</button>}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import type { Event, EventOption, PublicBundle, Registration, RegistrationOption
|
||||
import { BackLink } from "@/components/shared/BackLink";
|
||||
import { EventPicker } from "@/components/shared/EventPicker";
|
||||
import { apiV2Data } from "@/lib/apiV2";
|
||||
import { AttendeeFormModal, type AttendeeFormDef } from "@/components/shared/AttendeeFormModal";
|
||||
|
||||
// ─── Pricing helpers ─────────────────────────────────────────────────────────
|
||||
|
||||
@@ -91,6 +92,15 @@ export default function ManualRegistrationPage() {
|
||||
const [paySubmitting, setPaySubmitting] = useState(false);
|
||||
const [payMessage, setPayMessage] = useDismissingState<string | null>(null);
|
||||
const [payError, setPayError] = useDismissingState<string | null>(null);
|
||||
// A required attendee form holding the tickets back: fill it in now, or "Fill in later".
|
||||
const [formPrompt, setFormPrompt] = useState<{ registrationId: string; needed: number; form: AttendeeFormDef; name?: string } | null>(null);
|
||||
const promptForm = async (registrationId: string, needed: number, eventId: string, name?: string) => {
|
||||
if (!(needed > 0)) return;
|
||||
try {
|
||||
const ev = await fetchEvent<Event>(eventId, { authToken: token || undefined });
|
||||
setFormPrompt({ registrationId, needed, form: ev?.form, name });
|
||||
} catch {}
|
||||
};
|
||||
|
||||
// Load all users for client-side fuzzy matching
|
||||
useEffect(() => {
|
||||
@@ -164,7 +174,7 @@ export default function ManualRegistrationPage() {
|
||||
if (!payRegistrationId) { setPayError("Please select a registration"); return; }
|
||||
try {
|
||||
setPaySubmitting(true);
|
||||
await apiV2Data("post", "/payments", {
|
||||
const paid = await (apiV2Data("post", "/payments", {
|
||||
authToken: token,
|
||||
body: {
|
||||
amount: amt,
|
||||
@@ -174,8 +184,11 @@ export default function ManualRegistrationPage() {
|
||||
isDonation: false,
|
||||
paidAt: payPaidAtLocal ? new Date(payPaidAtLocal).toISOString() : undefined,
|
||||
},
|
||||
});
|
||||
setPayMessage(`Payment recorded (R ${amt.toFixed(2)}).`);
|
||||
}) as Promise<{ formsNeeded?: number; registration?: { eventId?: string } }>);
|
||||
setPayMessage(`Payment recorded (R ${amt.toFixed(2)}).${(paid?.formsNeeded || 0) > 0 ? " The attendee form is holding the tickets back." : ""}`);
|
||||
const paidReg = allRegistrations.find(r => r.id === payRegistrationId);
|
||||
const paidEventId = paid?.registration?.eventId || paidReg?.eventId;
|
||||
if (paidEventId) promptForm(payRegistrationId, paid?.formsNeeded || 0, paidEventId, paidReg?.user?.name);
|
||||
setPayAmount("");
|
||||
setPayPaidAtLocal("");
|
||||
// Refresh registrations so the displayed outstanding balance updates
|
||||
@@ -362,6 +375,7 @@ export default function ManualRegistrationPage() {
|
||||
setMessage(res?.couponError
|
||||
? `Manual registration created, but the code wasn't applied: ${res.couponError}`
|
||||
: coupon ? `Manual registration created with code ${coupon.code}.` : "Manual registration created successfully.");
|
||||
if ((res?.formsNeeded || 0) > 0) setFormPrompt({ registrationId: res.id, needed: res.formsNeeded || 0, form: fullEvent?.form, name: res.user?.name || guest.name });
|
||||
|
||||
// Pre-load the Record Payment tab with this registration so it's ready to go the
|
||||
// moment a supervisor clicks over — the tab itself is never switched to automatically.
|
||||
@@ -771,6 +785,24 @@ export default function ManualRegistrationPage() {
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{formPrompt && (
|
||||
<AttendeeFormModal
|
||||
key={formPrompt.registrationId}
|
||||
registrationId={formPrompt.registrationId}
|
||||
form={formPrompt.form}
|
||||
needed={formPrompt.needed}
|
||||
token={token}
|
||||
attendeeName={formPrompt.name}
|
||||
onDone={({ later, ticketsIssued, sentTo }) => {
|
||||
setFormPrompt(null);
|
||||
const issued = ticketsIssued > 0 ? " Tickets issued." : "";
|
||||
const text = later
|
||||
? `Attendee form left for later${sentTo && sentTo.length ? ` — a link was sent by ${sentTo.join(" and ")}` : ""}.${issued}`
|
||||
: `Attendee form saved.${issued}`;
|
||||
if (tab === "payment") setPayMessage(text); else setMessage(text);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user