import { useState } from 'react' import { useParams, useNavigate } from 'react-router-dom' import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query' import toast from 'react-hot-toast' import client from '../api/client' import { Percent } from 'lucide-react' import Badge from '../ui/Badge' import { ConfirmModal } from '../ui/Modal' import PaymentMethodModal from '../ui/PaymentMethodModal' import DesktopOrderingTab from './DesktopOrderingTab' function PrintOrderModal({ onClose, onPrint, printers }) { const [printerId, setPrinterId] = useState(printers[0]?.id ?? '') function submit() { if (!printerId) { toast.error('Επιλέξτε εκτυπωτή'); return } onPrint(Number(printerId)) onClose() } return (
Δεν υπάρχουν εγγραφές.
} const itemsById = Object.fromEntries((order.items || []).map(i => [i.id, i])) return (Δεν υπάρχουν συμβάντα τιμολόγησης για αυτή την παραγγελία.
"{ev.waiter_note}"
)} {ev.conditions_snapshot && Object.keys(ev.conditions_snapshot).length > 0 && (
{JSON.stringify(ev.conditions_snapshot, null, 2)}
Τραπέζι {order.table_name || order.table_id} · Ανοίχτηκε {formatDate(order.opened_at)} {order.closed_at && ` · Έκλεισε ${formatDate(order.closed_at)}`}
Κανένα αντικείμενο.
)} {order.items.map(item => { const isCancelled = item.status === 'cancelled' const isClosedItem = item.status === 'closed' const badgeStatus = isClosedItem ? 'closed_item' : item.status const hasPriceAdj = !!(item.price_adjustment && item.price_adjustment !== 0) const isDealItem = !!item.deal_id const itemPriceEvents = (priceEventsMap[item.id] ?? []).filter(ev => ['modifier_applied','waiter_discount','free_item_added'].includes(ev.event_type)) const EVENT_COLORS_ODP = { modifier_applied: '#2563eb', waiter_discount: '#7c3aed', free_item_added: '#16a34a' } return ({item.product?.name ?? `#${item.product_id}`} {item.course_id != null && ( {item.course_id} )} {isDealItem && ΔΩΡΕΑΝ}
{item.notes &&{item.notes}
}x{item.quantity} · €{effPrice(item).toFixed(2)}/τμχ {hasPriceAdj && ( €{(item.unit_price ?? 0).toFixed(2)} )}
{itemPriceEvents.map((ev, ei) => { const evColor = EVENT_COLORS_ODP[ev.event_type] || '#8a9099' const evLabel = ev.modifier_name || ev.deal_name || (ev.event_type === 'waiter_discount' ? 'Έκπτωση' : ev.event_type === 'free_item_added' ? 'Δωρεάν' : ev.event_type) return (↳ {evLabel} {ev.delta_amount != null && {ev.delta_amount > 0 ? '+' : ''}{ev.delta_amount.toFixed(2)} €}
) })} {item.paid_by && (Πληρώθηκε: {item.paid_by_name ?? waiterMap[item.paid_by] ?? `#${item.paid_by}`} {item.paid_at ? ` · ${formatDate(item.paid_at)}` : ''} {item.payment_method && ( {' · '}{(PAYMENT_METHOD_STYLES[item.payment_method] || { label: item.payment_method.toUpperCase() }).label} )}
)} {isClosedItem && (Απλήρωτο — κλείστηκε από manager
)}Δεν βρέθηκαν ενεργοί εκτυπωτές.