(fare: RouteFare)
| 113 | } |
| 114 | |
| 115 | const handleStartTrip = async (fare: RouteFare) => { |
| 116 | const payload = { |
| 117 | rideFareID: fare.id, |
| 118 | userID: userID, |
| 119 | } as HTTPTripStartRequestPayload |
| 120 | |
| 121 | if (!fare.id) { |
| 122 | alert("No Fare ID in the payload") |
| 123 | return |
| 124 | } |
| 125 | |
| 126 | const response = await fetch(`${API_URL}${BackendEndpoints.START_TRIP}`, { |
| 127 | method: 'POST', |
| 128 | body: JSON.stringify(payload), |
| 129 | }) |
| 130 | const data = await response.json() as HTTPTripStartResponse |
| 131 | |
| 132 | if (response.ok && trip) { |
| 133 | setTrip((prev) => ({ |
| 134 | ...prev, |
| 135 | tripID: data.tripID, |
| 136 | } as TripPreview)) |
| 137 | |
| 138 | } |
| 139 | |
| 140 | return data |
| 141 | } |
| 142 | |
| 143 | const handleCancelTrip = () => { |
| 144 | setTrip(null) |
nothing calls this directly
no outgoing calls
no test coverage detected