feat(waiter): English-first texts, part a: shell, sign-in, tables, settings, venues (platform-v2 step 4.5a)

- @xenia/i18n: new `waiter` namespace (en + el); the waiter's Greek texts become keys
  with English written fresh (Greek kept as the translation).
- App gates, side drawer / nav bars / notifications, user menu, login, table list and
  cards, settings, venues + pairing errors, install dialog, lock screen, update banners,
  QR scanner, favourites setup.
- Money and times through useFormat() (venue time, the language's number format):
  table cards, quick table view, user menu, notifications.
- waiter i18n.js: tw() for code outside components (pairing errors).
- The table-list's FavoritesSetupPage `.map(t => …)` renamed so it doesn't shadow t.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 03:50:33 +02:00
co-authored by Claude Opus 5.5
parent 8e0a786bbc
commit 37155c0457
20 changed files with 1229 additions and 375 deletions
+80 -71
View File
@@ -1,5 +1,6 @@
import { useEffect, useRef, useState, useCallback } from 'react'
import { useAllowed } from '@xenia/access'
import { useFormat, useTranslation } from '@xenia/i18n'
import { useNavigate, useSearchParams } from 'react-router-dom'
import TableCard from '../components/TableCard'
import useAuthStore from '../store/authStore'
@@ -11,7 +12,6 @@ import { getVenueSettings } from '../api/venueSettings'
import db from '../db/posdb'
import { FlagsIcon, TransferIcon, MergeIcon, PrintIcon, WaiterIcon } from '../components/Icons'
function fmtPrice(v) { return Number(v || 0).toFixed(2) + ' €' }
const _UNIT_LABELS = { kg: 'kg', liter: 'L', gram: 'g', ml: 'mL' }
function fmtItemQty(qty, unitType) {
@@ -44,14 +44,16 @@ function CheckIcon({ width = 18, height = 18 }) {
}
const QUICK_ACTIONS = [
{ Icon: FlagsIcon, label: 'Ενδείξεις Τραπεζιού', key: 'flags', color: '#fac823', iconBg: 'rgba(251,191,36,0.15)' },
{ Icon: TransferIcon, label: 'Μεταφορά', key: 'transfer', color: '#6099db', iconBg: 'rgba(96,165,250,0.15)' },
{ Icon: MergeIcon, label: 'Συγχώνευση', key: 'merge', color: '#6099db', iconBg: 'rgba(96,165,250,0.15)' },
{ Icon: PrintIcon, label: 'Εκτύπωση Σύνοψης', key: 'print_synopsis', color: '#cbd5e1', iconBg: 'rgba(148,163,184,0.15)' },
{ Icon: WaiterIcon, label: 'Ανάθεση Σερβιτόρου', key: 'assign_waiter', color: '#39b861', iconBg: 'rgba(34,197,94,0.15)' },
{ Icon: FlagsIcon, label: 'tables.actions.flags', key: 'flags', color: '#fac823', iconBg: 'rgba(251,191,36,0.15)' },
{ Icon: TransferIcon, label: 'tables.actions.transfer', key: 'transfer', color: '#6099db', iconBg: 'rgba(96,165,250,0.15)' },
{ Icon: MergeIcon, label: 'tables.actions.merge', key: 'merge', color: '#6099db', iconBg: 'rgba(96,165,250,0.15)' },
{ Icon: PrintIcon, label: 'tables.actions.printSynopsis', key: 'print_synopsis', color: '#cbd5e1', iconBg: 'rgba(148,163,184,0.15)' },
{ Icon: WaiterIcon, label: 'tables.actions.assignWaiter', key: 'assign_waiter', color: '#39b861', iconBg: 'rgba(34,197,94,0.15)' },
]
function TableQuickModal({ table, order, flags, onClose, onNavigate, onAction, onCancelOrder, onMarkAllServed, canCancel }) {
const { t } = useTranslation('waiter')
const { formatMoney: fmtPrice } = useFormat()
const tableName = table.label || `T${table.number}`
const activeItems = order?.items?.filter(i => i.status === 'active') || []
const total = activeItems.reduce((s, i) => s + i.unit_price * i.quantity, 0)
@@ -59,8 +61,8 @@ function TableQuickModal({ table, order, flags, onClose, onNavigate, onAction, o
const due = Math.max(0, total - paid)
const statusLabel = {
open: 'Ανοιχτό', partially_paid: 'Μερικώς πληρωμένο', paid: 'Πληρωμένο',
}[order?.status] || 'Ελεύθερο'
open: t('tables.status.open'), partially_paid: t('tables.status.partlyPaid'), paid: t('tables.status.paid'),
}[order?.status] || t('tables.status.free')
return (
<div className="modal-overlay" onClick={onClose}>
@@ -74,22 +76,22 @@ function TableQuickModal({ table, order, flags, onClose, onNavigate, onAction, o
{order ? (
<div style={{ display: 'flex', flexDirection: 'column', gap: 6, marginBottom: 12 }}>
<div style={{ display: 'flex', justifyContent: 'space-between', fontSize: 14 }}>
<span style={{ color: 'var(--muted)' }}>Σύνολο</span>
<span style={{ color: 'var(--muted)' }}>{t('common.total')}</span>
<span style={{ fontWeight: 600, color: 'var(--text)' }}>{fmtPrice(total)}</span>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between', fontSize: 14 }}>
<span style={{ color: 'var(--muted)' }}>Πληρωμένο</span>
<span style={{ color: 'var(--muted)' }}>{t('tables.quick.paid')}</span>
<span style={{ fontWeight: 600, color: '#22c55e' }}>{fmtPrice(paid)}</span>
</div>
{due > 0 && (
<div style={{ display: 'flex', justifyContent: 'space-between', fontSize: 14 }}>
<span style={{ color: 'var(--muted)' }}>Υπόλοιπο</span>
<span style={{ color: 'var(--muted)' }}>{t('tables.quick.due')}</span>
<span style={{ fontWeight: 700, color: '#f59e0b' }}>{fmtPrice(due)}</span>
</div>
)}
</div>
) : (
<p style={{ fontSize: 13, color: 'var(--muted)', marginBottom: 12 }}>Δεν υπάρχει ενεργή παραγγελία</p>
<p style={{ fontSize: 13, color: 'var(--muted)', marginBottom: 12 }}>{t('tables.quick.noOrder')}</p>
)}
{flags.length > 0 && (
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 8 }}>
@@ -107,7 +109,7 @@ function TableQuickModal({ table, order, flags, onClose, onNavigate, onAction, o
</div>
)}
<button className="btn btn--primary" style={{ width: '100%', marginTop: 14 }} onClick={() => { onClose(); onNavigate() }}>
Άνοιγμα τραπεζιού
{t('tables.quick.openTable')}
</button>
</div>
<div style={{ background: 'var(--bg2)', borderRadius: '0 0 16px 16px', padding: '8px 20px 24px', borderTop: '2px solid var(--border)' }}>
@@ -126,7 +128,7 @@ function TableQuickModal({ table, order, flags, onClose, onNavigate, onAction, o
<span style={{ width: 36, height: 36, borderRadius: 9, flexShrink: 0, background: a.iconBg, display: 'flex', alignItems: 'center', justifyContent: 'center', color: a.color }}>
<a.Icon width="18" height="18" />
</span>
<span style={{ fontSize: 15, fontWeight: 600, color: a.color }}>{a.label}</span>
<span style={{ fontSize: 15, fontWeight: 600, color: a.color }}>{t(a.label)}</span>
{!disabled && <span style={{ marginLeft: 'auto', color: 'var(--muted)', fontSize: 18 }}>›</span>}
</button>
)
@@ -149,7 +151,7 @@ function TableQuickModal({ table, order, flags, onClose, onNavigate, onAction, o
<span style={{ width: 36, height: 36, borderRadius: 9, flexShrink: 0, background: 'rgba(34,197,94,0.12)', display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#4ade80' }}>
<CheckIcon width="18" height="18" />
</span>
<span style={{ fontSize: 15, fontWeight: 600, color: '#4ade80' }}>Σήμανση Όλων ως Παραδοθέντα</span>
<span style={{ fontSize: 15, fontWeight: 600, color: '#4ade80' }}>{t('tables.quick.markAllServed')}</span>
</button>
)
})()}
@@ -173,7 +175,7 @@ function TableQuickModal({ table, order, flags, onClose, onNavigate, onAction, o
<circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/>
</svg>
</span>
<span style={{ fontSize: 15, fontWeight: 600, color: colour }}>Ακύρωση Παραγγελίας</span>
<span style={{ fontSize: 15, fontWeight: 600, color: colour }}>{t('tables.quick.cancelOrder')}</span>
</button>
)
})()}
@@ -187,6 +189,7 @@ function TableQuickModal({ table, order, flags, onClose, onNavigate, onAction, o
// ─── Filters modal ────────────────────────────────────────────────────────────
function FiltersModal({ groups, onClose }) {
const { t } = useTranslation('waiter')
const {
ownerFilter, statusFilter, zoneFilter,
setOwnerFilter, setStatusFilter, setZoneFilter,
@@ -214,22 +217,22 @@ function FiltersModal({ groups, onClose }) {
<div className="modal-handle" />
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<span style={{ fontSize: 17, fontWeight: 700, color: 'var(--text)' }}>Φίλτρα</span>
<span style={{ fontSize: 17, fontWeight: 700, color: 'var(--text)' }}>{t('tables.filter.title')}</span>
{hasActiveFilters && (
<button
onClick={() => { clearFilters(); onClose() }}
style={{ fontSize: 13, fontWeight: 600, color: 'var(--danger)', background: 'none', border: 'none', cursor: 'pointer', padding: '4px 8px' }}
>
Καθαρισμός
{t('common.clear')}
</button>
)}
</div>
{/* Owner: ALL | MINE */}
<div>
<p style={sectionLabel}>Ανάθεση</p>
<p style={sectionLabel}>{t('tables.filter.owner')}</p>
<div style={segmentedWrap}>
{[['all', 'Όλα'], ['mine', 'Δικά μου']].map(([key, lbl]) => (
{[['all', t('tables.filter.all')], ['mine', t('tables.filter.mine')]].map(([key, lbl]) => (
<button key={key} onClick={() => setOwnerFilter(key)} style={segBtn(ownerFilter === key)}>{lbl}</button>
))}
</div>
@@ -237,9 +240,9 @@ function FiltersModal({ groups, onClose }) {
{/* Status: ALL | FREE | OPEN | PAID */}
<div>
<p style={sectionLabel}>Κατάσταση</p>
<p style={sectionLabel}>{t('tables.filter.status')}</p>
<div style={{ ...segmentedWrap, display: 'grid', gridTemplateColumns: '1fr 1fr' }}>
{[['all', 'Όλα'], ['free', 'Ελεύθερα'], ['open', 'Ανοιχτά'], ['paid', 'Πληρωμένα']].map(([key, lbl]) => (
{[['all', t('tables.filter.all')], ['free', t('tables.filter.free')], ['open', t('tables.filter.open')], ['paid', t('tables.filter.paid')]].map(([key, lbl]) => (
<button key={key} onClick={() => setStatusFilter(key)} style={{ ...segBtn(statusFilter === key), borderRadius: 10 }}>{lbl}</button>
))}
</div>
@@ -248,7 +251,7 @@ function FiltersModal({ groups, onClose }) {
{/* Zones: multi-select, one segmented container per zone */}
{groups.length > 0 && (
<div>
<p style={sectionLabel}>Ζώνες {zoneFilter.length > 0 ? `(${zoneFilter.length} επιλεγμένες)` : ''}</p>
<p style={sectionLabel}>{zoneFilter.length > 0 ? t('tables.filter.zonesSelected', { count: zoneFilter.length }) : t('tables.filter.zones')}</p>
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 6 }}>
{groups.map(g => {
const active = zoneFilter.includes(g.id)
@@ -277,7 +280,7 @@ function FiltersModal({ groups, onClose }) {
</div>
)}
<button className="btn btn--secondary" style={{ width: '100%' }} onClick={onClose}>Εντάξει</button>
<button className="btn btn--secondary" style={{ width: '100%' }} onClick={onClose}>{t('common.ok')}</button>
</div>
</div>
)
@@ -298,6 +301,7 @@ function segBtn(active) {
// ─── Main page ────────────────────────────────────────────────────────────────
export default function TableListPage() {
const { t } = useTranslation('waiter')
const { user } = useAuthStore()
const { status: connStatus } = useConnectionStore()
const isOffline = connStatus !== 'online'
@@ -663,7 +667,7 @@ export default function TableListPage() {
borderBottom: '1px solid var(--border)',
overflowX: 'auto', scrollbarWidth: 'none',
}}>
<ZoneTab label="Όλα" active={effectiveZoneTab === 'all'} onClick={() => setActiveZoneTab('all')} />
<ZoneTab label={t('tables.filter.all')} active={effectiveZoneTab === 'all'} onClick={() => setActiveZoneTab('all')} />
{visibleGroups.map(g => (
<ZoneTab key={g.id} label={g.name} color={g.color}
active={effectiveZoneTab === g.id}
@@ -690,14 +694,14 @@ export default function TableListPage() {
color: 'var(--muted)', fontSize: 13, fontWeight: 600,
overflow: 'hidden', transition: pulling ? 'none' : 'height 0.2s',
}}>
{refreshing ? '⟳ Ανανέωση…' : pullY >= PULL_THRESHOLD ? '↑ Αφήστε για ανανέωση' : '↓ Τραβήξτε για ανανέωση'}
{refreshing ? `⟳ ${t('tables.pull.refreshing')}` : pullY >= PULL_THRESHOLD ? `↑ ${t('tables.pull.release')}` : `↓ ${t('tables.pull.pull')}`}
</div>
)}
{isOffline && tables.length === 0 && (
<div style={{ textAlign: 'center', padding: '48px 24px', color: 'var(--muted)' }}>
<div style={{ fontSize: 36, marginBottom: 12 }}>📡</div>
<p style={{ fontWeight: 700, fontSize: 16, color: 'var(--text)', marginBottom: 6 }}>Offline — δεν υπάρχουν αποθηκευμένα δεδομένα</p>
<p style={{ fontSize: 13, lineHeight: 1.5 }}>Συνδέσου στο δίκτυο μια φορά για να αποθηκευτούν τα δεδομένα τοπικά.</p>
<p style={{ fontWeight: 700, fontSize: 16, color: 'var(--text)', marginBottom: 6 }}>{t('tables.offlineNoData')}</p>
<p style={{ fontSize: 13, lineHeight: 1.5 }}>{t('tables.offlineNoDataBody')}</p>
</div>
)}
<div style={{
@@ -810,11 +814,11 @@ export default function TableListPage() {
<div className="modal-overlay" onClick={() => setCancelConfirm(null)}>
<div style={{ width: '100%', maxWidth: 400, margin: '0 auto', background: 'var(--bg2)', borderRadius: '16px 16px 0 0', padding: '24px 20px 32px' }} onClick={e => e.stopPropagation()}>
<div className="modal-handle" style={{ marginBottom: 16 }} />
<p style={{ fontSize: 18, fontWeight: 700, color: 'var(--text)', marginBottom: 8 }}>Ακύρωση Παραγγελίας;</p>
<p style={{ fontSize: 14, color: 'var(--muted)', marginBottom: 20 }}>Όλα τα ενεργά αντικείμενα θα ακυρωθούν και θα εκτυπωθεί απόδειξη ακύρωσης.</p>
<p style={{ fontSize: 18, fontWeight: 700, color: 'var(--text)', marginBottom: 8 }}>{t('tables.cancelConfirmTitle')}</p>
<p style={{ fontSize: 14, color: 'var(--muted)', marginBottom: 20 }}>{t('tables.cancelConfirmBody')}</p>
<div style={{ display: 'flex', gap: 10 }}>
<button className="btn btn--secondary" style={{ flex: 1 }} onClick={() => setCancelConfirm(null)}>Ακύρωση</button>
<button className="btn" style={{ flex: 1, background: '#ef4444', color: '#fff' }} onClick={() => executeCancelOrder(cancelConfirm.orderId)}>Επιβεβαίωση</button>
<button className="btn btn--secondary" style={{ flex: 1 }} onClick={() => setCancelConfirm(null)}>{t('common.cancel')}</button>
<button className="btn" style={{ flex: 1, background: '#ef4444', color: '#fff' }} onClick={() => executeCancelOrder(cancelConfirm.orderId)}>{t('common.confirm')}</button>
</div>
</div>
</div>
@@ -829,7 +833,7 @@ export default function TableListPage() {
const KDS_FILTER_CHIPS = [
{
key: 'all',
full: 'Όλες', short: 'All',
full: 'orders.chips.all', short: 'orders.chips.allShort',
icon: (
<svg width="14" height="14" viewBox="0 0 24 24" fill="none">
<rect x="3" y="3" width="7" height="7" rx="1.5" fill="currentColor"/>
@@ -842,7 +846,7 @@ const KDS_FILTER_CHIPS = [
},
{
key: 'pending',
full: 'Εκκρεμούν', short: 'PND',
full: 'orders.chips.pending', short: 'orders.chips.pendingShort',
icon: (
<svg width="14" height="14" viewBox="0 0 24 24" fill="none">
<path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm.5-13H11v6l5.25 3.15.75-1.23-4.5-2.67V7z" fill="currentColor"/>
@@ -852,7 +856,7 @@ const KDS_FILTER_CHIPS = [
},
{
key: 'preparing',
full: 'Σε Προετοιμασία', short: 'PRP',
full: 'orders.chips.preparing', short: 'orders.chips.preparingShort',
icon: (
<svg width="14" height="14" viewBox="0 0 24 24" fill="none">
<path d="M13.5 0.67s.74 2.65.74 4.8c0 2.06-1.35 3.73-3.41 3.73-2.07 0-3.63-1.67-3.63-3.73l.03-.36C5.21 7.51 4 10.62 4 14c0 4.42 3.58 8 8 8s8-3.58 8-8C20 8.61 17.41 3.8 13.5.67zM11.71 19c-1.78 0-3.22-1.4-3.22-3.14 0-1.62 1.05-2.76 2.81-3.12 1.77-.36 3.6-1.21 4.62-2.58.39 1.29.59 2.65.59 4.04 0 2.65-2.15 4.8-4.8 4.8z" fill="currentColor"/>
@@ -862,7 +866,7 @@ const KDS_FILTER_CHIPS = [
},
{
key: 'ready',
full: 'Έτοιμες', short: 'RDY',
full: 'orders.chips.ready', short: 'orders.chips.readyShort',
icon: (
<svg width="14" height="14" viewBox="0 0 24 24" fill="none">
<circle cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="2"/>
@@ -873,7 +877,7 @@ const KDS_FILTER_CHIPS = [
},
{
key: 'ready_items',
full: 'Μερικώς Έτοιμες', short: 'PRT',
full: 'orders.chips.partly', short: 'orders.chips.partlyShort',
icon: (
<svg width="14" height="14" viewBox="0 0 24 24" fill="none">
<path d="M12 2a10 10 0 0 1 0 20V2z" fill="currentColor" opacity="0.5"/>
@@ -885,9 +889,9 @@ const KDS_FILTER_CHIPS = [
]
const KDS_ITEM_COLORS = {
pending: { textColor: '#f59e0b', label: 'ΕΚΚΡΕΜΕΙ' },
preparing: { textColor: '#60a5fa', label: 'ΕΤΟΙΜΑΖΕΤΑΙ' },
done: { textColor: '#4ade80', label: 'READY' },
pending: { textColor: '#f59e0b', label: 'kds.pending' },
preparing: { textColor: '#60a5fa', label: 'kds.preparing' },
done: { textColor: '#4ade80', label: 'kds.ready' },
served: { textColor: null, label: null },
}
@@ -896,13 +900,14 @@ const KDS_ITEM_COLORS = {
// ─── Orders filter drawer ─────────────────────────────────────────────────────
function OrdersFilterDrawer({ myOnly, setMyOnly, sortBy, setSortBy, filter, setFilter, onClose }) {
const { t } = useTranslation('waiter')
const hasActive = myOnly || sortBy !== 'time' || filter !== 'all'
const STATUS_OPTIONS = [
{ key: 'all', label: 'Όλες' },
{ key: 'pending', label: 'PEND' },
{ key: 'preparing', label: 'PREP' },
{ key: 'ready', label: 'READY' },
{ key: 'all', label: t('orders.chips.all') },
{ key: 'pending', label: t('orders.chips.pendingShort') },
{ key: 'preparing', label: t('orders.chips.preparingShort') },
{ key: 'ready', label: t('orders.chips.readyShort') },
]
function toggleStatus(key) {
@@ -920,22 +925,22 @@ function OrdersFilterDrawer({ myOnly, setMyOnly, sortBy, setSortBy, filter, setF
<div className="modal-handle" />
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<span style={{ fontSize: 17, fontWeight: 700, color: 'var(--text)' }}>Φίλτρα Παραγγελιών</span>
<span style={{ fontSize: 17, fontWeight: 700, color: 'var(--text)' }}>{t('orders.filter.title')}</span>
{hasActive && (
<button
onClick={() => { setMyOnly(false); setSortBy('time'); setFilter('all'); onClose() }}
style={{ fontSize: 13, fontWeight: 600, color: 'var(--danger)', background: 'none', border: 'none', cursor: 'pointer', padding: '4px 8px' }}
>
Καθαρισμός
{t('common.clear')}
</button>
)}
</div>
{/* View filter */}
<div>
<p style={sectionLabel}>Προβολή</p>
<p style={sectionLabel}>{t('orders.filter.view')}</p>
<div style={segmentedWrap}>
{[['false', 'Όλες'], ['true', 'Δικές μου']].map(([val, lbl]) => (
{[['false', t('orders.chips.all')], ['true', t('orders.filter.mine')]].map(([val, lbl]) => (
<button key={val} onClick={() => setMyOnly(val === 'true')} style={segBtn(String(myOnly) === val)}>{lbl}</button>
))}
</div>
@@ -943,12 +948,12 @@ function OrdersFilterDrawer({ myOnly, setMyOnly, sortBy, setSortBy, filter, setF
{/* Sort method */}
<div>
<p style={sectionLabel}>Ταξινόμηση</p>
<p style={sectionLabel}>{t('orders.filter.sort')}</p>
<div style={{ display: 'flex', flexDirection: 'column', gap: 6 }}>
{[
['time', 'Κατά ώρα παραγγελίας'],
['latest_change', 'Κατά τελευταία αλλαγή'],
['kds_priority', 'Ready → Prep → Pend'],
['time', t('orders.sort.time')],
['latest_change', t('orders.sort.latest')],
['kds_priority', t('orders.sort.kds')],
].map(([key, lbl]) => (
<div key={key} style={segmentedWrap}>
<button onClick={() => setSortBy(key)} style={segBtn(sortBy === key)}>{lbl}</button>
@@ -959,7 +964,7 @@ function OrdersFilterDrawer({ myOnly, setMyOnly, sortBy, setSortBy, filter, setF
{/* Status filter (multi-select: ALL selects all 3) */}
<div>
<p style={sectionLabel}>Κατάσταση</p>
<p style={sectionLabel}>{t('tables.filter.status')}</p>
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 6 }}>
{STATUS_OPTIONS.map(({ key, label }) => (
<div key={key} style={segmentedWrap}>
@@ -974,13 +979,14 @@ function OrdersFilterDrawer({ myOnly, setMyOnly, sortBy, setSortBy, filter, setF
</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.ok')}</button>
</div>
</div>
)
}
function OrdersView({ orders, allOrders, tables, filter, setFilter, myOnly, setMyOnly, sortBy, setSortBy, showFilters, setShowFilters, onNavigate, onMarkAllServed, onRefresh }) {
const { t } = useTranslation('waiter')
const { chipStyle } = useTableViewStore()
const [expandedOrders, setExpandedOrders] = useState({})
const [refreshing, setRefreshing] = useState(false)
@@ -1032,10 +1038,10 @@ function OrdersView({ orders, allOrders, tables, filter, setFilter, myOnly, setM
const preparing = items.filter(i => kds(i.kds_status) === 'preparing').length
const done = items.filter(i => kds(i.kds_status) === 'done').length
const total = items.length
if (done === total) return { label: 'READY', color: '#4ade80', bg: 'rgba(34,197,94,0.15)' }
if (preparing > 0) return { label: 'ΕΤΟΙΜΑΖΕΤΑΙ', color: '#60a5fa', bg: 'rgba(96,165,250,0.15)' }
if (pending === total) return { label: 'ΕΚΚΡΕΜΕΙ', color: '#f59e0b', bg: 'rgba(245,158,11,0.15)' }
return { label: `${done}/${total} READY`, color: '#4ade80', bg: 'rgba(34,197,94,0.12)' }
if (done === total) return { label: t('kds.ready'), color: '#4ade80', bg: 'rgba(34,197,94,0.15)' }
if (preparing > 0) return { label: t('kds.preparing'), color: '#60a5fa', bg: 'rgba(96,165,250,0.15)' }
if (pending === total) return { label: t('kds.pending'), color: '#f59e0b', bg: 'rgba(245,158,11,0.15)' }
return { label: t('kds.someReady', { done, total }), color: '#4ade80', bg: 'rgba(34,197,94,0.12)' }
}
// Count per filter for badge
@@ -1071,7 +1077,7 @@ function OrdersView({ orders, allOrders, tables, filter, setFilter, myOnly, setM
const cs = chipStyle || 'icon_short'
const showIcon = cs === 'icon' || cs === 'icon_short' || cs === 'icon_full'
const showText = cs !== 'icon'
const textLabel = (cs === 'full' || cs === 'icon_full') ? chip.full : chip.short
const textLabel = t((cs === 'full' || cs === 'icon_full') ? chip.full : chip.short)
return (
<button
key={chip.key}
@@ -1116,12 +1122,12 @@ function OrdersView({ orders, allOrders, tables, filter, setFilter, myOnly, setM
color: 'var(--muted)', fontSize: 13, fontWeight: 600,
overflow: 'hidden', transition: pulling ? 'none' : 'height 0.2s',
}}>
{refreshing ? '⟳ Ανανέωση…' : pullY >= PULL_THRESHOLD ? '↑ Αφήστε για ανανέωση' : '↓ Τραβήξτε για ανανέωση'}
{refreshing ? `⟳ ${t('tables.pull.refreshing')}` : pullY >= PULL_THRESHOLD ? `↑ ${t('tables.pull.release')}` : `↓ ${t('tables.pull.pull')}`}
</div>
)}
{orders.length === 0 && (
<div style={{ textAlign: 'center', padding: '40px 0', color: 'var(--muted)', fontSize: 14 }}>
Δεν υπάρχουν παραγγελίες
{t('orders.none')}
</div>
)}
{orders.map(o => {
@@ -1168,7 +1174,7 @@ function OrdersView({ orders, allOrders, tables, filter, setFilter, myOnly, setM
{/* Item count */}
<span style={{ fontSize: 12, color: 'var(--muted)', marginLeft: 2 }}>
{visibleItems.length} είδη
{t('orders.items', { count: visibleItems.length })}
</span>
<span style={{ marginLeft: 'auto', color: 'var(--muted)', fontSize: 16, transition: 'transform 0.2s', display: 'inline-block', transform: expanded ? 'rotate(180deg)' : 'rotate(0deg)' }}>▾</span>
@@ -1199,7 +1205,7 @@ function OrdersView({ orders, allOrders, tables, filter, setFilter, myOnly, setM
fontSize: 9, fontWeight: 800, color: kdsC.textColor,
borderRadius: 3, padding: '1px 5px',
border: `1px solid ${kdsC.textColor}60`,
}}>{kdsC.label}</span>
}}>{t(kdsC.label)}</span>
)}
</div>
)
@@ -1213,7 +1219,7 @@ function OrdersView({ orders, allOrders, tables, filter, setFilter, myOnly, setM
background: 'var(--bg3)', color: 'var(--text)',
fontSize: 13, fontWeight: 600, cursor: 'pointer',
}}
>Άνοιγμα</button>
>{t('orders.open')}</button>
{o.items?.some(i => kds(i.kds_status) === 'done') && (
<button
onClick={() => onMarkAllServed(o.id)}
@@ -1222,7 +1228,7 @@ function OrdersView({ orders, allOrders, tables, filter, setFilter, myOnly, setM
background: 'rgba(34,197,94,0.15)', color: '#4ade80',
fontSize: 13, fontWeight: 700, cursor: 'pointer',
}}
>Σήμανση Παραδοθέντων</button>
>{t('orders.markServed')}</button>
)}
</div>
</div>
@@ -1278,6 +1284,8 @@ function OrdersView({ orders, allOrders, tables, filter, setFilter, myOnly, setM
// ─── Standalone order card (takeaway / delivery) ──────────────────────────────
function StandaloneOrderCard({ order, onClick }) {
const { t } = useTranslation('waiter')
const { formatMoney } = useFormat()
const isDelivery = order.order_type === 'delivery'
const activeItems = (order.items || []).filter(i => i.status === 'active')
const paidItems = (order.items || []).filter(i => i.status === 'paid')
@@ -1334,7 +1342,7 @@ function StandaloneOrderCard({ order, onClick }) {
background: `${statusColor}22`, color: statusColor,
border: `1px solid ${statusColor}44`,
}}>
{{ open: 'ΑΝΟΙΧΤΟ', partially_paid: 'ΜΕΡ. ΠΛΗΡΩΜ.', paid: 'ΠΛΗΡΩΜΕΝΟ' }[order.status] || order.status.toUpperCase()}
{{ open: t('card.open'), partially_paid: t('card.partlyPaid'), paid: t('card.paid') }[order.status] || order.status.toUpperCase()}
</span>
{kds !== 'served' && (
<span style={{
@@ -1343,15 +1351,15 @@ function StandaloneOrderCard({ order, onClick }) {
background: `${kdsColor}22`, color: kdsColor,
border: `1px solid ${kdsColor}44`,
}}>
{{ pending: 'ΕΚΚΡΕΜΕΙ', preparing: 'ΕΤΟΙΜΑΖΕΤΑΙ', done: 'READY' }[kds] || kds.toUpperCase()}
{{ pending: t('kds.pending'), preparing: t('kds.preparing'), done: t('kds.ready') }[kds] || kds.toUpperCase()}
</span>
)}
</div>
{/* Total + item count */}
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'baseline', marginTop: 'auto' }}>
<span style={{ fontSize: 11, color: 'var(--muted)' }}>{activeItems.length + paidItems.length} είδη</span>
<span style={{ fontSize: 14, fontWeight: 700, color: 'var(--text)' }}>{total.toFixed(2)} €</span>
<span style={{ fontSize: 11, color: 'var(--muted)' }}>{t('orders.items', { count: activeItems.length + paidItems.length })}</span>
<span style={{ fontSize: 14, fontWeight: 700, color: 'var(--text)' }}>{formatMoney(total)}</span>
</div>
</div>
)
@@ -1386,6 +1394,7 @@ function NewStandaloneCard({ label, color, icon, onClick }) {
// ─── Standalone page view ─────────────────────────────────────────────────────
function StandaloneView({ orders, gridCols, navigate }) {
const { t } = useTranslation('waiter')
const standaloneOrders = orders
.filter(o => o.order_type === 'takeaway' || o.order_type === 'delivery')
.sort((a, b) => new Date(a.opened_at || 0) - new Date(b.opened_at || 0))
@@ -1401,13 +1410,13 @@ function StandaloneView({ orders, gridCols, navigate }) {
}}>
{/* Fixed action cards always at top */}
<NewStandaloneCard
label="+ Νέο Takeaway"
label={t('orders.newTakeaway')}
color="#f59e0b"
icon="🥡"
onClick={() => navigate('/standalone/takeaway/add?new=1')}
/>
<NewStandaloneCard
label="+ Νέα Delivery"
label={t('orders.newDelivery')}
color="#60a5fa"
icon="🛵"
onClick={() => navigate('/standalone/delivery/add?new=1')}