@@ -156,42 +156,58 @@ class RentedVehicleLeg extends PureComponent {
156156 render ( ) {
157157 const { config, leg } = this . props
158158 const configCompanies = config . companies || [ ]
159+
160+ // Sometimes rented vehicles can be walked over things like stairs or other
161+ // ways that forbid the main mode of travel.
159162 if ( leg . mode === 'WALK' ) {
160163 return (
161164 < div className = 'place-subheader' >
162165 Walk vehicle along { leg . from . name }
163166 </ div >
164167 )
165168 }
166- if ( leg . rentedVehicle || leg . rentedBike || leg . rentedCar ) {
167- let pickUpString = 'Pick up'
168- if ( leg . rentedBike ) {
169- // TODO: Special case for TriMet may need to be refactored.
170- pickUpString += ` shared bike`
171- } else {
172- // Add company and vehicle labels.
169+
170+ let pickUpString = 'Pick up'
171+ if ( leg . rentedBike ) {
172+ // TODO: Special case for TriMet may need to be refactored.
173+ pickUpString += ` shared bike`
174+ } else {
175+ // Add company and vehicle labels.
176+ let vehicleName = ''
177+ // TODO allow more flexibility in customizing these mode strings
178+ let modeString = leg . rentedVehicle
179+ ? 'eScooter'
180+ : leg . rentedBike
181+ ? 'bike'
182+ : 'car'
183+
184+ // The networks attribute of the from data will only appear at the very
185+ // beggining of the rental. It is possible that there will be some forced
186+ // walking that occurs in the middle of the rental, so once the main mode
187+ // resumes there won't be any network info. In that case we simply return
188+ // that the rental is continuing.
189+ if ( leg . from . networks ) {
173190 const companies = leg . from . networks . map ( n => getCompanyForNetwork ( n , configCompanies ) )
174191 const companyLabel = companies . map ( co => co . label ) . join ( '/' )
175192 pickUpString += ` ${ companyLabel } `
176- const modeString = getModeForPlace ( leg . from )
177193 // Only show vehicle name for car rentals. For bikes and eScooters, these
178194 // IDs/names tend to be less relevant (or entirely useless) in this context.
179- const vehicleName = leg . rentedCar ? ` ${ leg . from . name } ` : ''
180- pickUpString += ` ${ modeString } ${ vehicleName } `
195+ if ( leg . rentedCar && leg . from . name ) {
196+ vehicleName = leg . from . name
197+ }
198+ modeString = getModeForPlace ( leg . from )
199+ } else {
200+ pickUpString = 'Continue using rental'
181201 }
182- // e.g., Pick up REACHNOW rented car XYZNDB OR
183- // Pick up SPIN eScooter
184- // Pick up shared bike
185- return (
186- < div className = 'place-subheader' >
187- { pickUpString }
188- </ div >
189- )
202+
203+ pickUpString += ` ${ modeString } ${ vehicleName } `
190204 }
191- // FIXME: Under what conditions would this be returned?
205+ // e.g., Pick up REACHNOW rented car XYZNDB OR
206+ // Pick up SPIN eScooter
207+ // Pick up shared bike
192208 return (
193209 < div className = 'place-subheader' >
194- Continue riding from { leg . from . name }
210+ { pickUpString }
195211 </ div >
196212 )
197213 }
0 commit comments