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:
@@ -15,6 +15,7 @@ COPY packages/i18n/package.json packages/i18n/
|
||||
COPY packages/api/package.json packages/api/
|
||||
COPY packages/access/package.json packages/access/
|
||||
COPY packages/signage/package.json packages/signage/
|
||||
COPY packages/floorplan/package.json packages/floorplan/
|
||||
COPY waiter_pwa/package.json waiter_pwa/
|
||||
COPY manager_dashboard/package.json manager_dashboard/
|
||||
COPY terminal/package.json terminal/
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
"@tanstack/react-query": "^5.107.1",
|
||||
"@xenia/access": "^0.0.0",
|
||||
"@xenia/api": "^0.0.0",
|
||||
"@xenia/floorplan": "^0.0.0",
|
||||
"@xenia/i18n": "^0.0.0",
|
||||
"@xenia/ui": "^0.0.0",
|
||||
"axios": "^1.21.1",
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
// The tables as a map on the phone (plan step 6.8, D-31): the floor plans of the waiter's zones with
|
||||
// each table's state now (@xenia/floorplan FloorView over GET /api/floor-plans/live). The Tables
|
||||
// page always opens on the list; this is its "Map" mode. Refreshes on the tables' live events and
|
||||
// after a reconnect. A tap opens the table like the list does.
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import { FloorView } from '@xenia/floorplan'
|
||||
import client from '../api/client'
|
||||
|
||||
const EVENTS = ['order_updated', 'order_paid', 'order_closed', 'table_list_changed', 'kds_order_updated', 'kds_item_updated',
|
||||
'reservation_updated', 'floor_plans.changed']
|
||||
|
||||
export default function FloorMapView({ zone, onPick }) {
|
||||
const [data, setData] = useState(null)
|
||||
const load = useCallback(async () => {
|
||||
try { setData((await client.get('/api/floor-plans/live')).data) } catch { /* offline: keep what we have */ }
|
||||
}, [])
|
||||
useEffect(() => {
|
||||
const first = setTimeout(load, 0)
|
||||
let timer = null
|
||||
const soon = () => { clearTimeout(timer); timer = setTimeout(load, 150) }
|
||||
const onEvent = e => { if (EVENTS.includes(e.detail?.type)) soon() }
|
||||
window.addEventListener('live-event', onEvent)
|
||||
window.addEventListener('live-reconnected', load)
|
||||
const tick = setInterval(load, 60_000)
|
||||
return () => {
|
||||
clearTimeout(first); clearTimeout(timer); clearInterval(tick)
|
||||
window.removeEventListener('live-event', onEvent)
|
||||
window.removeEventListener('live-reconnected', load)
|
||||
}
|
||||
}, [load])
|
||||
return (
|
||||
<div style={{ flex: 1, minHeight: 0, display: 'flex', flexDirection: 'column', padding: '10px 12px 88px' }} data-testid="waiter-floor">
|
||||
{data ? <FloorView data={data} zone={zone} onPick={onPick} /> : null}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import { useAllowed } from '@xenia/access'
|
||||
import { useFormat, useTranslation } from '@xenia/i18n'
|
||||
import { useNavigate, useSearchParams } from 'react-router-dom'
|
||||
import TableCard from '../components/TableCard'
|
||||
import FloorMapView from '../components/FloorMapView'
|
||||
import useAuthStore from '../store/authStore'
|
||||
import useTableColourStore from '../store/tableColourStore'
|
||||
import useConnectionStore from '../store/connectionStore'
|
||||
@@ -334,6 +335,8 @@ export default function TableListPage() {
|
||||
const PULL_THRESHOLD = 72
|
||||
|
||||
const navigate = useNavigate()
|
||||
const { t: tc } = useTranslation('common')
|
||||
const [mapView, setMapView] = useState(false) // 6.8: the floor plans; the page always opens on the list (D-31)
|
||||
const [searchParams] = useSearchParams()
|
||||
const pageTab = searchParams.get('tab') === 'orders' ? 'orders' : 'tables'
|
||||
const filterBtnRef = useRef(null)
|
||||
@@ -675,10 +678,20 @@ export default function TableListPage() {
|
||||
onClick={() => setActiveZoneTab(effectiveZoneTab === g.id ? 'all' : g.id)}
|
||||
/>
|
||||
))}
|
||||
<span style={{ flex: 1 }} />
|
||||
<button type="button" onClick={() => setMapView(v => !v)} aria-pressed={mapView} data-testid="tables-map-toggle"
|
||||
style={{ flexShrink: 0, padding: '6px 12px', borderRadius: 999, fontWeight: 700, fontSize: 13, cursor: 'pointer',
|
||||
border: `1.5px solid ${mapView ? 'var(--x-accent)' : 'var(--x-line)'}`,
|
||||
background: mapView ? 'var(--x-accent-soft)' : 'var(--x-surface)', color: mapView ? 'var(--x-accent-ink)' : 'var(--x-ink-2)' }}>
|
||||
{mapView ? tc('floorMap.list') : tc('floorMap.map')}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* ── Standalone view OR Table grid ────────────────────────────────── */}
|
||||
{effectiveZoneTab === 'standalone' ? (
|
||||
{mapView && effectiveZoneTab !== 'standalone' ? (
|
||||
<FloorMapView zone={effectiveZoneTab === 'all' ? null : effectiveZoneTab}
|
||||
onPick={tb => navigate(tb.order ? `/tables/${tb.id}` : `/tables/${tb.id}/add?new=1`)} />
|
||||
) : effectiveZoneTab === 'standalone' ? (
|
||||
<StandaloneView orders={orders} gridCols={gridCols} navigate={navigate} />
|
||||
) : (
|
||||
<div
|
||||
|
||||
Reference in New Issue
Block a user