Skip to content

Commit

Permalink
Display fallback for routes without a short name
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardehrenfried committed Nov 7, 2024
1 parent 0b751e5 commit ac64f85
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions client/src/components/ItineraryList/ItineraryLegDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ import { ItineraryGraphiQLLineLink } from './ItineraryGraphiQLLineLink.tsx';
import { ItineraryGraphiQLQuayLink } from './ItineraryGraphiQLQuayLink.tsx';
import { ItineraryGraphiQLAuthorityLink } from './ItineraryGraphiQLAuthorityLink.tsx';

/**
* Some GTFS trips don't have a short name (public code) so we use the long name in this case.
*/
function legName(leg: Leg): string {
if (leg.line?.publicCode) {
return leg.line.publicCode + ' ' + leg.toEstimatedCall?.destinationDisplay?.frontText;
} else {
return leg.line?.name || 'unknown';
}
}
export function ItineraryLegDetails({ leg, isLast }: { leg: Leg; isLast: boolean }) {
return (
<div className="itinerary-leg-details">
Expand All @@ -20,10 +30,7 @@ export function ItineraryLegDetails({ leg, isLast }: { leg: Leg; isLast: boolean
<b>{leg.mode}</b>{' '}
{leg.line && (
<>
<ItineraryGraphiQLLineLink
legId={leg.line?.id}
legName={leg.line.publicCode + ' ' + leg.toEstimatedCall?.destinationDisplay?.frontText}
/>
<ItineraryGraphiQLLineLink legId={leg.line?.id} legName={legName(leg)} />
, <ItineraryGraphiQLAuthorityLink legId={leg.authority?.id} legName={leg.authority?.name} />
</>
)}{' '}
Expand Down

0 comments on commit ac64f85

Please sign in to comment.