Skip to content

Commit

Permalink
correct showScheduleDeviation, enable flex
Browse files Browse the repository at this point in the history
  • Loading branch information
miles-grant-ibigroup committed Jan 30, 2025
1 parent 12e76dd commit 13b3026
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
3 changes: 2 additions & 1 deletion lib/components/narrative/line-itin/realtime-time-column.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FormattedTime } from 'react-intl'
import { isTransitLeg } from '@opentripplanner/core-utils/lib/itinerary'
import { isFlex, isTransitLeg } from '@opentripplanner/core-utils/lib/itinerary'
import { Leg } from '@opentripplanner/types'
import React, { ReactElement } from 'react'
import styled from 'styled-components'
Expand Down Expand Up @@ -50,6 +50,7 @@ function RealtimeTimeColumn({ isDestination, leg }: Props): ReactElement {
return (
<StyledStatusLabel
delay={delaySeconds}
isFlex={isFlex(leg)}
isRealtime={isRealtimeTransitLeg}
originalTime={originalTimeMillis}
time={timeMillis}
Expand Down
2 changes: 1 addition & 1 deletion lib/components/util/formatted-realtime-status-label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const FormattedRealtimeStatusLabel = ({
case 'scheduled':
return <FormattedMessage id="components.RealtimeStatusLabel.scheduled" />
default:
return null
return minutes
}
}

Expand Down
12 changes: 8 additions & 4 deletions lib/components/viewers/realtime-status-label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const STATUS = {
const RealtimeStatusLabel = ({
className,
delay,
isFlex = false,
isRealtime,
onTimeThresholdSeconds,
originalTime,
Expand All @@ -74,6 +75,7 @@ const RealtimeStatusLabel = ({
}: {
className?: string
delay: number
isFlex: boolean
isRealtime?: boolean
onTimeThresholdSeconds?: number
originalTime?: number
Expand Down Expand Up @@ -125,7 +127,9 @@ const RealtimeStatusLabel = ({
{showScheduleDeviation && (
<FormattedRealtimeStatusLabel
minutes={
isEarlyOrLate ? (
isFlex ? (
<FormattedMessage id="config.flex.flex-service" />
) : isEarlyOrLate ? (
<DelayText>
<FormattedDuration
duration={Math.abs(delay)}
Expand All @@ -137,10 +141,10 @@ const RealtimeStatusLabel = ({
)
}
// @ts-ignore getTripStatus is not typed yet
status={STATUS[status].label}
status={!isFlex && STATUS[status].label}
/>
)}
{isEarlyOrLate && (
{isEarlyOrLate && !isFlex && (
<InvisibleAdditionalDetails>
<FormattedMessage
id="components.MetroUI.originallyScheduledTime"
Expand All @@ -159,7 +163,7 @@ const RealtimeStatusLabel = ({

const mapStateToProps = (state: AppReduxState) => ({
onTimeThresholdSeconds: state.otp.config.onTimeThresholdSeconds,
showScheduleDeviation: state.otp.config.showScheduleDeviation
showScheduleDeviation: state.otp.config?.itinerary?.showScheduleDeviation
})

export default connect(mapStateToProps)(RealtimeStatusLabel)
4 changes: 2 additions & 2 deletions lib/util/config-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,8 @@ export interface ItineraryConfig {
showLegDurations?: boolean
showPlanFirstLastButtons?: boolean
showRouteFares?: boolean
/** Whether to show the x minutes late/early in the itinerary body */
showScheduleDeviation?: boolean
sortModes?: ItinerarySortOption[]
syncSortWithDepartArrive?: boolean
weights?: ItineraryCostWeights
Expand Down Expand Up @@ -423,8 +425,6 @@ export interface AppConfig {
routeViewer?: RouteViewerConfig
/** Approx delay in seconds to reset the UI to an initial URL if there is no user activity */
sessionTimeoutSeconds?: number
/** Whether to show the x minutes late/early in the itinerary body */
showScheduleDeviation?: boolean
stopViewer?: StopScheduleViewerConfig
/** Externally hosted terms of service URL */
termsOfServiceLink?: string
Expand Down

0 comments on commit 13b3026

Please sign in to comment.