Order Status Types
The application defines seven distinct order statuses:domain/order/order-status.ts
Status Definitions
RECEIVED
RECEIVED
RECEIVED - The initial status when a new order is created and received by the kitchen.Characteristics:
- First status in the order lifecycle
- Indicates the order has been placed but not yet acknowledged
- Usually displayed in the first column of the Kanban board
- →
CONFIRMED(order acknowledged by kitchen) - →
CANCELLED(order rejected or cancelled)
CONFIRMED
CONFIRMED
CONFIRMED - The order has been acknowledged by the kitchen staff and is queued for preparation.Characteristics:
- Kitchen has accepted the order
- Order is in the queue, waiting to be prepared
- Customer is notified that their order is confirmed
- →
PREPARING(kitchen starts preparing) - →
CANCELLED(order cancelled before preparation)
PREPARING
PREPARING
PREPARING - The kitchen is actively preparing the order.Characteristics:
- Food is being cooked/assembled
- Most active phase in the kitchen
- Cannot be moved backward to previous statuses
- →
READY(preparation complete) - →
CANCELLED(order cancelled during preparation)
READY
READY
READY - The order is complete and ready for pickup by the delivery courier.Characteristics:
- Food is prepared and packaged
- Waiting for courier to pick up
- Time-sensitive status (food should be picked up quickly)
- →
PICKED_UP(courier collects the order) - →
CANCELLED(order not picked up or cancelled)
PICKED_UP
PICKED_UP
PICKED_UP - The courier has collected the order and is on the way to deliver it.Characteristics:
- Order is in transit
- Assigned to a specific courier
- Customer can track delivery progress
- Displayed in the Riders section
- →
DELIVERED(order successfully delivered)
DELIVERED
DELIVERED
DELIVERED - The order has been successfully delivered to the customer.Characteristics:
- Final successful status
- Order lifecycle complete
- No further transitions possible
- None (terminal status)
CANCELLED
CANCELLED
CANCELLED - The order was cancelled before completion.Characteristics:
- Terminal status (like DELIVERED)
- Can be reached from any status except PICKED_UP and DELIVERED
- Requires handling refunds and notifications
- None (terminal status)
Status Transition Rules
The application enforces strict rules about which status transitions are allowed. These rules are defined in the domain layer:domain/order/order-transitions.ts
Transition Validation
ThecanTransition function is used throughout the application to validate status changes:
components/Kanban/Kanban.tsx
Transition Flow Diagram
CONFIRMED
Kitchen acknowledges the orderNext Steps:
- Start preparation →
PREPARING - Cancel before prep →
CANCELLED
PREPARING
Kitchen is actively working on the orderNext Steps:
- Complete preparation →
READY - Cancel during prep →
CANCELLED
READY
Order is ready for pickupNext Steps:
- Courier picks up →
PICKED_UP - Cancel if not picked up →
CANCELLED
Status Labels
The UI displays human-friendly labels for each status:components/order/constants/order-status-labels.ts
Implementation Examples
- Updating Status
- Status Validation
- Repository Implementation
- Real-time Updates
Updating Order Status
To update an order’s status, use theupdateOrderStatus method from the Orders context:The
updateOrderStatus method performs optimistic updates, immediately reflecting the change in the UI before the server confirms it.Terminal Statuses
Two statuses are terminal, meaning they are the end of an order’s lifecycle:DELIVERED
Successful completion of the order
- Customer received their food
- Payment processed
- Order archived
CANCELLED
Order was cancelled before delivery
- Refund may be issued
- Kitchen stops preparation
- Customer notified
Best Practices
Always Validate Transitions
Always Validate Transitions
Before updating an order status, always use the
canTransition function to ensure the transition is valid:Handle Errors Gracefully
Handle Errors Gracefully
Status updates can fail due to network issues or validation errors. Always handle errors and provide feedback to users:
Use Optimistic Updates
Use Optimistic Updates
The Orders context implements optimistic updates to provide immediate feedback while the server processes the request:
Respect Terminal Statuses
Respect Terminal Statuses
Never attempt to transition from
DELIVERED or CANCELLED statuses. These are final states:Related Concepts
Architecture
Learn about the layered architecture
Real-time Sync
Understand WebSocket synchronization
Order Repository
API reference for order operations