Skip to content

Commit

Permalink
ensure that situation icon is only being displayed during the correct…
Browse files Browse the repository at this point in the history
… period of time. (#453)
  • Loading branch information
jonasbrunvoll authored Nov 25, 2024
1 parent 9cf3aab commit d6462c8
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import { formatTripDuration } from '@atb/utils/date';
import { flatMap } from 'lodash';
import { getNoticesForLeg } from './utils';
import { RailReplacementBusMessage } from './rail-replacement-bus';
import { SituationOrNoticeIcon } from '@atb/modules/situations';
import {
isSituationValidAtDate,
SituationOrNoticeIcon,
} from '@atb/modules/situations';
import { isSubModeBoat } from '@atb/modules/transport-mode';
import { ColorIcon } from '@atb/components/icon';

Expand All @@ -28,6 +31,9 @@ export function TripPatternHeader({
);

const startModeAndPlaceText = getStartModeAndPlaceText(tripPattern, t);
const situations = flatMap(tripPattern.legs, (leg) => leg.situations).filter(
isSituationValidAtDate(new Date()),
);

return (
<header className={style.header}>
Expand All @@ -52,7 +58,7 @@ export function TripPatternHeader({
<RailReplacementBusMessage tripPattern={tripPattern} />

<SituationOrNoticeIcon
situations={flatMap(tripPattern.legs, (leg) => leg.situations)}
situations={situations}
notices={flatMap(tripPattern.legs, getNoticesForLeg)}
accessibilityLabel={startModeAndPlaceText}
cancellation={isCancelled}
Expand Down

0 comments on commit d6462c8

Please sign in to comment.