// One table booking at the counter (plan phase 3S, step S.6): who, how many, when, their note, // and the food they ordered ahead (with a warning when the venue's prices differ). A request is // confirmed or declined (the customer sees the answer and the reason); a confirmed booking says // when its food goes to the kitchen, seats the guests at a free table (their food's order moves // there, and is sent now if it hadn't been), or is cancelled / marked as a no-show. import { useState } from 'react' import { AlertTriangle, Ban, Check, ChefHat, MessageSquare, Phone, UserX, Users } from 'lucide-react' import { errorMessage } from '@xenia/api' import { useFormat, useTranslation } from '@xenia/i18n' import { Button, Dialog, EmptyState, Input, Select } from '@xenia/ui' import client from '../../api/client' import { bookingSteps, foodState, freeTables, whenLabel } from './logic/bookings' const REASONS = ['full', 'closed', 'party'] export default function BookingPanel({ booking, tables, onChanged }) { const { t } = useTranslation('terminal') const fmt = useFormat() const [busy, setBusy] = useState(false) const [error, setError] = useState('') const [table, setTable] = useState('') const [declining, setDeclining] = useState(false) if (!booking) { return ( ) } const steps = bookingSteps(booking) const food = foodState(booking) const free = freeTables(tables) const run = async (path, body) => { setBusy(true) setError('') try { await client.post(`/api/connect/bookings/${booking.id}/${path}`, body ?? {}) setDeclining(false) onChanged() } catch (err) { setError(errorMessage(err, t)); onChanged() } finally { setBusy(false) } } return ( ) } function Detail({ icon: Icon, children }) { return
} function DeclineDialog({ busy, error, onClose, onDecline }) { const { t } = useTranslation('terminal') const [choice, setChoice] = useState(null) const [other, setOther] = useState('') const reason = choice === 'other' ? other.trim() : choice ? t(`pos.bookings.reasons.${choice}`) : '' return ( }>

{t('pos.online.rejectBody')}

{[...REASONS, 'other'].map(r => ( ))}
{choice === 'other' && setOther(e.target.value)} maxLength={300} autoFocus aria-label={t('pos.online.reason')} />} {error &&

{error}

}
) }