MyNumeri better management and station integration#7
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request significantly refactors the state management and event handling logic in the
Managerpage, 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 usinguseMemo. 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
useStatevariables and refs for orders and station-specific lists with a singleordersMap(Map<string, Order>) as the canonical source of truth. All derived order lists and station mappings are now computed usinguseMemo, 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 onlyordersMap, 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:
useMemoto efficiently computeconfirmedOrders,readyOrders,pickedUpOrders, and all station-level order lists fromordersMapandstations. This eliminates the need for manual synchronization and deduplication logic.API Improvements:
Adds support for
autoScrollPagesEnabledanddisplayZoom(with bounds checking and rounding) in the display config PATCH API.Improves the SSE
/api/events/displayAPI to support theLast-Event-IDheader for event replay, and returns a valid SSE stream with a retry directive if the backend is unreachable, improving client robustness.Other:
useMemoimport toapp/manager/page.tsxto support the new derived state logic.References: