Skip to content

MyNumeri better management and station integration#7

Merged
Spampa merged 9 commits into
mainfrom
development
May 20, 2026
Merged

MyNumeri better management and station integration#7
Spampa merged 9 commits into
mainfrom
development

Conversation

@Spampa
Copy link
Copy Markdown
Contributor

@Spampa Spampa commented May 20, 2026

This pull request significantly refactors the state management and event handling logic in the Manager page, replacing multiple parallel state variables and refs with a single source of truth (ordersMap). It also improves the efficiency and maintainability of derived order lists and station mappings by using useMemo. Additionally, it adds new configuration options to the display config API and enhances the robustness of the SSE event stream API.

State Management Refactor:

  • Replaces multiple useState variables and refs for orders and station-specific lists with a single ordersMap (Map<string, Order>) as the canonical source of truth. All derived order lists and station mappings are now computed using useMemo, reducing complexity and risk of state inconsistency. [1] [2] [3]

  • Refactors all SSE event handlers (confirmed-order, order-status-update, order-station-status-update, order-cancelled) to update only ordersMap, with all UI lists and station mappings updating automatically via derived selectors. Removes all direct mutation of parallel state variables. [1] [2] [3]

Derived Data and Performance Improvements:

  • Uses useMemo to efficiently compute confirmedOrders, readyOrders, pickedUpOrders, and all station-level order lists from ordersMap and stations. This eliminates the need for manual synchronization and deduplication logic.

API Improvements:

  • Adds support for autoScrollPagesEnabled and displayZoom (with bounds checking and rounding) in the display config PATCH API.

  • Improves the SSE /api/events/display API to support the Last-Event-ID header for event replay, and returns a valid SSE stream with a retry directive if the backend is unreachable, improving client robustness.

Other:

  • Adds useMemo import to app/manager/page.tsx to support the new derived state logic.

References:

  • State management refactor and derived data: [1] [2] [3] [4] [5] [6]
  • Display config PATCH API:
  • SSE API improvements:
  • Import change:

@Spampa Spampa merged commit 36fc73f into main May 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant