'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(null); useEffect(() => { if (expanded) firstNameRef.current?.focus(); }, [expanded]); useEffect(() => { if (!expanded) setDetailsOpen(false); }, [expanded]); if (!expanded) { return ( ); } const field = (key: keyof WalkInDraft, value: string) => onChange({ ...draft, [key]: value }); return (

New walk-in

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" /> 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" />
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" /> {detailsOpen && (
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" /> 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" />
)}
); }