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
+20 -15
View File
@@ -2,6 +2,7 @@ import { useEffect, useState } from 'react'
import { BrowserRouter, Routes, Route, Navigate, Outlet, useNavigate } from 'react-router-dom'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { AccessProvider, useAccess, useCan, useModule } from '@xenia/access'
import { useTranslation } from '@xenia/i18n'
import { i18n } from './i18n'
import useAuthStore from './store/authStore'
import useShiftStore from './store/shiftStore'
@@ -40,6 +41,7 @@ import { deliveryMode, getActiveVenue } from './config/server'
// ─── Utility ─────────────────────────────────────────────────────────────────
function Spinner() {
const { t } = useTranslation('waiter')
return (
<div className="page page--centered" style={{ gap: 12 }}>
<div style={{
@@ -49,7 +51,7 @@ function Spinner() {
borderRadius: '50%',
animation: 'gate-spin 0.7s linear infinite',
}} />
<span style={{ color: 'var(--muted)', fontSize: 14 }}>Φόρτωση…</span>
<span style={{ color: 'var(--muted)', fontSize: 14 }}>{t('common.loading')}</span>
</div>
)
}
@@ -84,30 +86,33 @@ function GateBtn({ onClick, disabled, variant = 'primary', children }) {
}
function ClosedScreen({ onRefresh, onLogout }) {
const { t } = useTranslation('waiter')
return (
<GateCard emoji="🔒" title="Εστιατόριο κλειστό"
subtitle={'Δεν υπάρχει ενεργή ημέρα λειτουργίας.\nΖητήστε από τον διαχειριστή να ανοίξει την ημέρα.'}>
<GateCard emoji="🔒" title={t('gate.closedTitle')}
subtitle={t('gate.closedBody')}>
<div style={{ display: 'flex', gap: 12 }}>
<GateBtn variant="secondary" onClick={onRefresh}>Ανανέωση</GateBtn>
<GateBtn variant="danger" onClick={onLogout}>Αποσύνδεση</GateBtn>
<GateBtn variant="secondary" onClick={onRefresh}>{t('common.refresh')}</GateBtn>
<GateBtn variant="danger" onClick={onLogout}>{t('common.signOut')}</GateBtn>
</div>
</GateCard>
)
}
function WaitingManagerScreen({ onRefresh, onLogout }) {
const { t } = useTranslation('waiter')
return (
<GateCard emoji="⏳" title="Αναμονή για έναρξη βάρδιας"
subtitle="Ζητήστε από τον διαχειριστή να ξεκινήσει τη βάρδια σας.">
<GateCard emoji="⏳" title={t('gate.waitingTitle')}
subtitle={t('gate.waitingBody')}>
<div style={{ display: 'flex', gap: 12 }}>
<GateBtn variant="secondary" onClick={onRefresh}>Ανανέωση</GateBtn>
<GateBtn variant="danger" onClick={onLogout}>Αποσύνδεση</GateBtn>
<GateBtn variant="secondary" onClick={onRefresh}>{t('common.refresh')}</GateBtn>
<GateBtn variant="danger" onClick={onLogout}>{t('common.signOut')}</GateBtn>
</div>
</GateCard>
)
}
function StartShiftScreen({ username, onStart, onLogout }) {
const { t } = useTranslation('waiter')
const [startingCash, setStartingCash] = useState('')
const [starting, setStarting] = useState(false)
const [error, setError] = useState(null)
@@ -118,14 +123,14 @@ function StartShiftScreen({ username, onStart, onLogout }) {
try {
await onStart(startingCash ? parseFloat(startingCash) : null)
} catch (e) {
setError(apiError(e, 'Σφάλμα εκκίνησης βάρδιας'))
setError(apiError(e, t('gate.startFailed')))
setStarting(false)
}
}
return (
<GateCard emoji="👋" title={`Καλώς ήρθες, ${username}!`}
subtitle="Θέλεις να ξεκινήσεις τη βάρδια σου;">
<GateCard emoji="👋" title={t('gate.welcome', { name: username })}
subtitle={t('gate.startQuestion')}>
<div style={{
width: '100%', maxWidth: 320,
background: 'var(--bg2)', border: '1px solid var(--border)',
@@ -134,7 +139,7 @@ function StartShiftScreen({ username, onStart, onLogout }) {
}}>
<div>
<label style={{ fontSize: 13, fontWeight: 600, color: 'var(--muted)', display: 'block', marginBottom: 6 }}>
Αρχικά μετρητά (προαιρετικό)
{t('gate.startingCash')}
</label>
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<span style={{ color: 'var(--muted)', fontWeight: 700 }}>€</span>
@@ -160,7 +165,7 @@ function StartShiftScreen({ username, onStart, onLogout }) {
)}
<GateBtn onClick={handleStart} disabled={starting}>
{starting ? 'Εκκίνηση…' : '▶ Έναρξη Βάρδιας'}
{starting ? t('gate.starting') : `▶ ${t('gate.startShift')}`}
</GateBtn>
</div>
@@ -168,7 +173,7 @@ function StartShiftScreen({ username, onStart, onLogout }) {
style={{ fontSize: 13, color: 'var(--muted)', background: 'none', border: 'none', cursor: 'pointer' }}
onClick={onLogout}
>
Αποσύνδεση
{t('common.signOut')}
</button>
</GateCard>
)
+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>
)}
+6 -1
View File
@@ -1,4 +1,9 @@
// The waiter app's translations instance (plan step 4.1; its own texts become keys in 4.5).
// The waiter app's translations instance (plan step 4.1); its texts are keys in the `waiter`
// namespace of @xenia/i18n (step 4.5). Components use useTranslation('waiter'); code outside
// components (services, stores, native glue) uses tw('key').
import { createI18n } from '@xenia/i18n'
export const i18n = createI18n({ defaultNS: 'common' })
/** Translate a waiter key outside a component (the current language). */
export const tw = (key, options) => i18n.t(key, { ns: 'waiter', ...options })
+10 -17
View File
@@ -14,6 +14,7 @@ import { deliveryMode, saveVenue } from '../config/server'
import { syncTrustedKeys, tlsBaseUrl } from './tls'
import { SUPPORTED_API_VERSIONS } from './apiVersion'
import { tw } from '../i18n'
export { SUPPORTED_API_VERSIONS }
@@ -27,16 +28,16 @@ export class PairingError extends Error {}
*/
export function parseServerInput(raw) {
const text = String(raw || '').trim()
if (!text) throw new PairingError('Συμπληρώστε τη διεύθυνση του server.')
if (!text) throw new PairingError(tw('pairing.empty'))
const withScheme = /^https?:\/\//i.test(text) ? text : `http://${text}`
let url
try {
url = new URL(withScheme)
} catch {
throw new PairingError('Μη έγκυρη διεύθυνση. Παράδειγμα: 192.168.1.50')
throw new PairingError(tw('pairing.invalid'))
}
if (!url.hostname) throw new PairingError('Μη έγκυρη διεύθυνση. Παράδειγμα: 192.168.1.50')
if (!url.hostname) throw new PairingError(tw('pairing.invalid'))
return {
baseUrl: url.origin,
@@ -53,15 +54,13 @@ export async function probeServer(baseUrl) {
try {
res = await fetch(`${baseUrl}/api/system/identity`, { signal: controller.signal })
} catch {
throw new PairingError(
'Δεν βρέθηκε server σε αυτή τη διεύθυνση. Ελέγξτε ότι το κινητό είναι στο ίδιο WiFi με το κατάστημα.'
)
throw new PairingError(tw('pairing.noServer'))
} finally {
clearTimeout(timer)
}
if (res.status === 403) {
throw new PairingError('Ο server αρνήθηκε τη σύνδεση. Το κινητό πρέπει να είναι στο WiFi του καταστήματος.')
throw new PairingError(tw('pairing.refused'))
}
let identity = null
try {
@@ -70,12 +69,10 @@ export async function probeServer(baseUrl) {
// not JSON → not a Xenia server
}
if (!res.ok || identity?.app !== 'xenia-pos') {
throw new PairingError('Η διεύθυνση δεν ανήκει σε server Xenia.')
throw new PairingError(tw('pairing.notXenia'))
}
if (!SUPPORTED_API_VERSIONS.includes(identity.api_version)) {
throw new PairingError(
`Ο server (έκδοση ${identity.version}) δεν είναι συμβατός με αυτή την εφαρμογή. Ενημερώστε την εφαρμογή ή τον server.`
)
throw new PairingError(tw('pairing.incompatible', { version: identity.version }))
}
return identity
}
@@ -94,16 +91,12 @@ export async function pairWith(raw) {
const identity = await probeServer(baseUrl)
if (expectedSiteId && identity.site_id && identity.site_id !== expectedSiteId) {
throw new PairingError(
'Σε αυτή τη διεύθυνση απαντά διαφορετικό κατάστημα από αυτό του QR. Ζητήστε νέο QR από τον διαχειριστή.'
)
throw new PairingError(tw('pairing.otherVenue'))
}
const spki = identity.tls?.spki_sha256 || null
if (expectedKey && spki !== expectedKey) {
// The QR carries the real server's key: anything else is a different machine
throw new PairingError(
'Το κλειδί ασφαλείας του server δεν ταιριάζει με το QR. Ζητήστε νέο QR από τον διαχειριστή.'
)
throw new PairingError(tw('pairing.wrongKey'))
}
const venue = {
+22 -16
View File
@@ -3,6 +3,7 @@ import { useNavigate } from 'react-router-dom'
import { useProductCache } from '../hooks/useProductCache'
import useWaiterFavoritesStore from '../store/waiterFavoritesStore'
import { assetUrl } from '../config/server'
import { useFormat, useTranslation } from '@xenia/i18n'
// ── Heart icon ────────────────────────────────────────────────────────────────
function Heart({ filled, size = 22 }) {
@@ -87,6 +88,7 @@ function AttrSection({ title, items, favIds, onToggle }) {
}
function ItemFavoritesModal({ product, waiterAttrFavs, onSave, onClose }) {
const { t } = useTranslation('waiter')
// Local state: { quick: id[], ingredients: id[], options: id[], prefs: id[] }
// Start from waiter overrides if they exist, otherwise seed from manager's is_favorite flags
function seedFromManager() {
@@ -164,7 +166,7 @@ function ItemFavoritesModal({ product, waiterAttrFavs, onSave, onClose }) {
{product.name}
</div>
<div style={{ fontSize: 12, color: 'var(--muted)' }}>
{waiterAttrFavs ? 'Προσωπικές ρυθμίσεις ενεργές' : 'Χρήση ρυθμίσεων διαχειριστή'}
{waiterAttrFavs ? t('favSetup.personalOn') : t('favSetup.managerDefaults')}
</div>
</div>
<button
@@ -179,22 +181,22 @@ function ItemFavoritesModal({ product, waiterAttrFavs, onSave, onClose }) {
<div style={{ flex: 1, overflowY: 'auto', padding: '16px 16px 0' }}>
{!hasAnything ? (
<p style={{ color: 'var(--muted)', fontSize: 14, textAlign: 'center', padding: '32px 0' }}>
Αυτό το προϊόν δεν έχει επιλογές, υλικά ή προτιμήσεις.
{t('favSetup.noOptions')}
</p>
) : (
<>
<p style={{ fontSize: 13, color: 'var(--muted)', marginBottom: 16, lineHeight: 1.5 }}>
Επίλεξε ποιες επιλογές θα εμφανίζονται στην καρτέλα <strong style={{ color: '#ef4444' }}>♥ Αγαπημένα</strong> για αυτό το προϊόν. Αν δεν επιλέξεις τίποτα, θα χρησιμοποιηθούν οι ρυθμίσεις του διαχειριστή.
{t('favSetup.pickIntro')} <strong style={{ color: '#ef4444' }}>♥ {t('settings.tabs.favorites')}</strong>. {t('favSetup.pickOutro')}
</p>
<AttrSection
title="Γρήγορες Επιλογές"
title={t('drawer.tabs.quick')}
items={product.quick_options}
favIds={local.quick || []}
onToggle={id => toggle('quick', id)}
/>
<AttrSection
title="Υλικά"
title={t('drawer.tabs.ingredients')}
items={product.ingredients}
favIds={local.ingredients || []}
onToggle={id => toggle('ingredients', id)}
@@ -206,7 +208,7 @@ function ItemFavoritesModal({ product, waiterAttrFavs, onSave, onClose }) {
onToggle={id => toggle('options', id)}
/>
<AttrSection
title="Προτιμήσεις"
title={t('drawer.tabs.prefs')}
items={product.preference_sets}
favIds={local.prefs || []}
onToggle={id => toggle('prefs', id)}
@@ -231,7 +233,7 @@ function ItemFavoritesModal({ product, waiterAttrFavs, onSave, onClose }) {
fontSize: 13, fontWeight: 600, cursor: 'pointer',
}}
>
Επαναφορά
{t('settings.reset.title')}
</button>
)}
<button
@@ -243,7 +245,7 @@ function ItemFavoritesModal({ product, waiterAttrFavs, onSave, onClose }) {
fontSize: 15, fontWeight: 700, cursor: 'pointer',
}}
>
{totalSelected > 0 ? `Αποθήκευση (${totalSelected} επιλογές)` : 'Αποθήκευση'}
{totalSelected > 0 ? t('favSetup.saveCount', { count: totalSelected }) : t('common.save')}
</button>
</div>
</div>
@@ -253,6 +255,8 @@ function ItemFavoritesModal({ product, waiterAttrFavs, onSave, onClose }) {
// ── Product row (ALL tab) ─────────────────────────────────────────────────────
function ProductRow({ product, isFav, hasAttrOverride, onToggleFav, onEditAttrs }) {
const { t } = useTranslation('waiter')
const { formatMoney } = useFormat()
const hasAttrs = (
(product.quick_options || []).length > 0 ||
(product.ingredients || []).length > 0 ||
@@ -281,7 +285,7 @@ function ProductRow({ product, isFav, hasAttrOverride, onToggleFav, onEditAttrs
)}
</div>
<div style={{ fontSize: 12, color: hasAttrs ? 'var(--accent)' : 'var(--muted)' }}>
{hasAttrs ? 'Επιλογές αγαπημένων →' : `${Number(product.base_price).toFixed(2)} €`}
{hasAttrs ? `${t('favSetup.options')} →` : formatMoney(Number(product.base_price))}
</div>
</div>
@@ -298,6 +302,7 @@ function ProductRow({ product, isFav, hasAttrOverride, onToggleFav, onEditAttrs
// ── Draggable favorites list (pointer-events — works on touch + mouse) ─────────
function FavoritesList({ items, products, onReorder }) {
const { t } = useTranslation('waiter')
const [dragging, setDragging] = useState(null)
const [dropIndex, setDropIndex] = useState(null)
const containerRef = useRef(null)
@@ -355,7 +360,7 @@ function FavoritesList({ items, products, onReorder }) {
<path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"/>
</svg>
<p style={{ fontSize: 14, color: 'var(--muted)', textAlign: 'center', lineHeight: 1.6 }}>
Δεν έχεις προσθέσει αγαπημένα ακόμα.<br />Πήγαινε στην καρτέλα ΌΛΑ και πάτα την καρδιά δίπλα στα προϊόντα.
{t('favSetup.none')}<br />{t('favSetup.noneHow')}
</p>
</div>
)
@@ -417,6 +422,7 @@ function FavoritesList({ items, products, onReorder }) {
// ── Main page ─────────────────────────────────────────────────────────────────
export default function FavoritesSetupPage() {
const { t } = useTranslation('waiter')
const navigate = useNavigate()
const { products, categories } = useProductCache()
const { favorites, toggleFavorite, reorderFavorites, itemFavorites, setItemFavorites } = useWaiterFavoritesStore()
@@ -430,19 +436,19 @@ export default function FavoritesSetupPage() {
{/* Header */}
<header className="top-bar">
<button className="icon-btn" onClick={() => navigate(-1)}>←</button>
<span className="top-bar__title">Ρύθμιση Αγαπημένων</span>
<span className="top-bar__title">{t('settings.fav.setup')}</span>
<div style={{ width: 40 }} />
</header>
{/* Tabs */}
<div style={{ display: 'flex', borderBottom: '1px solid var(--border)', flexShrink: 0, background: 'var(--bg)' }}>
{[
{ key: 'all', label: 'ΌΛΑ' },
{ key: 'favorites', label: `ΑΓΑΠΗΜΈΝΑ (${favorites.length})` },
].map(t => (
{ key: 'all', label: t('favSetup.all') },
{ key: 'favorites', label: t('favSetup.favorites', { count: favorites.length }) },
].map(tb => (
<button
key={t.key}
onClick={() => setTab(t.key)}
key={tb.key}
onClick={() => setTab(tb.key)}
style={{
flex: 1, padding: '12px 8px',
background: 'none', border: 'none', cursor: 'pointer',
+18 -18
View File
@@ -1,6 +1,7 @@
import { useCallback, useEffect, useState } from 'react'
import { useNavigate } from 'react-router-dom'
import { useAccess } from '@xenia/access'
import { useTranslation } from '@xenia/i18n'
import PinPad from '../components/PinPad'
import useAuthStore from '../store/authStore'
import client from '../api/client'
@@ -20,6 +21,7 @@ function initialsOf(waiter) {
}
function WaiterCard({ waiter, onClick }) {
const { t } = useTranslation('waiter')
return (
<button
onClick={onClick}
@@ -70,7 +72,7 @@ function WaiterCard({ waiter, onClick }) {
background: '#22c55e',
flexShrink: 0,
boxShadow: '0 0 6px #22c55e88',
}} title="Σε βάρδια" />
}} title={t('login.onShift')} />
)}
<span style={{ color: 'var(--muted)', fontSize: 18, flexShrink: 0 }}>›</span>
@@ -89,6 +91,7 @@ function WaiterCard({ waiter, onClick }) {
// are shown in the user's language.
export default function LoginPage() {
const { t } = useTranslation('waiter')
const { login, savedUsername } = useAuthStore()
const { login: modes } = useAccess()
const mode = modes?.waiter_mode || 'pin'
@@ -137,7 +140,7 @@ export default function LoginPage() {
login({ id: data.user.id, username: data.user.username, role: data.user.role }, data.access_token)
navigate('/tables', { replace: true })
} catch (err) {
setError(apiError(err, mode === 'password' ? 'Λανθασμένος κωδικός' : 'Λανθασμένο PIN'))
setError(apiError(err, mode === 'password' ? t('login.wrongPassword') : t('login.wrongPin')))
setPassword('')
setAttempt(a => a + 1)
} finally {
@@ -150,7 +153,7 @@ export default function LoginPage() {
onClick={() => navigate('/venues')}
style={{ marginTop: 10, background: 'none', border: 'none', color: 'var(--muted)', fontSize: 13, cursor: 'pointer' }}
>
🏪 {getActiveVenue()?.name} · <span style={{ color: 'var(--accent)' }}>Αλλαγή</span>
🏪 {getActiveVenue()?.name} · <span style={{ color: 'var(--accent)' }} data-testid="venue-change">{t('common.change')}</span>
</button>
)
@@ -161,9 +164,7 @@ export default function LoginPage() {
<div className="login-box" style={{ textAlign: 'center' }} data-testid="login-tap-only">
<h1 className="app-title">XeniaPOS</h1>
<p style={{ color: 'var(--text)', fontSize: 15, lineHeight: 1.5 }}>
Σε αυτό το κατάστημα οι σερβιτόροι συνδέονται πατώντας το όνομά τους στις συνδεδεμένες οθόνες.
Από κινητό δεν γίνεται σύνδεση με αυτόν τον τρόπο — ζητήστε από τον διαχειριστή να αλλάξει
τον τρόπο σύνδεσης σε PIN ή κωδικό.
{t('login.tapOnly')}
</p>
{venueSwitch}
</div>
@@ -184,7 +185,7 @@ export default function LoginPage() {
{/* Static header — never scrolls */}
<div style={{ flexShrink: 0, padding: '40px 16px 20px', textAlign: 'center' }}>
<h1 className="app-title" style={{ marginBottom: 10 }}>Xenia POS</h1>
<p className="app-subtitle">Ποιος είσαι;</p>
<p className="app-subtitle">{t('login.whoAreYou')}</p>
{venueSwitch}
</div>
@@ -192,21 +193,20 @@ export default function LoginPage() {
<div style={{ flex: 1, overflowY: 'auto', padding: '4px 16px 40px' }}>
<div style={{ maxWidth: 480, margin: '0 auto' }}>
{loadingWaiters ? (
<p style={{ textAlign: 'center', color: 'var(--muted)', padding: 32 }}>Φόρτωση…</p>
<p style={{ textAlign: 'center', color: 'var(--muted)', padding: 32 }}>{t('common.loading')}</p>
) : serverUnreachable ? (
<div style={{ textAlign: 'center', padding: 32 }}>
<div style={{ fontSize: 48, marginBottom: 16 }}>🔌</div>
<p style={{ fontSize: 17, fontWeight: 700, color: '#ef4444', marginBottom: 8 }}>
Δεν βρέθηκε ο Server
{t('login.serverNotFound')}
</p>
<p style={{ fontSize: 14, color: 'var(--muted)', lineHeight: 1.6, marginBottom: 24 }}>
Δεν είναι δυνατή η σύνδεση με τον Manager.<br />
Δεν μπορεί να ξεκινήσει βάρδια χωρίς σύνδεση.
{t('login.serverNotFoundBody')}
</p>
<button className="btn btn--secondary" onClick={loadWaiters}>⟳ Επανάληψη</button>
<button className="btn btn--secondary" onClick={loadWaiters}>⟳ {t('common.retry')}</button>
</div>
) : waiters.length === 0 ? (
<p style={{ textAlign: 'center', color: 'var(--muted)', padding: 32 }}>Δεν βρέθηκαν σερβιτόροι</p>
<p style={{ textAlign: 'center', color: 'var(--muted)', padding: 32 }}>{t('login.noWaiters')}</p>
) : (
<div style={{ display: 'flex', flexDirection: 'column', gap: 10, alignItems: 'stretch' }}>
{sorted.map(w => (
@@ -260,7 +260,7 @@ export default function LoginPage() {
onClick={() => { setSelectedWaiter(null); setError(''); setPassword('') }}
style={{ background: 'none', border: 'none', color: 'var(--muted)', cursor: 'pointer', fontSize: 13, padding: '4px 8px' }}
>
Αλλαγή
{t('common.change')}
</button>
</div>
) : (
@@ -269,7 +269,7 @@ export default function LoginPage() {
<input
value={username}
onChange={e => setUsername(e.target.value)}
placeholder="Όνομα χρήστη"
placeholder={t('login.username')}
autoComplete="username"
autoCapitalize="none"
style={{ ...inputStyle, marginTop: 8 }}
@@ -287,7 +287,7 @@ export default function LoginPage() {
type="password"
value={password}
onChange={e => setPassword(e.target.value)}
placeholder="Κωδικός"
placeholder={t('login.password')}
autoComplete="current-password"
style={inputStyle}
data-testid="login-password"
@@ -298,12 +298,12 @@ export default function LoginPage() {
disabled={loading || !password || (!w && !username.trim())}
data-testid="login-submit"
>
{loading ? '…' : 'Σύνδεση'}
{loading ? '…' : t('login.signIn')}
</button>
</form>
) : (
<>
<p style={{ textAlign: 'center', color: 'var(--muted)', fontSize: 13, margin: '10px 0 12px' }}>Εισάγετε PIN</p>
<p style={{ textAlign: 'center', color: 'var(--muted)', fontSize: 13, margin: '10px 0 12px' }}>{t('login.enterPin')}</p>
<PinPad key={attempt} onSubmit={pin => signIn({ pin })} loading={loading} />
</>
)}
+127 -121
View File
@@ -6,22 +6,23 @@ import useNotificationSettingsStore from '../store/notificationSettingsStore'
import useOrderingSettingsStore from '../store/orderingSettingsStore'
import usePaymentSettingsStore from '../store/paymentSettingsStore'
import useWaiterFavoritesStore from '../store/waiterFavoritesStore'
import { useTranslation } from '@xenia/i18n'
const CHIP_STYLE_OPTIONS = [
{ key: 'full', label: 'Πλήρες κείμενο', example: 'Εκκρεμούν' },
{ key: 'short', label: 'Σύντομο κείμενο', example: 'PND' },
{ key: 'icon_full', label: 'Εικονίδιο + πλήρες', example: '⏳ Εκκρεμούν' },
{ key: 'icon_short', label: 'Εικονίδιο + σύντομο', example: '⏳ PND' },
{ key: 'icon', label: 'Μόνο εικονίδιο', example: '⏳' },
{ key: 'full', label: 'settings.chips.full', example: 'orders.chips.pending' },
{ key: 'short', label: 'settings.chips.short', example: 'orders.chips.pendingShort' },
{ key: 'icon_full', label: 'settings.chips.iconFull', example: 'settings.chips.exIconFull' },
{ key: 'icon_short', label: 'settings.chips.iconShort', example: 'settings.chips.exIconShort' },
{ key: 'icon', label: 'settings.chips.icon', example: '⏳' },
]
// ─── Tab definitions (stub future tabs here) ──────────────────────────────────
const TABS = [
{ key: 'layout', label: 'Εμφάνιση' },
{ key: 'leitourgia', label: 'Λειτουργία' },
{ key: 'ploigisi', label: 'Πλοήγηση' },
{ key: 'personalize', label: 'Αγαπημένα' },
{ key: 'layout', label: 'settings.tabs.layout' },
{ key: 'leitourgia', label: 'settings.tabs.operation' },
{ key: 'ploigisi', label: 'shell.navigation' },
{ key: 'personalize', label: 'settings.tabs.favorites' },
]
// ─── Density option data ──────────────────────────────────────────────────────
@@ -30,37 +31,37 @@ const DENSITY_OPTIONS = [
{
key: '1x1',
label: '1×1',
desc: '4 ανά σειρά — μόνο όνομα',
desc: 'settings.density.d1x1',
preview: <Grid4 />,
},
{
key: '2x1',
label: '2×1',
desc: '2 ανά σειρά — όνομα + κατάσταση',
desc: 'settings.density.d2x1',
preview: <Grid2H />,
},
{
key: '2x2',
label: '2×2',
desc: '2 ανά σειρά — συμπαγής κάρτα',
desc: 'settings.density.d2x2',
preview: <Grid2 />,
},
{
key: '4x1',
label: '4×1',
desc: '1 ανά σειρά — οριζόντια λίστα',
desc: 'settings.density.d4x1',
preview: <Grid1H />,
},
{
key: '4x2',
label: '4×2',
desc: '1 ανά σειρά — πλήρης κάρτα',
desc: 'settings.density.d4x2',
preview: <Grid1 />,
},
{
key: '4x3',
label: '4×3',
desc: '1 ανά σειρά — κάρτα με λίστα παραγγελίας',
desc: 'settings.density.d4x3',
preview: <Grid1Detail />,
},
]
@@ -153,22 +154,23 @@ function Grid1Detail() {
const ORDER_ITEM_LAYOUT_OPTIONS = [
{
key: 'compact',
label: 'Compact',
desc: 'Μία γραμμή — συμπαγής εμφάνιση, λιγότερο ύψος',
label: 'settings.itemLayout.compact',
desc: 'settings.itemLayout.compactDesc',
},
{
key: 'expanded',
label: 'Expanded',
desc: 'Δύο γραμμές — όνομα + KDS πάνω, τιμολόγηση κάτω',
label: 'settings.itemLayout.expanded',
desc: 'settings.itemLayout.expandedDesc',
},
{
key: 'fully_detailed',
label: 'Fully Detailed',
desc: 'Πλήρης ανάλυση — όνομα, τιμές, σερβιτόρος, ώρα, options',
label: 'settings.itemLayout.full',
desc: 'settings.itemLayout.fullDesc',
},
]
function LayoutTab() {
const { t } = useTranslation('waiter')
const { density, setDensity, chipStyle, setChipStyle, kdsDisplayStyle, setKdsDisplayStyle, orderItemLayout, setOrderItemLayout, mergePersist, setMergePersist } = useTableViewStore()
const { dark, toggle } = useThemeStore()
@@ -177,8 +179,8 @@ function LayoutTab() {
{/* Chip style */}
<section>
<h2 style={sectionTitle}>Εμφάνιση chips παραγγελιών</h2>
<p style={sectionSub}>Πώς εμφανίζονται τα φίλτρα στη σελίδα Παραγγελίες.</p>
<h2 style={sectionTitle}>{t('settings.chips.title')}</h2>
<p style={sectionSub}>{t('settings.chips.sub')}</p>
<div style={{ display: 'flex', flexDirection: 'column', gap: 8, marginTop: 14 }}>
{CHIP_STYLE_OPTIONS.map(opt => {
const active = (chipStyle || 'icon_short') === opt.key
@@ -197,9 +199,9 @@ function LayoutTab() {
>
<div style={{ flex: 1 }}>
<div style={{ fontSize: 15, fontWeight: 700, color: active ? 'var(--accent)' : 'var(--text)', marginBottom: 2 }}>
{opt.label}
{t(opt.label)}
</div>
<div style={{ fontSize: 12, color: 'var(--muted)' }}>{opt.example}</div>
<div style={{ fontSize: 12, color: 'var(--muted)' }}>{t(opt.example)}</div>
</div>
{active && (
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" style={{ flexShrink: 0, color: 'var(--accent)' }}>
@@ -215,8 +217,8 @@ function LayoutTab() {
{/* Card density */}
<section>
<h2 style={sectionTitle}>Κάρτες τραπεζιών</h2>
<p style={sectionSub}>Επίλεξε πόσα στοιχεία εμφανίζονται σε κάθε κάρτα.</p>
<h2 style={sectionTitle}>{t('settings.density.title')}</h2>
<p style={sectionSub}>{t('settings.density.sub')}</p>
<div style={{ display: 'flex', flexDirection: 'column', gap: 10, marginTop: 14 }}>
{DENSITY_OPTIONS.map(opt => {
@@ -252,10 +254,10 @@ function LayoutTab() {
color: active ? 'var(--accent)' : 'var(--text)',
marginBottom: 2,
}}>
{opt.label}
{t(opt.label)}
</div>
<div style={{ fontSize: 13, color: 'var(--muted)', lineHeight: 1.4 }}>
{opt.desc}
{t(opt.desc)}
</div>
</div>
@@ -274,12 +276,12 @@ function LayoutTab() {
{/* KDS status display */}
<section>
<h2 style={sectionTitle}>Εμφάνιση Κατάστασης KDS</h2>
<p style={sectionSub}>Πώς εμφανίζεται η κατάσταση KDS σε κάθε αντικείμενο παραγγελίας.</p>
<h2 style={sectionTitle}>{t('settings.kds.title')}</h2>
<p style={sectionSub}>{t('settings.kds.sub')}</p>
<div style={{ display: 'flex', gap: 10, marginTop: 14 }}>
{[
{ key: 'badge', label: 'Badge', desc: 'Κείμενο σε chip (ΕΚΚΡΕΜΕΙ, READY…)' },
{ key: 'icon', label: 'Εικονίδιο', desc: 'Μικρό χρωματιστό εικονίδιο — λιγότερος χώρος' },
{ key: 'badge', label: 'settings.kds.badge', desc: 'settings.kds.badgeDesc' },
{ key: 'icon', label: 'settings.kds.icon', desc: 'settings.kds.iconDesc' },
].map(opt => {
const active = (kdsDisplayStyle || 'badge') === opt.key
return (
@@ -295,8 +297,8 @@ function LayoutTab() {
transition: 'border-color 0.12s, background 0.12s',
}}
>
<span style={{ fontSize: 13, fontWeight: 800, color: active ? 'var(--accent)' : 'var(--text)' }}>{opt.label}</span>
<span style={{ fontSize: 12, color: 'var(--muted)', lineHeight: 1.4 }}>{opt.desc}</span>
<span style={{ fontSize: 13, fontWeight: 800, color: active ? 'var(--accent)' : 'var(--text)' }}>{t(opt.label)}</span>
<span style={{ fontSize: 12, color: 'var(--muted)', lineHeight: 1.4 }}>{t(opt.desc)}</span>
</button>
)
})}
@@ -305,8 +307,8 @@ function LayoutTab() {
{/* Order item layout */}
<section>
<h2 style={sectionTitle}>Layout Αντικειμένων Παραγγελίας</h2>
<p style={sectionSub}>Πώς εμφανίζεται κάθε αντικείμενο στη λίστα παραγγελίας ενός τραπεζιού.</p>
<h2 style={sectionTitle}>{t('settings.itemLayout.title')}</h2>
<p style={sectionSub}>{t('settings.itemLayout.sub')}</p>
<div style={{ display: 'flex', flexDirection: 'column', gap: 8, marginTop: 14 }}>
{ORDER_ITEM_LAYOUT_OPTIONS.map(opt => {
const active = (orderItemLayout || 'compact') === opt.key
@@ -325,9 +327,9 @@ function LayoutTab() {
>
<div style={{ flex: 1 }}>
<div style={{ fontSize: 15, fontWeight: 700, color: active ? 'var(--accent)' : 'var(--text)', marginBottom: 2 }}>
{opt.label}
{t(opt.label)}
</div>
<div style={{ fontSize: 12, color: 'var(--muted)', lineHeight: 1.4 }}>{opt.desc}</div>
<div style={{ fontSize: 12, color: 'var(--muted)', lineHeight: 1.4 }}>{t(opt.desc)}</div>
</div>
{active && (
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" style={{ flexShrink: 0, color: 'var(--accent)' }}>
@@ -343,13 +345,13 @@ function LayoutTab() {
{/* Merge view persistence */}
<section>
<h2 style={sectionTitle}>Διατήρηση Προβολής Συγχώνευσης</h2>
<p style={sectionSub}>Πόσο διατηρείται η επιλεγμένη προβολή συγχώνευσης αντικειμένων.</p>
<h2 style={sectionTitle}>{t('settings.merge.title')}</h2>
<p style={sectionSub}>{t('settings.merge.sub')}</p>
<div style={{ display: 'flex', flexDirection: 'column', gap: 8, marginTop: 14 }}>
{[
{ key: 'off', label: 'OFF', desc: 'Επαναφορά στην αρχική κατά την πλοήγηση' },
{ key: 'per_order', label: 'ΔΙΑΤΗΡΗΣΗ ΑΝΑ ΠΑΡΑΓΓΕΛΙΑ', desc: 'Διατηρείται μέχρι το κλείσιμο της παραγγελίας' },
{ key: 'global', label: 'ΔΙΑΤΗΡΗΣΗ ΠΑΝΤΑ', desc: 'Ίδια ρύθμιση για όλα τα τραπέζια, πάντα' },
{ key: 'off', label: 'settings.merge.off', desc: 'settings.merge.offDesc' },
{ key: 'per_order', label: 'settings.merge.perOrder', desc: 'settings.merge.perOrderDesc' },
{ key: 'global', label: 'settings.merge.global', desc: 'settings.merge.globalDesc' },
].map(opt => {
const active = (mergePersist || 'off') === opt.key
return (
@@ -366,8 +368,8 @@ function LayoutTab() {
}}
>
<div style={{ flex: 1 }}>
<div style={{ fontSize: 15, fontWeight: 700, color: active ? 'var(--accent)' : 'var(--text)', marginBottom: 2 }}>{opt.label}</div>
<div style={{ fontSize: 12, color: 'var(--muted)' }}>{opt.desc}</div>
<div style={{ fontSize: 15, fontWeight: 700, color: active ? 'var(--accent)' : 'var(--text)', marginBottom: 2 }}>{t(opt.label)}</div>
<div style={{ fontSize: 12, color: 'var(--muted)' }}>{t(opt.desc)}</div>
</div>
{active && (
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" style={{ flexShrink: 0, color: 'var(--accent)' }}>
@@ -383,12 +385,12 @@ function LayoutTab() {
{/* Theme */}
<section>
<h2 style={sectionTitle}>Θέμα</h2>
<h2 style={sectionTitle}>{t('settings.theme.title')}</h2>
<div style={{ display: 'flex', gap: 10, marginTop: 14 }}>
{[
{ key: false, icon: '☀️', label: 'Φωτεινό' },
{ key: true, icon: '🌙', label: 'Σκοτεινό' },
{ key: false, icon: '☀️', label: 'settings.theme.light' },
{ key: true, icon: '🌙', label: 'settings.theme.dark' },
].map(opt => {
const active = dark === opt.key
return (
@@ -410,7 +412,7 @@ function LayoutTab() {
<span style={{
fontSize: 14, fontWeight: 600,
color: active ? 'var(--accent)' : 'var(--muted)',
}}>{opt.label}</span>
}}>{t(opt.label)}</span>
</button>
)
})}
@@ -428,23 +430,23 @@ const sectionSub = {
fontSize: 14, color: 'var(--muted)', lineHeight: 1.5,
}
// ─── Λειτουργία tab ──────────────────────────────────────────────────────────
// ─── Operation tab ──────────────────────────────────────────────────────────
const POPUP_MODE_OPTIONS = [
{
key: 'all',
label: 'Popup Everything',
desc: 'Εμφανίζεται popup για κάθε ειδοποίηση (KDS, μηνύματα, κλπ.)',
label: 'settings.popup.all',
desc: 'settings.popup.allDesc',
},
{
key: 'manager_only',
label: 'Popup μόνο για μηνύματα διαχειριστή',
desc: 'KDS ειδοποιήσεις αποθηκεύονται στο κουδούνι χωρίς popup.',
label: 'settings.popup.manager',
desc: 'settings.popup.managerDesc',
},
{
key: 'never',
label: 'Never Popup',
desc: 'Καμία αναδυόμενη ειδοποίηση. Ανοίξτε το κουδούνι για να τις δείτε — και θα σβηστούν αυτόματα.',
label: 'settings.popup.never',
desc: 'settings.popup.neverDesc',
},
]
@@ -482,22 +484,23 @@ function ToggleRow({ label, desc, checked, onChange }) {
const PAYMENT_SAFETY_OPTIONS = [
{
key: 'off',
label: 'Απενεργοποιημένο',
desc: 'Η πληρωμή επιβεβαιώνεται με ένα απλό πάτημα.',
label: 'settings.paySafety.off',
desc: 'settings.paySafety.offDesc',
},
{
key: 'second_confirm',
label: 'Δεύτερη Επιβεβαίωση',
desc: 'Μετά την επιβεβαίωση πληρωμής, εμφανίζεται ένα επιπλέον παράθυρο ασφαλείας πριν ολοκληρωθεί η πληρωμή.',
label: 'settings.paySafety.second',
desc: 'settings.paySafety.secondDesc',
},
{
key: 'long_press',
label: 'Παρατεταμένο Πάτημα',
desc: 'Για να επιβεβαιωθεί η πληρωμή, πρέπει να κρατήσετε πατημένο το κουμπί για ~1 δευτερόλεπτο.',
label: 'settings.paySafety.hold',
desc: 'settings.paySafety.holdDesc',
},
]
function LeitourgiaTab() {
const { t } = useTranslation('waiter')
const { popupMode, persistentPopup, setPopupMode, setPersistentPopup } = useNotificationSettingsStore()
const { summaryBeforeSend, setSummaryBeforeSend } = useOrderingSettingsStore()
const { paymentSafety, setPaymentSafety } = usePaymentSettingsStore()
@@ -507,8 +510,8 @@ function LeitourgiaTab() {
{/* Popup mode */}
<section>
<h2 style={sectionTitle}>Στυλ ειδοποιήσεων</h2>
<p style={sectionSub}>Πότε εμφανίζονται αναδυόμενα banners κατά την παραλαβή ειδοποίησης.</p>
<h2 style={sectionTitle}>{t('settings.popup.title')}</h2>
<p style={sectionSub}>{t('settings.popup.sub')}</p>
<div style={{ display: 'flex', flexDirection: 'column', gap: 8, marginTop: 14 }}>
{POPUP_MODE_OPTIONS.map(opt => {
const active = popupMode === opt.key
@@ -527,9 +530,9 @@ function LeitourgiaTab() {
>
<div style={{ flex: 1 }}>
<div style={{ fontSize: 15, fontWeight: 700, color: active ? 'var(--accent)' : 'var(--text)', marginBottom: 2 }}>
{opt.label}
{t(opt.label)}
</div>
<div style={{ fontSize: 12, color: 'var(--muted)', lineHeight: 1.4 }}>{opt.desc}</div>
<div style={{ fontSize: 12, color: 'var(--muted)', lineHeight: 1.4 }}>{t(opt.desc)}</div>
</div>
{active && (
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" style={{ flexShrink: 0, color: 'var(--accent)' }}>
@@ -545,16 +548,16 @@ function LeitourgiaTab() {
{/* Persistent popup */}
<section>
<h2 style={sectionTitle}>Επιμονή Popup</h2>
<h2 style={sectionTitle}>{t('settings.persist.title')}</h2>
<p style={sectionSub}>
{persistentPopup
? 'Τα popups παραμένουν μέχρι να πατήσετε OK.'
: 'Τα popups κλείνουν αυτόματα μετά από 3 δευτερόλεπτα και η ειδοποίηση σβήνεται αμέσως κατά την παραλαβή.'}
? t('settings.persist.on')
: t('settings.persist.off')}
</p>
<div style={{ marginTop: 14 }}>
<ToggleRow
label="Persistent Popup"
desc={persistentPopup ? 'Ενεργό — απαιτεί χειροκίνητο κλείσιμο' : 'Ανενεργό — αυτόματο κλείσιμο σε 3 δευτ.'}
label={t('settings.persist.label')}
desc={persistentPopup ? t('settings.persist.onDesc') : t('settings.persist.offDesc')}
checked={persistentPopup}
onChange={() => setPersistentPopup(!persistentPopup)}
/>
@@ -563,14 +566,14 @@ function LeitourgiaTab() {
{/* Summary before send */}
<section>
<h2 style={sectionTitle}>Σύνοψη πριν την Αποστολή</h2>
<h2 style={sectionTitle}>{t('settings.summary.title')}</h2>
<p style={sectionSub}>
Αντί για απευθείας αποστολή, εμφανίζεται πρώτα σελίδα επισκόπησης με όλα τα προϊόντα, τις επιλογές, και τη σημείωση παραγγελίας.
{t('settings.summary.sub')}
</p>
<div style={{ marginTop: 14 }}>
<ToggleRow
label="Σύνοψη + Αποστολή"
desc={summaryBeforeSend ? 'Ενεργό — εμφανίζεται modal επισκόπησης πριν την αποστολή' : 'Ανενεργό — άμεση αποστολή'}
label={t('settings.summary.label')}
desc={summaryBeforeSend ? t('settings.summary.onDesc') : t('settings.summary.offDesc')}
checked={summaryBeforeSend}
onChange={() => setSummaryBeforeSend(!summaryBeforeSend)}
/>
@@ -579,9 +582,9 @@ function LeitourgiaTab() {
{/* Payment safety switch */}
<section>
<h2 style={sectionTitle}>Ασφάλεια Πληρωμών</h2>
<h2 style={sectionTitle}>{t('settings.paySafety.title')}</h2>
<p style={sectionSub}>
Προσθέτει ένα επιπλέον βήμα επιβεβαίωσης για να αποφύγετε τυχαίες πληρωμές. Ακόμα κι αν κάνετε λάθος, ο διαχειριστής μπορεί να ενεργοποιήσει την αναίρεση πληρωμής.
{t('settings.paySafety.sub')}
</p>
<div style={{ display: 'flex', flexDirection: 'column', gap: 8, marginTop: 14 }}>
{PAYMENT_SAFETY_OPTIONS.map(opt => {
@@ -601,9 +604,9 @@ function LeitourgiaTab() {
>
<div style={{ flex: 1 }}>
<div style={{ fontSize: 15, fontWeight: 700, color: active ? 'var(--accent)' : 'var(--text)', marginBottom: 2 }}>
{opt.label}
{t(opt.label)}
</div>
<div style={{ fontSize: 12, color: 'var(--muted)', lineHeight: 1.4 }}>{opt.desc}</div>
<div style={{ fontSize: 12, color: 'var(--muted)', lineHeight: 1.4 }}>{t(opt.desc)}</div>
</div>
{active && (
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" style={{ flexShrink: 0, color: 'var(--accent)' }}>
@@ -621,9 +624,10 @@ function LeitourgiaTab() {
)
}
// ─── Προσωπικά tab ────────────────────────────────────────────────────────────
// ─── Personal tab ────────────────────────────────────────────────────────────
function PersonalizeTab() {
const { t } = useTranslation('waiter')
const navigate = useNavigate()
const { favorites, resetAll } = useWaiterFavoritesStore()
const [confirmReset, setConfirmReset] = useState(false)
@@ -639,11 +643,11 @@ function PersonalizeTab() {
{/* Favorites setup */}
<section>
<h2 style={sectionTitle}>Αγαπημένα Προϊόντα</h2>
<h2 style={sectionTitle}>{t('settings.fav.title')}</h2>
<p style={sectionSub}>
{favorites.length > 0
? `${favorites.length} αγαπημένα ενεργά — εμφανίζονται ως πρώτη κατηγορία στο ProductPicker.`
: 'Δεν έχεις ορίσει αγαπημένα ακόμα. Πάτα παρακάτω για να ξεκινήσεις.'}
? t('settings.fav.count', { count: favorites.length })
: t('settings.fav.none')}
</p>
<div style={{ marginTop: 14 }}>
<button
@@ -660,8 +664,8 @@ function PersonalizeTab() {
<path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"/>
</svg>
<div style={{ flex: 1 }}>
<div style={{ fontSize: 15, fontWeight: 700, color: 'var(--accent)' }}>Ρύθμιση Αγαπημένων</div>
<div style={{ fontSize: 12, color: 'var(--muted)', marginTop: 2 }}>Επίλεξε προϊόντα και άλλαξε σειρά εμφάνισης</div>
<div style={{ fontSize: 15, fontWeight: 700, color: 'var(--accent)' }}>{t('settings.fav.setup')}</div>
<div style={{ fontSize: 12, color: 'var(--muted)', marginTop: 2 }}>{t('settings.fav.setupSub')}</div>
</div>
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" style={{ color: 'var(--accent)', flexShrink: 0 }}>
<path d="M9 18l6-6-6-6" stroke="currentColor" strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round"/>
@@ -672,11 +676,11 @@ function PersonalizeTab() {
{/* Reset all */}
<section>
<h2 style={sectionTitle}>Επαναφορά</h2>
<h2 style={sectionTitle}>{t('settings.reset.title')}</h2>
<p style={sectionSub}>
{confirmReset
? 'Είσαι σίγουρος; Αυτή η ενέργεια δεν μπορεί να αναιρεθεί.'
: 'Διαγράφει όλα τα αγαπημένα και επαναφέρει τις προτιμήσεις στις εργοστασιακές τιμές.'}
? t('settings.reset.sure')
: t('settings.reset.sub')}
</p>
<div style={{ marginTop: 14 }}>
<button
@@ -696,9 +700,9 @@ function PersonalizeTab() {
</svg>
<div style={{ flex: 1 }}>
<div style={{ fontSize: 15, fontWeight: 700, color: confirmReset ? 'var(--danger)' : 'var(--text)' }}>
{confirmReset ? 'Πάτα ξανά για επιβεβαίωση' : 'Επαναφορά Όλων'}
{confirmReset ? t('settings.reset.again') : t('settings.reset.all')}
</div>
<div style={{ fontSize: 12, color: 'var(--muted)', marginTop: 2 }}>Αγαπημένα & ρυθμίσεις</div>
<div style={{ fontSize: 12, color: 'var(--muted)', marginTop: 2 }}>{t('settings.reset.allSub')}</div>
</div>
</button>
</div>
@@ -708,12 +712,12 @@ function PersonalizeTab() {
)
}
// ─── Πλοήγηση tab ─────────────────────────────────────────────────────────────
// ─── Navigation tab ─────────────────────────────────────────────────────────────
const ALL_NAV_ITEMS = [
{
key: 'tables',
label: 'Τραπέζια',
label: 'nav.tables',
icon: (
<svg width="20" height="20" viewBox="0 0 24 24" fill="none">
<rect x="3" y="3" width="7" height="7" rx="1.5" fill="currentColor"/>
@@ -725,7 +729,7 @@ const ALL_NAV_ITEMS = [
},
{
key: 'orders',
label: 'Παραγγελίες',
label: 'nav.orders',
icon: (
<svg width="20" height="20" 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="2" strokeLinecap="round"/>
@@ -735,7 +739,7 @@ const ALL_NAV_ITEMS = [
},
{
key: 'messages',
label: 'Chat',
label: 'nav.chat',
icon: (
<svg width="20" height="20" 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="2" strokeLinecap="round" strokeLinejoin="round"/>
@@ -744,7 +748,7 @@ const ALL_NAV_ITEMS = [
},
{
key: 'standalone',
label: 'Takeaway',
label: 'nav.takeaway',
icon: (
<svg width="20" height="20" viewBox="0 0 24 24" fill="none">
<path d="M5 12H3l9-9 9 9h-2" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
@@ -755,7 +759,7 @@ const ALL_NAV_ITEMS = [
},
{
key: 'shift-overview',
label: 'Βάρδια',
label: 'nav.shift',
icon: (
<svg width="20" height="20" viewBox="0 0 24 24" fill="none">
<circle cx="12" cy="12" r="9" stroke="currentColor" strokeWidth="2"/>
@@ -765,7 +769,7 @@ const ALL_NAV_ITEMS = [
},
{
key: 'order-log',
label: 'Αρχείο',
label: 'nav.log',
icon: (
<svg width="20" height="20" viewBox="0 0 24 24" fill="none">
<path d="M6 9V2h12v7" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
@@ -806,6 +810,7 @@ function Checkbox({ checked }) {
}
function PloigisiTab() {
const { t } = useTranslation('waiter')
const { navStyle, setNavStyle, navItems, setNavItems, tripleItems, setTripleItems } = useTableViewStore()
const NAV_MAP = Object.fromEntries(ALL_NAV_ITEMS.map(i => [i.key, i]))
@@ -917,12 +922,12 @@ function PloigisiTab() {
{/* Nav style picker */}
<section>
<h2 style={sectionTitle}>Στυλ γραμμής πλοήγησης</h2>
<p style={sectionSub}>Πώς εμφανίζεται η γραμμή πλοήγησης στο κάτω μέρος της οθόνης.</p>
<h2 style={sectionTitle}>{t('settings.navStyle.title')}</h2>
<p style={sectionSub}>{t('settings.navStyle.sub')}</p>
<div style={{ display: 'flex', gap: 10, marginTop: 14 }}>
{[
{ key: 'triple', label: 'Triple Pill', desc: 'Σταθερά 3 κουμπιά με εικονίδιο + κείμενο σε pill μορφή' },
{ key: 'icon_navbar', label: 'Icon Navbar', desc: 'Android-style με 1–5 εικονίδια που μπορείτε να διαμορφώσετε' },
{ key: 'triple', label: 'settings.navStyle.triple', desc: 'settings.navStyle.tripleDesc' },
{ key: 'icon_navbar', label: 'settings.navStyle.icons', desc: 'settings.navStyle.iconsDesc' },
].map(opt => {
const active = navStyle === opt.key
return (
@@ -939,8 +944,8 @@ function PloigisiTab() {
transition: 'border-color 0.12s, background 0.12s',
}}
>
<span style={{ fontSize: 13, fontWeight: 800, color: active ? 'var(--accent)' : 'var(--text)' }}>{opt.label}</span>
<span style={{ fontSize: 12, color: 'var(--muted)', lineHeight: 1.4 }}>{opt.desc}</span>
<span style={{ fontSize: 13, fontWeight: 800, color: active ? 'var(--accent)' : 'var(--text)' }}>{t(opt.label)}</span>
<span style={{ fontSize: 12, color: 'var(--muted)', lineHeight: 1.4 }}>{t(opt.desc)}</span>
</button>
)
})}
@@ -950,8 +955,8 @@ function PloigisiTab() {
{/* Triple Pill item editor */}
{navStyle === 'triple' && (
<section>
<h2 style={sectionTitle}>Στοιχεία Triple Pill</h2>
<p style={sectionSub}>Επίλεξε ακριβώς 3 κουμπιά και σύρε για να αλλάξεις τη σειρά τους.</p>
<h2 style={sectionTitle}>{t('settings.triple.title')}</h2>
<p style={sectionSub}>{t('settings.triple.sub')}</p>
<div
style={{ display: 'flex', flexDirection: 'column', gap: 0, marginTop: 14 }}
@@ -986,7 +991,7 @@ function PloigisiTab() {
>
<DragHandle />
<span style={{ color: 'var(--accent)', flexShrink: 0 }}>{item.icon}</span>
<span style={{ flex: 1, fontSize: 15, fontWeight: 700, color: 'var(--accent)' }}>{item.label}</span>
<span style={{ flex: 1, fontSize: 15, fontWeight: 700, color: 'var(--accent)' }}>{t(item.label)}</span>
<button
onClick={() => toggleTripleItem(item.key)}
style={{ background: 'none', border: 'none', cursor: 'pointer', padding: 0 }}
@@ -1010,7 +1015,7 @@ function PloigisiTab() {
<div style={{ display: 'flex', alignItems: 'center', gap: 10, padding: '4px 0', margin: '4px 0 8px' }}>
<div style={{ flex: 1, height: 1, background: 'var(--border)' }} />
<span style={{ fontSize: 11, color: 'var(--muted)', fontWeight: 700, textTransform: 'uppercase', letterSpacing: 0.8 }}>
Διαθέσιμα
{t('settings.available')}
</span>
<div style={{ flex: 1, height: 1, background: 'var(--border)' }} />
</div>
@@ -1026,7 +1031,7 @@ function PloigisiTab() {
>
<span style={{ width: 20, flexShrink: 0 }} />
<span style={{ color: 'var(--muted)', flexShrink: 0 }}>{item.icon}</span>
<span style={{ flex: 1, fontSize: 15, fontWeight: 700, color: 'var(--text)' }}>{item.label}</span>
<span style={{ flex: 1, fontSize: 15, fontWeight: 700, color: 'var(--text)' }}>{t(item.label)}</span>
<button
onClick={() => toggleTripleItem(item.key)}
style={{ background: 'none', border: 'none', cursor: tripleItems.length >= 3 ? 'not-allowed' : 'pointer', padding: 0, opacity: tripleItems.length >= 3 ? 0.4 : 1 }}
@@ -1039,8 +1044,8 @@ function PloigisiTab() {
)}
<p style={{ fontSize: 12, color: 'var(--muted)', marginTop: 4, lineHeight: 1.5 }}>
{tripleItems.length}/3 κουμπιά ενεργά
{tripleItems.length >= 3 ? ' — μέγιστο' : ''}
{t('settings.triple.count', { count: tripleItems.length })}
{tripleItems.length >= 3 ? ` — ${t('settings.max')}` : ''}
</p>
</section>
)}
@@ -1048,8 +1053,8 @@ function PloigisiTab() {
{/* Icon navbar item editor */}
{navStyle === 'icon_navbar' && (
<section>
<h2 style={sectionTitle}>Στοιχεία Icon Navbar</h2>
<p style={sectionSub}>Επίλεξε ποια εικονίδια εμφανίζονται (1–5). Σύρε για να αλλάξεις τη σειρά.</p>
<h2 style={sectionTitle}>{t('settings.icons.title')}</h2>
<p style={sectionSub}>{t('settings.icons.sub')}</p>
<div
style={{ display: 'flex', flexDirection: 'column', gap: 0, marginTop: 14 }}
@@ -1088,7 +1093,7 @@ function PloigisiTab() {
>
<DragHandle />
<span style={{ color: 'var(--accent)', flexShrink: 0 }}>{item.icon}</span>
<span style={{ flex: 1, fontSize: 15, fontWeight: 700, color: 'var(--accent)' }}>{item.label}</span>
<span style={{ flex: 1, fontSize: 15, fontWeight: 700, color: 'var(--accent)' }}>{t(item.label)}</span>
<button
onClick={() => toggleItem(item.key)}
style={{ background: 'none', border: 'none', cursor: 'pointer', padding: 0 }}
@@ -1112,7 +1117,7 @@ function PloigisiTab() {
<div style={{ display: 'flex', alignItems: 'center', gap: 10, padding: '4px 0', marginBottom: 8 }}>
<div style={{ flex: 1, height: 1, background: 'var(--border)' }} />
<span style={{ fontSize: 11, color: 'var(--muted)', fontWeight: 700, textTransform: 'uppercase', letterSpacing: 0.8 }}>
Διαθέσιμα
{t('settings.available')}
</span>
<div style={{ flex: 1, height: 1, background: 'var(--border)' }} />
</div>
@@ -1131,7 +1136,7 @@ function PloigisiTab() {
>
<span style={{ width: 20, flexShrink: 0 }} />
<span style={{ color: 'var(--muted)', flexShrink: 0 }}>{item.icon}</span>
<span style={{ flex: 1, fontSize: 15, fontWeight: 700, color: 'var(--text)' }}>{item.label}</span>
<span style={{ flex: 1, fontSize: 15, fontWeight: 700, color: 'var(--text)' }}>{t(item.label)}</span>
<button
onClick={() => toggleItem(item.key)}
style={{ background: 'none', border: 'none', cursor: 'pointer', padding: 0 }}
@@ -1143,8 +1148,8 @@ function PloigisiTab() {
</div>
<p style={{ fontSize: 12, color: 'var(--muted)', marginTop: 4, lineHeight: 1.5 }}>
{navItems.length}/5 εικονίδια ενεργά
{navItems.length >= 5 ? ' — μέγιστο' : ''}
{t('settings.icons.count', { count: navItems.length })}
{navItems.length >= 5 ? ` — ${t('settings.max')}` : ''}
</p>
</section>
)}
@@ -1156,6 +1161,7 @@ function PloigisiTab() {
// ─── Main page ────────────────────────────────────────────────────────────────
export default function SettingsPage() {
const { t } = useTranslation('waiter')
const navigate = useNavigate()
const [activeTab, setActiveTab] = useState('layout')
@@ -1175,9 +1181,9 @@ export default function SettingsPage() {
<svg width="20" height="20" viewBox="0 0 20 20" fill="none">
<path d="M12.5 15l-5-5 5-5" stroke="currentColor" strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round"/>
</svg>
Πίσω
{t('common.back')}
</button>
<span className="top-bar__title" style={{ textAlign: 'center' }}>Ρυθμίσεις</span>
<span className="top-bar__title" style={{ textAlign: 'center' }}>{t('nav.settings')}</span>
{/* spacer to balance the back button */}
<div style={{ width: 72 }} />
</header>
@@ -1208,7 +1214,7 @@ export default function SettingsPage() {
transition: 'color 0.12s',
}}
>
{tab.label}
{t(tab.label)}
</button>
))}
</div>
+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')}
+13 -12
View File
@@ -3,6 +3,7 @@ import useThemeStore from '../store/themeStore'
import QrScannerModal from '../components/QrScannerModal'
import { pairWith } from '../native/pairing'
import { getActiveVenue, listVenues, removeVenue, switchVenue } from '../config/server'
import { useTranslation } from '@xenia/i18n'
/**
* Native app: pair with a venue server and switch between paired venues.
@@ -12,6 +13,7 @@ import { getActiveVenue, listVenues, removeVenue, switchVenue } from '../config/
* screen, the user menu and the offline screen.
*/
export default function VenuesPage({ firstRun = false }) {
const { t } = useTranslation('waiter')
const dark = useThemeStore(s => s.dark)
const [venues, setVenues] = useState(listVenues)
const [address, setAddress] = useState('')
@@ -33,15 +35,15 @@ export default function VenuesPage({ firstRun = false }) {
const venue = await pairWith(raw)
switchVenue(venue.siteId) // reloads the app into the venue
} catch (e) {
setError(e.message || 'Αποτυχία σύνδεσης.')
setError(e.message || t('venues.failed'))
setBusy(false)
}
}, [])
function handleRemove(venue) {
const msg = venue.siteId === active?.siteId
? `Αφαίρεση του ενεργού καταστήματος «${venue.name}»; Θα χρειαστεί νέα σύνδεση.`
: `Αφαίρεση του καταστήματος «${venue.name}» από αυτό το κινητό;`
? t('venues.removeActive', { name: venue.name })
: t('venues.remove', { name: venue.name })
if (!window.confirm(msg)) return
removeVenue(venue.siteId)
if (venue.siteId === active?.siteId) {
@@ -58,18 +60,17 @@ export default function VenuesPage({ firstRun = false }) {
onClick={() => window.history.length > 1 ? window.history.back() : window.location.replace('/')}
style={{ alignSelf: 'flex-start', background: 'none', border: 'none', color: 'var(--muted)', fontSize: 15, cursor: 'pointer', padding: 0 }}
>
← Πίσω
← {t('common.back')}
</button>
)}
<div style={{ textAlign: 'center' }}>
<div style={{ fontSize: 44, marginBottom: 8 }}>🏪</div>
<h1 style={{ fontSize: 22, fontWeight: 700, color: 'var(--text)', marginBottom: 6 }}>
{firstRun ? 'Σύνδεση με κατάστημα' : 'Καταστήματα'}
{firstRun ? t('venues.connectTitle') : t('venues.title')}
</h1>
<p style={{ fontSize: 14, color: 'var(--muted)', lineHeight: 1.5 }}>
Σαρώστε το QR από τον διαχειριστή ή πληκτρολογήστε τη διεύθυνση του server.
Το κινητό πρέπει να είναι στο WiFi του καταστήματος.
{t('venues.intro')}
</p>
</div>
@@ -91,14 +92,14 @@ export default function VenuesPage({ firstRun = false }) {
<div style={{ fontSize: 16, fontWeight: 600, color: 'var(--text)' }}>
{v.name}
{isActive && (
<span style={{ marginLeft: 8, fontSize: 11, fontWeight: 700, color: 'var(--accent)' }}>ΕΝΕΡΓΟ</span>
<span style={{ marginLeft: 8, fontSize: 11, fontWeight: 700, color: 'var(--accent)' }}>{t('venues.active')}</span>
)}
</div>
<div style={{ fontSize: 12, color: 'var(--muted)', fontFamily: 'monospace' }}>{v.baseUrl}</div>
</button>
<button
onClick={() => handleRemove(v)}
aria-label="Αφαίρεση"
aria-label={t('venues.removeLabel')}
style={{ background: 'none', border: 'none', color: 'var(--muted)', fontSize: 22, cursor: 'pointer', padding: 4 }}
>
×
@@ -111,7 +112,7 @@ export default function VenuesPage({ firstRun = false }) {
<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
<button className="btn btn--accent btn--lg" onClick={() => { setError(null); setScanning(true) }} disabled={busy}>
📷 Σάρωση QR
📷 {t('venues.scan')}
</button>
<div style={{ display: 'flex', gap: 8 }}>
@@ -119,7 +120,7 @@ export default function VenuesPage({ firstRun = false }) {
value={address}
onChange={e => setAddress(e.target.value)}
onKeyDown={e => e.key === 'Enter' && address && connect(address)}
placeholder="π.χ. 192.168.1.50"
placeholder={t('venues.placeholder')}
inputMode="url"
autoCapitalize="off"
autoCorrect="off"
@@ -131,7 +132,7 @@ export default function VenuesPage({ firstRun = false }) {
/>
<button className="btn btn--secondary" onClick={() => connect(address)} disabled={busy || !address}
style={{ height: 52, padding: '0 18px' }}>
{busy ? 'Έλεγχος…' : 'Σύνδεση'}
{busy ? t('venues.checking') : t('venues.connect')}
</button>
</div>
+1 -1
View File
@@ -7,7 +7,7 @@ import { deliveryMode } from '../config/server'
* It opens by itself once, the first time an Android phone opens the waiter app
* in a browser, and only if this venue's server actually serves the APK. Closing it or tapping
* download marks it as seen for good; after that it's reachable from the side
* drawer ("Εγκατάσταση εφαρμογής", above Settings).
* drawer ("Install the app", above Settings).
*/
export const APK_URL = import.meta.env.VITE_APP_DOWNLOAD_URL || '/downloads/xenia-waiter.apk'