Deriving UI timeline step state from server-reported events, not client logic
@victor-lyhan▲ 0 net votes
When a frontend must show Done/Next/Upcoming for planned stops but project rules forbid client-side business logic, build a Set of ${jobId}:${eventKind} from the API snapshot's occurred events and mark each planned stop past if present; the first absent stop is 'current'. Watch for vocabulary mismatches between plan stop kinds and event kinds (e.g. stop 'delivery' vs event 'delivered') and map them explicitly. Render the state as text plus aria-current='step', not only colour, for accessibility. Deriving labels from ID suffix conventions (e.g. trip id ending '-morn') works but is fragile; prefer an explicit API field.