Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove use of isTransit() function #1267

Open
wants to merge 8 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/components/narrative/default/itinerary-description.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function ItineraryDescription({ itinerary }: Props): JSX.Element {
let transitMode
itinerary.legs.forEach((leg) => {
const { duration, mode, rentedBike, rentedVehicle } = leg
if (isTransit(mode) && duration > primaryTransitDuration) {
if (leg.transitLeg && duration > primaryTransitDuration) {
primaryTransitDuration = duration

// If custom TransitModes have been defined for the given mode/leg, attempt to use them,
Expand Down
12 changes: 8 additions & 4 deletions lib/components/narrative/line-itin/LegIconWithA11y.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Leg } from '@opentripplanner/types'

import { getFormattedMode } from '../../../util/i18n'
import coreUtils from '@opentripplanner/core-utils'
import InvisibleA11yLabel from '../../util/invisible-a11y-label'
Expand All @@ -8,15 +10,17 @@ import { ComponentContext } from '../../../util/contexts'

import { useIntl } from 'react-intl'

const { isTransit } = coreUtils.itinerary
type Props = {
leg: Leg
}

const LegIconWithA11y = (props: any) => {
const LegIconWithA11y = (props: Props): JSX.Element => {
// @ts-expect-error No type on ComponentContext
const { LegIcon } = useContext(ComponentContext)
const intl = useIntl()
const { leg } = props
const { mode } = leg
const ariaLabel = isTransit(mode) ? getFormattedMode(mode, intl) : null
const { mode, transitLeg } = leg
const ariaLabel = transitLeg ? getFormattedMode(mode, intl) : null
daniel-heppner-ibigroup marked this conversation as resolved.
Show resolved Hide resolved
return (
<>
<LegIcon {...props} />
Expand Down
247 changes: 0 additions & 247 deletions lib/components/narrative/line-itin/itin-summary.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function RealtimeTimeColumn({ isDestination, leg }: Props): ReactElement {
}

const timeMillis = isDestination ? leg.endTime : leg.startTime
const isTransitLeg = isTransit(leg.mode)
const isTransitLeg = leg.transitLeg
const isRealtimeTransitLeg = isTransitLeg && leg.realTime

// For non-transit legs show only the scheduled time.
Expand Down
2 changes: 1 addition & 1 deletion lib/util/itinerary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ export function getTotalFare(
) {
hasBikeshare = true
}
if (coreUtils.itinerary.isTransit(leg.mode) && transitFare == null) {
if (leg.transitLeg && transitFare == null) {
transitFareNotProvided = true
}
})
Expand Down
Loading