For a real-time dashboard, the data needs to stay fresh. When a staff member changes an order status, customers watching the display should see it update automatically. The Zone component combined with useInterval creates this "live" experience - just like how airport departure boards constantly refresh to show the latest flight information.
Let's look at how to control the display with props and automatic refresh:
The Unit component now accepts a showControls prop that determines whether to display action buttons. This simple flag allows the same card component to be used in both staff management views (with controls) and customer dashboard views (without controls).
Now let's see how the Zone component manages automatic data refresh:
Let's understand the key features of this Zone component:
⏱️useInterval
The useInterval hook refreshes the slice data every 3 seconds. This ensures the dashboard stays current without manual user interaction - perfect for displays that need to show live order status.
🔄refreshIcecreamOrder
The refresh function is automatically generated for each slice. It re-queries the data using the same conditions defined in the slice, ensuring consistent data fetching.
📋Load.Units
Load.Units handles rendering a list of items with proper loading states. It automatically manages the mapping from slice data to individual Unit cards.