Most attendees arrive without their QR open, and taking money at the door meant leaving the scanner for the event dashboard, where the Add Ticket modal demanded an email and recorded no payment method. The screen now leads with manual name search, keeps the camera one tap away behind a fullscreen overlay, and creates and charges walk-ins inline. Check-in and payment are one action: anything done here is born confirmed, paid (or comp) and checked in through a single endpoint, POST /api/events/:eventId/door-checkin. There are no confirm dialogs anywhere, because they stall the queue; a ten-second Undo replaces them, reversing exactly what the action changed via the undo state recorded alongside its idempotency key. Writes fire in the background with retries, so venue wifi never blocks the person at the door, and a capacity limit only warns, since staff at the door are the authority. Every write carries a client-generated idempotency key, inserted in the same transaction as the writes it guards, so a double tap or a retry after a timeout cannot produce a second ticket, payment or check-in. Search runs entirely in memory over one preloaded list: names are matched accent- and case-insensitively in both directions, per word, prefix before substring, with a mostly-numeric query searching phone digits so two people with the same name can be told apart. Door money is recorded as payments.source 'door' plus payments.method (cash, bitcoin, transfer or guest) while provider keeps its existing value, so capacity counting, the stale-booking sweeps and the admin payment lists are unaffected and revenue can still be split pre-sale versus door. Bitcoin records the payment as made, on the same trust model as cash, with no invoice generated; lib/doorPayments.ts is where a real Lightning flow slots in later. Also fixes the SQLite tickets DDL, which still created the pre-split attendee_name column with NOT NULL email and phone. Only fresh databases were affected -- existing ones were relaxed by later ALTERs -- but on those, door walk-ins (and any other ticket) could not be inserted at all. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
160 lines
5.2 KiB
TypeScript
160 lines
5.2 KiB
TypeScript
'use client';
|
|
|
|
import clsx from 'clsx';
|
|
import {
|
|
CheckCircleIcon,
|
|
ArrowUturnLeftIcon,
|
|
UserGroupIcon,
|
|
} from '@heroicons/react/24/outline';
|
|
import type { DoorAttendee, DoorPaymentMethod } from '@/lib/api';
|
|
import { formatCurrency, parseDate, EVENT_TIMEZONE } from '@/lib/utils';
|
|
import { PaymentButtons } from './PaymentButtons';
|
|
|
|
function checkinTime(checkinAt: string | null): string {
|
|
if (!checkinAt) return '';
|
|
return parseDate(checkinAt).toLocaleTimeString([], {
|
|
hour: '2-digit',
|
|
minute: '2-digit',
|
|
timeZone: EVENT_TIMEZONE,
|
|
});
|
|
}
|
|
|
|
const METHOD_LABELS: Record<DoorPaymentMethod, string> = {
|
|
cash: 'cash',
|
|
bitcoin: 'bitcoin',
|
|
transfer: 'transfer',
|
|
guest: 'guest',
|
|
};
|
|
|
|
/** The second line of a row: everything staff needs to decide in one glance. */
|
|
function statusLine(attendee: DoorAttendee, currency: string): string {
|
|
if (attendee.status === 'cancelled') return 'Cancelled';
|
|
if (attendee.checkedIn) {
|
|
const time = checkinTime(attendee.checkinAt);
|
|
const how = attendee.doorMethod ? ` · paid ${METHOD_LABELS[attendee.doorMethod]}` : '';
|
|
return time ? `Checked in ${time}${how}` : `Checked in${how}`;
|
|
}
|
|
|
|
const parts: string[] = [];
|
|
if (attendee.paymentStatus === 'comp') parts.push('Guest');
|
|
else if (attendee.paymentStatus === 'paid') parts.push('Paid');
|
|
else parts.push(`Unpaid · ${formatCurrency(attendee.amountDue, currency)} due`);
|
|
|
|
if (attendee.isGroupBooking) parts.push('group booking');
|
|
if (attendee.status === 'pending') parts.push('pending');
|
|
return parts.join(' · ');
|
|
}
|
|
|
|
export function AttendeeRow({
|
|
attendee,
|
|
currency,
|
|
price,
|
|
expanded,
|
|
flashing,
|
|
busy,
|
|
onTap,
|
|
onPay,
|
|
}: {
|
|
attendee: DoorAttendee;
|
|
currency: string;
|
|
price: number;
|
|
expanded: boolean;
|
|
flashing: boolean;
|
|
busy: boolean;
|
|
onTap: () => void;
|
|
onPay: (method: DoorPaymentMethod, amount: number) => void;
|
|
}) {
|
|
const isCancelled = attendee.status === 'cancelled';
|
|
const settled = attendee.paymentStatus === 'paid' || attendee.paymentStatus === 'comp';
|
|
// A settled, not-yet-arrived attendee is the one-tap case: the whole row checks
|
|
// them in. Everyone else opens the tenders inline instead.
|
|
const isOneTap = !isCancelled && !attendee.checkedIn && settled;
|
|
|
|
return (
|
|
<div
|
|
className={clsx(
|
|
'rounded-2xl border transition-colors',
|
|
flashing
|
|
? 'bg-emerald-600 border-emerald-400'
|
|
: attendee.checkedIn || isCancelled
|
|
? 'bg-gray-900 border-gray-800'
|
|
: 'bg-gray-800 border-gray-700',
|
|
)}
|
|
>
|
|
<button
|
|
onClick={onTap}
|
|
disabled={busy}
|
|
className="w-full text-left px-4 py-3 min-h-[64px] flex items-center gap-3 active:scale-[0.99] transition-transform disabled:opacity-60"
|
|
>
|
|
<div className="flex-1 min-w-0">
|
|
<p
|
|
className={clsx(
|
|
'font-bold text-lg truncate',
|
|
flashing ? 'text-white' : attendee.checkedIn || isCancelled ? 'text-gray-400' : 'text-white',
|
|
)}
|
|
>
|
|
{attendee.fullName}
|
|
</p>
|
|
<p
|
|
className={clsx(
|
|
'text-sm truncate flex items-center gap-1.5',
|
|
flashing
|
|
? 'text-emerald-50'
|
|
: isCancelled
|
|
? 'text-red-400'
|
|
: attendee.checkedIn
|
|
? 'text-gray-500'
|
|
: attendee.paymentStatus === 'unpaid'
|
|
? 'text-amber-400'
|
|
: 'text-gray-400',
|
|
)}
|
|
>
|
|
{attendee.isGroupBooking && !attendee.checkedIn && <UserGroupIcon className="w-4 h-4 flex-shrink-0" />}
|
|
{statusLine(attendee, currency)}
|
|
</p>
|
|
</div>
|
|
|
|
{flashing ? (
|
|
<CheckCircleIcon className="w-8 h-8 text-white flex-shrink-0" />
|
|
) : attendee.checkedIn ? (
|
|
<CheckCircleIcon className="w-7 h-7 text-emerald-500/60 flex-shrink-0" />
|
|
) : isCancelled ? (
|
|
<span className="flex-shrink-0 text-[10px] font-bold uppercase tracking-wide px-2 py-1 rounded-full bg-red-950 text-red-400">
|
|
Cancelled
|
|
</span>
|
|
) : isOneTap ? (
|
|
<span className="flex-shrink-0 text-xs font-bold uppercase tracking-wide text-primary-yellow">
|
|
Check in
|
|
</span>
|
|
) : (
|
|
<span className="flex-shrink-0 text-xs font-bold uppercase tracking-wide text-amber-400">
|
|
Collect
|
|
</span>
|
|
)}
|
|
</button>
|
|
|
|
{expanded && !attendee.checkedIn && (
|
|
<div className="px-3 pb-3 pt-1 space-y-2">
|
|
{isCancelled && (
|
|
<p className="text-xs text-gray-400 px-1 flex items-center gap-1.5">
|
|
<ArrowUturnLeftIcon className="w-4 h-4" />
|
|
Reactivate as a walk-in — pick how they are paying.
|
|
</p>
|
|
)}
|
|
<PaymentButtons price={price} currency={currency} onPay={onPay} disabled={busy} />
|
|
</div>
|
|
)}
|
|
|
|
{expanded && attendee.checkedIn && (
|
|
<div className="px-4 pb-3 -mt-1">
|
|
<p className="text-sm text-gray-400">
|
|
Already checked in
|
|
{attendee.checkinAt ? ` at ${checkinTime(attendee.checkinAt)}` : ''}
|
|
{attendee.checkedInBy ? ` by ${attendee.checkedInBy}` : ''}.
|
|
</p>
|
|
</div>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|