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
+34 -27
View File
@@ -1,6 +1,7 @@
import { useEffect, useState } from 'react'
import { useNavigate, useLocation } from 'react-router-dom'
import { useCan, useModule } from '@xenia/access'
import { useFormat, useTranslation } from '@xenia/i18n'
import UserMenu from './UserMenu'
import { useNotifications } from '../context/NotificationContext'
import useNotificationSettingsStore from '../store/notificationSettingsStore'
@@ -16,8 +17,8 @@ import useFailedPrintCount from '../hooks/useFailedPrintCount'
const NAV_REGISTRY = {
tables: {
key: 'tables',
label: 'Τραπέζια',
shortLabel: 'Τραπέζια',
label: 'nav.tables',
shortLabel: 'nav.tables',
href: '/tables?tab=tables',
match: (loc) => loc.pathname === '/tables' && loc.search !== '?tab=orders',
icon: (
@@ -31,8 +32,8 @@ const NAV_REGISTRY = {
},
orders: {
key: 'orders',
label: 'Ενεργές Παραγγελίες',
shortLabel: 'Παραγγελίες',
label: 'nav.activeOrders',
shortLabel: 'nav.orders',
href: '/tables?tab=orders',
match: (loc) => loc.pathname === '/tables' && loc.search === '?tab=orders',
icon: (
@@ -44,8 +45,8 @@ const NAV_REGISTRY = {
},
messages: {
key: 'messages',
label: 'Μηνύματα',
shortLabel: 'Μηνύματα',
label: 'nav.messages',
shortLabel: 'nav.messages',
href: '/messages',
match: (loc) => loc.pathname === '/messages',
icon: (
@@ -56,8 +57,8 @@ const NAV_REGISTRY = {
},
standalone: {
key: 'standalone',
label: 'Takeaway',
shortLabel: 'Takeaway',
label: 'nav.takeaway',
shortLabel: 'nav.takeaway',
href: '/tables',
match: () => false,
icon: (
@@ -70,8 +71,8 @@ const NAV_REGISTRY = {
},
'shift-overview': {
key: 'shift-overview',
label: 'Βάρδια',
shortLabel: 'Βάρδια',
label: 'nav.shift',
shortLabel: 'nav.shift',
href: '/shift-overview',
match: (loc) => loc.pathname === '/shift-overview',
icon: (
@@ -83,8 +84,8 @@ const NAV_REGISTRY = {
},
'order-log': {
key: 'order-log',
label: 'Αρχείο',
shortLabel: 'Αρχείο',
label: 'nav.log',
shortLabel: 'nav.log',
href: '/order-log',
match: (loc) => loc.pathname === '/order-log',
icon: (
@@ -206,14 +207,16 @@ function BellButton({ onClick, count }) {
// ─── Notification drawer ──────────────────────────────────────────────────────
function NotificationDrawer({ messages, onClose }) {
const { t } = useTranslation('waiter')
const { formatTime } = useFormat()
return (
<div className="modal-overlay" onClick={onClose}>
<div className="modal-sheet" onClick={e => e.stopPropagation()} style={{ maxHeight: '80svh' }}>
<div className="modal-handle" />
<h2 className="modal-title" style={{ marginBottom: 8 }}>Ειδοποιήσεις</h2>
<h2 className="modal-title" style={{ marginBottom: 8 }}>{t('shell.notifications')}</h2>
{messages.length === 0 && (
<p style={{ textAlign: 'center', color: 'var(--muted)', padding: '24px 0' }}>
Δεν υπάρχουν ειδοποιήσεις
{t('shell.noNotifications')}
</p>
)}
<div style={{ display: 'flex', flexDirection: 'column', overflowY: 'auto', flex: 1 }}>
@@ -231,17 +234,17 @@ function NotificationDrawer({ messages, onClose }) {
)}
<div style={{ fontSize: 14, fontWeight: 600, color: 'var(--text)' }}>{msg.body}</div>
{tableIds.length > 0 && (
<div style={{ fontSize: 12, color: 'var(--muted)', marginTop: 2 }}>Τραπέζι: {tableIds.join(', ')}</div>
<div style={{ fontSize: 12, color: 'var(--muted)', marginTop: 2 }}>{t('shell.notificationTables', { tables: tableIds.join(', ') })}</div>
)}
<div style={{ fontSize: 11, color: 'var(--muted)', marginTop: 2 }}>
{new Date(msg.created_at).toLocaleTimeString('el-GR', { hour: '2-digit', minute: '2-digit' })}
{formatTime(msg.created_at)}
</div>
</div>
</div>
)
})}
</div>
<button className="btn btn--secondary" style={{ width: '100%', marginTop: 4 }} onClick={onClose}>Κλείσιμο</button>
<button className="btn btn--secondary" style={{ width: '100%', marginTop: 4 }} onClick={onClose}>{t('common.close')}</button>
</div>
</div>
)
@@ -253,7 +256,7 @@ const DRAWER_NAV_ITEMS = [
{ ...NAV_REGISTRY.tables },
{
key: 'standalone',
label: 'Takeaway / Delivery',
label: 'nav.takeawayDelivery',
href: '/tables',
match: () => false, // active state handled separately in SideDrawer
icon: (
@@ -268,7 +271,7 @@ const DRAWER_NAV_ITEMS = [
{ ...NAV_REGISTRY.messages },
{
key: 'shift-overview',
label: 'Σύνοψη Βάρδιας',
label: 'nav.shiftSummary',
href: '/shift-overview',
match: (loc) => loc.pathname === '/shift-overview',
icon: (
@@ -280,7 +283,7 @@ const DRAWER_NAV_ITEMS = [
},
{
key: 'order-log',
label: 'Αρχείο Παραγγελιών',
label: 'nav.orderLog',
href: '/order-log',
match: (loc) => loc.pathname === '/order-log',
icon: (
@@ -295,7 +298,7 @@ const DRAWER_NAV_ITEMS = [
const DRAWER_SETTINGS_ITEM = {
key: 'settings',
label: 'Settings',
label: 'nav.settings',
href: '/settings',
match: (loc) => loc.pathname.startsWith('/settings'),
icon: (
@@ -308,7 +311,7 @@ const DRAWER_SETTINGS_ITEM = {
const DRAWER_INSTALL_ITEM = {
key: 'install-app',
label: 'Εγκατάσταση εφαρμογής',
label: 'nav.installApp',
match: () => false,
icon: (
<svg width="22" height="22" viewBox="0 0 24 24" fill="none">
@@ -338,6 +341,7 @@ function InstallAppDrawerButton({ location, onClose }) {
}
function DrawerButton({ item, location, onNavigate, active: activeProp, onClick }) {
const { t } = useTranslation('waiter')
const active = activeProp ?? item.match(location)
return (
<button
@@ -353,7 +357,7 @@ function DrawerButton({ item, location, onNavigate, active: activeProp, onClick
}}
>
<span style={{ opacity: active ? 1 : 0.6, flexShrink: 0 }}>{item.icon}</span>
{item.label}
{t(item.label)}
{active && (
<div style={{ marginLeft: 'auto', width: 6, height: 6, borderRadius: '50%', background: 'var(--accent)' }} />
)}
@@ -362,6 +366,7 @@ function DrawerButton({ item, location, onNavigate, active: activeProp, onClick
}
function SideDrawer({ open, onClose }) {
const { t } = useTranslation('waiter')
const navigate = useNavigate()
const chatOn = useChatOn()
const location = useLocation()
@@ -406,13 +411,13 @@ function SideDrawer({ open, onClose }) {
{/* Drawer header */}
<div style={{ padding: '20px 20px 16px', borderBottom: '1px solid var(--border)' }}>
<div style={{ fontSize: 22, fontWeight: 800, color: 'var(--accent)', letterSpacing: -0.5 }}>Xenia</div>
<div style={{ fontSize: 12, color: 'var(--muted)', marginTop: 2 }}>POS System</div>
<div style={{ fontSize: 12, color: 'var(--muted)', marginTop: 2 }}>{t('shell.posSystem')}</div>
</div>
{/* Main nav items */}
<div style={{ flex: 1, padding: '12px 10px', display: 'flex', flexDirection: 'column', gap: 4, overflowY: 'auto' }}>
<div style={{ fontSize: 10, fontWeight: 700, color: 'var(--muted)', textTransform: 'uppercase', letterSpacing: 1, padding: '4px 10px 8px' }}>
Πλοήγηση
{t('shell.navigation')}
</div>
{DRAWER_NAV_ITEMS.filter(shown(chatOn)).map(item => {
const isStandaloneActive = location.pathname === '/tables' && activeZoneTab === 'standalone'
@@ -461,6 +466,7 @@ function PillBadge({ count, color = '#ef4444' }) {
}
function TripleFooter({ location, navigate, chatUnread, kdsReady, tripleItems }) {
const { t } = useTranslation('waiter')
const { activeZoneTab, setActiveZoneTab } = useTableViewStore()
const chatOn = useChatOn()
const items = (tripleItems || ['tables', 'orders', 'messages']).map(k => NAV_REGISTRY[k]).filter(Boolean).filter(shown(chatOn))
@@ -513,7 +519,7 @@ function TripleFooter({ location, navigate, chatUnread, kdsReady, tripleItems })
{item.key === 'orders' && <svg width="15" height="15" viewBox="0 0 24 24" fill="none"><path d="M9 5H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2M9 5a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2M9 5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round"/><path d="M9 12h6M9 16h4" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round"/></svg>}
{item.key === 'messages' && <svg width="15" height="15" viewBox="0 0 24 24" fill="none"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round"/></svg>}
</span>
{item.shortLabel ?? item.label}
{t(item.shortLabel ?? item.label)}
{badge && <PillBadge count={badge.count} color={badge.color} />}
</button>
)
@@ -526,6 +532,7 @@ function TripleFooter({ location, navigate, chatUnread, kdsReady, tripleItems })
// ─── Icon navbar footer ───────────────────────────────────────────────────────
function IconNavbar({ navItems, location, navigate, chatUnread, kdsReady }) {
const { t } = useTranslation('waiter')
const { activeZoneTab, setActiveZoneTab } = useTableViewStore()
const chatOn = useChatOn()
const items = navItems
@@ -597,7 +604,7 @@ function IconNavbar({ navItems, location, navigate, chatUnread, kdsReady }) {
)}
</span>
<span style={{ fontSize: 10, fontWeight: active ? 700 : 500, letterSpacing: 0.2 }}>
{item.shortLabel ?? item.label}
{t(item.shortLabel ?? item.label)}
</span>
</button>
)
+4 -2
View File
@@ -1,5 +1,6 @@
import { useEffect, useState } from 'react'
import { markBundleReady, syncVenueBundle } from '../native/bundles'
import { useTranslation } from '@xenia/i18n'
const FIRST_SYNC_DELAY_MS = 3000 // let a TLS upgrade / rediscovery reload settle first
const PERIODIC_SYNC_MS = 30 * 60_000
@@ -11,6 +12,7 @@ const PERIODIC_SYNC_MS = 30 * 60_000
* only if the venue's UI needs a newer APK than the one installed.
*/
export default function BundleSync() {
const { t } = useTranslation('waiter')
const [apkUpdate, setApkUpdate] = useState(null) // APK download URL when the shell is too old
useEffect(() => {
@@ -47,7 +49,7 @@ export default function BundleSync() {
boxShadow: '0 8px 32px rgba(0,0,0,0.4)',
}}>
<span style={{ flex: 1, fontSize: 13, color: 'var(--text)', lineHeight: 1.35 }}>
Ο server του καταστήματος χρειάζεται νεότερη έκδοση της εφαρμογής.
{t('update.needsNewerApp')}
</span>
<a
href={apkUpdate}
@@ -58,7 +60,7 @@ export default function BundleSync() {
fontSize: 14, fontWeight: 700, textDecoration: 'none', whiteSpace: 'nowrap',
}}
>
Ενημέρωση
{t('update.update')}
</a>
</div>
)
+16 -14
View File
@@ -1,17 +1,18 @@
import { useEffect } from 'react'
import useInstallPromptStore, { APK_URL, canOfferApp } from '../store/installPromptStore'
import { useTranslation } from '@xenia/i18n'
const BENEFITS = [
{ icon: '⚡', title: 'Ανοίγει αμέσως', text: 'Χωρίς φόρτωση από τον browser, σαν κανονική εφαρμογή.' },
{ icon: '📶', title: 'Αντέχει στο WiFi', text: 'Συνεχίζει να δουλεύει όταν χάνεται για λίγο η σύνδεση.' },
{ icon: '🔒', title: 'Ασφαλής σύνδεση', text: 'Κρυπτογραφημένη επικοινωνία με τον server του καταστήματος.' },
{ icon: '🔄', title: 'Χωρίς ρυθμίσεις', text: 'Βρίσκει μόνη της τον server και ενημερώνεται αυτόματα.' },
{ icon: '⚡', title: 'install.fast', text: 'install.fastText' },
{ icon: '📶', title: 'install.wifi', text: 'install.wifiText' },
{ icon: '🔒', title: 'install.secure', text: 'install.secureText' },
{ icon: '🔄', title: 'install.noSetup', text: 'install.noSetupText' },
]
const STEPS = [
'Πατήστε «Λήψη εφαρμογής».',
'Ανοίξτε το αρχείο και επιτρέψτε την εγκατάσταση.',
'Ανοίξτε το Xenia και σαρώστε ξανά το QR του καταστήματος.',
'install.step1',
'install.step2',
'install.step3',
]
/**
@@ -19,6 +20,7 @@ const STEPS = [
* Opens by itself once; afterwards from the side drawer.
*/
export default function InstallAppDialog() {
const { t } = useTranslation('waiter')
const { open, dismiss, autoOpen } = useInstallPromptStore()
useEffect(() => {
@@ -56,10 +58,10 @@ export default function InstallAppDialog() {
style={{ borderRadius: 18, boxShadow: '0 6px 20px rgba(0,0,0,0.35)' }}
/>
<h2 id="install-app-title" style={{ fontSize: 20, fontWeight: 800, color: 'var(--text)', margin: '14px 0 4px' }}>
Εφαρμογή Xenia
{t('install.title')}
</h2>
<p style={{ fontSize: 13, color: 'var(--muted)', lineHeight: 1.45 }}>
Εγκαταστήστε την εφαρμογή για γρηγορότερη και πιο σταθερή λειτουργία.
{t('install.intro')}
</p>
</div>
@@ -73,8 +75,8 @@ export default function InstallAppDialog() {
{b.icon}
</span>
<div>
<div style={{ fontSize: 14, fontWeight: 700, color: 'var(--text)' }}>{b.title}</div>
<div style={{ fontSize: 12.5, color: 'var(--muted)', lineHeight: 1.4 }}>{b.text}</div>
<div style={{ fontSize: 14, fontWeight: 700, color: 'var(--text)' }}>{t(b.title)}</div>
<div style={{ fontSize: 12.5, color: 'var(--muted)', lineHeight: 1.4 }}>{t(b.text)}</div>
</div>
</div>
))}
@@ -84,7 +86,7 @@ export default function InstallAppDialog() {
margin: 0, padding: '12px 14px 12px 32px', borderRadius: 12, background: 'var(--bg3)',
fontSize: 12.5, color: 'var(--muted)', lineHeight: 1.55,
}}>
{STEPS.map(s => <li key={s}>{s}</li>)}
{STEPS.map(s => <li key={s}>{t(s)}</li>)}
</ol>
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
@@ -95,10 +97,10 @@ export default function InstallAppDialog() {
className="btn btn--accent btn--lg"
style={{ textDecoration: 'none', display: 'flex', alignItems: 'center', justifyContent: 'center' }}
>
Λήψη εφαρμογής
{t('install.download')}
</a>
<button className="btn btn--secondary" onClick={dismiss} style={{ minHeight: 44 }}>
Όχι τώρα
{t('install.later')}
</button>
</div>
</div>
+7 -5
View File
@@ -20,6 +20,7 @@ import { apiError } from '../api/errors'
import { getVenueSettings } from '../api/venueSettings'
import { storageKey } from '../config/server'
import { idleAction, idleLimits } from '../logic/idle'
import { useTranslation } from '@xenia/i18n'
const ACTIVITY_EVENTS = ['pointerdown', 'keydown', 'touchstart', 'scroll']
const SAVE_EVERY_MS = 5_000
@@ -84,6 +85,7 @@ function touchActivity() {
}
export default function LockScreen() {
const { t } = useTranslation('waiter')
const { user, savedUsername, unlock, logout } = useAuthStore()
const { login: modes } = useAccess()
const usePassword = modes?.waiter_mode === 'password'
@@ -108,7 +110,7 @@ export default function LockScreen() {
unlock(data.user)
} catch (err) {
if (isError(err, 'auth.session_ended')) { signOut(); return }
setError(apiError(err, usePassword ? 'Λανθασμένος κωδικός' : 'Λανθασμένο PIN'))
setError(apiError(err, usePassword ? t('login.wrongPassword') : t('login.wrongPin')))
setPassword('')
setAttempt(a => a + 1)
} finally {
@@ -127,7 +129,7 @@ export default function LockScreen() {
>
<div className="login-box" style={{ textAlign: 'center' }}>
<div style={{ fontSize: 40 }}>🔒</div>
<p style={{ fontSize: 18, fontWeight: 700, color: 'var(--text)', margin: '6px 0 2px' }}>Κλειδωμένο</p>
<p style={{ fontSize: 18, fontWeight: 700, color: 'var(--text)', margin: '6px 0 2px' }}>{t('lock.locked')}</p>
<p style={{ fontSize: 14, color: 'var(--muted)', marginBottom: 12 }}>{user?.full_name || user?.username || savedUsername}</p>
{usePassword ? (
@@ -136,7 +138,7 @@ export default function LockScreen() {
type="password"
value={password}
onChange={e => setPassword(e.target.value)}
placeholder="Κωδικός"
placeholder={t('login.password')}
autoComplete="current-password"
data-testid="unlock-password"
style={{
@@ -144,7 +146,7 @@ export default function LockScreen() {
border: '1px solid var(--border)', background: 'var(--bg2)', color: 'var(--text)', fontSize: 16,
}}
/>
<button type="submit" className="btn btn--primary btn--lg" disabled={busy || !password}>Ξεκλείδωμα</button>
<button type="submit" className="btn btn--primary btn--lg" disabled={busy || !password}>{t('lock.unlock')}</button>
</form>
) : (
<PinPad key={attempt} onSubmit={pin => tryUnlock({ pin })} loading={busy} />
@@ -157,7 +159,7 @@ export default function LockScreen() {
data-testid="lock-sign-out"
style={{ marginTop: 16, background: 'none', border: 'none', color: 'var(--muted)', fontSize: 13, cursor: 'pointer' }}
>
Αποσύνδεση (άλλος σερβιτόρος)
{t('lock.signOutOther')}
</button>
</div>
</div>
+7 -5
View File
@@ -1,8 +1,9 @@
import { useEffect, useRef, useState } from 'react'
import QrScanner from 'qr-scanner'
import { useTranslation } from '@xenia/i18n'
const MSG_DENIED = 'Δεν δόθηκε άδεια κάμερας. Επιτρέψτε την από τις ρυθμίσεις του κινητού ή πληκτρολογήστε τη διεύθυνση.'
const MSG_NO_CAMERA = 'Δεν ήταν δυνατή η ενεργοποίηση της κάμερας. Πληκτρολογήστε τη διεύθυνση.'
const MSG_DENIED = 'qr.denied'
const MSG_NO_CAMERA = 'qr.noCamera'
/**
* Full-screen camera view that resolves the first QR code it sees.
@@ -11,6 +12,7 @@ const MSG_NO_CAMERA = 'Δεν ήταν δυνατή η ενεργοποίηση
* the normal Android runtime permission prompt.
*/
export default function QrScannerModal({ onResult, onClose }) {
const { t } = useTranslation('waiter')
const videoRef = useRef(null)
const [error, setError] = useState(null)
@@ -73,17 +75,17 @@ export default function QrScannerModal({ onResult, onClose }) {
padding: 32, textAlign: 'center', color: '#e2e8f0', fontSize: 15, lineHeight: 1.5,
background: 'rgba(15,23,42,0.92)',
}}>
{error}
{t(error)}
</div>
)}
</div>
<div style={{ padding: 16, display: 'flex', flexDirection: 'column', gap: 10, background: '#0f172a' }}>
{!error && (
<p style={{ color: '#94a3b8', fontSize: 13, textAlign: 'center' }}>
Σκοπεύστε το QR από τον διαχειριστή (Ρυθμίσεις → Γενικά → Σερβιτόροι WiFi)
{t('qr.aim')}
</p>
)}
<button className="btn btn--secondary btn--lg" onClick={onClose} style={{ width: '100%' }}>Ακύρωση</button>
<button className="btn btn--secondary btn--lg" onClick={onClose} style={{ width: '100%' }}>{t('common.cancel')}</button>
</div>
</div>
)
+31 -21
View File
@@ -1,4 +1,5 @@
import { useRef, useState, useEffect } from 'react'
import { useFormat, useTranslation } from '@xenia/i18n'
import useThemeStore from '../store/themeStore'
import useTableColourStore from '../store/tableColourStore'
import { assetUrl } from '../config/server'
@@ -36,11 +37,11 @@ function fmtItemQtyTC(qty, unitType) {
const STATUS_LABELS = {
free: 'ΕΛΕΥΘΕΡΟ',
open: 'ΑΝΟΙΧΤΟ',
mine: 'ΔΙΚΟ ΜΟΥ',
paid: 'ΠΛΗΡΩΜΕΝΟ',
partially_paid: 'ΜΕΡ. ΠΛHΡ.',
free: 'card.free',
open: 'card.open',
mine: 'card.mine',
paid: 'card.paid',
partially_paid: 'card.partlyPaid',
}
// ─── KDS badge helpers ────────────────────────────────────────────────────────
@@ -131,6 +132,7 @@ function WaiterAvatar({ waiter, size = 22, ring }) {
// Renders [icon] Name, [icon] Name inline. Falls back to icons + "X Waiters" if they don't fit
// (we approximate "don't fit" as > 2 waiters for the compact footer height).
function WaiterRow({ waiters, size = 22, cfg }) {
const { t } = useTranslation('waiter')
if (!waiters?.length) return null
const textColor = cfg.nameText
@@ -172,7 +174,7 @@ function WaiterRow({ waiters, size = 22, cfg }) {
}}>+{waiters.length - 3}</div>
)}
<span style={{ fontSize: 12, fontWeight: 600, color: textColor, opacity: 0.7, marginLeft: 4 }}>
{waiters.length} σερβιτόροι
{t('card.waiters', { count: waiters.length })}
</span>
</div>
)
@@ -266,14 +268,16 @@ function FlagChip({ flag }) {
// ─── Amount display ───────────────────────────────────────────────────────────
function Amount({ value, size = 22, color }) {
const s = Number(value || 0).toFixed(2)
const [whole, cents] = s.split('.')
// the venue's money format (4.5), the cents smaller: "2,40 €" / "€2.40"
const { formatMoney } = useFormat()
const m = /^(.*?)([.,])(\d{2})(\D*)$/.exec(formatMoney(Number(value || 0)))
const [whole, cents] = m ? [m[1], `${m[2]}${m[3]}${m[4]}`] : [formatMoney(Number(value || 0)), '']
const isNum = typeof size === 'number'
const centsSize = isNum ? size * 0.56 : `calc(${size} * 0.56)`
return (
<div style={{ lineHeight: 1, color: color || 'inherit' }}>
<span style={{ fontSize: size, fontWeight: 800, letterSpacing: -0.5 }}>{whole}</span>
<span style={{ fontSize: centsSize, fontWeight: 800, opacity: 0.8 }}>.{cents}€</span>
<span style={{ fontSize: centsSize, fontWeight: 800, opacity: 0.8 }}>{cents}</span>
</div>
)
}
@@ -282,6 +286,7 @@ function Amount({ value, size = 22, color }) {
// 1x1 — square-ish, 4 per row. Badges top (up to 2 + +N), name center, KDS badge bottom (replaces status).
function Card1x1({ table, _order, flags, _waiterObjects, cfg, statusKey, kdsBadge, flashOverlay }) {
const { t } = useTranslation('waiter')
return (
<div style={{
width: '100%', aspectRatio: '1 / 1.05',
@@ -319,7 +324,7 @@ function Card1x1({ table, _order, flags, _waiterObjects, cfg, statusKey, kdsBadg
background: cfg.badgeBg, borderRadius: 3,
padding: '1px 4px', whiteSpace: 'nowrap',
}}>
{STATUS_LABELS[statusKey]}
{t(STATUS_LABELS[statusKey])}
</span>
)}
</div>
@@ -329,6 +334,7 @@ function Card1x1({ table, _order, flags, _waiterObjects, cfg, statusKey, kdsBadg
// 2x1 — half width, compact horizontal. Name left, KDS badge (or status) + flags right.
function Card2x1({ table, _order, flags, _waiterObjects, cfg, statusKey, kdsBadge, flashOverlay }) {
const { t } = useTranslation('waiter')
return (
<div style={{
width: '100%', height: 64,
@@ -357,7 +363,7 @@ function Card2x1({ table, _order, flags, _waiterObjects, cfg, statusKey, kdsBadg
{kdsBadge ? (
<KdsBadge badge={kdsBadge} small />
) : (
<StatusPill label={STATUS_LABELS[statusKey]} badgeBg={cfg.badgeBg} badgeText={cfg.badgeText} small />
<StatusPill label={t(STATUS_LABELS[statusKey])} badgeBg={cfg.badgeBg} badgeText={cfg.badgeText} small />
)}
{flags.length > 0 && (
<FlagDots flags={flags} size={18} maxShow={3} />
@@ -369,6 +375,7 @@ function Card2x1({ table, _order, flags, _waiterObjects, cfg, statusKey, kdsBadg
// 2x2 — current-style square. Name top-left, status below, amount bottom-left, KDS badge top-right, flags right.
function Card2x2({ table, order, flags, _waiterObjects, cfg, statusKey, kdsBadge, flashOverlay }) {
const { t } = useTranslation('waiter')
const isFree = !order
const total = order?.items?.filter(i => i.status === 'active').reduce((s, i) => s + i.unit_price * i.quantity, 0) ?? 0
@@ -392,7 +399,7 @@ function Card2x2({ table, order, flags, _waiterObjects, cfg, statusKey, kdsBadge
{table.label || `T${table.number}`}
</span>
<div style={{ marginTop: 5 }}>
<StatusPill label={STATUS_LABELS[statusKey]} badgeBg={cfg.badgeBg} badgeText={cfg.badgeText} small />
<StatusPill label={t(STATUS_LABELS[statusKey])} badgeBg={cfg.badgeBg} badgeText={cfg.badgeText} small />
</div>
{/* Always reserve amount height — invisible when free */}
<div style={{ marginTop: 'auto', paddingTop: 8, minHeight: 28, visibility: isFree ? 'hidden' : 'visible' }}>
@@ -419,6 +426,7 @@ function Card2x2({ table, order, flags, _waiterObjects, cfg, statusKey, kdsBadge
// 4x1 — full width horizontal. Name + amount left-center, flags, KDS badge (or status) right.
function Card4x1({ table, order, flags, _waiterObjects, cfg, statusKey, kdsBadge, flashOverlay }) {
const { t } = useTranslation('waiter')
const isFree = !order
const total = order?.items?.filter(i => i.status === 'active').reduce((s, i) => s + i.unit_price * i.quantity, 0) ?? 0
@@ -462,7 +470,7 @@ function Card4x1({ table, order, flags, _waiterObjects, cfg, statusKey, kdsBadge
{kdsBadge ? (
<KdsBadge badge={kdsBadge} />
) : (
<StatusPill label={STATUS_LABELS[statusKey]} badgeBg={cfg.badgeBg} badgeText={cfg.badgeText} />
<StatusPill label={t(STATUS_LABELS[statusKey])} badgeBg={cfg.badgeBg} badgeText={cfg.badgeText} />
)}
</div>
</div>
@@ -471,6 +479,7 @@ function Card4x1({ table, order, flags, _waiterObjects, cfg, statusKey, kdsBadge
// 4x2 — full width, tall. Top row: name LEFT | status + KDS badge CENTER (v-centered with amount) | amount RIGHT.
function Card4x2({ table, order, flags, waiterObjects, groupName, cfg, statusKey, kdsBadge, flashOverlay }) {
const { t } = useTranslation('waiter')
const isFree = !order
const total = order?.items?.filter(i => i.status === 'active').reduce((s, i) => s + i.unit_price * i.quantity, 0) ?? 0
const showWaiters = !isFree && waiterObjects.length > 0
@@ -511,7 +520,7 @@ function Card4x2({ table, order, flags, waiterObjects, groupName, cfg, statusKey
{/* center: status + KDS badge side-by-side, vertically centered */}
<div style={{ display: 'flex', alignItems: 'center', gap: 6, flexShrink: 0 }}>
<StatusPill label={STATUS_LABELS[statusKey]} badgeBg={cfg.badgeBg} badgeText={cfg.badgeText} />
<StatusPill label={t(STATUS_LABELS[statusKey])} badgeBg={cfg.badgeBg} badgeText={cfg.badgeText} />
{kdsBadge && <KdsBadge badge={kdsBadge} />}
</div>
@@ -555,6 +564,7 @@ function Card4x2({ table, order, flags, waiterObjects, groupName, cfg, statusKey
// 4x3 — full width, two-column detail card. Left: name/zone/status/amount. Right: items. KDS footer. Waiter footer.
function Card4x3({ table, order, flags, waiterObjects, groupName, cfg, statusKey, _kdsBadge, flashOverlay }) {
const { t } = useTranslation('waiter')
const isFree = !order
const activeItems = order?.items?.filter(i => i.status === 'active') ?? []
const total = activeItems.reduce((s, i) => s + i.unit_price * i.quantity, 0)
@@ -568,10 +578,10 @@ function Card4x3({ table, order, flags, waiterObjects, groupName, cfg, statusKey
const preparing = relevant.filter(i => kds(i.kds_status) === 'preparing').length
const done = relevant.filter(i => kds(i.kds_status) === 'done').length
const total = relevant.length
if (done === total && total > 0) return { text: 'Όλα Έτοιμα για Παράδοση', color: '#4ade80' }
if (done === total && total > 0) return { text: t('card.allReady'), color: '#4ade80' }
const parts = []
if (preparing > 0) parts.push(`${preparing} Ετοιμάζεται`)
if (done > 0) parts.push(`${done} Έτοιμα`)
if (preparing > 0) parts.push(t('card.preparingCount', { count: preparing }))
if (done > 0) parts.push(t('card.readyCount', { count: done }))
return parts.length > 0 ? { text: parts.join(' · '), color: done > 0 ? '#4ade80' : '#60a5fa' } : null
})()
@@ -611,7 +621,7 @@ function Card4x3({ table, order, flags, waiterObjects, groupName, cfg, statusKey
</div>
<div style={{ marginTop: 8 }}>
<StatusPill label={STATUS_LABELS[statusKey]} badgeBg={cfg.badgeBg} badgeText={cfg.badgeText} small />
<StatusPill label={t(STATUS_LABELS[statusKey])} badgeBg={cfg.badgeBg} badgeText={cfg.badgeText} small />
</div>
{flags.length > 0 && (
@@ -628,11 +638,11 @@ function Card4x3({ table, order, flags, waiterObjects, groupName, cfg, statusKey
<div style={{ flex: 1, minWidth: 0, overflow: 'hidden' }}>
{isFree ? (
<div style={{ height: '100%', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
<span style={{ fontSize: 12, color: cfg.nameText, opacity: 0.35 }}>Ελεύθερο</span>
<span style={{ fontSize: 12, color: cfg.nameText, opacity: 0.35 }}>{t('card.freeLower')}</span>
</div>
) : activeItems.length === 0 ? (
<div style={{ height: '100%', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
<span style={{ fontSize: 12, color: cfg.nameText, opacity: 0.35 }}>Κανένα είδος</span>
<span style={{ fontSize: 12, color: cfg.nameText, opacity: 0.35 }}>{t('card.noItems')}</span>
</div>
) : (
<div style={{ display: 'flex', flexDirection: 'column', gap: 3, minWidth: 0 }}>
@@ -654,7 +664,7 @@ function Card4x3({ table, order, flags, waiterObjects, groupName, cfg, statusKey
))}
{activeItems.length > 7 && (
<div style={{ fontSize: 11, color: cfg.nameText, opacity: 0.5, marginTop: 2 }}>
+{activeItems.length - 7} ακόμα…
{t('card.more', { count: activeItems.length - 7 })}
</div>
)}
</div>
+4 -2
View File
@@ -1,6 +1,8 @@
import { useRegisterSW } from 'virtual:pwa-register/react'
import { useTranslation } from '@xenia/i18n'
export default function UpdatePrompt() {
const { t } = useTranslation('waiter')
const {
needRefresh: [needRefresh],
updateServiceWorker,
@@ -26,7 +28,7 @@ export default function UpdatePrompt() {
whiteSpace: 'nowrap',
}}>
<span style={{ fontSize: 14, color: 'var(--text)', fontWeight: 500 }}>
Νέα έκδοση διαθέσιμη
{t('update.available')}
</span>
<button
onClick={() => updateServiceWorker(true)}
@@ -41,7 +43,7 @@ export default function UpdatePrompt() {
cursor: 'pointer',
}}
>
Ενημέρωση
{t('update.update')}
</button>
</div>
)
+43 -23
View File
@@ -1,27 +1,27 @@
import { useEffect, useRef, useState } from 'react'
import { useNavigate } from 'react-router-dom'
import { useCan } from '@xenia/access'
import { useAccess, useCan } from '@xenia/access'
import { LANGUAGE_NAMES, setUserLanguage, useFormat, useLanguage, useTranslation } from '@xenia/i18n'
import useAuthStore from '../store/authStore'
import useShiftStore from '../store/shiftStore'
import useThemeStore from '../store/themeStore'
import client from '../api/client'
import { deliveryMode, getActiveVenue } from '../config/server'
function formatTime(iso) {
if (!iso) return ''
return new Date(iso).toLocaleTimeString('el-GR', { hour: '2-digit', minute: '2-digit' })
}
function formatDuration(iso) {
function formatDuration(iso, t) {
if (!iso) return ''
const mins = Math.floor((Date.now() - new Date(iso).getTime()) / 60000)
if (mins < 60) return `${mins}λ`
if (mins < 60) return t('common.minutesShort', { m: mins })
const h = Math.floor(mins / 60)
const m = mins % 60
return m === 0 ? `${h}ω` : `${h}ω ${m}λ`
return m === 0 ? t('common.hoursShort', { h }) : t('common.hoursMinutesShort', { h, m })
}
export default function UserMenu() {
const { t, i18n } = useTranslation('waiter')
const { formatTime, formatMoney } = useFormat()
const { language, languages } = useLanguage()
const { refresh } = useAccess()
const [open, setOpen] = useState(false)
const [busy, setBusy] = useState(false)
const ref = useRef(null)
@@ -41,6 +41,18 @@ export default function UserMenu() {
return () => document.removeEventListener('mousedown', onClick)
}, [])
// The screen changes at once; the choice is saved to the profile and the bootstrap reloaded,
// so it holds on the next sign-in and on the other apps.
async function chooseLanguage(lng) {
setOpen(false)
try {
await setUserLanguage(i18n, lng, { save: l => client.patch('/api/auth/me', { language: l }) })
await refresh()
} catch {
window.alert(t('menu.languageNotSaved'))
}
}
function handleLogout() {
setOpen(false)
logout()
@@ -52,7 +64,7 @@ export default function UserMenu() {
const isWaiter = !canDashboard // works in a shift (plan 4.1: the key, not the role)
async function handleEndShift() {
if (!window.confirm('Να τελειώσει η βάρδια σου;')) return
if (!window.confirm(t('menu.endShiftConfirm'))) return
setBusy(true)
try {
await client.post('/api/shifts/end', {})
@@ -86,7 +98,7 @@ export default function UserMenu() {
<div ref={ref} style={{ position: 'relative' }}>
<button
onClick={() => setOpen(o => !o)}
title="Μενού χρήστη"
title={t('menu.title')} data-testid="user-menu"
style={{
display: 'flex', alignItems: 'center', gap: 6,
padding: '8px 14px', borderRadius: 20, border: '2px solid transparent',
@@ -122,20 +134,20 @@ export default function UserMenu() {
margin: '4px 8px 2px',
}}>
<div style={{ fontSize: 11, fontWeight: 700, color: 'var(--muted)', textTransform: 'uppercase', letterSpacing: 0.6, marginBottom: 4 }}>
Βάρδια ενεργή
{t('menu.shiftActive')}
</div>
<div style={{ fontSize: 13, color: 'var(--text)', display: 'flex', justifyContent: 'space-between' }}>
<span>Από {formatTime(shift.started_at)}</span>
<span style={{ color: 'var(--muted)' }}>{formatDuration(shift.started_at)}</span>
<span>{t('menu.since', { time: formatTime(shift.started_at) })}</span>
<span style={{ color: 'var(--muted)' }}>{formatDuration(shift.started_at, t)}</span>
</div>
{shift.starting_cash != null && (
<div style={{ fontSize: 12, color: 'var(--muted)', marginTop: 2 }}>
Αρχικά: €{shift.starting_cash.toFixed(2)}
{t('menu.startingCash', { amount: formatMoney(shift.starting_cash) })}
</div>
)}
{activeBreak && (
<div style={{ fontSize: 12, color: 'var(--accent)', marginTop: 4, fontWeight: 600 }}>
☕ Σε διάλειμμα από {formatTime(activeBreak.started_at)}
☕ {t('menu.onBreakSince', { time: formatTime(activeBreak.started_at) })}
</div>
)}
</div>
@@ -147,7 +159,7 @@ export default function UserMenu() {
disabled={busy}
>
<span className="user-menu-item__icon">{activeBreak ? '▶' : '☕'}</span>
<span>{activeBreak ? 'Τέλος Διαλείμματος' : 'Διάλειμμα'}</span>
<span>{activeBreak ? t('menu.endBreak') : t('menu.break')}</span>
</button>
{/* End shift button */}
@@ -159,11 +171,11 @@ export default function UserMenu() {
style={{ color: 'var(--danger)' }}
>
<span className="user-menu-item__icon">⏹</span>
<span>Τέλος Βάρδιας</span>
<span>{t('menu.endShift')}</span>
</button>
) : (
<div style={{ padding: '8px 16px', fontSize: 12, color: 'var(--muted)', fontStyle: 'italic' }}>
Ζητήστε από τον διαχειριστή να κλείσει τη βάρδια
{t('menu.askManagerToEnd')}
</div>
)}
@@ -175,27 +187,35 @@ export default function UserMenu() {
{deliveryMode() === 'native' && (
<button className="user-menu-item" onClick={() => { setOpen(false); navigate('/venues') }}>
<span className="user-menu-item__icon">🏪</span>
<span>Κατάστημα: {getActiveVenue()?.name ?? '—'}</span>
<span>{t('menu.venue', { name: getActiveVenue()?.name ?? '—' })}</span>
</button>
)}
{/* ── Theme toggle ──────────────────────────────────── */}
<button className="user-menu-item" onClick={() => { toggle(); setOpen(false) }}>
<span className="user-menu-item__icon">{dark ? '☀️' : '🌙'}</span>
<span>{dark ? 'Φωτεινό θέμα' : 'Σκοτεινό θέμα'}</span>
<span>{dark ? t('menu.lightTheme') : t('menu.darkTheme')}</span>
</button>
{/* ── Language (plan step 4.5, D-12): saved to the person's profile ── */}
{languages.filter(l => l !== language).map(l => (
<button key={l} className="user-menu-item" data-testid={`menu-language-${l}`} onClick={() => chooseLanguage(l)}>
<span className="user-menu-item__icon">🌐</span>
<span>{LANGUAGE_NAMES[l] ?? l}</span>
</button>
))}
<div className="user-menu-divider" />
{/* ── Lock (plan step 4.2): the same waiter unlocks with their PIN ── */}
<button className="user-menu-item" data-testid="menu-lock" onClick={() => { setOpen(false); lock() }}>
<span className="user-menu-item__icon">🔒</span>
<span>Κλείδωμα</span>
<span>{t('menu.lock')}</span>
</button>
<button className="user-menu-item user-menu-item--danger" onClick={handleLogout}>
<span className="user-menu-item__icon">⏏</span>
<span>Αποσύνδεση</span>
<span>{t('common.signOut')}</span>
</button>
</div>
)}