Claiming Orders
Staccato uses an exclusive claim system where each order is assigned to exactly one staff member.
Claim Flow
- Staff sees a
pendingorder in the queue - Taps “Claim” button
OrderQueueService.claimOrder(orderId:):- Verifies the order is still
pending - Verifies no one else has claimed it (
assigned_tois null) - Sets
statustoin_progress - Sets
assigned_toto the current user’s ID - Sets
claimed_atto the current timestamp
- Verifies the order is still
- Order moves to the “In Progress” section
Validation Rules
| Check | Error |
|---|---|
| Order already claimed by another staff member | orderAlreadyClaimed |
Order status is not pending | invalidStatusTransition |
| User is not authenticated | notAuthenticated |
Unclaiming
Staff can release an order back to the queue:
- Tap the unclaim action on a claimed order
OrderQueueService.unclaimOrder(orderId:):- Verifies the order is assigned to the current user
- Sets
statusback topending - Sets
assigned_totonull - Sets
claimed_attonull
- Order returns to the “Pending” section
Only the staff member who claimed the order can unclaim it.
Database Updates
-- Claim: sets assigned_to and status
UPDATE orders SET
status = 'in_progress',
assigned_to = 'staff-user-id',
claimed_at = NOW()
WHERE id = 'order-id';
-- Unclaim: resets to pending
UPDATE orders SET
status = 'pending',
assigned_to = NULL,
claimed_at = NULL
WHERE id = 'order-id';