From a0161a67d2443840c55e29191c5b2c99848af80d Mon Sep 17 00:00:00 2001 From: Michilis Date: Sat, 22 Aug 2026 04:39:54 +0000 Subject: [PATCH] Add "paid at the door" ticket type to the Add Ticket modal. Door walk-ins were only expressible as an unpaid ticket, which left the cash out of revenue. The new type records the cash payment as paid and makes every field optional, since a walk-in often gives no details: a blank name is logged as "Walk-in", and a confirmation email only goes out when an email is entered. Door tickets reuse paymentStatus 'paid' (the column enum is capped at paid/unpaid/comp) so badges and revenue totals pick them up with no migration; the cash payment row is referenced "Paid at door" to keep them distinguishable from emailed manual tickets. Co-Authored-By: Claude Opus 5 --- backend/src/routes/tickets.ts | 36 +++++++++++++------ .../events/[id]/_modals/AddTicketModal.tsx | 25 ++++++++++--- .../admin/events/[id]/_modals/EventModals.tsx | 10 ++++++ .../admin/events/[id]/_tabs/AttendeesTab.tsx | 3 ++ frontend/src/app/admin/events/[id]/_types.ts | 3 +- frontend/src/app/admin/events/[id]/page.tsx | 4 +-- frontend/src/lib/api/tickets.ts | 7 ++-- 7 files changed, 68 insertions(+), 20 deletions(-) diff --git a/backend/src/routes/tickets.ts b/backend/src/routes/tickets.ts index 776dbfa..9cee47a 100644 --- a/backend/src/routes/tickets.ts +++ b/backend/src/routes/tickets.ts @@ -1529,14 +1529,18 @@ ticketsRouter.post('/admin/create', requireAuth(['admin', 'organizer', 'staff']) // Unified admin add-attendee endpoint backing the single Add Ticket modal. // type drives payment handling: // paid — email required; paid cash payment; confirmation email + QR sent +// door — paid in cash at the door; all fields optional; counts toward revenue; +// confirmation email only when an email is provided // unpaid — QR issued with balance due (collect at door); pending tpago payment; // pay-link (Bancard/TPago) email sent when an email is provided // guest — free comp ticket, not counted in revenue; confirmation email only // when an email is provided ticketsRouter.post('/admin/add', requireAuth(['admin', 'organizer', 'staff']), zValidator('json', z.object({ eventId: z.string(), - type: z.enum(['paid', 'unpaid', 'guest']), - firstName: z.string().min(1), + type: z.enum(['paid', 'door', 'unpaid', 'guest']), + // Door walk-ins can be logged with nothing filled in, so firstName is only + // required for the other types + firstName: z.string().optional().or(z.literal('')), lastName: z.string().optional().or(z.literal('')), email: z.string().email().optional().or(z.literal('')), phone: z.string().optional().or(z.literal('')), @@ -1546,6 +1550,9 @@ ticketsRouter.post('/admin/add', requireAuth(['admin', 'organizer', 'staff']), z }).refine((d) => d.type !== 'paid' || !!(d.email && d.email.trim()), { message: 'Email is required for paid tickets', path: ['email'], +}).refine((d) => d.type === 'door' || !!(d.firstName && d.firstName.trim()), { + message: 'First name is required', + path: ['firstName'], })), async (c) => { const data = c.req.valid('json'); @@ -1565,9 +1572,11 @@ ticketsRouter.post('/admin/add', requireAuth(['admin', 'organizer', 'staff']), z ? data.email!.trim() : `${data.type === 'guest' ? 'guest' : 'door'}-${generateId()}@${data.type === 'guest' ? 'guestinvite' : 'doorentry'}.local`; + // Nameless door walk-ins still need a display name on the ticket + const firstName = (data.firstName && data.firstName.trim()) || 'Walk-in'; const fullName = data.lastName && data.lastName.trim() - ? `${data.firstName} ${data.lastName}`.trim() - : data.firstName; + ? `${firstName} ${data.lastName.trim()}` + : firstName; // Find or create user let user = await dbGet( @@ -1613,13 +1622,13 @@ ticketsRouter.post('/admin/add', requireAuth(['admin', 'organizer', 'staff']), z const ticketId = generateId(); const qrCode = generateTicketCode(); - const paymentStatus = data.type === 'guest' ? 'comp' : data.type === 'paid' ? 'paid' : 'unpaid'; + const paymentStatus = data.type === 'guest' ? 'comp' : data.type === 'unpaid' ? 'unpaid' : 'paid'; const newTicket = { id: ticketId, userId: user.id, eventId: data.eventId, - attendeeFirstName: data.firstName, + attendeeFirstName: firstName, attendeeLastName: data.lastName && data.lastName.trim() ? data.lastName.trim() : null, attendeeEmail: hasEmail ? data.email!.trim() : null, attendeePhone: data.phone && data.phone.trim() ? data.phone.trim() : null, @@ -1636,7 +1645,7 @@ ticketsRouter.post('/admin/add', requireAuth(['admin', 'organizer', 'staff']), z await (db as any).insert(tickets).values(newTicket); - // Payment record: paid cash for paid/guest ($0 for guest), pending tpago for unpaid + // Payment record: paid cash for paid/door/guest ($0 for guest), pending tpago for unpaid const paymentId = generateId(); const newPayment = data.type === 'unpaid' ? { @@ -1659,7 +1668,11 @@ ticketsRouter.post('/admin/add', requireAuth(['admin', 'organizer', 'staff']), z amount: data.type === 'guest' ? 0 : event.price, currency: event.currency, status: 'paid', - reference: data.type === 'guest' ? 'Guest invite' : 'Manual ticket', + reference: data.type === 'guest' + ? 'Guest invite' + : data.type === 'door' + ? 'Paid at door' + : 'Manual ticket', paidAt: now, paidByAdminId: adminUser?.id || null, createdAt: now, @@ -1668,8 +1681,8 @@ ticketsRouter.post('/admin/add', requireAuth(['admin', 'organizer', 'staff']), z await (db as any).insert(payments).values(newPayment); - // Emails (asynchronous): paid always confirms; guest confirms when an email - // exists; unpaid sends the TPago (Bancard) pay-link instructions instead + // Emails (asynchronous): paid always confirms; door/guest confirm only when an + // email exists; unpaid sends the TPago (Bancard) pay-link instructions instead if (data.type === 'unpaid') { if (hasEmail) { emailService.sendPaymentInstructions(ticketId).then(result => { @@ -1692,6 +1705,9 @@ ticketsRouter.post('/admin/add', requireAuth(['admin', 'organizer', 'staff']), z const messages: Record = { paid: 'Ticket created — confirmation email sent', + door: hasEmail + ? 'Ticket created — paid at the door, confirmation email sent' + : 'Ticket created — paid at the door', unpaid: hasEmail ? 'Unpaid ticket created — payment link sent' : 'Unpaid ticket created — collect payment at the door', diff --git a/frontend/src/app/admin/events/[id]/_modals/AddTicketModal.tsx b/frontend/src/app/admin/events/[id]/_modals/AddTicketModal.tsx index d971606..e676d41 100644 --- a/frontend/src/app/admin/events/[id]/_modals/AddTicketModal.tsx +++ b/frontend/src/app/admin/events/[id]/_modals/AddTicketModal.tsx @@ -24,18 +24,21 @@ interface AddTicketModalProps { const TYPE_OPTIONS: { value: AddTicketType; label: string }[] = [ { value: 'paid', label: 'Paid' }, + { value: 'door', label: 'At Door' }, { value: 'unpaid', label: 'Unpaid' }, { value: 'guest', label: 'Guest' }, ]; const SUBMIT_LABELS: Record = { paid: 'Create & send ticket', + door: 'Record door payment', unpaid: 'Create & send pay link', guest: 'Invite guest', }; const SUBMIT_ICONS: Record = { paid: EnvelopeIcon, + door: BanknotesIcon, unpaid: LinkIcon, guest: StarIcon, }; @@ -47,6 +50,15 @@ function previewLines(form: AddTicketFormState, eventPriceLabel: string): string if (form.type === 'paid') { lines.push(`Payment of ${eventPriceLabel} recorded as paid — counts toward revenue`); lines.push('Confirmation email with QR ticket sent'); + } else if (form.type === 'door') { + lines.push(`Cash payment of ${eventPriceLabel} recorded as paid at the door — counts toward revenue`); + lines.push('QR code issued'); + if (!form.firstName.trim()) { + lines.push('No name — the ticket is logged as a "Walk-in"'); + } + lines.push(hasEmail + ? 'Confirmation email with QR ticket sent' + : 'No email — nothing is sent, walk-in kept on the list only'); } else if (form.type === 'unpaid') { lines.push(`Ticket marked unpaid — balance of ${eventPriceLabel} to collect at the door`); lines.push('QR code issued, flagged "unpaid" for door staff'); @@ -66,12 +78,14 @@ function previewLines(form: AddTicketFormState, eventPriceLabel: string): string const PREVIEW_STYLES: Record = { paid: { box: 'bg-blue-50 border-blue-200', icon: 'text-blue-500', text: 'text-blue-800' }, + door: { box: 'bg-emerald-50 border-emerald-200', icon: 'text-emerald-500', text: 'text-emerald-800' }, unpaid: { box: 'bg-orange-50 border-orange-200', icon: 'text-orange-500', text: 'text-orange-800' }, guest: { box: 'bg-amber-50 border-amber-200', icon: 'text-amber-500', text: 'text-amber-800' }, }; const PREVIEW_ICONS: Record = { paid: CheckCircleIcon, + door: BanknotesIcon, unpaid: BanknotesIcon, guest: StarIcon, }; @@ -88,6 +102,8 @@ export function AddTicketModal({ if (!open) return null; const emailRequired = form.type === 'paid'; + // Door walk-ins can be logged with nothing filled in + const nameRequired = form.type !== 'door'; const style = PREVIEW_STYLES[form.type]; const PreviewIcon = PREVIEW_ICONS[form.type]; const SubmitIcon = SUBMIT_ICONS[form.type]; @@ -120,7 +136,7 @@ export function AddTicketModal({ type="button" onClick={() => setForm((f) => ({ ...f, type: option.value }))} className={clsx( - 'flex-1 px-3 py-2 text-sm font-medium rounded-btn min-h-[36px] transition-colors', + 'flex-1 px-2 py-2 text-xs sm:text-sm font-medium rounded-btn min-h-[36px] whitespace-nowrap transition-colors', form.type === option.value ? 'bg-white shadow-sm text-primary-dark' : 'text-gray-500 hover:text-gray-700' @@ -133,11 +149,11 @@ export function AddTicketModal({
- - First Name {nameRequired && '*'} + setForm((f) => ({ ...f, firstName: e.target.value }))} className="w-full px-3 py-2.5 text-sm rounded-btn border border-secondary-light-gray focus:outline-none focus:ring-2 focus:ring-primary-yellow" - placeholder="First name" /> + placeholder={nameRequired ? 'First name' : 'First name (optional)'} />
@@ -155,6 +171,7 @@ export function AddTicketModal({ placeholder={emailRequired ? 'email@example.com' : 'email@example.com (optional)'} />

{form.type === 'paid' && 'Ticket will be sent to this email'} + {form.type === 'door' && 'Optional — if provided, the ticket confirmation is sent here'} {form.type === 'unpaid' && 'If provided, the payment link is sent here'} {form.type === 'guest' && 'If provided, a confirmation email will be sent'}

diff --git a/frontend/src/app/admin/events/[id]/_modals/EventModals.tsx b/frontend/src/app/admin/events/[id]/_modals/EventModals.tsx index d4acfe2..b00c995 100644 --- a/frontend/src/app/admin/events/[id]/_modals/EventModals.tsx +++ b/frontend/src/app/admin/events/[id]/_modals/EventModals.tsx @@ -133,6 +133,16 @@ export function EventModals(props: EventModalsProps) {

Send confirmation email with QR ticket

+