MCPcopy Create free account
hub / github.com/codealong-dev/ride-sharing / handleStartTrip

Function handleStartTrip

web/src/components/RiderMap.tsx:115–141  ·  view source on GitHub ↗
(fare: RouteFare)

Source from the content-addressed store, hash-verified

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)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected