feat(waiter): the waiter app on the shared foundations (api client, access, i18n), lint clean, starts offline
Plan step 4.1. No visible change to layout or flows. - api/client.js on @xenia/api createApiClient (CS-8 baseURL, 401 → sign out, no answer → backend-offline, err.xenia, the manager-approval retry); the PIN login handles its own 401 (before, a wrong PIN reloaded the page). - <AccessProvider> at the root with an i18n instance: modules, permission keys, venue, language from bootstrap; who is signed in comes with it (no more /api/auth/me polling). packages/access: AccessProvider gains `cache` (the last bootstrap per session; used when the server can't be reached, `offline` in the context, keeps retrying) and `failed` (the app's own screen when there's nothing cached). The waiter caches per venue, shows its offline page (server search) on a first start without a server, retries every 5 s; ServerRediscovery and BundleSync run outside the bootstrap. - Role names → keys: the shift gate and the user menu use core.dashboard.access. - One shared, offline-cached read of the venue settings (api/venueSettings.js) instead of seven GET /api/settings/ calls; apiError() shows backend error codes in the user's language (17 places). - Lint: 78 errors → 0 (unused code, empty catches, two duplicate style keys, a component created during render, refs read during render → state, hooks after an early return); set-state-in-effect is a warning like the manager/terminal; lint in run-all. - Tests: tests/bootstrapCache.test.mjs; e2e browser: an offline restart stays signed in. Android rediscovery waits for what the screen shows instead of fixed sleeps: 10/10 three runs in a row (KI-009). Terminal 3.4 waits for both displays before the sale. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,8 @@ import ProductPicker from '../components/ProductPicker'
|
||||
import OrderDrawer from '../components/OrderDrawer'
|
||||
import OrderSummaryModal from '../components/OrderSummaryModal'
|
||||
import client from '../api/client'
|
||||
import { apiError } from '../api/errors'
|
||||
import { getVenueSettings } from '../api/venueSettings'
|
||||
import db from '../db/posdb'
|
||||
import { useProductCache } from '../hooks/useProductCache'
|
||||
import useOrderingSettingsStore from '../store/orderingSettingsStore'
|
||||
@@ -195,14 +197,14 @@ export default function AddItemsPage() {
|
||||
_key: Date.now() + Math.random(),
|
||||
}))
|
||||
setCart(initialCart)
|
||||
} catch {}
|
||||
} catch { /* ignore */ }
|
||||
}
|
||||
}
|
||||
load()
|
||||
}, [tableId, isStandalone, orderType])
|
||||
|
||||
useEffect(() => {
|
||||
client.get('/api/settings/').then(r => {
|
||||
getVenueSettings().then(r => {
|
||||
const s = r.data
|
||||
if (s?.['orders.courses_enabled']?.value === 'true') {
|
||||
try { setCourses(JSON.parse(s?.['orders.courses']?.value || '[]')) } catch { /* ignore */ }
|
||||
@@ -348,7 +350,7 @@ export default function AddItemsPage() {
|
||||
setTimeout(() => navigate('/tables'), 1200)
|
||||
}
|
||||
} catch (err) {
|
||||
setError(err.response?.data?.detail || 'Σφάλμα αποστολής — η παραγγελία δεν στάλθηκε')
|
||||
setError(apiError(err, 'Σφάλμα αποστολής — η παραγγελία δεν στάλθηκε'))
|
||||
} finally {
|
||||
setSending(false)
|
||||
}
|
||||
@@ -685,7 +687,7 @@ export default function AddItemsPage() {
|
||||
|
||||
return (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
|
||||
{groups.map((group, gi) => (
|
||||
{groups.map((group, _gi) => (
|
||||
<div key={group.course?.id ?? '__none__'} style={{ position: 'relative' }}>
|
||||
{/* Colored left accent bar */}
|
||||
<div style={{
|
||||
@@ -949,7 +951,7 @@ export default function AddItemsPage() {
|
||||
|
||||
// ── Deal Offer Modal ──────────────────────────────────────────────────────────
|
||||
|
||||
function DealOfferModal({ offer, products, onAccept, onDismiss }) {
|
||||
function DealOfferModal({ offer, _products, onAccept, onDismiss }) {
|
||||
const isFreeItem = offer.action_type === 'free_item'
|
||||
const isFreeChoice = offer.action_type === 'free_choice'
|
||||
const isDiscount = ['set_price','add_amount','add_percent','apply_modifier'].includes(offer.action_type)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import client from '../api/client'
|
||||
import { apiError } from '../api/errors'
|
||||
import useAuthStore from '../store/authStore'
|
||||
import useChatStore from '../store/chatStore'
|
||||
|
||||
@@ -53,7 +54,6 @@ function Avatar({ label, size = 44, isGroup = false }) {
|
||||
|
||||
function ConvRow({ conv, currentUserId, onClick }) {
|
||||
const isGroup = conv.type === 'group'
|
||||
const isDirect = conv.type === 'direct'
|
||||
|
||||
const title = isGroup
|
||||
? (conv.name || 'Ομάδα')
|
||||
@@ -74,7 +74,7 @@ function ConvRow({ conv, currentUserId, onClick }) {
|
||||
onClick={onClick}
|
||||
style={{
|
||||
display: 'flex', alignItems: 'center', gap: 12,
|
||||
padding: '14px 16px', borderBottom: '1px solid var(--border)',
|
||||
padding: '14px 16px',
|
||||
background: 'none', border: 'none', borderBottom: '1px solid var(--border)',
|
||||
width: '100%', textAlign: 'left', cursor: 'pointer',
|
||||
}}
|
||||
@@ -150,7 +150,7 @@ function NewChatDrawer({ currentUserId, onClose, onConversationCreated }) {
|
||||
})
|
||||
onConversationCreated(res.data)
|
||||
} catch (e) {
|
||||
setError(e.response?.data?.detail || 'Σφάλμα δημιουργίας συνομιλίας')
|
||||
setError(apiError(e, 'Σφάλμα δημιουργίας συνομιλίας'))
|
||||
setCreating(false)
|
||||
}
|
||||
}
|
||||
@@ -167,7 +167,7 @@ function NewChatDrawer({ currentUserId, onClose, onConversationCreated }) {
|
||||
})
|
||||
onConversationCreated(res.data)
|
||||
} catch (e) {
|
||||
setError(e.response?.data?.detail || 'Σφάλμα δημιουργίας ομάδας')
|
||||
setError(apiError(e, 'Σφάλμα δημιουργίας ομάδας'))
|
||||
setCreating(false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,7 +203,6 @@ export default function ChatThreadPage() {
|
||||
const displayMessages = [...rawMessages].reverse()
|
||||
|
||||
const isGroup = conv?.type === 'group'
|
||||
const isDirect = conv?.type === 'direct'
|
||||
|
||||
const title = isGroup
|
||||
? (conv?.name || 'Ομάδα')
|
||||
@@ -215,7 +214,7 @@ export default function ChatThreadPage() {
|
||||
try {
|
||||
await client.post(`/api/chat/conversations/${conversationId}/read`)
|
||||
markConvRead(conversationId)
|
||||
} catch {}
|
||||
} catch { /* ignore */ }
|
||||
}, [conversationId, markConvRead])
|
||||
|
||||
// ── Initial load ─────────────────────────────────────────────────────────────
|
||||
@@ -229,7 +228,7 @@ export default function ChatThreadPage() {
|
||||
try {
|
||||
const r = await client.get(`/api/chat/conversations/${conversationId}`)
|
||||
if (!cancelled) upsertConversation(r.data)
|
||||
} catch {}
|
||||
} catch { /* ignore */ }
|
||||
}
|
||||
|
||||
// Load first page of messages
|
||||
@@ -287,7 +286,7 @@ export default function ChatThreadPage() {
|
||||
el.scrollTop = el.scrollHeight - prevScrollHeight + prevScrollTop
|
||||
}
|
||||
})
|
||||
} catch {}
|
||||
} catch { /* ignore */ }
|
||||
setLoadingMore(false)
|
||||
}
|
||||
|
||||
@@ -405,7 +404,7 @@ export default function ChatThreadPage() {
|
||||
.reduce((s, c) => s + (c.unread_count || 0), 0),
|
||||
}))
|
||||
navigate('/messages', { replace: true })
|
||||
} catch {}
|
||||
} catch { /* ignore */ }
|
||||
setShowLeave(false)
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import { useNavigate } from 'react-router-dom'
|
||||
import PinPad from '../components/PinPad'
|
||||
import useAuthStore from '../store/authStore'
|
||||
import client from '../api/client'
|
||||
import { apiError } from '../api/errors'
|
||||
import { assetUrl, deliveryMode, getActiveVenue } from '../config/server'
|
||||
|
||||
|
||||
@@ -103,11 +104,11 @@ export default function LoginPage() {
|
||||
setLoading(true)
|
||||
try {
|
||||
// We send waiter id as identifier; backend matches by id+pin
|
||||
const { data } = await client.post('/api/auth/login-by-id', { waiter_id: selectedWaiter.id, pin })
|
||||
const { data } = await client.post('/api/auth/login-by-id', { waiter_id: selectedWaiter.id, pin }, { xenia: { ignoreUnauthorized: true } })
|
||||
login({ id: data.user.id, username: data.user.username, role: data.user.role }, data.access_token)
|
||||
navigate('/tables', { replace: true })
|
||||
} catch (err) {
|
||||
setError(err.response?.data?.detail || 'Λανθασμένο PIN')
|
||||
setError(apiError(err, 'Λανθασμένο PIN'))
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
|
||||
@@ -3,6 +3,9 @@ import { deliveryMode } from '../config/server'
|
||||
import { canRediscover, rediscover } from '../native/autoRediscover'
|
||||
import { useState } from 'react'
|
||||
|
||||
// Shown at /offline, and (plan step 4.1) instead of the whole app when the server can't be
|
||||
// reached on a start with no cached bootstrap (the app retries by itself and then opens the
|
||||
// screen the address asks for).
|
||||
export default function OfflinePage() {
|
||||
const [checking, setChecking] = useState(false)
|
||||
const [search, setSearch] = useState(null) // null | { done, total } | 'not-found'
|
||||
|
||||
@@ -812,12 +812,14 @@ function PloigisiTab() {
|
||||
|
||||
// ── Icon Navbar drag state ────────────────────────────────────────────────────
|
||||
const dragKey = useRef(null)
|
||||
const [dragging, setDragging] = useState(null) // drawn dimmed while dragged (refs aren't read in render)
|
||||
const touchDragKey = useRef(null)
|
||||
const itemRefs = useRef({})
|
||||
const [dropIndex, setDropIndex] = useState(null)
|
||||
|
||||
// ── Triple Pill drag state ────────────────────────────────────────────────────
|
||||
const triDragKey = useRef(null)
|
||||
const [triDragging, setTriDragging] = useState(null)
|
||||
const triTouchDragKey = useRef(null)
|
||||
const triItemRefs = useRef({})
|
||||
const [triDropIndex, setTriDropIndex] = useState(null)
|
||||
@@ -865,45 +867,45 @@ function PloigisiTab() {
|
||||
}
|
||||
|
||||
// ── Icon Navbar drag handlers ────────────────────────────────────────────────
|
||||
function onDragStart(key) { dragKey.current = key }
|
||||
function onDragStart(key) { dragKey.current = key; setDragging(key) }
|
||||
function onDragOverContainer(e, items) {
|
||||
e.preventDefault()
|
||||
setDropIndex(computeDropIndex(e.clientY, itemRefs, items))
|
||||
}
|
||||
function onDropContainer(items) {
|
||||
applyReorder(dragKey.current, dropIndex, items, setNavItems)
|
||||
dragKey.current = null; setDropIndex(null)
|
||||
dragKey.current = null; setDragging(null); setDropIndex(null)
|
||||
}
|
||||
function onDragEnd() { dragKey.current = null; setDropIndex(null) }
|
||||
function onTouchStart(e, key) { touchDragKey.current = key }
|
||||
function onDragEnd() { dragKey.current = null; setDragging(null); setDropIndex(null) }
|
||||
function onTouchStart(e, key) { touchDragKey.current = key; setDragging(key) }
|
||||
function onTouchMove(e, items) {
|
||||
e.preventDefault()
|
||||
setDropIndex(computeDropIndex(e.touches[0].clientY, itemRefs, items))
|
||||
}
|
||||
function onTouchEnd(items) {
|
||||
applyReorder(touchDragKey.current, dropIndex, items, setNavItems)
|
||||
touchDragKey.current = null; setDropIndex(null)
|
||||
touchDragKey.current = null; setDragging(null); setDropIndex(null)
|
||||
}
|
||||
|
||||
// ── Triple Pill drag handlers ────────────────────────────────────────────────
|
||||
function triOnDragStart(key) { triDragKey.current = key }
|
||||
function triOnDragStart(key) { triDragKey.current = key; setTriDragging(key) }
|
||||
function triOnDragOver(e, items) {
|
||||
e.preventDefault()
|
||||
setTriDropIndex(computeDropIndex(e.clientY, triItemRefs, items))
|
||||
}
|
||||
function triOnDrop(items) {
|
||||
applyReorder(triDragKey.current, triDropIndex, items, setTripleItems)
|
||||
triDragKey.current = null; setTriDropIndex(null)
|
||||
triDragKey.current = null; setTriDragging(null); setTriDropIndex(null)
|
||||
}
|
||||
function triOnDragEnd() { triDragKey.current = null; setTriDropIndex(null) }
|
||||
function triOnTouchStart(e, key) { triTouchDragKey.current = key }
|
||||
function triOnDragEnd() { triDragKey.current = null; setTriDragging(null); setTriDropIndex(null) }
|
||||
function triOnTouchStart(e, key) { triTouchDragKey.current = key; setTriDragging(key) }
|
||||
function triOnTouchMove(e, items) {
|
||||
e.preventDefault()
|
||||
setTriDropIndex(computeDropIndex(e.touches[0].clientY, triItemRefs, items))
|
||||
}
|
||||
function triOnTouchEnd(items) {
|
||||
applyReorder(triTouchDragKey.current, triDropIndex, items, setTripleItems)
|
||||
triTouchDragKey.current = null; setTriDropIndex(null)
|
||||
triTouchDragKey.current = null; setTriDragging(null); setTriDropIndex(null)
|
||||
}
|
||||
|
||||
const enabledItems = navItems.map(k => NAV_MAP[k]).filter(Boolean)
|
||||
@@ -978,7 +980,7 @@ function PloigisiTab() {
|
||||
border: '2px solid var(--accent)',
|
||||
background: 'var(--accent)18',
|
||||
cursor: 'grab', userSelect: 'none',
|
||||
opacity: (triDragKey.current === item.key || triTouchDragKey.current === item.key) ? 0.4 : 1,
|
||||
opacity: triDragging === item.key ? 0.4 : 1,
|
||||
transition: 'opacity 0.1s',
|
||||
}}
|
||||
>
|
||||
@@ -1080,7 +1082,7 @@ function PloigisiTab() {
|
||||
background: 'var(--accent)18',
|
||||
cursor: 'grab',
|
||||
userSelect: 'none',
|
||||
opacity: (dragKey.current === item.key || touchDragKey.current === item.key) ? 0.4 : 1,
|
||||
opacity: dragging === item.key ? 0.4 : 1,
|
||||
transition: 'opacity 0.1s',
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import AppShell from '../components/AppShell'
|
||||
import client from '../api/client'
|
||||
import { getVenueSettings } from '../api/venueSettings'
|
||||
|
||||
// ── helpers ───────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -144,7 +145,7 @@ export default function ShiftOverviewPage() {
|
||||
|
||||
const { data: settings } = useQuery({
|
||||
queryKey: ['pos-settings'],
|
||||
queryFn: () => client.get('/api/settings/').then(r => r.data),
|
||||
queryFn: () => getVenueSettings().then(r => r.data),
|
||||
staleTime: 60_000,
|
||||
})
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { useEffect, useState, useRef, useCallback } from 'react'
|
||||
import { useEffect, useState, useRef } from 'react'
|
||||
import { useNavigate, useParams, useSearchParams } from 'react-router-dom'
|
||||
import OrderSummary from '../components/OrderSummary'
|
||||
import useAuthStore from '../store/authStore'
|
||||
import useConnectionStore from '../store/connectionStore'
|
||||
import client from '../api/client'
|
||||
import { apiError } from '../api/errors'
|
||||
import { getVenueSettings } from '../api/venueSettings'
|
||||
import db from '../db/posdb'
|
||||
import { queueOfflineSplit, queueOfflinePayment as queueOfflinePaymentOp } from '../services/offlineOrders'
|
||||
import { TransferIcon, MergeIcon, FlagsIcon, WaiterIcon, PrintIcon } from '../components/Icons'
|
||||
@@ -365,13 +366,13 @@ function ItemActionModal({ target, onOrderAgain, onSplit, onMoveToTable, onCance
|
||||
|
||||
// ─── Apply Discount modal ─────────────────────────────────────────────────────
|
||||
|
||||
function ApplyDiscountModal({ order, waiterId, onClose, onApplied }) {
|
||||
function ApplyDiscountModal({ order, _waiterId, onClose, onApplied }) {
|
||||
const activeItems = (order?.items ?? []).filter(i => i.status === 'active')
|
||||
const [selectedIds, setSelectedIds] = useState(activeItems.map(i => i.id))
|
||||
const [pct, setPct] = useState(10)
|
||||
const [note, setNote] = useState('')
|
||||
const [applying, setApplying] = useState(false)
|
||||
const [remaining, setRemaining] = useState(null) // { shift, workday }
|
||||
const [, setRemaining] = useState(null) // { shift, workday }
|
||||
const [error, setError] = useState('')
|
||||
|
||||
const PCT_PRESETS = [5, 10, 15, 20, 25, 50, 100]
|
||||
@@ -406,7 +407,7 @@ function ApplyDiscountModal({ order, waiterId, onClose, onApplied }) {
|
||||
onApplied()
|
||||
onClose()
|
||||
} catch (e) {
|
||||
setError(e?.response?.data?.detail || 'Σφάλμα εφαρμογής έκπτωσης')
|
||||
setError(apiError(e, 'Σφάλμα εφαρμογής έκπτωσης'))
|
||||
} finally {
|
||||
setApplying(false)
|
||||
}
|
||||
@@ -546,7 +547,7 @@ function DiscountIcon({ width = 20, height = 20 }) {
|
||||
)
|
||||
}
|
||||
|
||||
function ActionsSheet({ order, tableId, isStandalone, onClose, onTransfer, onMerge, onSetFlags, onAssignWaiter, onPrintSynopsis, onCancelOrder, onMarkAllServed, canCancel, canDiscount, onApplyDiscount }) {
|
||||
function ActionsSheet({ order, _tableId, isStandalone, onClose, onTransfer, onMerge, onSetFlags, onAssignWaiter, onPrintSynopsis, onCancelOrder, onMarkAllServed, canCancel, canDiscount, onApplyDiscount }) {
|
||||
const hasOrder = !!order
|
||||
const hasServable = hasOrder && order.items?.some(i => i.kds_status === 'done')
|
||||
const hasActiveItems = hasOrder && order.items?.some(i => i.status === 'active')
|
||||
@@ -605,7 +606,7 @@ function ActionsSheet({ order, tableId, isStandalone, onClose, onTransfer, onMer
|
||||
|
||||
// ─── Table picker (for transfer / merge / move-items) ─────────────────────────
|
||||
|
||||
function TablePicker({ title, subtitle, tables, currentTableId, onSelect, onClose, loading }) {
|
||||
function TablePicker({ title, subtitle, tables, _currentTableId, onSelect, onClose, loading }) {
|
||||
return (
|
||||
<div className="modal-overlay modal-overlay--top" onClick={onClose}>
|
||||
<div className="modal-sheet modal-sheet--top" onClick={e => e.stopPropagation()}>
|
||||
@@ -651,7 +652,7 @@ function TablePicker({ title, subtitle, tables, currentTableId, onSelect, onClos
|
||||
|
||||
// ─── Flag picker ──────────────────────────────────────────────────────────────
|
||||
|
||||
function FlagPicker({ tableId, currentFlagIds, flagDefs, onSave, onClose, loading }) {
|
||||
function FlagPicker({ _tableId, currentFlagIds, flagDefs, onSave, onClose, loading }) {
|
||||
const [selected, setSelected] = useState(currentFlagIds || [])
|
||||
|
||||
// Sync selected when currentFlagIds loads
|
||||
@@ -1037,7 +1038,6 @@ export default function TableDetailPage() {
|
||||
const { tableId, orderId: standaloneOrderId } = useParams()
|
||||
const isStandalone = !!standaloneOrderId
|
||||
const [searchParams, setSearchParams] = useSearchParams()
|
||||
const { user } = useAuthStore()
|
||||
const navigate = useNavigate()
|
||||
|
||||
const [table, setTable] = useState(null)
|
||||
@@ -1226,7 +1226,7 @@ export default function TableDetailPage() {
|
||||
client.get('/api/pricing/discount-settings/me')
|
||||
.then(r => setCanDiscount(!!r.data.can_apply_discounts))
|
||||
.catch(() => {})
|
||||
client.get('/api/settings/')
|
||||
getVenueSettings()
|
||||
.then(r => {
|
||||
setCardEnabled(r.data?.['payments.card_enabled']?.value === 'true')
|
||||
setRevertAllowed(r.data?.['payments.waiter_revert_allowed']?.value === 'true')
|
||||
@@ -1322,7 +1322,7 @@ export default function TableDetailPage() {
|
||||
await client.post('/api/orders/', { table_id: Number(tableId) })
|
||||
await load()
|
||||
} catch (err) {
|
||||
setError(err.response?.data?.detail || 'Σφάλμα ανοίγματος')
|
||||
setError(apiError(err, 'Σφάλμα ανοίγματος'))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1358,15 +1358,14 @@ export default function TableDetailPage() {
|
||||
if (res.data?.auto_closed || andClose) {
|
||||
if (andClose && !res.data?.auto_closed) {
|
||||
// Payment succeeded, now close the order explicitly
|
||||
try { await client.post(`/api/orders/${order.id}/close`) } catch {}
|
||||
try { await client.post(`/api/orders/${order.id}/close`) } catch { /* ignore */ }
|
||||
}
|
||||
navigate('/tables', { replace: true })
|
||||
return
|
||||
}
|
||||
await load()
|
||||
} catch (err) {
|
||||
const detail = err?.response?.data?.detail
|
||||
setError(detail ? `Σφάλμα πληρωμής: ${detail}` : 'Σφάλμα πληρωμής')
|
||||
setError(apiError(err, 'Σφάλμα πληρωμής'))
|
||||
} finally {
|
||||
setPaying(false)
|
||||
}
|
||||
@@ -1379,7 +1378,7 @@ export default function TableDetailPage() {
|
||||
setPaidSelectedIds([])
|
||||
await load()
|
||||
} catch (err) {
|
||||
setError(err.response?.data?.detail || 'Σφάλμα αναίρεσης πληρωμής')
|
||||
setError(apiError(err, 'Σφάλμα αναίρεσης πληρωμής'))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1389,7 +1388,7 @@ export default function TableDetailPage() {
|
||||
setConfirmClose(false)
|
||||
navigate('/tables')
|
||||
} catch (err) {
|
||||
setError(err.response?.data?.detail || 'Σφάλμα κλεισίματος')
|
||||
setError(apiError(err, 'Σφάλμα κλεισίματος'))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1405,7 +1404,7 @@ export default function TableDetailPage() {
|
||||
setItemActionTarget(null)
|
||||
await load()
|
||||
} catch (err) {
|
||||
setError(err.response?.data?.detail || 'Σφάλμα ακύρωσης')
|
||||
setError(apiError(err, 'Σφάλμα ακύρωσης'))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1415,7 +1414,7 @@ export default function TableDetailPage() {
|
||||
await client.delete(`/api/orders/${order.id}?print_cancellation=true`)
|
||||
navigate('/tables')
|
||||
} catch (err) {
|
||||
setError(err.response?.data?.detail || 'Σφάλμα ακύρωσης παραγγελίας')
|
||||
setError(apiError(err, 'Σφάλμα ακύρωσης παραγγελίας'))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1434,7 +1433,7 @@ export default function TableDetailPage() {
|
||||
setPaidSelectedIds([])
|
||||
await load()
|
||||
} catch (err) {
|
||||
setError(err.response?.data?.detail || 'Σφάλμα σήμανσης')
|
||||
setError(apiError(err, 'Σφάλμα σήμανσης'))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1446,7 +1445,7 @@ export default function TableDetailPage() {
|
||||
await client.post(`/api/kds/orders/${order.id}/items/mark-all-served`)
|
||||
await load()
|
||||
} catch (err) {
|
||||
setError(err.response?.data?.detail || 'Σφάλμα σήμανσης')
|
||||
setError(apiError(err, 'Σφάλμα σήμανσης'))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1493,7 +1492,7 @@ export default function TableDetailPage() {
|
||||
setSelectedIds([])
|
||||
await load()
|
||||
} catch (err) {
|
||||
setError(err.response?.data?.detail || 'Σφάλμα διαχωρισμού')
|
||||
setError(apiError(err, 'Σφάλμα διαχωρισμού'))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1506,7 +1505,7 @@ export default function TableDetailPage() {
|
||||
await client.post(`/api/orders/${order.id}/transfer`, { target_table_id: targetTable.id })
|
||||
navigate('/tables')
|
||||
} catch (err) {
|
||||
setError(err.response?.data?.detail || 'Σφάλμα μεταφοράς')
|
||||
setError(apiError(err, 'Σφάλμα μεταφοράς'))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1521,7 +1520,7 @@ export default function TableDetailPage() {
|
||||
await client.post(`/api/orders/${order.id}/merge`, { target_order_id: targetOrder.id })
|
||||
navigate('/tables')
|
||||
} catch (err) {
|
||||
setError(err.response?.data?.detail || 'Σφάλμα συγχώνευσης')
|
||||
setError(apiError(err, 'Σφάλμα συγχώνευσης'))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1540,7 +1539,7 @@ export default function TableDetailPage() {
|
||||
setSelectedIds([])
|
||||
await load()
|
||||
} catch (err) {
|
||||
setError(err.response?.data?.detail || 'Σφάλμα μεταφοράς αντικειμένων')
|
||||
setError(apiError(err, 'Σφάλμα μεταφοράς αντικειμένων'))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1778,7 +1777,7 @@ export default function TableDetailPage() {
|
||||
onClick={() => setShowMergeModal(true)}
|
||||
style={{
|
||||
width: 40, flexShrink: 0,
|
||||
borderRadius: 10, border: 'none', cursor: 'pointer',
|
||||
borderRadius: 10, cursor: 'pointer',
|
||||
background: mergeMode !== MERGE_OFF ? 'rgba(99,102,241,0.25)' : 'var(--bg2)',
|
||||
color: mergeMode !== MERGE_OFF ? '#a5b4fc' : 'var(--muted)',
|
||||
border: mergeMode !== MERGE_OFF ? '1px solid rgba(99,102,241,0.45)' : '1px solid var(--border)',
|
||||
@@ -2177,7 +2176,7 @@ export default function TableDetailPage() {
|
||||
if (order) {
|
||||
try {
|
||||
await client.patch(`/api/orders/${order.id}/customer-count`, { customer_count: v })
|
||||
} catch {}
|
||||
} catch { /* ignore */ }
|
||||
}
|
||||
}}
|
||||
onClose={() => setCustomerCountOpen(false)}
|
||||
|
||||
@@ -6,6 +6,7 @@ import useTableColourStore from '../store/tableColourStore'
|
||||
import useConnectionStore from '../store/connectionStore'
|
||||
import useTableViewStore from '../store/tableViewStore'
|
||||
import client from '../api/client'
|
||||
import { getVenueSettings } from '../api/venueSettings'
|
||||
import db from '../db/posdb'
|
||||
import { FlagsIcon, TransferIcon, MergeIcon, PrintIcon, WaiterIcon } from '../components/Icons'
|
||||
|
||||
@@ -111,7 +112,7 @@ function TableQuickModal({ table, order, flags, onClose, onNavigate, onAction, o
|
||||
<div style={{ background: 'var(--bg2)', borderRadius: '0 0 16px 16px', padding: '8px 20px 24px', borderTop: '2px solid var(--border)' }}>
|
||||
<p style={{ fontSize: 11, fontWeight: 700, color: 'var(--muted)', letterSpacing: 1, marginBottom: 8, marginTop: 8 }}>ACTIONS</p>
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 0 }}>
|
||||
{QUICK_ACTIONS.map((a, i) => {
|
||||
{QUICK_ACTIONS.map((a, _i) => {
|
||||
const disabled = !order && a.key !== 'flags'
|
||||
return (
|
||||
<button key={a.key} disabled={disabled} onClick={() => { onClose(); onAction(a.key) }} style={{
|
||||
@@ -306,7 +307,7 @@ export default function TableListPage() {
|
||||
const [flagDefs, setFlagDefs] = useState([])
|
||||
const [flagAssignments, setFlagAssignments] = useState([])
|
||||
const [waiters, setWaiters] = useState([]) // waiter objects for avatar lookup
|
||||
const [offline, setOffline] = useState(false)
|
||||
const [, setOffline] = useState(false)
|
||||
const [showFilters, setShowFilters] = useState(false)
|
||||
const [quickModal, setQuickModal] = useState(null)
|
||||
const [canCancel, setCanCancel] = useState(false)
|
||||
@@ -391,7 +392,7 @@ export default function TableListPage() {
|
||||
client.get('/api/tables/groups'),
|
||||
client.get('/api/flags/defs'),
|
||||
client.get('/api/flags/assignments'),
|
||||
client.get('/api/settings/'),
|
||||
getVenueSettings(),
|
||||
client.get('/api/waiters/on-shift'),
|
||||
])
|
||||
|
||||
@@ -452,14 +453,14 @@ export default function TableListPage() {
|
||||
setCancelConfirm(null)
|
||||
setQuickModal(null)
|
||||
load()
|
||||
} catch {}
|
||||
} catch { /* ignore */ }
|
||||
}
|
||||
|
||||
async function executeMarkAllServed(orderId) {
|
||||
try {
|
||||
await client.post(`/api/kds/orders/${orderId}/items/mark-all-served`)
|
||||
load()
|
||||
} catch {}
|
||||
} catch { /* ignore */ }
|
||||
}
|
||||
|
||||
// ── SSE live updates ───────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user