Module 10 Β· Bookings: Forms & the Full Loop β Lesson 4 of 4 Β· ~12 min
The Walker's Side: Closing the Loop
A booking is a tiny state machine
Five statuses, and only a few legal moves between them:
.pendingβacceptβ.confirmed, or βdeclineβ.cancelled.confirmedβstartβ.inProgress.inProgressβcompleteβ.completed.pending/.confirmedβowner cancelβ.cancelled
The backend is the referee β it rejects illegal moves β and the whole client side of it is one APIClient method: transitionBooking(id:action:), which POSTs to /bookings/{id}/{action} where the action string is accept, decline, start, or complete.
Walkers see their walks through a different endpoint, too: assignedBookings() hits /bookings/assigned β the bookings assigned to them, rather than the ones they created. Here's their view model, from the top of WalkerHomeView.swift: