feat: the table map (platform-v2 step 6.8, D-31)

- floor_plans / floor_items (0035), tables' plan_id + width/height/rotation/shape;
  /api/floor-plans (set-up, catalog.tables.manage, floor_plans.changed) and
  /api/floor-plans/live (each table's state, guests, waiters, time; zone rule)
- @xenia/floorplan: the drawing (Floor, Item, TableShape, FloorView) and its geometry
  (grid snap in whole cells, outlines, chairs), tested
- manager: Management -> Tables -> Floor plans (editor: drag, grid, irregular floor,
  walls/bar/labels/areas, background picture), Tables page List / Map
- counter POS: Tables List / Map; waiter: Map mode, the list stays the default
- tests: test_floor_plans.py, floor + geometry unit tests, manager/waiter/terminal e2e

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-18 17:00:45 +02:00
co-authored by Claude Opus 5.5
parent fd3254aa31
commit f4aae6abbc
47 changed files with 2102 additions and 8 deletions
+16 -1
View File
@@ -33,6 +33,7 @@ import ReceiptPanel from './ReceiptPanel'
import ReceiptsView from './ReceiptsView'
import SaleCart from './SaleCart'
import TablePanel from './TablePanel'
import TablesMap from './TablesMap'
import TablesView from './TablesView'
import { useBookings, useMenu, useOnline, useReceipts, useTables } from './usePos'
@@ -46,10 +47,12 @@ export default function PosScreen() {
}
function Counter({ menu, t }) {
const { t: tc } = useTranslation('common')
const { language } = useLanguage()
const { formatMoney } = useFormat()
const [mode, setMode] = useState('sale') // sale | tables | online | receipts
const [tableId, setTableId] = useState(null) // the open table (tables mode)
const [tablesView, setTablesView] = useState('list') // list | map (6.8; the list first, always)
const [zone, setZone] = useState(null)
const [category, setCategory] = useState(() => menu.settings.start_category_id ?? null)
const [query, setQuery] = useState('')
@@ -207,7 +210,19 @@ function Counter({ menu, t }) {
</>
) : picking ? (
<main className="col-span-2 flex flex-col min-h-0 min-w-0">
<TablesView data={tables.data} zone={zone} onPick={id => { setTableId(id); setTableCart([]) }} />
<div className="px-3 pt-3 flex">
<div className="flex rounded-control border border-line overflow-hidden" role="group">
{['list', 'map'].map(v => (
<button key={v} type="button" aria-pressed={tablesView === v} onClick={() => setTablesView(v)} data-testid={`pos-tables-${v}`}
className={`px-4 py-2 text-label font-semibold ${tablesView === v ? 'bg-accent-soft text-accent-ink' : 'bg-surface text-ink-2'}`}>
{tc(`floorMap.${v}`)}
</button>
))}
</div>
</div>
{tablesView === 'map'
? <TablesMap zone={zone} onPick={id => { setTableId(id); setTableCart([]) }} />
: <TablesView data={tables.data} zone={zone} onPick={id => { setTableId(id); setTableCart([]) }} />}
</main>
) : (
<>
+16
View File
@@ -0,0 +1,16 @@
// The tables at the counter as a map (plan step 6.8, D-31): the venue's floor plans with each
// table's state now (@xenia/floorplan FloorView over GET /api/floor-plans/live), live. A tap opens
// the table, as in the list. The list stays the default; the map is a button away.
import { FloorView } from '@xenia/floorplan'
import { Spinner } from '@xenia/ui'
import { useFloorLive } from './usePos'
export default function TablesMap({ zone, onPick }) {
const { data } = useFloorLive()
if (!data) return <div className="flex-1 flex items-center justify-center"><Spinner /></div>
return (
<div className="flex-1 min-h-0 p-3 flex flex-col" data-testid="pos-floor">
<FloorView data={data} zone={zone} onPick={table => onPick(table.id)} />
</div>
)
}
+13
View File
@@ -92,6 +92,19 @@ export function useTables() {
return { data, reload: load }
}
/** The table map (6.8): GET /api/floor-plans/live, reloaded on the tables' events and plan changes. */
export function useFloorLive() {
const [data, setData] = useState(null)
const load = useCallback(async () => {
try { setData((await client.get('/api/floor-plans/live', quiet)).data) } catch { /* the shell shows offline */ }
}, [])
const soon = useCoalesced(load)
useEffect(() => { load() }, [load])
useLiveEvent('ready', load)
useLiveEvents([...TABLE_EVENTS, 'floor_plans.changed', 'reservation_updated'], soon)
return { data, reload: load }
}
/** GET /api/orders/{id} for one order (null id → null); reloads on that order's events.
* → { order, gone, reload } (gone: closed or removed meanwhile). */
export function useOrder(orderId) {