Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Display fallback for routes without a short name
Browse files Browse the repository at this point in the history
leonardehrenfried committed Nov 7, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
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
@@ -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">
@@ -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} />
</>
)}{' '}

0 comments on commit ac64f85

Please sign in to comment.