feat(manager): design pass 1 — every page on <Page>, shared toolbars, fees under Online orders, QR codes under Tables, day stats reworked
From the owner's page-by-page review (2026-11-20): - every page root is <Page> (scrolls, fills 1080p, 16:9 centred on ultrawides); not yet: products, management/tables, stock (next pass) - /dashboard: more padding in cards (p-card), quieter secondary text, 11px uppercase labels everywhere (text-overline) - day stats: xl dialog, "● Day running · Opened …" as text, the six figures in equal boxes, "On tabs" in the payments bar, shared Tabs - /tables: Segmented List / Map / QR codes (?view=; /online/qr redirects), filter chips + zones multi-select at one height, the card itself opens the table (button removed), cards ~20% wider - /online-orders: shared Tabs with Settings (= the old /online/fees page, which redirects to ?tab=settings); orders fill the width - contacts, customers, expenses: PageHeader + Toolbar + SearchInput + multi-select Dropdowns (kinds; statuses, categories); table cells vertically centred; the Spent tip opens on hover - filterCards / filterContacts / filterExpenses take several values (unit tests added) - docs/DESIGN.md: the design language (CS-20 in the pack README) - tests/e2e/manager_layout.mjs: the page rule at 1920x1080 and 3440x1440; manager.mjs and manager_look.mjs follow the moved pages Verified: manager build + lint (0 errors), unit tests (manager 99, ui 24, i18n 31, api 25, access 8), i18n guard, manager_layout.mjs all passed, manager.mjs 228 checks all passed. Not checked: the waiter app and the terminal by eye (they only get the muted ink-2 token). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,11 +4,15 @@
|
||||
// and can tell its waiters (or everyone) a message. Tickets that didn't print are listed below
|
||||
// with what can be done about them (6.10).
|
||||
// Everything stays current through the live events.
|
||||
// 2026-11-20: the toolbar is the shared one (view, state chips, zones as a multi-select), a click on
|
||||
// the card opens the table (no separate button), and the tables' QR codes are a view here (?view=qr;
|
||||
// was the page /online/qr) for whoever manages the QR menu.
|
||||
import { useState } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { Clock, Lock, Printer, Zap } from 'lucide-react'
|
||||
import { useNavigate, useSearchParams } from 'react-router-dom'
|
||||
import { Clock, LayoutGrid, Lock, Map as MapIcon, Printer, QrCode, Zap } from 'lucide-react'
|
||||
import { useCan, useModule } from '@xenia/access'
|
||||
import { useFormat, useTranslation } from '@xenia/i18n'
|
||||
import { Button, EmptyState, IconButton, Select, Spinner, cx } from '@xenia/ui'
|
||||
import { Dropdown, EmptyState, FilterChip, IconButton, Page, Segmented, Spinner, Toolbar, ToolbarSpacer, cx } from '@xenia/ui'
|
||||
import client from '../../api/client'
|
||||
import { useLiveQuery } from '../../live/useLiveQuery'
|
||||
import LiveFloor from '../floor/LiveFloor'
|
||||
@@ -16,6 +20,7 @@ import { useDuration } from '../overview/hooks'
|
||||
import { TABLE_STATES, durationParts, orderTotal, tableCards, tableName } from '../overview/overviewLogic'
|
||||
import { Money, Pill } from '../overview/parts'
|
||||
import PrintProblemsCard from './PrintProblemsCard'
|
||||
import TableQrCodes from '../online/TableQrCodes'
|
||||
import { BORDER, SOFT, SOLID } from '../overview/tones'
|
||||
import QuickActions from './QuickActions'
|
||||
import { NO_ZONE, cardTarget, filterCards, flagsByTable, personName } from './orderLogic'
|
||||
@@ -27,9 +32,15 @@ export default function TablesPage() {
|
||||
const { t } = useTranslation('manager')
|
||||
const tc = useTranslation('common').t
|
||||
const navigate = useNavigate()
|
||||
const [view, setView] = useState('list')
|
||||
const qrModule = useModule('connect_menu')
|
||||
const qrAllowed = useCan('connect_menu.manage')
|
||||
const qrOn = qrModule && qrAllowed
|
||||
const [params, setParams] = useSearchParams()
|
||||
const views = ['list', 'map', ...(qrOn ? ['qr'] : [])]
|
||||
const view = views.includes(params.get('view')) ? params.get('view') : 'list'
|
||||
const setView = v => setParams(p => { const n = new URLSearchParams(p); n.set('view', v); return n }, { replace: true })
|
||||
const [states, setStates] = useState([])
|
||||
const [zone, setZone] = useState('')
|
||||
const [zones, setZones] = useState([])
|
||||
const [quick, setQuick] = useState(null) // a card
|
||||
|
||||
const { data: tables = [], isPending: loadingTables } = useLiveQuery({
|
||||
@@ -45,49 +56,47 @@ export default function TablesPage() {
|
||||
const { data: staff = [] } = useLiveQuery({ queryKey: ['waiters'], queryFn: () => client.get('/api/waiters/').then(r => r.data), staleTime: 60_000 })
|
||||
|
||||
const cards = tableCards(tables, orders)
|
||||
const shown = filterCards(cards, { states, zone })
|
||||
const shown = filterCards(cards, { states, zones })
|
||||
const flags = flagsByTable(flagDefs, flagRows)
|
||||
const name = id => personName(staff.find(s => s.id === id)) || `#${id}`
|
||||
const toggleState = s => setStates(list => (list.includes(s) ? list.filter(x => x !== s) : [...list, s]))
|
||||
|
||||
if (loadingTables || loadingOrders) return <div className="h-full grid place-items-center"><Spinner /></div>
|
||||
|
||||
const viewIcon = { list: <LayoutGrid size={15} />, map: <MapIcon size={15} />, qr: <QrCode size={15} /> }
|
||||
const oneZone = zones.length === 1 && zones[0] !== NO_ZONE ? Number(zones[0]) : null
|
||||
|
||||
return (
|
||||
<div className="h-full overflow-y-auto p-4 lg:p-6 grid gap-4 content-start" data-testid="tables-page">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<div className="flex rounded-control border border-line overflow-hidden" role="group">
|
||||
{['list', 'map'].map(v => (
|
||||
<button key={v} type="button" aria-pressed={view === v} onClick={() => setView(v)} data-testid={`tables-view-${v}`}
|
||||
className={cx('px-3 py-1.5 text-label font-medium', view === v ? 'bg-accent-soft text-accent-ink' : 'bg-surface text-ink-2 hover:bg-surface-2')}>
|
||||
{tc(`floorMap.${v}`)}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
<span className="flex-1" />
|
||||
<Page testId="tables-page">
|
||||
<Toolbar className="print:hidden">
|
||||
<Segmented value={view} onChange={setView} aria-label={t('orders.tables.viewAs')}
|
||||
options={views.map(v => ({ value: v, label: v === 'qr' ? t('orders.tables.qrCodes') : tc(`floorMap.${v}`), icon: viewIcon[v], testId: `tables-view-${v}` }))} />
|
||||
<ToolbarSpacer />
|
||||
{view === 'list' && TABLE_STATES.map(s => (
|
||||
<button key={s} type="button" aria-pressed={states.includes(s)} onClick={() => toggleState(s)} data-testid={`tables-state-${s}`}
|
||||
className={cx('inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full border text-label font-semibold',
|
||||
states.includes(s) ? `${SOFT[STATE_TONE[s]]} ${BORDER[STATE_TONE[s]]}` : 'border-line bg-surface text-ink-2 hover:bg-surface-2')}>
|
||||
<span className={cx('w-2 h-2 rounded-full', SOLID[STATE_TONE[s]])} aria-hidden="true" />
|
||||
<FilterChip key={s} tone={STATE_TONE[s]} pressed={states.includes(s)} onClick={() => toggleState(s)} data-testid={`tables-state-${s}`}
|
||||
count={cards.filter(c => c.state === s).length}>
|
||||
{t(`overview.tableState.${s}`)}
|
||||
<span className="tabular-nums text-ink">{cards.filter(c => c.state === s).length}</span>
|
||||
</button>
|
||||
</FilterChip>
|
||||
))}
|
||||
<Select size="sm" value={zone} onChange={e => setZone(e.target.value)} aria-label={t('orders.tables.zone')} data-testid="tables-zone">
|
||||
<option value="">{t('orders.tables.allZones')}</option>
|
||||
{groups.map(g => <option key={g.id} value={String(g.id)}>{g.name}</option>)}
|
||||
<option value={NO_ZONE}>{t('orders.tables.noZone')}</option>
|
||||
</Select>
|
||||
</div>
|
||||
{view !== 'qr' && (
|
||||
<Dropdown multiple value={zones} onChange={setZones} allLabel={t('orders.tables.allZones')} aria-label={t('orders.tables.zone')} data-testid="tables-zone"
|
||||
options={[
|
||||
...groups.map(g => ({ value: String(g.id), label: g.name, dot: g.color || undefined })),
|
||||
{ value: NO_ZONE, label: t('orders.tables.noZone') },
|
||||
]} />
|
||||
)}
|
||||
</Toolbar>
|
||||
|
||||
{view === 'qr' && <TableQrCodes />}
|
||||
|
||||
{view === 'map' && (
|
||||
<LiveFloor zone={zone && zone !== NO_ZONE ? Number(zone) : null} onOpen={id => navigate(`/orders/${id}`)} />
|
||||
<LiveFloor zone={oneZone} onOpen={id => navigate(`/orders/${id}`)} />
|
||||
)}
|
||||
|
||||
{view === 'list' && (shown.length === 0
|
||||
? <EmptyState title={t('orders.tables.none')} />
|
||||
: (
|
||||
<div className="grid gap-3 grid-cols-[repeat(auto-fill,minmax(17rem,1fr))]">
|
||||
<div className="grid gap-4 grid-cols-[repeat(auto-fill,minmax(min(100%,20.5rem),1fr))]">
|
||||
{shown.map(card => (
|
||||
<TableCard key={card.table.id} card={card} zone={groups.length > 1 ? groups.find(g => g.id === card.table.group_id)?.name : null} flags={flags[card.table.id] ?? []} waiterName={name}
|
||||
onOpen={() => navigate(cardTarget(card))} onQuick={() => setQuick(card)} />
|
||||
@@ -95,10 +104,10 @@ export default function TablesPage() {
|
||||
</div>
|
||||
))}
|
||||
|
||||
<PrintProblemsCard onOpen={id => navigate(`/orders/${id}`)} />
|
||||
{view !== 'qr' && <PrintProblemsCard onOpen={id => navigate(`/orders/${id}`)} />}
|
||||
|
||||
{quick && <QuickActions card={quick} flagDefs={flagDefs} current={flags[quick.table.id] ?? []} onClose={() => setQuick(null)} />}
|
||||
</div>
|
||||
</Page>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -114,7 +123,7 @@ function TableCard({ card, zone, flags, waiterName, onOpen, onQuick }) {
|
||||
return (
|
||||
<div className={cx('relative rounded-card border bg-surface shadow-raised overflow-hidden grid', BORDER[tone])} data-testid="table-card" data-state={state} data-table={table.id}>
|
||||
<span className={cx('absolute inset-y-0 left-0 w-1.5', SOLID[tone])} aria-hidden="true" />
|
||||
<button type="button" onClick={onOpen} className="text-left pl-5 pr-4 pt-3 pb-2 grid gap-2 hover:bg-surface-2 transition-colors duration-fast"
|
||||
<button type="button" onClick={onOpen} data-testid="table-open" className="text-left pl-5 pr-4 pt-4 pb-3 grid gap-2.5 hover:bg-surface-2 transition-colors duration-fast"
|
||||
aria-label={t('orders.tables.open', { table: tableName(table), state: t(`overview.tableState.${state}`) })}>
|
||||
<span className="flex items-start gap-2">
|
||||
<span className="flex-1 grid gap-1">
|
||||
@@ -137,24 +146,23 @@ function TableCard({ card, zone, flags, waiterName, onOpen, onQuick }) {
|
||||
</span>
|
||||
<span className="grid grid-cols-2 gap-2">
|
||||
<span className="grid">
|
||||
<span className="text-caption font-semibold uppercase tracking-wide text-ink-3">{t('orders.total')}</span>
|
||||
<span className="text-overline font-semibold uppercase tracking-wide text-ink-3">{t('orders.total')}</span>
|
||||
{order ? <Money value={orderTotal(order.items)} className="text-title font-semibold text-ink" /> : <span className="text-title text-ink-3">—</span>}
|
||||
</span>
|
||||
<span className="grid">
|
||||
<span className="text-caption font-semibold uppercase tracking-wide text-ink-3">{t('orders.tables.time')}</span>
|
||||
<span className="text-overline font-semibold uppercase tracking-wide text-ink-3">{t('orders.tables.time')}</span>
|
||||
<span className={cx('text-title tabular-nums inline-flex items-center gap-1', long ? 'font-bold text-warning-ink' : 'text-ink')}>
|
||||
{order ? <><Clock size={14} aria-hidden="true" />{since(order.opened_at)}</> : <span className="text-ink-3">—</span>}
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
</button>
|
||||
<div className="flex items-center gap-2 pl-5 pr-2 py-2 border-t border-line">
|
||||
<div className="flex items-center gap-2 pl-5 pr-2 py-1.5 border-t border-line">
|
||||
<span className="flex-1 min-w-0 truncate text-label text-ink-2">
|
||||
{!order ? (table.seat_count ? t('orders.tables.seats', { count: table.seat_count }) : '')
|
||||
: order.waiters.length ? order.waiters.map(w => waiterName(w.waiter_id)).join(', ') : t('orders.tables.noWaiter')}
|
||||
</span>
|
||||
<IconButton size="sm" variant="ghost" label={t('orders.quick.title', { table: tableName(table) })} onClick={onQuick} data-testid="table-quick"><Zap size={16} /></IconButton>
|
||||
<Button size="sm" variant={order ? 'secondary' : 'primary'} onClick={onOpen} data-testid="table-open">{order ? t('orders.tables.view') : t('orders.tables.take')}</Button>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user