Repository navigation
feat(display): add order filter and POS controls - #1531
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
|
ⓘ Your Qodo trial ends soon. Ask your workspace admin to set up billing to keep reviews running after the trial. Manage billing |
PR Summary by QodoFilter customer display order types and add POS pickup controls
AI Description
Diagram
High-Level Assessment
Files changed (50)
|
Code Review by Qodo
1. Every paid order clogs the POS Active tab without KDS
|
bd58d1a to
de72852
Compare
…plete, and KDS permission
de72852 to
9aa3dea
Compare
Fixes #1523
Intent
Build the Customer Display Order-Type Filter and POS Ready/Picked-Up Controls so that:
What Changed
order_typesfilter (takeaway,dine_in,online,delivery, defaulting to['takeaway']) to Customer Display configuration, settings UI (CustomerDisplayCard),GET /api/customer-display/feed, andGET /api/ordersmulti-type query filtering (type=takeaway,dine_in) so board pagination and projection filter eligible order types in SQL.completedorders with unserved live items in active order views and Customer Display projections regardless of whether KDS is enabled, and updatedPATCH /api/orders/:id/statusforreadyandservedtransitions to advance activeorder_itemswhile preserving terminalcompletedorder status.getOrderEffectivePrepStatusand Mark Ready / Picked Up controls on the POS Orders list and detail panel (OrderCard,OrderDetailPanel,OrdersMasterList) with localized labels across all supported locales.Risk Assessment
✅ Low: Customer display order-type filtering, POS ready/picked-up controls, pre-pagination SQL filtering, item catch-up transitions, and documentation contracts are cleanly implemented and verified across backend, frontend, and test suites.
Testing
Ran focused backend suites (
test:customer-display-config,test:customer-display-settings-route,test:customer-display-feed, andtest:orders-search), built the backend and static frontend, and drove the full browser E2E scenarios infrontend/e2e/customer-display-kds-readiness.spec.tsagainst an isolated server instance on ports 43001-43003, capturing 6 visual screenshots in the evidence directory; after fixing a prior-section fixture leak intests/customer-display-feed.test.tsand a falseselectedOrderNotInCurrentListbanner inhandleUpdateOrderPrepStatus, all scenarios and checks passed.Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 3 issues found → auto-fixed ✅
main/routes/orders.ts:3587- InPATCH /api/orders/:id/status,isSameOrderState(main/routes/orders.ts:3587-3594) explicitly excludes(currentOrder.status === 'ready' && status === 'ready' && hasPendingOrPreparingItems)and(currentOrder.status === 'served' && status === 'served' && hasActivePickupItems)so unadvancedorder_itemscan catch up when an active order has pending/preparing/ready lines (for example afterPOST /api/orders/:id/itemsappends apendingitem whilekds_enabled = 'false'). However,VALID_TRANSITIONS[currentOrder.status](main/routes/orders.ts:3616-3623) never includescurrentOrder.statusandcanTransitionCompletedPreparation(main/routes/orders.ts:3625-3634) only checkscurrentOrder.status === 'completed', so any request that bypassesisSameOrderStatevia those two conditions immediately throws400 Cannot transition order status from 'ready' to 'ready'(or'served' to 'served') atmain/routes/orders.ts:3636-3643. Conversely, whencurrentOrder.status === 'completed'and all active items are already'served',projectBoardStatusFromItemsreturnsnull, so repeatingPATCH /api/orders/:id/statuswith{ status: 'served' }is neither matched byisSameOrderState(main/routes/orders.ts:3591-3593, which only checksstatus === 'ready') nor allowed bycanTransitionCompletedPreparation, throwing400instead of returning an idempotent200. Sibling site:getOrderEffectivePrepStatus(shared/order-item-status.ts:180-185) only callsprojectBoardStatusFromItems(order.items)whenorder.status === 'completed', so if a newpendingitem is appended/restored onto areadyorservedactive order while KDS is disabled, the POS/orderspage continues showingPicked Up(or no button forserved) instead ofMark Readyuntil the order is settled tocompleted.main/routes/orders.ts:821- The paired Customer Display feed (main/services/customer-display-tokens.ts:406-411) passesorderTypes: config.order_typesintoselectBoardEligibleOrderPageso excluded order types (dine_in,delivery,onlineby default) are filtered in SQL before pagination. On the signed-in Customer Display path, however,fetchSignedInBoardOrders(frontend/src/lib/customer-display.ts:161-178) does not pass the configuredorder_typestoGET /api/orders, andmain/routes/orders.ts:818-824(plus siblingmain/routes/orders.ts:848-853) hardcodesCUSTOMER_DISPLAY_ORDER_TYPES(all four order types) when callingselectBoardEligibleOrderPageandcollectProjectedCompletedOrderIds. Because<24hcompletedorders with unserved items are now included even whenkds_enabled = 'false'(where every paiddine_in,delivery, oronlineorder retainsorder_items.status = 'pending'), excluded order types consumeGET /api/orderspage slots and server-sidebatchHydrateOrderswork beforefetchSignedInBoardOrdersdiscards them on the client, increasing poll page count and hiding older eligibletakeawayorders once 5,000 excluded-type rows sit ahead of them. Pass the configured board order types toGET /api/ordersand filter by them inselectBoardEligibleOrderPage/collectProjectedCompletedOrderIdsbefore pagination.docs/architecture/frontend.md:222-docs/architecture/frontend.md:222-238introduces a duplicate### Customer Display board filtering and POS pickup controlssubsection under## State managementinstead of updating the canonical## Customer displaysection atdocs/architecture/frontend.md:595-633(wheredocs/architecture/frontend.md:608still states that the config only sets which statuses show, the refresh interval, and whether the last-updated time is shown). Sibling documentation sites with stale contracts from this change:docs/architecture/order-lifecycle.md:424-434still states that<24hcompletedorders with unfinished live items remain inGET /api/orders?view=active,GET /api/orders?status=active, and/customer-displayonly "When KDS is enabled" and omitsPATCH /api/orders/:id/status(ready/served) oncompletedorders;docs/reference/api.md:650-651omitsorder_typesfromGET /api/settings/customer-displayandPUT /api/settings/customer-display; anddocs/reference/api.md:327still states thatcompletedis unconditionally terminal onPATCH /api/orders/:id/status.🔧 Fix applied.
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
npm run test:customer-display-confignpm run test:customer-display-settings-routenpm run test:customer-display-feednpm run test:orders-searchnpm run build && npm run build:frontendcd frontend && E2E_BASE_URL=http://127.0.0.1:43001 E2E_KDS_BASE_URL=http://127.0.0.1:43002 E2E_SERVER_APP_BASE_URL=http://127.0.0.1:43003 FLO_E2E_EVIDENCE_DIR=~/.no-mistakes/evidence/01M6YKM0CCKHGTSSW8J47YY4ET npx playwright test e2e/customer-display-kds-readiness.spec.ts --config=playwright.config.ts --project=chromium✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.