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,
+4 -3
View File
@@ -4,6 +4,7 @@ import { useProductCache } from '../hooks/useProductCache'
import useWaiterFavoritesStore from '../store/waiterFavoritesStore'
import { assetUrl } from '../config/server'
import { useFormat, useTranslation } from '@xenia/i18n'
import { money } from '../i18n'
// ── Heart icon ────────────────────────────────────────────────────────────────
function Heart({ filled, size = 22 }) {
@@ -67,10 +68,10 @@ function AttrSection({ title, items, favIds, onToggle }) {
{item.name}
</div>
{item.extra_cost != null && item.extra_cost !== 0 && (
<div style={{ fontSize: 12, color: 'var(--muted)' }}>+{Number(item.extra_cost).toFixed(2)} €</div>
<div style={{ fontSize: 12, color: 'var(--muted)' }}>+{money(item.extra_cost)}</div>
)}
{item.price != null && item.price !== 0 && (
<div style={{ fontSize: 12, color: 'var(--muted)' }}>+{Number(item.price).toFixed(2)} €</div>
<div style={{ fontSize: 12, color: 'var(--muted)' }}>+{money(item.price)}</div>
)}
</div>
<button
@@ -407,7 +408,7 @@ function FavoritesList({ items, products, onReorder }) {
{product.name}
</span>
<span style={{ fontSize: 12, color: 'var(--muted)', flexShrink: 0 }}>{Number(product.base_price).toFixed(2)} €</span>
<span style={{ fontSize: 12, color: 'var(--muted)', flexShrink: 0 }}>{money(product.base_price)}</span>
</div>
{dropIndex === idx + 1 && dragging != null && dragging !== idx && (
+158 -151
View File
@@ -5,14 +5,16 @@ import OrderSummary from '../components/OrderSummary'
import useConnectionStore from '../store/connectionStore'
import client from '../api/client'
import { apiError } from '../api/errors'
import { money } from '../i18n'
import { getVenueSettings } from '../api/venueSettings'
import db from '../db/posdb'
import { queueOfflineSplit, queueOfflinePayment as queueOfflinePaymentOp } from '../services/offlineOrders'
import { TransferIcon, MergeIcon, FlagsIcon, WaiterIcon, PrintIcon } from '../components/Icons'
import usePaymentSettingsStore from '../store/paymentSettingsStore'
import useTableViewStore from '../store/tableViewStore'
import { useTranslation } from '@xenia/i18n'
function fmtPrice(v) { return Number(v).toFixed(2) + ' €' }
const fmtPrice = money
// ─── Merge mode ───────────────────────────────────────────────────────────────
@@ -20,12 +22,6 @@ const MERGE_OFF = 'off'
const MERGE_IDENTICAL = 'identical' // same product + options + price
const MERGE_SAME_ITEM = 'same_item' // same product + same effective unit price
const MERGE_LABELS = {
[MERGE_OFF]: 'ΔΙΑΧΩΡΙΣΜΟΣ',
[MERGE_IDENTICAL]: 'ΙΔΙΑ ITEMS',
[MERGE_SAME_ITEM]: 'ΙΔΙΑ ΤΙΜΗ',
}
// Returns a stable string key for grouping under MERGE_IDENTICAL
function identicalKey(item) {
const effPrice = ((item.unit_price ?? 0) + (item.price_adjustment ?? 0)).toFixed(4)
@@ -73,6 +69,7 @@ function mergeItems(items, mode) {
// ─── Split stepper modal ──────────────────────────────────────────────────────
function SplitModal({ item, onConfirm, onClose }) {
const { t } = useTranslation('waiter')
const [splitQty, setSplitQty] = useState(1)
const max = item.quantity - 1
@@ -80,12 +77,12 @@ function SplitModal({ item, onConfirm, 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.split.title')}</h2>
<p style={{ textAlign: 'center', color: '#94a3b8', fontSize: 14, marginBottom: 4 }}>
{item.product?.name} ×{item.quantity}
</p>
<p style={{ textAlign: 'center', color: '#94a3b8', fontSize: 13, marginBottom: 16 }}>
Χώρισε σε πόσα;
{t('detail.split.howMany')}
</p>
<div className="modal-qty" style={{ marginBottom: 8 }}>
@@ -95,14 +92,14 @@ function SplitModal({ item, onConfirm, onClose }) {
</div>
<div style={{ display: 'flex', justifyContent: 'center', gap: 20, marginBottom: 20, fontSize: 13, color: '#94a3b8' }}>
<span>Νέα γραμμή: <strong style={{ color: '#f59e0b' }}>×{splitQty}</strong></span>
<span>Μένει: <strong style={{ color: '#64748b' }}>×{item.quantity - splitQty}</strong></span>
<span>{t('detail.split.newLine')} <strong style={{ color: '#f59e0b' }}>×{splitQty}</strong></span>
<span>{t('detail.split.remains')} <strong style={{ color: '#64748b' }}>×{item.quantity - splitQty}</strong></span>
</div>
<div style={{ display: 'flex', gap: 12 }}>
<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={() => onConfirm(splitQty)}>
Διαχωρισμός
{t('detail.split.title')}
</button>
</div>
</div>
@@ -113,6 +110,7 @@ function SplitModal({ item, onConfirm, onClose }) {
// ─── Price adjust modal ───────────────────────────────────────────────────────
function PriceAdjustModal({ item, onConfirm, onClose }) {
const { t } = useTranslation('waiter')
const basePrice = item.unit_price ?? 0
const [adj, setAdj] = useState(item.price_adjustment ?? 0)
const [editing, setEditing] = useState(false)
@@ -148,7 +146,7 @@ function PriceAdjustModal({ item, onConfirm, 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.price.title')}</h2>
<p style={{ textAlign: 'center', color: 'var(--muted)', fontSize: 13, margin: '0 0 16px' }}>
{item.product?.name}
</p>
@@ -180,15 +178,15 @@ function PriceAdjustModal({ item, onConfirm, onClose }) {
borderRadius: 12, padding: '6px 20px', cursor: 'pointer',
}}
>
{effective.toFixed(2)} €
{fmtPrice(effective)}
</button>
)}
{adj !== 0 && (
<div style={{ fontSize: 12, color: adj > 0 ? '#22c55e' : '#f87171', marginTop: 4 }}>
Βασική: {basePrice.toFixed(2)} € {adj > 0 ? '+' : ''}{adj.toFixed(2)} €
{t('detail.price.base', { base: fmtPrice(basePrice), change: `${adj > 0 ? '+' : ''}${fmtPrice(adj)}` })}
</div>
)}
<div style={{ fontSize: 11, color: 'var(--muted)', marginTop: 2 }}>Πάτα για πληκτρολόγιο</div>
<div style={{ fontSize: 11, color: 'var(--muted)', marginTop: 2 }}>{t('detail.price.tapToType')}</div>
</div>
{/* +/- stepper (0.1 step) */}
@@ -226,14 +224,14 @@ function PriceAdjustModal({ item, onConfirm, onClose }) {
color: 'var(--muted)', fontSize: 13, cursor: 'pointer',
}}
>
Επαναφορά αρχικής τιμής
{t('detail.price.reset')}
</button>
)}
<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={() => onConfirm(adj)}>
Εφαρμογή
{t('common.apply')}
</button>
</div>
</div>
@@ -244,9 +242,10 @@ function PriceAdjustModal({ item, onConfirm, onClose }) {
// ─── Item action modal (long-press) ──────────────────────────────────────────
function ItemActionModal({ target, onOrderAgain, onSplit, onMoveToTable, onCancel, canCancel, cancelNeedsApproval, priceAdjAllowed, priceNeedsApproval, canMove, onAdjustPrice, onClose }) {
const { t } = useTranslation('waiter')
const { items, singleStacked, multiSelect } = target
const label = multiSelect
? `${items.length} αντικείμενα επιλεγμένα`
? t('detail.selected', { count: items.length })
: items[0]?.product?.name || `#${items[0]?.product_id}`
const actionRows = [
@@ -254,8 +253,8 @@ function ItemActionModal({ target, onOrderAgain, onSplit, onMoveToTable, onCance
key: 'adjust_price',
color: '#f59e0b',
iconBg: 'rgba(245,158,11,0.15)',
label: 'Ρύθμιση τιμής',
sub: priceNeedsApproval ? 'Με έγκριση διαχειριστή (PIN)' : 'Αλλαγή τιμής για αυτό το αντικείμενο',
label: t('detail.item.price'),
sub: priceNeedsApproval ? t('detail.withApproval') : t('detail.item.priceSub'),
icon: (
<svg width="18" height="18" viewBox="0 0 24 24" fill="none">
<circle cx="12" cy="12" r="9" stroke="#f59e0b" strokeWidth="2"/>
@@ -269,8 +268,8 @@ function ItemActionModal({ target, onOrderAgain, onSplit, onMoveToTable, onCance
key: 'order_again',
color: '#22c55e',
iconBg: 'rgba(34,197,94,0.15)',
label: 'Παραγγελία ξανά',
sub: 'Προσθήκη στο νέο καλάθι',
label: t('detail.item.again'),
sub: t('detail.item.againSub'),
icon: (
<svg width="18" height="18" viewBox="0 0 24 24" fill="none">
<path d="M1 4v6h6M23 20v-6h-6" stroke="#22c55e" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
@@ -284,8 +283,8 @@ function ItemActionModal({ target, onOrderAgain, onSplit, onMoveToTable, onCance
key: 'move',
color: '#f97316',
iconBg: 'rgba(249,115,22,0.15)',
label: 'Μεταφορά σε άλλο τραπέζι',
sub: 'Μεταφορά επιλεγμένων αντικειμένων',
label: t('detail.item.move'),
sub: t('detail.item.moveSub'),
icon: (
<svg width="18" height="18" viewBox="0 0 24 24" fill="none">
<path d="M5 12h14M12 5l7 7-7 7" stroke="#f97316" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
@@ -298,8 +297,8 @@ function ItemActionModal({ target, onOrderAgain, onSplit, onMoveToTable, onCance
key: 'split',
color: '#60a5fa',
iconBg: 'rgba(96,165,250,0.15)',
label: 'Διαχωρισμός',
sub: 'Χώρισμα σε δύο γραμμές',
label: t('detail.split.title'),
sub: t('detail.item.splitSub'),
icon: (
<svg width="18" height="18" viewBox="0 0 24 24" fill="none">
<path d="M16 3h5v5M4 20L21 3M21 16v5h-5M15 15l6 6M4 4l5 5" stroke="#60a5fa" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
@@ -312,8 +311,8 @@ function ItemActionModal({ target, onOrderAgain, onSplit, onMoveToTable, onCance
key: 'cancel',
color: canCancel ? '#ef4444' : '#6b7280',
iconBg: canCancel ? 'rgba(239,68,68,0.15)' : 'rgba(107,114,128,0.1)',
label: 'Ακύρωση παραγγελίας',
sub: !canCancel ? 'Δεν επιτρέπεται η ακύρωση' : cancelNeedsApproval ? 'Με έγκριση διαχειριστή (PIN)' : 'Ακύρωση επιλεγμένων αντικειμένων',
label: t('detail.item.cancel'),
sub: !canCancel ? t('detail.cancelNotAllowed') : cancelNeedsApproval ? t('detail.withApproval') : t('detail.item.cancelSub'),
icon: (
<svg width="18" height="18" viewBox="0 0 24 24" fill="none">
<circle cx="12" cy="12" r="10" stroke={canCancel ? '#ef4444' : '#6b7280'} strokeWidth="2"/>
@@ -358,7 +357,7 @@ function ItemActionModal({ target, onOrderAgain, onSplit, onMoveToTable, onCance
))}
<button className="btn btn--secondary" style={{ width: '100%', marginTop: 12 }} onClick={onClose}>
Άκυρο
{t('common.cancel')}
</button>
</div>
</div>
@@ -368,6 +367,7 @@ function ItemActionModal({ target, onOrderAgain, onSplit, onMoveToTable, onCance
// ─── Apply Discount modal ─────────────────────────────────────────────────────
function ApplyDiscountModal({ order, _waiterId, onClose, onApplied }) {
const { t } = useTranslation('waiter')
const activeItems = (order?.items ?? []).filter(i => i.status === 'active')
const [selectedIds, setSelectedIds] = useState(activeItems.map(i => i.id))
const [pct, setPct] = useState(10)
@@ -392,8 +392,8 @@ function ApplyDiscountModal({ order, _waiterId, onClose, onApplied }) {
const roundedPct = Math.round(pct * 10) / 10
async function apply() {
if (selectedIds.length === 0) { setError('Επιλέξτε τουλάχιστον ένα αντικείμενο'); return }
if (roundedPct <= 0 || roundedPct > 100) { setError('Μη έγκυρο ποσοστό'); return }
if (selectedIds.length === 0) { setError(t('detail.discount.pickOne')); return }
if (roundedPct <= 0 || roundedPct > 100) { setError(t('detail.discount.badPct')); return }
setApplying(true); setError('')
try {
const res = await client.post(`/api/orders/${order.id}/items/discount`, {
@@ -408,7 +408,7 @@ function ApplyDiscountModal({ order, _waiterId, onClose, onApplied }) {
onApplied()
onClose()
} catch (e) {
setError(apiError(e, 'Σφάλμα εφαρμογής έκπτωσης'))
setError(apiError(e, t('detail.discount.failed')))
} finally {
setApplying(false)
}
@@ -418,14 +418,14 @@ function ApplyDiscountModal({ order, _waiterId, onClose, onApplied }) {
<div className="modal-overlay" onClick={onClose}>
<div className="modal-sheet" onClick={e => e.stopPropagation()} style={{ gap: 0 }}>
<div className="modal-handle" />
<h2 className="modal-title" style={{ marginBottom: 4 }}>Εφαρμογή Έκπτωσης</h2>
<h2 className="modal-title" style={{ marginBottom: 4 }}>{t('detail.actions.discount')}</h2>
<p style={{ textAlign: 'center', fontSize: 12, color: 'var(--muted)', marginBottom: 16 }}>
Η τελική τιμή στρογγυλοποιείται στο 0.10 €
{t('detail.discount.rounding')}
</p>
{/* Item multi-select */}
<div style={{ marginBottom: 14 }}>
<p style={{ fontSize: 12, color: 'var(--muted)', marginBottom: 8 }}>Αντικείμενα</p>
<p style={{ fontSize: 12, color: 'var(--muted)', marginBottom: 8 }}>{t('detail.discount.items')}</p>
<div style={{ display: 'flex', flexDirection: 'column', gap: 6, maxHeight: 180, overflowY: 'auto' }}>
{activeItems.map(item => {
const eff = (item.unit_price ?? 0) + (item.price_adjustment ?? 0)
@@ -450,11 +450,11 @@ function ApplyDiscountModal({ order, _waiterId, onClose, onApplied }) {
<div style={{ fontSize: 13, fontWeight: 600, color: 'var(--text)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
{item.product?.name ?? `#${item.product_id}`}
</div>
<div style={{ fontSize: 11, color: 'var(--muted)' }}>×{item.quantity} · {eff.toFixed(2)} €</div>
<div style={{ fontSize: 11, color: 'var(--muted)' }}>×{item.quantity} · {fmtPrice(eff)}</div>
</div>
{checked && (
<div style={{ fontSize: 12, fontWeight: 700, color: '#4ade80', shrink: 0 }}>
→ {newPrice.toFixed(2)} €
→ {fmtPrice(newPrice)}
</div>
)}
</button>
@@ -465,7 +465,7 @@ function ApplyDiscountModal({ order, _waiterId, onClose, onApplied }) {
{/* Percent picker */}
<div style={{ marginBottom: 14 }}>
<p style={{ fontSize: 12, color: 'var(--muted)', marginBottom: 8 }}>Ποσοστό έκπτωσης</p>
<p style={{ fontSize: 12, color: 'var(--muted)', marginBottom: 8 }}>{t('detail.discount.pct')}</p>
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 6, marginBottom: 10 }}>
{PCT_PRESETS.map(p => (
<button key={p} onClick={() => setPct(p)}
@@ -488,16 +488,16 @@ function ApplyDiscountModal({ order, _waiterId, onClose, onApplied }) {
}} />
<span style={{ fontSize: 14, color: 'var(--muted)' }}>%</span>
<span style={{ fontSize: 13, color: '#4ade80', fontWeight: 700 }}>
−{discountTotal.toFixed(2)} €
−{fmtPrice(discountTotal)}
</span>
</div>
</div>
{/* Note */}
<div style={{ marginBottom: 14 }}>
<p style={{ fontSize: 12, color: 'var(--muted)', marginBottom: 6 }}>Σημείωση (προαιρετικό)</p>
<p style={{ fontSize: 12, color: 'var(--muted)', marginBottom: 6 }}>{t('detail.discount.note')}</p>
<input value={note} onChange={e => setNote(e.target.value)}
placeholder="π.χ. VIP πελάτης"
placeholder={t('detail.discount.notePlaceholder')}
style={{
width: '100%', padding: '9px 12px', borderRadius: 10,
border: '1.5px solid var(--border)', background: 'var(--bg3)',
@@ -510,9 +510,9 @@ function ApplyDiscountModal({ order, _waiterId, onClose, onApplied }) {
)}
<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={apply} disabled={applying}>
{applying ? 'Εφαρμογή…' : 'Εφαρμογή'}
{applying ? t('detail.discount.applying') : t('common.apply')}
</button>
</div>
</div>
@@ -549,20 +549,21 @@ function DiscountIcon({ width = 20, height = 20 }) {
}
function ActionsSheet({ order, _tableId, isStandalone, onClose, onTransfer, onMerge, onSetFlags, onAssignWaiter, onPrintSynopsis, onCancelOrder, onMarkAllServed, canCancel, cancelNeedsApproval, canDiscount, canMove, onApplyDiscount }) {
const { t } = useTranslation('waiter')
const hasOrder = !!order
const hasServable = hasOrder && order.items?.some(i => i.kds_status === 'done')
const hasActiveItems = hasOrder && order.items?.some(i => i.status === 'active')
const allActions = [
{ Icon: CheckIcon, label: 'Σήμανση Όλων ως Παραδοθέντα', sub: 'Σήμανση όλων των έτοιμων ειδών ως παραδοθέντα',
{ Icon: CheckIcon, label: t('tables.quick.markAllServed'), sub: t('detail.actions.markAllServedSub'),
onClick: hasServable ? onMarkAllServed : null, color: hasServable ? '#4ade80' : '#6b7280', iconBg: hasServable ? 'rgba(34,197,94,0.15)' : 'rgba(107,114,128,0.1)' },
{ Icon: DiscountIcon, label: 'Εφαρμογή Έκπτωσης', sub: canDiscount ? 'Έκπτωση σε αντικείμενα παραγγελίας' : 'Δεν επιτρέπεται η εφαρμογή έκπτωσης',
{ Icon: DiscountIcon, label: t('detail.actions.discount'), sub: canDiscount ? t('detail.actions.discountSub') : t('detail.actions.discountNotAllowed'),
onClick: (hasActiveItems && canDiscount) ? onApplyDiscount : null, color: (hasActiveItems && canDiscount) ? '#a78bfa' : '#6b7280', iconBg: (hasActiveItems && canDiscount) ? 'rgba(167,139,250,0.15)' : 'rgba(107,114,128,0.1)' },
{ Icon: TransferIcon, label: 'Μεταφορά Τραπεζιού', sub: 'Μεταφορά σε άλλο τραπέζι', onClick: hasOrder ? onTransfer : null, color: '#6099db', iconBg: 'rgba(96,165,250,0.15)', tableOnly: true, needsMove: true },
{ Icon: MergeIcon, label: 'Συγχώνευση Τραπεζιού', sub: 'Συγχώνευση με άλλο τραπέζι', onClick: hasOrder ? onMerge : null, color: '#6099db', iconBg: 'rgba(96,165,250,0.15)', tableOnly: true, needsMove: true },
{ Icon: FlagsIcon, label: 'Ενδείξεις Τραπεζιού', sub: 'Επιλογή σημαιών', onClick: onSetFlags, color: '#fac823', iconBg: 'rgba(251,191,36,0.15)', tableOnly: true },
{ Icon: WaiterIcon, label: 'Ανάθεση Σερβιτόρου', sub: 'Προσθήκη σερβιτόρου στην παραγγελία', onClick: hasOrder ? onAssignWaiter : null, color: '#39b861', iconBg: 'rgba(34,197,94,0.15)' },
{ Icon: PrintIcon, label: 'Εκτύπωση Σύνοψης', sub: 'Εκτύπωση σύνοψης παραγγελίας', onClick: hasOrder ? onPrintSynopsis : null, color: '#cbd5e1', iconBg: 'rgba(148,163,184,0.15)' },
{ Icon: CancelIcon, label: 'Ακύρωση Παραγγελίας', sub: !canCancel ? 'Δεν επιτρέπεται η ακύρωση' : cancelNeedsApproval ? 'Με έγκριση διαχειριστή (PIN)' : 'Ακύρωση ολόκληρης παραγγελίας',
{ Icon: TransferIcon, label: t('detail.actions.transfer'), sub: t('detail.item.move'), onClick: hasOrder ? onTransfer : null, color: '#6099db', iconBg: 'rgba(96,165,250,0.15)', tableOnly: true, needsMove: true },
{ Icon: MergeIcon, label: t('detail.actions.merge'), sub: t('detail.actions.mergeSub'), onClick: hasOrder ? onMerge : null, color: '#6099db', iconBg: 'rgba(96,165,250,0.15)', tableOnly: true, needsMove: true },
{ Icon: FlagsIcon, label: t('tables.actions.flags'), sub: t('detail.actions.flagsSub'), onClick: onSetFlags, color: '#fac823', iconBg: 'rgba(251,191,36,0.15)', tableOnly: true },
{ Icon: WaiterIcon, label: t('tables.actions.assignWaiter'), sub: t('detail.actions.assignSub'), onClick: hasOrder ? onAssignWaiter : null, color: '#39b861', iconBg: 'rgba(34,197,94,0.15)' },
{ Icon: PrintIcon, label: t('tables.actions.printSynopsis'), sub: t('detail.actions.printSub'), onClick: hasOrder ? onPrintSynopsis : null, color: '#cbd5e1', iconBg: 'rgba(148,163,184,0.15)' },
{ Icon: CancelIcon, label: t('tables.quick.cancelOrder'), sub: !canCancel ? t('detail.cancelNotAllowed') : cancelNeedsApproval ? t('detail.withApproval') : t('detail.actions.cancelSub'),
onClick: (hasOrder && canCancel) ? onCancelOrder : null, color: (hasOrder && canCancel) ? '#ef4444' : '#6b7280', iconBg: (hasOrder && canCancel) ? 'rgba(239,68,68,0.15)' : 'rgba(107,114,128,0.1)' },
]
// plan 4.3: discounts show only with pricing.discounts.apply, transfer/merge with ordering.orders.open
@@ -612,6 +613,7 @@ function ActionsSheet({ order, _tableId, isStandalone, onClose, onTransfer, onMe
// ─── Table picker (for transfer / merge / move-items) ─────────────────────────
function TablePicker({ title, subtitle, tables, _currentTableId, onSelect, onClose, loading }) {
const { t } = useTranslation('waiter')
return (
<div className="modal-overlay modal-overlay--top" onClick={onClose}>
<div className="modal-sheet modal-sheet--top" onClick={e => e.stopPropagation()}>
@@ -620,15 +622,15 @@ function TablePicker({ title, subtitle, tables, _currentTableId, onSelect, onClo
{subtitle && <p style={{ textAlign: 'center', color: '#94a3b8', fontSize: 13, marginBottom: 4 }}>{subtitle}</p>}
<div style={{ display: 'flex', flexDirection: 'column', gap: 0, maxHeight: '60svh', overflowY: 'auto' }}>
{loading && (
<p style={{ textAlign: 'center', color: '#64748b', padding: 24 }}>Φόρτωση…</p>
<p style={{ textAlign: 'center', color: '#64748b', padding: 24 }}>{t('common.loading')}</p>
)}
{!loading && tables.length === 0 && (
<p style={{ textAlign: 'center', color: '#64748b', padding: 24 }}>Δεν υπάρχουν διαθέσιμα τραπέζια</p>
<p style={{ textAlign: 'center', color: '#64748b', padding: 24 }}>{t('detail.noTables')}</p>
)}
{!loading && tables.map(t => (
{!loading && tables.map(tb => (
<button
key={t.id}
onClick={() => onSelect(t)}
key={tb.id}
onClick={() => onSelect(tb)}
style={{
width: '100%', display: 'flex', alignItems: 'center', justifyContent: 'space-between',
padding: '14px 4px', background: 'none', border: 'none',
@@ -637,11 +639,11 @@ function TablePicker({ title, subtitle, tables, _currentTableId, onSelect, onClo
>
<div>
<div style={{ fontSize: 15, fontWeight: 600, color: 'var(--text)' }}>
{t.label || `T${t.number}`}
{tb.label || `T${tb.number}`}
</div>
{t.orderStatus && (
{tb.orderStatus && (
<div style={{ fontSize: 12, color: '#f59e0b', marginTop: 2 }}>
{t.orderStatus === 'open' ? 'Ανοιχτό' : t.orderStatus === 'partially_paid' ? 'Μερικώς πληρωμένο' : t.orderStatus}
{tb.orderStatus === 'open' ? t('tables.status.open') : tb.orderStatus === 'partially_paid' ? t('tables.status.partlyPaid') : tb.orderStatus}
</div>
)}
</div>
@@ -649,7 +651,7 @@ function TablePicker({ title, subtitle, tables, _currentTableId, onSelect, onClo
</button>
))}
</div>
<button className="btn btn--secondary" style={{ width: '100%', marginTop: 8 }} onClick={onClose}>Άκυρο</button>
<button className="btn btn--secondary" style={{ width: '100%', marginTop: 8 }} onClick={onClose}>{t('common.cancel')}</button>
</div>
</div>
)
@@ -658,6 +660,7 @@ function TablePicker({ title, subtitle, tables, _currentTableId, onSelect, onClo
// ─── Flag picker ──────────────────────────────────────────────────────────────
function FlagPicker({ _tableId, currentFlagIds, flagDefs, onSave, onClose, loading }) {
const { t } = useTranslation('waiter')
const [selected, setSelected] = useState(currentFlagIds || [])
// Sync selected when currentFlagIds loads
@@ -671,13 +674,13 @@ function FlagPicker({ _tableId, currentFlagIds, flagDefs, onSave, onClose, loadi
<div className="modal-overlay modal-overlay--top" onClick={onClose}>
<div className="modal-sheet modal-sheet--top" onClick={e => e.stopPropagation()}>
<div className="modal-handle" />
<h2 className="modal-title">Ενδείξεις Τραπεζιού</h2>
<h2 className="modal-title">{t('tables.actions.flags')}</h2>
<div style={{ display: 'flex', flexDirection: 'column', gap: 0, marginBottom: 20 }}>
{loading && (
<p style={{ textAlign: 'center', color: '#64748b', padding: 16 }}>Φόρτωση…</p>
<p style={{ textAlign: 'center', color: '#64748b', padding: 16 }}>{t('common.loading')}</p>
)}
{!loading && flagDefs.length === 0 && (
<p style={{ textAlign: 'center', color: '#64748b', padding: 16 }}>Δεν υπάρχουν σημαίες</p>
<p style={{ textAlign: 'center', color: '#64748b', padding: 16 }}>{t('detail.noFlags')}</p>
)}
{!loading && flagDefs.map(f => {
const sel = selected.includes(f.id)
@@ -710,8 +713,8 @@ function FlagPicker({ _tableId, currentFlagIds, flagDefs, onSave, onClose, loadi
})}
</div>
<div style={{ display: 'flex', gap: 12 }}>
<button className="btn btn--secondary" style={{ flex: 1 }} onClick={onClose}>Άκυρο</button>
<button className="btn btn--primary" style={{ flex: 1 }} onClick={() => onSave(selected)}>Αποθήκευση</button>
<button className="btn btn--secondary" style={{ flex: 1 }} onClick={onClose}>{t('common.cancel')}</button>
<button className="btn btn--primary" style={{ flex: 1 }} onClick={() => onSave(selected)}>{t('common.save')}</button>
</div>
</div>
</div>
@@ -721,6 +724,7 @@ function FlagPicker({ _tableId, currentFlagIds, flagDefs, onSave, onClose, loadi
// ─── Assign waiter picker ─────────────────────────────────────────────────────
function AssignWaiterPicker({ orderId, currentWaiterIds, waiters, onAssigned, onClose, loading }) {
const { t } = useTranslation('waiter')
const [saving, setSaving] = useState(false)
async function assign(waiterId) {
@@ -743,13 +747,13 @@ function AssignWaiterPicker({ orderId, currentWaiterIds, waiters, onAssigned, on
<div className="modal-overlay modal-overlay--top" onClick={onClose}>
<div className="modal-sheet modal-sheet--top" onClick={e => e.stopPropagation()}>
<div className="modal-handle" />
<h2 className="modal-title">Ανάθεση Σερβιτόρου</h2>
<h2 className="modal-title">{t('tables.actions.assignWaiter')}</h2>
<div style={{ display: 'flex', flexDirection: 'column', gap: 0, marginBottom: 16, maxHeight: '60svh', overflowY: 'auto' }}>
{loading && (
<p style={{ textAlign: 'center', color: '#64748b', padding: 16 }}>Φόρτωση…</p>
<p style={{ textAlign: 'center', color: '#64748b', padding: 16 }}>{t('common.loading')}</p>
)}
{!loading && available.length === 0 && (
<p style={{ textAlign: 'center', color: '#64748b', padding: 16 }}>Όλοι οι σερβιτόροι έχουν ήδη ανατεθεί</p>
<p style={{ textAlign: 'center', color: '#64748b', padding: 16 }}>{t('detail.allAssigned')}</p>
)}
{!loading && available.map(w => (
<button
@@ -774,7 +778,7 @@ function AssignWaiterPicker({ orderId, currentWaiterIds, waiters, onAssigned, on
</button>
))}
</div>
<button className="btn btn--secondary" style={{ width: '100%' }} onClick={onClose}>Άκυρο</button>
<button className="btn btn--secondary" style={{ width: '100%' }} onClick={onClose}>{t('common.cancel')}</button>
</div>
</div>
)
@@ -783,6 +787,7 @@ function AssignWaiterPicker({ orderId, currentWaiterIds, waiters, onAssigned, on
// ─── Print synopsis picker ────────────────────────────────────────────────────
function PrintSynopsisPicker({ orderId, onClose }) {
const { t } = useTranslation('waiter')
const [printers, setPrinters] = useState([])
const [printing, setPrinting] = useState(false)
@@ -806,8 +811,8 @@ function PrintSynopsisPicker({ orderId, onClose }) {
<div className="modal-overlay modal-overlay--top" onClick={onClose}>
<div className="modal-sheet modal-sheet--top" onClick={e => e.stopPropagation()}>
<div className="modal-handle" />
<h2 className="modal-title">Εκτύπωση Σύνοψης</h2>
<p style={{ textAlign: 'center', color: '#94a3b8', fontSize: 13, marginBottom: 8 }}>Επιλέξτε εκτυπωτή</p>
<h2 className="modal-title">{t('tables.actions.printSynopsis')}</h2>
<p style={{ textAlign: 'center', color: '#94a3b8', fontSize: 13, marginBottom: 8 }}>{t('detail.pickPrinter')}</p>
<div style={{ display: 'flex', flexDirection: 'column', gap: 0, marginBottom: 16 }}>
{printers.filter(p => p.reachable).map(p => (
<button
@@ -833,7 +838,7 @@ function PrintSynopsisPicker({ orderId, onClose }) {
</div>
))}
</div>
<button className="btn btn--secondary" style={{ width: '100%' }} onClick={onClose}>Άκυρο</button>
<button className="btn btn--secondary" style={{ width: '100%' }} onClick={onClose}>{t('common.cancel')}</button>
</div>
</div>
)
@@ -842,25 +847,26 @@ function PrintSynopsisPicker({ orderId, onClose }) {
// ─── Pay confirm modal ────────────────────────────────────────────────────────
function CancelConfirmModal({ itemCount, onConfirm, 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">Ακύρωση παραγγελίας;</h2>
<h2 className="modal-title">{t('detail.cancel.title')}</h2>
<p style={{ color: '#94a3b8', textAlign: 'center', marginBottom: 24, fontSize: 14 }}>
{itemCount === null
? 'Ολόκληρη η παραγγελία θα ακυρωθεί οριστικά.'
: `${itemCount} αντικείμενο${itemCount !== 1 ? 'α' : ''} θα ακυρωθ${itemCount !== 1 ? 'ούν' : 'εί'} οριστικά.`}
? t('detail.cancel.whole')
: t('detail.cancel.items', { count: itemCount })}
</p>
<div style={{ display: 'flex', gap: 12 }}>
<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
onClick={onConfirm}
style={{
flex: 1, height: 48, borderRadius: 12, border: 'none',
background: '#dc2626', color: 'white', fontSize: 15, fontWeight: 700, cursor: 'pointer',
}}
>Ακύρωση ✕</button>
>{t('detail.cancel.button')}</button>
</div>
</div>
</div>
@@ -868,6 +874,7 @@ function CancelConfirmModal({ itemCount, onConfirm, onClose }) {
}
function PayConfirmModal({ payAll, payIds, activeItems, andClose, cardEnabled, onConfirm, onClose }) {
const { t } = useTranslation('waiter')
const { paymentSafety } = usePaymentSettingsStore()
const [method, setMethod] = useState('cash')
const [secondConfirmOpen, setSecondConfirmOpen] = useState(false)
@@ -878,10 +885,10 @@ function PayConfirmModal({ payAll, payIds, activeItems, andClose, cardEnabled, o
.filter(i => payIds.includes(i.id))
.reduce((s, i) => s + ((i.unit_price ?? 0) + (i.price_adjustment ?? 0)) * i.quantity, 0)
const title = andClose ? 'Επιβεβαίωση Πληρωμής και Κλείσιμο' : 'Επιβεβαίωση πληρωμής'
const title = andClose ? t('detail.pay.titleClose') : t('detail.pay.title')
const subtitle = andClose
? 'Όλα τα αντικείμενα — το τραπέζι θα κλείσει αμέσως μετά'
: payAll ? 'Όλα τα αντικείμενα' : `${payIds.length} αντικείμενο${payIds.length !== 1 ? 'α' : ''}`
? t('detail.pay.allAndClose')
: payAll ? t('detail.pay.all') : t('detail.pay.items', { count: payIds.length })
function handleConfirmClick() {
if (paymentSafety === 'second_confirm') {
@@ -929,7 +936,7 @@ function PayConfirmModal({ payAll, payIds, activeItems, andClose, cardEnabled, o
cursor: 'pointer', transition: 'all 0.12s',
}}
>
{m === 'cash' ? '💵 Μετρητά' : '💳 Κάρτα'}
{m === 'cash' ? `💵 ${t('detail.pay.cash')}` : `💳 ${t('detail.pay.card')}`}
</button>
))}
</div>
@@ -937,7 +944,7 @@ function PayConfirmModal({ payAll, payIds, activeItems, andClose, cardEnabled, o
<div style={{ display: 'flex', gap: 12 }}>
<button className="btn btn--secondary" style={{ flex: 1 }} onClick={onClose}>
Άκυρο
{t('common.cancel')}
</button>
{paymentSafety === 'long_press' ? (
<button
@@ -951,7 +958,7 @@ function PayConfirmModal({ payAll, payIds, activeItems, andClose, cardEnabled, o
onPointerLeave={cancelLongPress}
>
<span style={{ position: 'relative', zIndex: 1 }}>
{longPressActive ? 'Κρατήστε…' : 'Πληρώθηκαν ✓'}
{longPressActive ? t('detail.pay.hold') : `${t('detail.pay.paid')} ✓`}
</span>
{longPressActive && (
<span style={{
@@ -963,7 +970,7 @@ function PayConfirmModal({ payAll, payIds, activeItems, andClose, cardEnabled, o
</button>
) : (
<button className="btn btn--success" style={{ flex: 1 }} onClick={handleConfirmClick}>
Πληρώθηκαν ✓
{t('detail.pay.paid')} ✓
</button>
)}
</div>
@@ -977,17 +984,17 @@ function PayConfirmModal({ payAll, payIds, activeItems, andClose, cardEnabled, o
}} onClick={e => e.stopPropagation()}>
<div style={{ background: 'var(--bg2,#1e293b)', borderRadius: 14, padding: 24, width: '100%' }}>
<p style={{ color: '#f1f5f9', fontWeight: 700, fontSize: 15, textAlign: 'center', marginBottom: 8 }}>
Είσαι σίγουρος;
{t('common.sure')}
</p>
<p style={{ color: '#94a3b8', fontSize: 13, textAlign: 'center', marginBottom: 20 }}>
{fmtPrice(payTotal)} — {method === 'card' ? 'Κάρτα' : 'Μετρητά'}
{fmtPrice(payTotal)} — {method === 'card' ? t('detail.pay.card') : t('detail.pay.cash')}
</p>
<div style={{ display: 'flex', gap: 10 }}>
<button className="btn btn--secondary" style={{ flex: 1 }} onClick={() => setSecondConfirmOpen(false)}>
Πίσω
{t('common.back')}
</button>
<button className="btn btn--success" style={{ flex: 1 }} onClick={() => onConfirm(method)}>
Ναι, Πληρώθηκαν ✓
{t('detail.pay.yesPaid')} ✓
</button>
</div>
</div>
@@ -1001,15 +1008,16 @@ function PayConfirmModal({ payAll, payIds, activeItems, andClose, cardEnabled, o
// ─── 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]
return (
<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>
<div style={{ display: 'flex', gap: 8, justifyContent: 'center', marginBottom: 20 }}>
{QUICK.map(n => (
@@ -1027,9 +1035,9 @@ function CustomerCountModal({ value, onChange, onClose }) {
<button className="qty-btn" onClick={() => setCount(c => c + 1)}>+</button>
</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>
@@ -1040,6 +1048,7 @@ function CustomerCountModal({ value, onChange, onClose }) {
// ─── Main page ────────────────────────────────────────────────────────────────
export default function TableDetailPage() {
const { t } = useTranslation('waiter')
const { tableId, orderId: standaloneOrderId } = useParams()
const isStandalone = !!standaloneOrderId
const [searchParams, setSearchParams] = useSearchParams()
@@ -1191,7 +1200,7 @@ export default function TableDetailPage() {
if (waitersRes.status === 200) setAllWaiters(waitersRes.data)
}
} catch {
if (!table) setError('Σφάλμα φόρτωσης')
if (!table) setError(t('detail.err.load'))
} finally {
setLoading(false)
}
@@ -1324,7 +1333,7 @@ export default function TableDetailPage() {
await client.post('/api/orders/', { table_id: Number(tableId) })
await load()
} catch (err) {
setError(apiError(err, 'Σφάλμα ανοίγματος'))
setError(apiError(err, t('detail.err.open')))
}
}
@@ -1346,7 +1355,7 @@ export default function TableDetailPage() {
const updatedOrder = await db.pos_orders.get(order.id)
if (!updatedOrder || updatedOrder.status === 'paid') navigate('/tables', { replace: true })
} catch {
setError('Σφάλμα αποθήκευσης offline πληρωμής')
setError(t('detail.err.offlinePay'))
} finally {
setPaying(false)
}
@@ -1367,7 +1376,7 @@ export default function TableDetailPage() {
}
await load()
} catch (err) {
setError(apiError(err, 'Σφάλμα πληρωμής'))
setError(apiError(err, t('detail.err.pay')))
} finally {
setPaying(false)
}
@@ -1380,7 +1389,7 @@ export default function TableDetailPage() {
setPaidSelectedIds([])
await load()
} catch (err) {
setError(apiError(err, 'Σφάλμα αναίρεσης πληρωμής'))
setError(apiError(err, t('detail.err.revert')))
}
}
@@ -1390,7 +1399,7 @@ export default function TableDetailPage() {
setConfirmClose(false)
navigate('/tables')
} catch (err) {
setError(apiError(err, 'Σφάλμα κλεισίματος'))
setError(apiError(err, t('detail.err.close')))
}
}
@@ -1406,7 +1415,7 @@ export default function TableDetailPage() {
setItemActionTarget(null)
await load()
} catch (err) {
setError(apiError(err, 'Σφάλμα ακύρωσης'))
setError(apiError(err, t('detail.err.cancel')))
}
}
@@ -1416,7 +1425,7 @@ export default function TableDetailPage() {
await client.delete(`/api/orders/${order.id}?print_cancellation=true`)
navigate('/tables')
} catch (err) {
setError(apiError(err, 'Σφάλμα ακύρωσης παραγγελίας'))
setError(apiError(err, t('detail.err.cancelOrder')))
}
}
@@ -1435,7 +1444,7 @@ export default function TableDetailPage() {
setPaidSelectedIds([])
await load()
} catch (err) {
setError(apiError(err, 'Σφάλμα σήμανσης'))
setError(apiError(err, t('detail.err.mark')))
}
}
@@ -1447,7 +1456,7 @@ export default function TableDetailPage() {
await client.post(`/api/kds/orders/${order.id}/items/mark-all-served`)
await load()
} catch (err) {
setError(apiError(err, 'Σφάλμα σήμανσης'))
setError(apiError(err, t('detail.err.mark')))
}
}
@@ -1484,7 +1493,7 @@ export default function TableDetailPage() {
setSelectedIds([])
await loadFromDB()
} catch (err) {
setError(err.message || 'Σφάλμα διαχωρισμού offline')
setError(err.message || t('detail.err.splitOffline'))
}
return
}
@@ -1494,7 +1503,7 @@ export default function TableDetailPage() {
setSelectedIds([])
await load()
} catch (err) {
setError(apiError(err, 'Σφάλμα διαχωρισμού'))
setError(apiError(err, t('detail.err.split')))
}
}
@@ -1507,7 +1516,7 @@ export default function TableDetailPage() {
await client.post(`/api/orders/${order.id}/transfer`, { target_table_id: targetTable.id })
navigate('/tables')
} catch (err) {
setError(apiError(err, 'Σφάλμα μεταφοράς'))
setError(apiError(err, t('detail.err.transfer')))
}
}
@@ -1515,14 +1524,14 @@ export default function TableDetailPage() {
async function doMerge(targetTable) {
if (!order) return
const targetOrder = allOrders.find(o => o.table_id === targetTable.id)
if (!targetOrder) { setError('Δεν βρέθηκε παραγγελία στο τραπέζι'); return }
if (!targetOrder) { setError(t('detail.err.noTargetOrder')); return }
setPendingTable(null)
setActionsMode(null)
try {
await client.post(`/api/orders/${order.id}/merge`, { target_order_id: targetOrder.id })
navigate('/tables')
} catch (err) {
setError(apiError(err, 'Σφάλμα συγχώνευσης'))
setError(apiError(err, t('detail.err.merge')))
}
}
@@ -1530,7 +1539,7 @@ export default function TableDetailPage() {
async function doMoveItems(targetTable) {
if (!order || selectedIds.length === 0) return
const targetOrder = allOrders.find(o => o.table_id === targetTable.id)
if (!targetOrder) { setError('Δεν βρέθηκε παραγγελία στο τραπέζι'); return }
if (!targetOrder) { setError(t('detail.err.noTargetOrder')); return }
setPendingTable(null)
setActionsMode(null)
try {
@@ -1541,7 +1550,7 @@ export default function TableDetailPage() {
setSelectedIds([])
await load()
} catch (err) {
setError(apiError(err, 'Σφάλμα μεταφοράς αντικειμένων'))
setError(apiError(err, t('detail.err.moveItems')))
}
}
@@ -1552,7 +1561,7 @@ export default function TableDetailPage() {
setCurrentFlagIds(flagIds)
setActionsMode(null)
} catch {
setError('Σφάλμα αποθήκευσης σημαιών')
setError(t('detail.err.flags'))
}
}
@@ -1585,7 +1594,7 @@ export default function TableDetailPage() {
? (order?.order_type === 'delivery' ? `Delivery #${standaloneOrderId}` : `Takeaway #${standaloneOrderId}`)
: (table ? (table.label || `T${table.number}`) : '—')
if (loading) return <div className="page page--centered"><p style={{ color: '#94a3b8' }}>Φόρτωση…</p></div>
if (loading) return <div className="page page--centered"><p style={{ color: '#94a3b8' }}>{t('common.loading')}</p></div>
return (
<div className="page">
@@ -1607,7 +1616,7 @@ export default function TableDetailPage() {
color: customerCount ? '#f59e0b' : 'var(--muted)',
cursor: 'pointer', fontSize: 13, fontWeight: 700,
}}
title="Αριθμός πελατών"
title={t('detail.guests.button')}
>
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
<path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/>
@@ -1689,9 +1698,9 @@ export default function TableDetailPage() {
{!order && !isStandalone && (
<div style={{ flex: 1, display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center' }}>
<p style={{ color: '#94a3b8', marginBottom: 24 }}>Δεν υπάρχει ενεργή παραγγελία</p>
<p style={{ color: '#94a3b8', marginBottom: 24 }}>{t('tables.quick.noOrder')}</p>
<button className="btn btn--primary btn--lg" onClick={openOrder}>
Άνοιγμα Παραγγελίας
{t('detail.openOrder')}
</button>
</div>
)}
@@ -1743,7 +1752,7 @@ export default function TableDetailPage() {
transition: 'background 0.15s',
}}
>
Εκκρεμή {activeItems.length > 0 && (
{t('detail.tabs.unpaid')} {activeItems.length > 0 && (
<span style={{
display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
background: activeTab === 'active' ? 'rgba(0,0,0,0.2)' : 'var(--bg3)',
@@ -1762,7 +1771,7 @@ export default function TableDetailPage() {
transition: 'background 0.15s',
}}
>
Πληρωμένα {paidItems.length > 0 && (
{t('detail.tabs.paid')} {paidItems.length > 0 && (
<span style={{
display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
background: activeTab === 'paid' ? 'rgba(0,0,0,0.2)' : 'var(--bg3)',
@@ -1887,7 +1896,7 @@ export default function TableDetailPage() {
<div style={{ padding: '8px 0' }}>
{paidItems.length === 0 ? (
<p style={{ color: '#64748b', textAlign: 'center', padding: '24px 0', fontSize: 14 }}>
Δεν υπάρχουν πληρωμένα αντικείμενα
{t('detail.noPaid')}
</p>
) : (
<>
@@ -1973,7 +1982,7 @@ export default function TableDetailPage() {
cursor: 'pointer',
fontSize: 13, fontWeight: 700, letterSpacing: 0.5,
}}
>ΑΝΑΙΡΕΣΗ</button>
>{t('detail.revert.button')}</button>
)}
</div>
)}
@@ -2029,7 +2038,7 @@ export default function TableDetailPage() {
}}
disabled={isOffline}
style={{ borderRadius: 999, flex: 1, opacity: isOffline ? 0.4 : 1 }}
title={isOffline ? 'Μη διαθέσιμο offline' : undefined}
title={isOffline ? t('detail.notOffline') : undefined}
>
<span style={{ marginRight: 6 }}>✕</span>CLOSE
</button>
@@ -2042,12 +2051,12 @@ export default function TableDetailPage() {
<div className="modal-overlay" onClick={() => setShowMergeModal(false)} style={{ alignItems: 'flex-end' }}>
<div className="modal-sheet" onClick={e => e.stopPropagation()} style={{ borderRadius: '20px 20px 0 0', paddingBottom: 40, gap: 0 }}>
<div className="modal-handle" />
<p style={{ fontSize: 17, fontWeight: 700, color: 'var(--text)', marginBottom: 20, paddingTop: 4 }}>Εμφάνιση Αντικειμένων</p>
<p style={{ fontSize: 17, fontWeight: 700, color: 'var(--text)', marginBottom: 20, paddingTop: 4 }}>{t('detail.view.title')}</p>
{[
{ mode: MERGE_OFF, label: 'ΑΡΧΙΚΗ', desc: 'Ακριβώς όπως παραγγέλθηκαν' },
{ mode: MERGE_IDENTICAL, label: 'ΣΥΓΧΩΝΕΥΣΗ ΠΑΡΟΜΟΙΩΝ', desc: 'Ίδιο προϊόν, ίδιες επιλογές, ίδια τιμή' },
{ mode: MERGE_SAME_ITEM, label: 'ΣΥΓΧΩΝΕΥΣΗ ΟΛΩΝ', desc: 'Ίδιο προϊόν με ίδια τελική τιμή' },
{ mode: MERGE_OFF, label: t('detail.view.off'), desc: t('detail.view.offDesc') },
{ mode: MERGE_IDENTICAL, label: t('detail.view.identical'), desc: t('detail.view.identicalDesc') },
{ mode: MERGE_SAME_ITEM, label: t('detail.view.sameItem'), desc: t('detail.view.sameItemDesc') },
].map(({ mode, label, desc }) => {
const active = mergeMode === mode
return (
@@ -2082,7 +2091,7 @@ export default function TableDetailPage() {
})}
<button className="btn btn--secondary" style={{ width: '100%', marginTop: 20 }} onClick={() => setShowMergeModal(false)}>
Άκυρο
{t('common.cancel')}
</button>
</div>
</div>
@@ -2223,22 +2232,22 @@ export default function TableDetailPage() {
<div className="modal-overlay" onClick={() => setRevertConfirm(null)}>
<div className="modal-sheet" onClick={e => e.stopPropagation()}>
<div className="modal-handle" />
<h2 className="modal-title">Αναίρεση Πληρωμής;</h2>
<h2 className="modal-title">{t('detail.revert.title')}</h2>
<p style={{ color: '#94a3b8', textAlign: 'center', marginBottom: 24 }}>
{revertConfirm.itemIds.length === 1
? '1 αντικείμενο θα επιστραφεί σε μη πληρωμένο.'
: `${revertConfirm.itemIds.length} αντικείμενα θα επιστραφούν σε μη πληρωμένα.`}
? t('detail.revert.items', { count: 1 })
: t('detail.revert.items', { count: revertConfirm.itemIds.length })}
</p>
<div style={{ display: 'flex', gap: 12 }}>
<button className="btn btn--secondary" style={{ flex: 1 }} onClick={() => setRevertConfirm(null)}>
Άκυρο
{t('common.cancel')}
</button>
<button
className="btn btn--danger"
style={{ flex: 1 }}
onClick={() => revertPayment(revertConfirm.itemIds)}
>
Αναίρεση ✓
{t('detail.revert.confirm')} ✓
</button>
</div>
</div>
@@ -2250,13 +2259,13 @@ export default function TableDetailPage() {
<div className="modal-overlay" onClick={() => setConfirmClose(false)}>
<div className="modal-sheet" onClick={e => e.stopPropagation()}>
<div className="modal-handle" />
<h2 className="modal-title">Κλείσιμο παραγγελίας;</h2>
<h2 className="modal-title">{t('detail.close.title')}</h2>
<p style={{ color: '#94a3b8', textAlign: 'center', marginBottom: 24 }}>
Αυτή η ενέργεια δεν αναιρείται.
{t('detail.close.body')}
</p>
<div style={{ display: 'flex', gap: 12 }}>
<button className="btn btn--secondary" style={{ flex: 1 }} onClick={() => setConfirmClose(false)}>
Άκυρο
{t('common.cancel')}
</button>
<button className="btn btn--danger" style={{ flex: 1 }} onClick={closeOrder}>
CLOSE
@@ -2300,8 +2309,8 @@ export default function TableDetailPage() {
{/* Transfer picker */}
{actionsMode === 'transfer' && !pendingTable && (
<TablePicker
title="Μεταφορά Τραπεζιού"
subtitle="Επιλέξτε κενό τραπέζι"
title={t('detail.actions.transfer')}
subtitle={t('detail.move.pickFree')}
tables={transferTargets}
currentTableId={Number(tableId)}
onSelect={t => setPendingTable({ table: t, mode: 'transfer' })}
@@ -2313,8 +2322,8 @@ export default function TableDetailPage() {
{/* Merge picker */}
{actionsMode === 'merge' && !pendingTable && (
<TablePicker
title="Συγχώνευση Τραπεζιού"
subtitle="Τα αντικείμενα μεταφέρονται στο επιλεγμένο τραπέζι"
title={t('detail.actions.merge')}
subtitle={t('detail.move.mergeSub')}
tables={mergeTargets}
currentTableId={Number(tableId)}
onSelect={t => setPendingTable({ table: t, mode: 'merge' })}
@@ -2326,8 +2335,8 @@ export default function TableDetailPage() {
{/* Move items picker */}
{actionsMode === 'move_items' && !pendingTable && (
<TablePicker
title="Μεταφορά Αντικειμένων"
subtitle={`Μεταφορά ${selectedIds.length} αντικειμένου${selectedIds.length !== 1 ? 'ων' : ''} σε τραπέζι`}
title={t('detail.move.itemsTitle')}
subtitle={t('detail.move.subtitle', { count: selectedIds.length })}
tables={moveItemsTargets}
currentTableId={Number(tableId)}
onSelect={t => setPendingTable({ table: t, mode: 'move_items' })}
@@ -2342,21 +2351,21 @@ export default function TableDetailPage() {
<div className="modal-sheet modal-sheet--top" onClick={e => e.stopPropagation()}>
<div className="modal-handle" />
<h2 className="modal-title">
{pendingTable.mode === 'transfer' ? 'Επιβεβαίωση Μεταφοράς'
: pendingTable.mode === 'merge' ? 'Επιβεβαίωση Συγχώνευσης'
: 'Επιβεβαίωση Μεταφοράς Αντικειμένων'}
{pendingTable.mode === 'transfer' ? t('detail.move.confirmTransfer')
: pendingTable.mode === 'merge' ? t('detail.move.confirmMerge')
: t('detail.move.confirmItems')}
</h2>
<p style={{ textAlign: 'center', color: '#94a3b8', fontSize: 14, marginBottom: 4 }}>
{pendingTable.mode === 'transfer' ? 'Μεταφορά παραγγελίας στο τραπέζι'
: pendingTable.mode === 'merge' ? 'Συγχώνευση παραγγελίας με το τραπέζι'
: `Μεταφορά ${selectedIds.length} αντικειμένου${selectedIds.length !== 1 ? 'ων' : ''} στο τραπέζι`}
{pendingTable.mode === 'transfer' ? t('detail.move.transferTo')
: pendingTable.mode === 'merge' ? t('detail.move.mergeWith')
: t('detail.move.itemsTo', { count: selectedIds.length })}
</p>
<p style={{ textAlign: 'center', fontSize: 22, fontWeight: 700, color: 'var(--accent)', marginBottom: 20 }}>
{pendingTable.table.label || `T${pendingTable.table.number}`}
</p>
<div style={{ display: 'flex', gap: 12 }}>
<button className="btn btn--secondary" style={{ flex: 1 }} onClick={() => setPendingTable(null)}>
Άκυρο
{t('common.cancel')}
</button>
<button
className="btn btn--primary"
@@ -2367,9 +2376,7 @@ export default function TableDetailPage() {
else doMoveItems(pendingTable.table)
}}
>
{pendingTable.mode === 'transfer' ? 'Μεταφορά ✓'
: pendingTable.mode === 'merge' ? 'Συγχώνευση ✓'
: 'Μεταφορά ✓'}
{pendingTable.mode === 'merge' ? t('tables.actions.merge') : t('tables.actions.transfer')} ✓
</button>
</div>
</div>