How Trip Offers Work
When a passenger requests a ride, the system matches them with available drivers based on proximity and other factors. If you’re selected, you’ll receive a trip offer modal with all the trip details.Trip offers expire after a countdown timer (typically 20 seconds). You must respond before the timer runs out.
Understanding the Trip Offer Modal
When you receive a trip offer, a modal window appears with the following information:Countdown Timer
At the top of the modal, you’ll see a timer showing how many seconds you have to respond. The timer appears as:The timer counts down in real-time. If it reaches 0, the offer expires automatically.
Trip Summary
The modal displays key trip metrics:
- Distance: Total distance from pickup to destination (e.g., “5.2 km”)
- Duration: Estimated trip duration (e.g., “12 min”)
Route Information
The pickup and dropoff locations are clearly marked:
- Origin (🧭 icon): Where you’ll pick up the passenger
- Destination (📍 icon): Where you’ll drop off the passenger
Accepting a Trip Offer
To accept a trip offer:Review the Details
Quickly review the pickup location, destination, distance, and fare to ensure you want to take this trip.
What Happens After Accepting
From the code intrip.facade.ts:140-174, when you accept an offer:
- The countdown timer stops
- The system calls the backend API to confirm acceptance
- Your trip data refreshes to show the latest information
- The assignment is marked as handled to prevent duplicate offers
- Your phase changes to “assigned”
- You’re redirected to the active trip screen
Declining a Trip Offer
If you don’t want to accept a particular trip:Offer Expiration
If you don’t respond within the countdown period:- The offer automatically expires when the timer reaches 0 seconds
- The modal closes automatically with a “timeout” status
- The trip is offered to another driver
- You remain available for new trip offers
The system prevents duplicate offers by tracking handled assignments using
markAssignmentHandled() with the unique assignmentId.Technical Details
Countdown Mechanism
The countdown timer works by:- Receiving an
expiresAtISO timestamp orttlSecvalue from the server - Calculating remaining seconds:
(expiresAt - now) / 1000 - Ticking down every second using RxJS
interval(1000) - Auto-closing the modal when reaching 0
trip.facade.ts:499-524:
State Management
The app uses a centralized store to manage trip state. When an offer arrives:phaseis set to'assigned'activeTripIdis updated with the trip IDofferAssignmentIdstores the unique assignment identifier- The trip data is refreshed via
refreshTrip()
Troubleshooting
The modal doesn't appear when I receive an offer
The modal doesn't appear when I receive an offer
This can happen if:
- You’re not in
idlephase (already on a trip) - The assignment was already handled (duplicate prevention)
- Your app lost connection to the WebSocket server
Buttons are disabled when the timer is still running
Buttons are disabled when the timer is still running
I accepted but nothing happened
I accepted but nothing happened
If the accept action fails:
- Check your internet connection
- The trip may have been assigned to another driver
- An error message should appear in the UI from
store.setError()
Best Practices
Respond Quickly
Try to respond within the first 10 seconds to ensure you don’t miss opportunities.
Check the Route
Always verify the pickup location is within a reasonable distance before accepting.
Monitor Your Phase
You’ll only receive offers when in
idle phase. Complete or cancel current trips to receive new ones.Stay Connected
Offers arrive via WebSocket. A stable internet connection ensures you don’t miss trip requests.
Related Topics
- Managing Your Availability - Learn how to go online/offline
- Trip Management - Complete trip lifecycle and phases
- Real-Time Updates - WebSocket events for trip offers