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>
158 lines
5.2 KiB
TypeScript
158 lines
5.2 KiB
TypeScript
'use client';
|
|
|
|
import { useState, useEffect, useRef } from 'react';
|
|
import { UserPlusIcon, ChevronDownIcon } from '@heroicons/react/24/outline';
|
|
import clsx from 'clsx';
|
|
import type { DoorPaymentMethod } from '@/lib/api';
|
|
import { PaymentButtons } from './PaymentButtons';
|
|
|
|
export interface WalkInDraft {
|
|
firstName: string;
|
|
lastName: string;
|
|
phone: string;
|
|
email: string;
|
|
ruc: string;
|
|
}
|
|
|
|
export const emptyWalkIn = (firstName = ''): WalkInDraft => ({
|
|
firstName,
|
|
lastName: '',
|
|
phone: '',
|
|
email: '',
|
|
ruc: '',
|
|
});
|
|
|
|
/**
|
|
* The pinned bottom row. Collapsed it is a single tap; expanded it is a first
|
|
* name and four tenders. Email, phone and RUC live behind "Add details" so the
|
|
* rare person who wants a receipt never slows down the queue behind them.
|
|
*/
|
|
export function WalkInRow({
|
|
typedText,
|
|
expanded,
|
|
draft,
|
|
price,
|
|
currency,
|
|
busy,
|
|
onExpand,
|
|
onChange,
|
|
onPay,
|
|
onCancel,
|
|
}: {
|
|
typedText: string;
|
|
expanded: boolean;
|
|
draft: WalkInDraft;
|
|
price: number;
|
|
currency: string;
|
|
busy: boolean;
|
|
onExpand: () => void;
|
|
onChange: (draft: WalkInDraft) => void;
|
|
onPay: (method: DoorPaymentMethod, amount: number) => void;
|
|
onCancel: () => void;
|
|
}) {
|
|
const [detailsOpen, setDetailsOpen] = useState(false);
|
|
const firstNameRef = useRef<HTMLInputElement>(null);
|
|
|
|
useEffect(() => {
|
|
if (expanded) firstNameRef.current?.focus();
|
|
}, [expanded]);
|
|
|
|
useEffect(() => {
|
|
if (!expanded) setDetailsOpen(false);
|
|
}, [expanded]);
|
|
|
|
if (!expanded) {
|
|
return (
|
|
<button
|
|
onClick={onExpand}
|
|
className="w-full min-h-[64px] px-4 py-3 rounded-2xl border-2 border-dashed border-primary-yellow/50 bg-primary-yellow/5 text-left flex items-center gap-3 active:scale-[0.99] transition-transform"
|
|
>
|
|
<UserPlusIcon className="w-6 h-6 text-primary-yellow flex-shrink-0" />
|
|
<span className="font-bold text-primary-yellow truncate">
|
|
{typedText ? `Add "${typedText}" as walk-in` : 'Add a walk-in'}
|
|
</span>
|
|
</button>
|
|
);
|
|
}
|
|
|
|
const field = (key: keyof WalkInDraft, value: string) => onChange({ ...draft, [key]: value });
|
|
|
|
return (
|
|
<div className="rounded-2xl border-2 border-primary-yellow/50 bg-gray-800 p-3 space-y-2">
|
|
<div className="flex items-center justify-between px-1">
|
|
<p className="font-bold text-primary-yellow">New walk-in</p>
|
|
<button onClick={onCancel} className="text-sm text-gray-400 min-h-[48px] px-2 active:text-white">
|
|
Cancel
|
|
</button>
|
|
</div>
|
|
|
|
<div className="grid grid-cols-2 gap-2">
|
|
<input
|
|
ref={firstNameRef}
|
|
value={draft.firstName}
|
|
onChange={(e) => field('firstName', e.target.value)}
|
|
placeholder="First name"
|
|
autoComplete="off"
|
|
autoCorrect="off"
|
|
spellCheck={false}
|
|
className="min-h-[48px] px-4 bg-gray-900 border border-gray-700 rounded-xl text-white placeholder:text-gray-500 focus:outline-none focus:ring-2 focus:ring-primary-yellow"
|
|
/>
|
|
<input
|
|
value={draft.lastName}
|
|
onChange={(e) => field('lastName', e.target.value)}
|
|
placeholder="Last name (optional)"
|
|
autoComplete="off"
|
|
autoCorrect="off"
|
|
spellCheck={false}
|
|
className="min-h-[48px] px-4 bg-gray-900 border border-gray-700 rounded-xl text-white placeholder:text-gray-500 focus:outline-none focus:ring-2 focus:ring-primary-yellow"
|
|
/>
|
|
</div>
|
|
|
|
<input
|
|
value={draft.phone}
|
|
onChange={(e) => field('phone', e.target.value)}
|
|
placeholder="Phone (optional)"
|
|
inputMode="tel"
|
|
autoComplete="off"
|
|
className="w-full min-h-[48px] px-4 bg-gray-900 border border-gray-700 rounded-xl text-white placeholder:text-gray-500 focus:outline-none focus:ring-2 focus:ring-primary-yellow"
|
|
/>
|
|
|
|
<button
|
|
onClick={() => setDetailsOpen((open) => !open)}
|
|
className="w-full min-h-[48px] flex items-center justify-between px-2 text-sm text-gray-400 active:text-white"
|
|
>
|
|
Add details (email, RUC)
|
|
<ChevronDownIcon className={clsx('w-4 h-4 transition-transform', detailsOpen && 'rotate-180')} />
|
|
</button>
|
|
|
|
{detailsOpen && (
|
|
<div className="space-y-2">
|
|
<input
|
|
value={draft.email}
|
|
onChange={(e) => field('email', e.target.value)}
|
|
placeholder="Email — sends the usual confirmation"
|
|
inputMode="email"
|
|
autoComplete="off"
|
|
autoCapitalize="none"
|
|
className="w-full min-h-[48px] px-4 bg-gray-900 border border-gray-700 rounded-xl text-white placeholder:text-gray-500 focus:outline-none focus:ring-2 focus:ring-primary-yellow"
|
|
/>
|
|
<input
|
|
value={draft.ruc}
|
|
onChange={(e) => field('ruc', e.target.value)}
|
|
placeholder="RUC (for factura)"
|
|
autoComplete="off"
|
|
className="w-full min-h-[48px] px-4 bg-gray-900 border border-gray-700 rounded-xl text-white placeholder:text-gray-500 focus:outline-none focus:ring-2 focus:ring-primary-yellow"
|
|
/>
|
|
</div>
|
|
)}
|
|
|
|
<PaymentButtons
|
|
price={price}
|
|
currency={currency}
|
|
onPay={onPay}
|
|
disabled={busy || !draft.firstName.trim()}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|