Repository navigation
feat(kds): kanban view as alternative to tabs, with shared WS/auth - #118
Conversation
|
@khaira777, an update after the first push: I caught two bugs in the kanban view. Both are fixed in commit 392edf4:
Smaller fixes in the same commit: the 300 ms drag delay became a 6 px distance guard so a tap on the card body is a no-op, and the tabs pill row got shrink-0 plus a small dashboard padding fix so the active pill ring and the first card no longer draw under the sidebar icon column. Migration v22 still adds kds_default_view, default tabs. No change for existing tenants until the owner flips it in Settings -> KDS. localStorage['kds_user'] was dropped in favor of localStorage['token'] so POS and KDS share one session. Diff in useKdsConnection.ts lines 295-337. Tell me if you want kds_user back. Anything you want changed before this lands, say the word. |
aae968c to
392edf4
Compare
|
@carvalab I like this a lot. I will review the functionality soon and get back too you. Since we are still keeping the old view in addition to this Kan-ban view, there is no downside to add additional feature as long as it don't conflict with anything else and is lightweight without any external or additional dependencies. |
Kanban previously rendered one card per item, which broke a multi-item order into unrelated tiles. Tabs already group by order, so the kanban now does the same: one card per (order, status) with the order header, table, time, and special instructions, and a list of items inside. Dragging the card updates every item in that group to the new status. A 6 px distance guard replaces the previous 300 ms hold so taps on the card body do not start a drag; tapping an item inside still opens the status modal for partial moves. Item buttons now stop pointerdown and click propagation so tapping an item inside the card opens the modal instead of starting a drag. Per-item special instructions (e.g. "sin carne") render under each kanban item, in the same red italic style tabs uses. They were missing before. Tabs pill row got shrink-0 so the active pill's ring stops overlapping the first card on short viewports. The /pos and /kds dashboard wrapper gets the missing p-4 padding so the active pill ring and the first card border no longer draw under the sidebar icon column. The old ItemCard component is no longer used and was removed.
The kanban branch predated 18 commits on main. Cherry-pick of the original two commits left three loose ends that this commit bundles: - add_kds_default_view migration conflicted with main's v22 (add_customers_phone_digits), so it's renumbered to v26 and the matching test schema-version assertions bump from 25 to 26. - The original KDS pages had a native window.confirm() logout prompt that main replaced with the useConfirm hook; that hook is now re-wired inside useKdsConnection so handleLogout awaits a Promise, and KdsWorkspace renders the returned ConfirmDialog. - The dashboard /kds page uses useServerKdsInfo, which fetches /api/kds/info — an endpoint that only exists on the standalone KDS server (port 3002). The dashboard runs on the main API origin (port 3001), so the fetch 404'd and chefs never saw the admin-set default. Swap it for a small inline hook that hits /api/settings/kds, which lives on the main API.
392edf4 to
91119b9
Compare
Summary
The chef-facing KDS now has two layouts, and you switch between them from a header pill:
The default layout is per tenant and lives in Settings → KDS. A chef can override it for the current session with
localStorage['kds_view_override'].Preview
Architecture
useKdsConnectionis the single hook for both the dashboard and the standalone KDS. It owns the WebSocket lifecycle, falls back to REST polling when the socket is down, handles login, and updates item statuses. It derives the WS host from the axios baseURL, so the dashboard (Next dev on :3000, backend on :3001) reaches the right server in dev.useKdsViewresolves the active view in this order: per-session override, then server default, thentabs.useServerKdsInfoplusfetchServerInfoinlib/i18npull tenant metadata from the publicGET /api/kds/infoendpoint. No auth, so the standalone KDS can paint before login.Auth storage now matches the POS convention.
useKdsConnectionwrites the JWT tolocalStorage['token'], same keystore/auth.tsuses, and rehydrates viaGET /auth/meon mount. The dashboard KDS shareslib/api.tswith the POS, so this is the one token key both layers read.Recent changes
shrink-0so the active pill's ring stops overlapping the first card on short viewports.Backend
kds_default_viewsetting.main/kds-server.tsandmain/services/kds.tsbroadcast order updates to KDS WebSocket subscribers.main/routes/settings.tsexposesGET/PUT /api/kds/default-view.The old
KdsMasonryBoarddemo page is gone. The kanban lives at/kds.