feat: bump client-services (accumulated feature work + deploy fixes)

Snapshot of in-progress work across local_backend, manager_dashboard,
and waiter_pwa (pricing, chat, fiscal, prep zones, recovery codes, CRM,
inventory, permissions), plus the nginx/docker-compose deploy fixes for
the Unraid + NPM reverse-proxy setup.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-19 10:00:14 +03:00
co-authored by Claude Sonnet 5
parent 02ec1aa28f
commit 34ae328b0d
182 changed files with 34874 additions and 3556 deletions
+195 -8
View File
@@ -3,9 +3,11 @@ 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 ?? '')
@@ -37,8 +39,9 @@ function PrintOrderModal({ onClose, onPrint, printers }) {
)
}
function effPrice(item) { return (item.unit_price ?? 0) + (item.price_adjustment ?? 0) }
function itemTotal(item) {
return (item.unit_price * item.quantity).toFixed(2)
return (effPrice(item) * item.quantity).toFixed(2)
}
const PAYMENT_METHOD_STYLES = {
@@ -147,6 +150,98 @@ function AuditTab({ order, waiterMap }) {
)
}
// ─── Price Events Tab ────────────────────────────────────────────────────────
const PRICE_EVENT_LABELS = {
modifier_applied: 'Τροποποιητής',
deal_triggered: 'Προσφορά',
deal_offer_shown: 'Προσφορά (εμφανίστηκε)',
deal_offer_accepted: 'Προσφορά (αποδεκτή)',
deal_offer_dismissed:'Προσφορά (απορρίφθηκε)',
waiter_discount: 'Έκπτωση σερβιτόρου',
free_item_added: 'Δωρεάν αντικείμενο',
}
const PRICE_EVENT_COLORS = {
modifier_applied: { bg: '#eff6ff', color: '#1d4ed8', border: '#93c5fd' },
deal_triggered: { bg: '#f0fdf4', color: '#15803d', border: '#86efac' },
deal_offer_shown: { bg: '#fefce8', color: '#a16207', border: '#fde68a' },
deal_offer_accepted: { bg: '#f0fdf4', color: '#15803d', border: '#86efac' },
deal_offer_dismissed:{ bg: '#fef2f2', color: '#b91c1c', border: '#fca5a5' },
waiter_discount: { bg: '#fdf4ff', color: '#7e22ce', border: '#d8b4fe' },
free_item_added: { bg: '#f0fdf4', color: '#15803d', border: '#86efac' },
}
function PriceEventsTab({ orderId }) {
const { data: events = [], isLoading } = useQuery({
queryKey: ['price-events', orderId],
queryFn: () => client.get(`/api/pricing/events/order/${orderId}`).then(r => r.data),
})
if (isLoading) return (
<div className="flex justify-center py-16">
<div className="w-5 h-5 rounded-full border-2 border-sky-500 border-t-transparent animate-spin" />
</div>
)
if (events.length === 0) return (
<div className="py-16 text-center text-gray-400">
<Percent className="w-8 h-8 mx-auto mb-2 opacity-30" />
<p className="text-sm">Δεν υπάρχουν συμβάντα τιμολόγησης για αυτή την παραγγελία.</p>
</div>
)
return (
<div className="divide-y divide-gray-100">
{events.map(ev => {
const label = PRICE_EVENT_LABELS[ev.event_type] ?? ev.event_type
const style = PRICE_EVENT_COLORS[ev.event_type] ?? { bg: '#f8fafc', color: '#334155', border: '#cbd5e1' }
const hasDelta = ev.price_before != null && ev.price_after != null
return (
<div key={ev.id} className="flex items-start gap-3 px-4 py-3">
<div className="shrink-0 mt-0.5">
<span style={{ fontSize: 11, fontWeight: 700, padding: '2px 8px', borderRadius: 99, background: style.bg, color: style.color, border: `1px solid ${style.border}` }}>
{label}
</span>
</div>
<div className="flex-1 min-w-0 text-sm">
<div className="flex flex-wrap gap-x-3 gap-y-0.5 items-baseline">
{ev.modifier_name && <span className="font-medium text-gray-800">{ev.modifier_name}</span>}
{ev.deal_name && <span className="font-medium text-gray-800">{ev.deal_name}</span>}
{ev.applied_by_username && (
<span className="text-gray-500 text-xs">από {ev.applied_by_username}</span>
)}
{hasDelta && (
<span className={`text-xs font-semibold ${ev.delta_amount < 0 ? 'text-green-700' : 'text-red-600'}`}>
{ev.delta_amount > 0 ? '+' : ''}{ev.delta_amount?.toFixed(2)}€
<span className="font-normal text-gray-400 ml-1">
({ev.price_before?.toFixed(2)} → {ev.price_after?.toFixed(2)})
</span>
</span>
)}
</div>
{ev.waiter_note && (
<p className="text-xs text-gray-400 mt-0.5 italic">"{ev.waiter_note}"</p>
)}
{ev.conditions_snapshot && Object.keys(ev.conditions_snapshot).length > 0 && (
<details className="mt-1">
<summary className="text-xs text-gray-400 cursor-pointer hover:text-gray-600">Συνθήκες</summary>
<pre className="text-[10px] text-gray-500 bg-gray-50 rounded p-2 mt-1 overflow-x-auto">
{JSON.stringify(ev.conditions_snapshot, null, 2)}
</pre>
</details>
)}
</div>
<div className="shrink-0 text-right">
<span className="text-xs text-gray-400">{formatDate(ev.applied_at)}</span>
</div>
</div>
)
})}
</div>
)
}
export default function OrderDetailPage({ orderId: propOrderId, readOnly = false }) {
const { orderId: paramOrderId } = useParams()
const orderId = propOrderId ?? paramOrderId
@@ -178,6 +273,18 @@ export default function OrderDetailPage({ orderId: propOrderId, readOnly = false
staleTime: 60_000,
})
const { data: rawPriceEvents = [] } = useQuery({
queryKey: ['price-events', orderId],
queryFn: () => client.get(`/api/pricing/events/order/${orderId}`).then(r => r.data),
enabled: !!orderId,
staleTime: 30_000,
})
const priceEventsMap = rawPriceEvents.reduce((acc, ev) => {
if (!acc[ev.order_item_id]) acc[ev.order_item_id] = []
acc[ev.order_item_id].push(ev)
return acc
}, {})
const printOrder = useMutation({
mutationFn: (printerId) => client.post(`/api/orders/${orderId}/print`, { printer_id: printerId }),
onSuccess: () => toast.success('Αποστολή στον εκτυπωτή…'),
@@ -272,10 +379,52 @@ export default function OrderDetailPage({ orderId: propOrderId, readOnly = false
const activeItems = order.items.filter(i => i.status === 'active')
const total = order.items
.filter(i => i.status !== 'cancelled')
.reduce((s, i) => s + i.unit_price * i.quantity, 0)
.reduce((s, i) => s + effPrice(i) * i.quantity, 0)
const isOpen = ['open', 'partially_paid'].includes(order.status)
// The ordering tab needs full height and no outer padding
if (tab === 'order') {
return (
<div style={{ display: 'flex', flexDirection: 'column', height: '100%', overflow: 'hidden' }}>
{/* Compact header strip */}
<div style={{ padding: '10px 20px', borderBottom: '1px solid #e2e8f0', display: 'flex', alignItems: 'center', gap: 16, flexShrink: 0 }}>
{!propOrderId && (
<button onClick={() => navigate(-1)} className="btn btn-ghost text-sm">← Πίσω</button>
)}
<div style={{ fontSize: 14, color: '#64748b' }}>
Τραπέζι {order.table_name || order.table_id}
</div>
<Badge status={order.status} />
<span style={{ fontSize: 14, fontWeight: 700, color: '#1e293b' }}>€{total.toFixed(2)}</span>
<div style={{ flex: 1 }} />
{/* Tab strip inline */}
<div style={{ display: 'flex', gap: 1, borderBottom: 'none' }}>
{[['overview', 'Επισκόπηση'], ['order', 'Παραγγελία'], ['pricing', 'Τιμολόγηση'], ['audit', 'Ιστορικό']].map(([key, label]) => (
<button key={key} onClick={() => setTab(key)}
style={{
padding: '6px 14px', fontSize: 13, fontWeight: tab === key ? 700 : 500,
background: 'none', border: 'none', cursor: 'pointer',
borderBottom: `2px solid ${tab === key ? '#4f46e5' : 'transparent'}`,
color: tab === key ? '#4f46e5' : '#64748b',
}}>
{label}
</button>
))}
</div>
</div>
{/* Full-height ordering terminal */}
<div style={{ flex: 1, minHeight: 0, overflow: 'hidden' }}>
<DesktopOrderingTab
orderId={orderId}
tableId={order.table_id}
orderStatus={order.status}
/>
</div>
</div>
)
}
return (
<div className="overflow-y-auto h-full p-6">
<div className="max-w-3xl mx-auto space-y-6">
@@ -286,8 +435,7 @@ export default function OrderDetailPage({ orderId: propOrderId, readOnly = false
{/* Header */}
<div className="card p-5 flex flex-wrap gap-4 items-start justify-between">
<div>
<h1 className="text-xl font-bold text-gray-800">Παραγγελία #{order.id}</h1>
<p className="text-sm text-gray-500 mt-1">
<p className="text-sm text-gray-500">
Τραπέζι {order.table_name || order.table_id} · Ανοίχτηκε {formatDate(order.opened_at)}
{order.closed_at && ` · Έκλεισε ${formatDate(order.closed_at)}`}
</p>
@@ -367,7 +515,7 @@ export default function OrderDetailPage({ orderId: propOrderId, readOnly = false
{/* Tabs */}
<div className="flex gap-1 border-b border-gray-200">
{[['overview', 'Επισκόπηση'], ['audit', 'Ιστορικό Συναλλαγών']].map(([key, label]) => (
{[['overview', 'Επισκόπηση'], ['order', 'Παραγγελία'], ['pricing', 'Τιμολόγηση'], ['audit', 'Ιστορικό Συναλλαγών']].map(([key, label]) => (
<button
key={key}
onClick={() => setTab(key)}
@@ -423,12 +571,45 @@ export default function OrderDetailPage({ orderId: propOrderId, readOnly = false
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 (
<div key={item.id} className={`flex items-center gap-3 px-4 py-3 ${isCancelled ? 'opacity-40 line-through' : ''} ${isClosedItem ? 'bg-amber-50/50' : ''}`}>
<div className="flex-1 min-w-0">
<p className="font-medium text-gray-800 text-sm">{item.product?.name ?? `#${item.product_id}`}</p>
<p className="font-medium text-gray-800 text-sm" style={{ display: 'flex', alignItems: 'center', gap: 6, flexWrap: 'wrap' }}>
{item.product?.name ?? `#${item.product_id}`}
{item.course_id != null && (
<span style={{
display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
width: 18, height: 18, borderRadius: '50%',
background: '#6366f1', color: '#fff',
fontSize: 10, fontWeight: 700,
}} title="Course">
{item.course_id}
</span>
)}
{isDealItem && <span style={{ fontSize: 10, fontWeight: 700, padding: '1px 5px', borderRadius: 4, background: 'rgba(167,139,250,0.12)', color: '#7c3aed', border: '1px solid rgba(167,139,250,0.3)' }}>ΔΩΡΕΑΝ</span>}
</p>
{item.notes && <p className="text-xs text-gray-400">{item.notes}</p>}
<p className="text-xs text-gray-500">x{item.quantity} · €{item.unit_price.toFixed(2)}/τμχ</p>
<p className="text-xs" style={{ color: hasPriceAdj ? '#3b82f6' : '#6b7280' }}>
x{item.quantity} · €{effPrice(item).toFixed(2)}/τμχ
{hasPriceAdj && (
<span className="ml-1 line-through text-gray-400">€{(item.unit_price ?? 0).toFixed(2)}</span>
)}
</p>
{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 (
<p key={ei} className="text-xs" style={{ color: evColor, display: 'flex', alignItems: 'center', gap: 3 }}>
<span style={{ opacity: 0.6 }}>↳</span>
<span>{evLabel}</span>
{ev.delta_amount != null && <span style={{ fontWeight: 600 }}>{ev.delta_amount > 0 ? '+' : ''}{ev.delta_amount.toFixed(2)} €</span>}
</p>
)
})}
{item.paid_by && (
<p className="text-xs text-green-600 mt-0.5">
Πληρώθηκε: {item.paid_by_name ?? waiterMap[item.paid_by] ?? `#${item.paid_by}`}
@@ -445,7 +626,7 @@ export default function OrderDetailPage({ orderId: propOrderId, readOnly = false
)}
</div>
<div className="flex items-center gap-2 shrink-0">
<span className="text-sm font-semibold text-gray-700 w-14 text-right">€{itemTotal(item)}</span>
<span className="text-sm font-semibold w-14 text-right" style={{ color: hasPriceAdj ? '#3b82f6' : '#374151' }}>€{itemTotal(item)}</span>
{isOpen && !readOnly && item.status === 'active' && (
<>
<button
@@ -516,6 +697,12 @@ export default function OrderDetailPage({ orderId: propOrderId, readOnly = false
</div>
</>}
{tab === 'pricing' && (
<div className="card divide-y divide-gray-100">
<PriceEventsTab orderId={orderId} />
</div>
)}
{tab === 'audit' && (
<div className="card divide-y divide-gray-100">
<AuditTab order={order} waiterMap={waiterMap} />