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: