feat(waiter): English-first texts, part b: table detail, ordering, options, payment (platform-v2 step 4.5b)

- Table detail (actions, item actions, split, price, discount, pay / revert / close,
  move / merge / transfer, guests, flags, assign, print), the order drawer (tabs,
  options, quick notes, price change, summary), add items (cart, totals, deals,
  search), the order summary and the summary before sending, the product picker.
- Money everywhere here in the language's format (`money()` in waiter i18n.js for
  helpers shared by several components, useFormat() elsewhere).
- The default quick notes are keys (the venue's own quick notes still win).
- Variables named `t` (tables, tabs, timers) renamed so they don't shadow t().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 03:59:12 +02:00
co-authored by Claude Opus 5.5
parent 37155c0457
commit 2c4f78af47
10 changed files with 939 additions and 337 deletions
+66 -57
View File
@@ -13,22 +13,24 @@ import useConnectionStore from '../store/connectionStore'
import useAuthStore from '../store/authStore'
import { queueOfflineOrder } from '../services/offlineOrders'
import { assetUrl } from '../config/server'
import { money } from '../i18n'
import { LineError, estimate, wireLine } from '@xenia/api'
import { useTranslation } from '@xenia/i18n'
// A cart item whose option is not on the menu any more (4.4: lines go by id)
const lineErrorText = err => `«${err.product}»: το «${err.what}» δεν υπάρχει πια στο μενού. Αφαιρέστε το και προσθέστε το ξανά.`
const money = v => `${Number(v || 0).toFixed(2)} €`
const lineErrorText = (err, t) => t('add.optionGone', { product: err.product, what: err.what })
// ─── Global Course Modal ──────────────────────────────────────────────────────
function GlobalCourseModal({ courses, selected, onSelect, onClose }) {
const { t } = useTranslation('waiter')
return (
<div className="modal-overlay" onClick={onClose}>
<div className="modal-sheet" onClick={e => e.stopPropagation()}>
<div className="modal-handle" />
<h2 className="modal-title">Set Course</h2>
<h2 className="modal-title">{t('add.course.title')}</h2>
<p style={{ textAlign: 'center', color: 'var(--muted)', fontSize: 13, margin: '0 0 16px' }}>
Quick-add items will use this course.
{t('add.course.sub')}
</p>
<div style={{ display: 'flex', flexDirection: 'column', gap: 8, marginBottom: 16 }}>
{courses.map(c => (
@@ -57,10 +59,10 @@ function GlobalCourseModal({ courses, selected, onSelect, onClose }) {
style={{ width: '100%', marginBottom: 8 }}
onClick={() => { onSelect(null); onClose() }}
>
Clear
{t('common.clear')}
</button>
)}
<button className="btn btn--secondary" style={{ width: '100%' }} onClick={onClose}>Cancel</button>
<button className="btn btn--secondary" style={{ width: '100%' }} onClick={onClose}>{t('common.cancel')}</button>
</div>
</div>
)
@@ -69,6 +71,7 @@ function GlobalCourseModal({ courses, selected, onSelect, onClose }) {
// ─── Customer count modal ─────────────────────────────────────────────────────
function CustomerCountModal({ value, onChange, onClose }) {
const { t } = useTranslation('waiter')
const [count, setCount] = useState(value ?? 0)
const QUICK = [1, 2, 3, 4, 5, 6]
@@ -76,9 +79,9 @@ function CustomerCountModal({ value, onChange, onClose }) {
<div className="modal-overlay" onClick={onClose}>
<div className="modal-sheet" onClick={e => e.stopPropagation()}>
<div className="modal-handle" />
<h2 className="modal-title">Αριθμός Πελατών</h2>
<h2 className="modal-title">{t('detail.guests.title')}</h2>
<p style={{ textAlign: 'center', color: 'var(--muted)', fontSize: 13, margin: '0 0 20px' }}>
Πόσα άτομα κάθονται στο τραπέζι;
{t('detail.guests.question')}
</p>
{/* Quick pick */}
@@ -105,9 +108,9 @@ function CustomerCountModal({ value, onChange, onClose }) {
</div>
<div style={{ display: 'flex', gap: 10 }}>
<button className="btn btn--secondary" style={{ flex: 1 }} onClick={onClose}>Άκυρο</button>
<button className="btn btn--secondary" style={{ flex: 1 }} onClick={onClose}>{t('common.cancel')}</button>
<button className="btn btn--primary" style={{ flex: 1 }} onClick={() => { onChange(count || null); onClose() }}>
Εφαρμογή
{t('common.apply')}
</button>
</div>
</div>
@@ -120,13 +123,14 @@ function CustomerCountModal({ value, onChange, onClose }) {
// menu's prices as an estimate. A line the server would refuse shows its reason here.
function CartTotal({ priced, estimatedTotal, offline }) {
const { t } = useTranslation('waiter')
const exact = !!priced?.data
return (
<div data-testid="cart-total" data-estimated={exact ? 'false' : 'true'}
style={{ display: 'flex', flexDirection: 'column', gap: 4 }}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'baseline' }}>
<span style={{ fontSize: 13, color: 'var(--muted)', fontWeight: 600 }}>
{exact ? 'Σύνολο' : offline ? 'Σύνολο (εκτίμηση, χωρίς σύνδεση)' : 'Σύνολο (εκτίμηση)'}
{exact ? t('common.total') : offline ? t('add.totalEstimateOffline') : t('add.totalEstimate')}
</span>
<span style={{ fontSize: 17, fontWeight: 800, color: 'var(--text)', fontVariantNumeric: 'tabular-nums' }}>
{exact ? money(priced.data.total) : `≈ ${money(estimatedTotal)}`}
@@ -148,6 +152,7 @@ function fmtDraftQty(qty, unitType) {
}
export default function AddItemsPage() {
const { t } = useTranslation('waiter')
const { tableId, orderType } = useParams()
const isStandalone = !!orderType // true when on /standalone/:orderType/add
const [searchParams] = useSearchParams()
@@ -199,8 +204,8 @@ export default function AddItemsPage() {
try {
const statusRes = await client.get(`/api/tables/${tableId}/status`)
setOrderId(statusRes.data.active_order_id)
const t = statusRes.data.table
if (t) setTableLabel(t.label || `T${t.number}`)
const tbl = statusRes.data.table
if (tbl) setTableLabel(tbl.label || `T${tbl.number}`)
// Load existing customer count from the active order
if (statusRes.data.active_order_id) {
const { data: o } = await client.get(`/api/orders/${statusRes.data.active_order_id}`)
@@ -208,8 +213,8 @@ export default function AddItemsPage() {
}
} catch {
// Offline — read table label from IDB snapshot
const t = await db.pos_tables.get(Number(tableId))
if (t) setTableLabel(t.label || `T${t.number}`)
const tbl = await db.pos_tables.get(Number(tableId))
if (tbl) setTableLabel(tbl.label || `T${tbl.number}`)
// orderId stays null — offline orders don't need a pre-existing server order
}
}
@@ -325,17 +330,17 @@ export default function AddItemsPage() {
if (!quoteKey) return undefined
let lines
try { lines = cartLines() } catch (err) {
const t = setTimeout(() => setQuote({ key: quoteKey, data: null, error: err instanceof LineError ? lineErrorText(err) : String(err) }), 0)
return () => clearTimeout(t)
const timer = setTimeout(() => setQuote({ key: quoteKey, data: null, error: err instanceof LineError ? lineErrorText(err, t) : String(err) }), 0)
return () => clearTimeout(timer)
}
const t = setTimeout(() => {
const timer = setTimeout(() => {
client.post('/api/orders/quote', {
lines, order_id: orderId ?? undefined, order_type: isStandalone ? orderType : 'here',
}, { noOverride: true })
.then(r => setQuote({ key: quoteKey, data: r.data, error: null }))
.catch(err => setQuote({ key: quoteKey, data: null, error: apiError(err, '') }))
}, 250)
return () => clearTimeout(t)
return () => clearTimeout(timer)
}, [quoteKey]) // eslint-disable-line react-hooks/exhaustive-deps
const priced = quote && quote.key === quoteKey ? quote : null
@@ -370,7 +375,7 @@ export default function AddItemsPage() {
setTimeout(() => navigate('/tables'), 1200)
} catch (err) {
console.error('[offline order] save failed:', err)
setError(err instanceof LineError ? lineErrorText(err) : 'Σφάλμα αποθήκευσης offline παραγγελίας')
setError(err instanceof LineError ? lineErrorText(err, t) : t('add.offlineSaveFailed'))
} finally {
setSending(false)
}
@@ -382,7 +387,7 @@ export default function AddItemsPage() {
let lines
try { lines = cartLines() } catch (err) {
if (!(err instanceof LineError)) throw err
setError(lineErrorText(err))
setError(lineErrorText(err, t))
return
}
let activeOrderId = orderId
@@ -414,7 +419,7 @@ export default function AddItemsPage() {
setTimeout(() => navigate('/tables'), 1200)
}
} catch (err) {
setError(apiError(err, 'Σφάλμα αποστολής — η παραγγελία δεν στάλθηκε'))
setError(apiError(err, t('add.sendFailed')))
} finally {
setSending(false)
}
@@ -517,11 +522,11 @@ export default function AddItemsPage() {
if (item.selected_options?.length) {
item.selected_options.forEach(o => {
if (o.price_delta && o.price_delta !== 0)
lines.push(`${o.name} (${o.price_delta > 0 ? '+' : ''}${o.price_delta.toFixed(2)} €)`)
lines.push(`${o.name} (${o.price_delta > 0 ? '+' : ''}${money(o.price_delta)})`)
else lines.push(o.name)
})
}
if (item.removed_ingredients?.length) lines.push(`Χωρίς: ${item.removed_ingredients.join(', ')}`)
if (item.removed_ingredients?.length) lines.push(t('add.withoutList', { names: item.removed_ingredients.join(', ') }))
if (item.notes) lines.push(item.notes)
return lines
}
@@ -534,14 +539,14 @@ export default function AddItemsPage() {
<div className="page" style={{ position: 'relative' }}>
<header className="top-bar">
<button className="icon-btn" onClick={handleBack}>←</button>
<span className="top-bar__title">{tableLabel || (isNewTable ? 'Νέα Παραγγελία' : 'Προσθήκη')}</span>
<span className="top-bar__title">{tableLabel || (isNewTable ? t('add.newOrder') : t('add.add'))}</span>
<div style={{ display: 'flex', alignItems: 'center', gap: 4 }}>
{/* Customer count button */}
<button
className="icon-btn"
style={{ position: 'relative' }}
onClick={() => setCustomerCountOpen(true)}
title="Αριθμός πελατών"
title={t('detail.guests.button')}
>
<svg width="20" height="20" viewBox="0 0 24 24" fill="none">
<path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
@@ -566,7 +571,7 @@ export default function AddItemsPage() {
className="icon-btn"
style={{ position: 'relative' }}
onClick={() => setGlobalCourseOpen(true)}
title="Set course"
title={t('add.course.title')}
>
<svg width="20" height="20" viewBox="0 0 24 24" fill="none">
<circle cx="12" cy="12" r="9" stroke="currentColor" strokeWidth="2" strokeLinecap="round"/>
@@ -588,14 +593,14 @@ export default function AddItemsPage() {
</button>
)}
{/* Search button */}
<button className="icon-btn" onClick={() => { setSearchQuery(''); setSearchOpen(true) }} title="Αναζήτηση">
<button className="icon-btn" onClick={() => { setSearchQuery(''); setSearchOpen(true) }} title={t('add.search.title')}>
<svg width="20" height="20" viewBox="0 0 24 24" fill="none">
<circle cx="11" cy="11" r="7" stroke="currentColor" strokeWidth="2.2"/>
<path d="M16.5 16.5L21 21" stroke="currentColor" strokeWidth="2.2" strokeLinecap="round"/>
</svg>
</button>
{/* Categories button */}
<button className="icon-btn" onClick={() => setViewAllOpen(true)} title="Όλες οι κατηγορίες">
<button className="icon-btn" onClick={() => setViewAllOpen(true)} title={t('add.allCategories')}>
<svg width="20" height="20" viewBox="0 0 24 24" fill="none">
<rect x="3" y="3" width="7" height="7" rx="1.5" stroke="currentColor" strokeWidth="2" strokeLinecap="round"/>
<rect x="14" y="3" width="7" height="7" rx="1.5" stroke="currentColor" strokeWidth="2" strokeLinecap="round"/>
@@ -646,7 +651,7 @@ export default function AddItemsPage() {
<QuickAddToast product={quickToast.product} count={quickToast.count} />
)}
{/* ── Bottom bar: floating mini-cart + full-width ΑΠΟΣΤΟΛΗ ─────────────── */}
{/* ── Bottom bar: floating mini-cart + full-width SEND ─────────────── */}
<div style={{
background: 'var(--bg2)',
borderTop: '1px solid var(--border)',
@@ -680,7 +685,7 @@ export default function AddItemsPage() {
})}
{hiddenCount > 0 && (
<div style={{ fontSize: 11, color: 'var(--muted)', textAlign: 'right' }}>
+{hiddenCount} ακόμα — δείτε όλα →
{t('add.moreSeeAll', { count: hiddenCount })}
</div>
)}
</div>
@@ -693,7 +698,7 @@ export default function AddItemsPage() {
onClick={() => summaryBeforeSend && cart.length > 0 ? setSummaryOpen(true) : sendOrder()}
disabled={cart.length === 0 || sending}
>
{sending ? 'Αποστολή…' : summaryBeforeSend && cart.length > 0 ? `ΣΥΝΟΨΗ (${cart.length})` : `ΑΠΟΣΤΟΛΗ${cart.length > 0 ? ` (${cart.length})` : ''}`}
{sending ? t('add.sending') : summaryBeforeSend && cart.length > 0 ? t('add.summaryCount', { count: cart.length }) : cart.length > 0 ? t('add.sendCount', { count: cart.length }) : t('add.send')}
</button>
{error && <p className="error-msg" style={{ marginTop: 8 }}>{error}</p>}
@@ -728,8 +733,8 @@ export default function AddItemsPage() {
{/* Drawer header */}
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', padding: '14px 16px', borderBottom: '1px solid var(--border)', flexShrink: 0 }}>
<div>
<div style={{ fontSize: 16, fontWeight: 700, color: 'var(--text)' }}>Παραγγελία</div>
<div style={{ fontSize: 12, color: 'var(--muted)', marginTop: 1 }}>{cart.length} {cart.length === 1 ? 'προϊόν' : 'προϊόντα'}</div>
<div style={{ fontSize: 16, fontWeight: 700, color: 'var(--text)' }}>{t('add.order')}</div>
<div style={{ fontSize: 12, color: 'var(--muted)', marginTop: 1 }}>{t('add.products', { count: cart.length })}</div>
</div>
<button onClick={() => setCartOpen(false)} style={{ background: 'var(--bg3)', border: 'none', borderRadius: '50%', width: 34, height: 34, display: 'flex', alignItems: 'center', justifyContent: 'center', cursor: 'pointer', color: 'var(--text)' }}>
<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><path d="M6 6L18 18M6 18L18 6" stroke="currentColor" strokeWidth="2.2" strokeLinecap="round"/></svg>
@@ -739,7 +744,7 @@ export default function AddItemsPage() {
{/* Item list */}
<div style={{ flex: 1, overflowY: 'auto', padding: 12 }}>
{cart.length === 0 ? (
<p style={{ color: 'var(--muted)', textAlign: 'center', padding: '40px 0', fontSize: 14 }}>Η παραγγελία είναι κενή.</p>
<p style={{ color: 'var(--muted)', textAlign: 'center', padding: '40px 0', fontSize: 14 }}>{t('add.empty')}</p>
) : courses.length > 0 ? (() => {
// Group by course, ordered by course definition, "no course" last
const groups = []
@@ -768,7 +773,7 @@ export default function AddItemsPage() {
textTransform: 'uppercase', letterSpacing: 0.8,
marginBottom: 6,
}}>
{group.course ? group.course.name : 'No course'}
{group.course ? group.course.name : t('add.course.none')}
</div>
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
{group.items.map(item => {
@@ -822,7 +827,7 @@ export default function AddItemsPage() {
autoFocus
value={orderNote}
onChange={e => setOrderNote(e.target.value)}
placeholder="Σημείωση για ολόκληρη την παραγγελία…"
placeholder={t('add.note.placeholder')}
rows={3}
style={{
width: '100%', resize: 'none', padding: '10px 12px',
@@ -835,7 +840,7 @@ export default function AddItemsPage() {
onClick={() => setOrderNoteEditing(false)}
style={{ alignSelf: 'flex-end', background: 'none', border: 'none', fontSize: 12, fontWeight: 700, color: 'var(--accent)', cursor: 'pointer', padding: '2px 0' }}
>
Αποθήκευση
{t('common.save')}
</button>
</div>
) : orderNote ? (
@@ -843,7 +848,7 @@ export default function AddItemsPage() {
onClick={() => setOrderNoteEditing(true)}
style={{ cursor: 'pointer', padding: '9px 12px', background: 'rgba(245,158,11,0.09)', border: '1.5px solid rgba(245,158,11,0.3)', borderRadius: 10, fontSize: 13, color: 'var(--text)', lineHeight: 1.5, whiteSpace: 'pre-wrap', position: 'relative' }}
>
<span style={{ fontSize: 10, fontWeight: 700, color: '#f59e0b', textTransform: 'uppercase', letterSpacing: 0.6, display: 'block', marginBottom: 3 }}>Σημείωση Παραγγελίας</span>
<span style={{ fontSize: 10, fontWeight: 700, color: '#f59e0b', textTransform: 'uppercase', letterSpacing: 0.6, display: 'block', marginBottom: 3 }}>{t('add.note.title')}</span>
{orderNote}
<span style={{ position: 'absolute', top: 8, right: 10, fontSize: 11, color: '#f59e0b', fontWeight: 700 }}>✎</span>
</div>
@@ -858,7 +863,7 @@ export default function AddItemsPage() {
}}
>
<svg width="15" height="15" viewBox="0 0 24 24" fill="none"><path d="M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7" stroke="currentColor" strokeWidth="2" strokeLinecap="round"/><path d="M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/></svg>
Προσθήκη σημείωσης παραγγελίας
{t('add.note.add')}
</button>
)}
</div>
@@ -875,7 +880,7 @@ export default function AddItemsPage() {
onClick={() => { setCartOpen(false); if (summaryBeforeSend) setSummaryOpen(true); else sendOrder() }}
disabled={cart.length === 0 || sending}
>
{sending ? 'Αποστολή…' : summaryBeforeSend ? `ΣΥΝΟΨΗ (${cart.length})` : `ΑΠΟΣΤΟΛΗ (${cart.length})`}
{sending ? t('add.sending') : summaryBeforeSend ? t('add.summaryCount', { count: cart.length }) : t('add.sendCount', { count: cart.length })}
</button>
</div>
</div>
@@ -1008,7 +1013,7 @@ export default function AddItemsPage() {
)}
</svg>
<span style={{ color: printAck._offline || printAck._pending ? '#fcd34d' : '#86efac', fontWeight: 700, fontSize: 18, letterSpacing: 0.3 }}>
{printAck._offline ? 'Αποθηκεύτηκε Offline' : printAck._pending ? 'Στάλθηκε — Εκτύπωση σε εξέλιξη' : 'Εκτυπώθηκε Επιτυχώς'}
{printAck._offline ? t('add.ack.offline') : printAck._pending ? t('add.ack.printing') : t('add.ack.printed')}
</span>
</div>
<style>{`
@@ -1024,6 +1029,7 @@ export default function AddItemsPage() {
// ── Deal Offer Modal ──────────────────────────────────────────────────────────
function DealOfferModal({ offer, _products, onAccept, onDismiss }) {
const { t } = useTranslation('waiter')
const isFreeItem = offer.action_type === 'free_item'
const isFreeChoice = offer.action_type === 'free_choice'
const isDiscount = ['set_price','add_amount','add_percent','apply_modifier'].includes(offer.action_type)
@@ -1069,7 +1075,7 @@ function DealOfferModal({ offer, _products, onAccept, onDismiss }) {
stroke="#a78bfa" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
</svg>
</div>
<h2 style={{ margin: 0, fontSize: 17, fontWeight: 700, color: '#a78bfa' }}>Προσφορά Ενεργοποιήθηκε!</h2>
<h2 style={{ margin: 0, fontSize: 17, fontWeight: 700, color: '#a78bfa' }}>{t('add.deal.title')}</h2>
<p style={{ margin: '6px 0 0', fontSize: 14, fontWeight: 600, color: 'var(--text)' }}>{offer.deal_name}</p>
</div>
@@ -1080,7 +1086,7 @@ function DealOfferModal({ offer, _products, onAccept, onDismiss }) {
background: 'rgba(34,197,94,0.08)', border: '1.5px solid rgba(34,197,94,0.3)',
borderRadius: 12,
}}>
<p style={{ margin: 0, fontSize: 13, color: 'var(--muted)', marginBottom: 4 }}>Δωρεάν προϊόν:</p>
<p style={{ margin: 0, fontSize: 13, color: 'var(--muted)', marginBottom: 4 }}>{t('add.deal.freeProduct')}</p>
<p style={{ margin: 0, fontSize: 15, fontWeight: 700, color: '#4ade80' }}>
{offer.free_item_name}
{offer.free_quantity > 1 && <span style={{ color: '#f59e0b', marginLeft: 6 }}>×{offer.free_quantity}</span>}
@@ -1092,8 +1098,8 @@ function DealOfferModal({ offer, _products, onAccept, onDismiss }) {
{isFreeChoice && offer.free_choices?.length > 0 && (
<div style={{ marginBottom: 16 }}>
<p style={{ fontSize: 12, color: 'var(--muted)', marginBottom: 8 }}>
Επιλέξτε {offer.free_quantity ?? 1} δωρεάν {offer.free_quantity === 1 ? 'προϊόν' : 'προϊόντα'}
{remaining > 0 && <span style={{ color: '#a78bfa', marginLeft: 4 }}>({remaining} ακόμα)</span>}
{t('add.deal.pickFree', { count: offer.free_quantity ?? 1 })}
{remaining > 0 && <span style={{ color: '#a78bfa', marginLeft: 4 }}>{t('add.deal.remaining', { count: remaining })}</span>}
</p>
<div style={{ display: 'flex', flexDirection: 'column', gap: 6, maxHeight: 220, overflowY: 'auto' }}>
{offer.free_choices.map(choice => {
@@ -1130,21 +1136,21 @@ function DealOfferModal({ offer, _products, onAccept, onDismiss }) {
borderRadius: 12, textAlign: 'center',
}}>
<span style={{ fontSize: 14, color: 'var(--muted)', textDecoration: 'line-through' }}>
{offer.price_before.toFixed(2)} €
{money(offer.price_before)}
</span>
<span style={{ fontSize: 22, fontWeight: 800, color: '#4ade80', margin: '0 12px' }}>
{offer.price_after.toFixed(2)} €
{money(offer.price_after)}
</span>
</div>
)}
<div style={{ display: 'flex', gap: 10 }}>
<button className="btn btn--secondary" style={{ flex: 1 }} onClick={onDismiss}>
Παράβλεψη
{t('add.deal.skip')}
</button>
<button className="btn btn--primary" style={{ flex: 1, background: '#7c3aed', borderColor: '#7c3aed' }}
onClick={handleAccept} disabled={!canConfirm}>
{isFreeItem ? 'Προσθήκη Δωρεάν' : isFreeChoice ? 'Επιβεβαίωση' : 'Εφαρμογή'}
{isFreeItem ? t('add.deal.addFree') : isFreeChoice ? t('common.confirm') : t('common.apply')}
</button>
</div>
</div>
@@ -1155,6 +1161,7 @@ function DealOfferModal({ offer, _products, onAccept, onDismiss }) {
// ── Quick-Add Toast ───────────────────────────────────────────────────────────
function QuickAddToast({ product, count }) {
const { t } = useTranslation('waiter')
const initials = product.name.trim().split(/\s+/).slice(0, 2).map(w => w[0]).join('').toUpperCase()
return (
<div style={{
@@ -1188,7 +1195,7 @@ function QuickAddToast({ product, count }) {
fontSize: 13, fontWeight: 600, color: 'var(--text)',
overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap',
}}>{product.name}</div>
<div style={{ fontSize: 11, color: 'var(--muted)', marginTop: 1 }}>στο καλάθι</div>
<div style={{ fontSize: 11, color: 'var(--muted)', marginTop: 1 }}>{t('add.inCart')}</div>
</div>
{/* Count badge */}
<div style={{
@@ -1230,6 +1237,7 @@ function SectionIcon({ type }) {
}
function CartItem({ item, product, summaryLines, sections, onEdit, onRemove, onChangeQty }) {
const { t } = useTranslation('waiter')
const [expanded, setExpanded] = useState(false)
const hasDetails = sections.length > 0
@@ -1262,7 +1270,7 @@ function CartItem({ item, product, summaryLines, sections, onEdit, onRemove, onC
{/* Edit — stop propagation so it doesn't toggle expand */}
<button onClick={e => { e.stopPropagation(); onEdit() }} style={{ background: 'none', border: '1px solid var(--border)', borderRadius: 7, color: 'var(--muted)', cursor: 'pointer', padding: '3px 9px', fontSize: 12, fontWeight: 500, flexShrink: 0 }}>
Επεξ.
{t('add.edit')}
</button>
{/* Remove */}
<button onClick={e => { e.stopPropagation(); onRemove() }} style={{ background: 'none', border: 'none', color: 'var(--danger)', cursor: 'pointer', padding: 4, display: 'flex', alignItems: 'center', flexShrink: 0 }}>
@@ -1307,7 +1315,7 @@ function CartItem({ item, product, summaryLines, sections, onEdit, onRemove, onC
{sec.type === 'removed' && sec.lines.map((line, li) => (
<div key={li} style={{ display: 'flex', alignItems: 'center', gap: 7 }}>
<SectionIcon type="removed" />
<span style={{ fontSize: 12, color: 'var(--text)', flex: 1 }}>Χωρίς {line.name}</span>
<span style={{ fontSize: 12, color: 'var(--text)', flex: 1 }}>{t('drawer.without', { name: line.name })}</span>
</div>
))}
{sec.type === 'note' && sec.lines.map((line, li) => (
@@ -1366,6 +1374,7 @@ function CartItem({ item, product, summaryLines, sections, onEdit, onRemove, onC
function SearchModal({ products, query, setQuery, onClose, onAdd, courses = [], quickNotes }) {
const { t } = useTranslation('waiter')
const [drawerProduct, setDrawerProduct] = useState(null)
const activeProducts = products.filter(p => p.lifecycle_status !== 'archived')
@@ -1404,11 +1413,11 @@ function SearchModal({ products, query, setQuery, onClose, onAdd, courses = [],
<div style={{ flex: 1, overflowY: 'auto', minHeight: 0 }}>
{query.trim().length === 0 ? (
<p style={{ textAlign: 'center', color: 'var(--muted)', padding: '16px 20px', fontSize: 14 }}>
Πληκτρολογήστε για αναζήτηση…
{t('add.search.type')}
</p>
) : results.length === 0 ? (
<p style={{ textAlign: 'center', color: 'var(--muted)', padding: '16px 20px', fontSize: 14 }}>
Δεν βρέθηκαν προϊόντα για «{query}»
{t('add.search.none', { query })}
</p>
) : results.map(p => {
const initials = p.name.trim().split(/\s+/).slice(0, 2).map(w => w[0]).join('').toUpperCase()
@@ -1439,7 +1448,7 @@ function SearchModal({ products, query, setQuery, onClose, onAdd, courses = [],
{p.name}
</div>
<div style={{ fontSize: 12, color: 'var(--muted)', marginTop: 2 }}>
{Number(p.base_price).toFixed(2)} €
{money(p.base_price)}
</div>
</div>
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" style={{ color: 'var(--muted)', flexShrink: 0 }}>
@@ -1465,7 +1474,7 @@ function SearchModal({ products, query, setQuery, onClose, onAdd, courses = [],
autoFocus
value={query}
onChange={e => setQuery(e.target.value)}
placeholder="Αναζήτηση προϊόντος…"
placeholder={t('add.search.placeholder')}
style={{
flex: 1, height: 44, background: 'var(--bg2)',
border: '1px solid var(--border)', borderRadius: 12,