11import React from 'react' ;
2- import { FormattedMessage } from 'react-intl' ;
32import cx from 'classnames' ;
43import PlatformNumber from '../PlatformNumber' ;
5- import { modeUsesTrack } from '../../util/modeUtils' ;
4+ import {
5+ getTrackOrPierOrPlatformChangeText ,
6+ getTrackOrPierOrPlatformWithNumText ,
7+ } from '../../util/modeUtils' ;
68import { isPlatformChanged } from '../../util/legUtils' ;
79import { legShape } from '../../util/shapes' ;
810
@@ -25,24 +27,14 @@ function BoardingInformation({ leg }) {
2527 } ) }
2628 >
2729 { comma }
28- { platformChanged ? (
29- < >
30- < FormattedMessage
31- id = { modeUsesTrack ( leg . mode ) ? 'track' : 'platform' }
32- />
33- < PlatformNumber
34- number = { platformCode }
35- updated = { platformChanged }
36- isRailOrSubway = { modeUsesTrack ( leg . mode ) }
37- withText = { false }
38- />
39- </ >
40- ) : (
41- < FormattedMessage
42- id = { modeUsesTrack ( leg . mode ) ? 'track-num' : 'platform-num' }
43- values = { { platformCode } }
44- />
45- ) }
30+ < PlatformNumber
31+ number = { platformCode }
32+ short = { false }
33+ updated = { platformChanged }
34+ mode = { leg . mode }
35+ withText
36+ plain
37+ />
4638 </ span >
4739 ) ;
4840 }
@@ -53,19 +45,6 @@ BoardingInformation.propTypes = {
5345 leg : legShape . isRequired ,
5446} ;
5547
56- /**
57- * Returns a message indicating a platform or track change.
58- * @param {boolean } isTrack - True if the mode uses track, false for platform.
59- * @param {Object } intl - The intl object for formatting messages.
60- * @return {string } The platform change label.
61- */
62- function getPlatformChangeLabel ( isTrack , intl ) {
63- return intl . formatMessage ( {
64- id : isTrack ? 'navigation-track-change' : 'navigation-platform-change' ,
65- defaultMessage : isTrack ? 'Track change' : 'Platform change' ,
66- } ) ;
67- }
68-
6948/**
7049 * Returns a string with platform/track information for a transit leg, for screen reader use.
7150 * @param {Object } leg - The transit leg object.
@@ -78,21 +57,20 @@ function getBoardingInformationText(leg, intl, showPlatformChangeLabel = true) {
7857 }
7958 const platformCode = leg ?. from ?. stop ?. platformCode ;
8059 if ( platformCode ) {
81- const isTrack = modeUsesTrack ( leg . mode ) ;
8260 const platformChangeLabelText =
8361 showPlatformChangeLabel && isPlatformChanged ( leg )
84- ? `${ getPlatformChangeLabel ( isTrack , intl ) } :`
62+ ? `${ getTrackOrPierOrPlatformChangeText ( intl , leg . mode ) } :`
8563 : '' ;
86- const platformLabel = intl . formatMessage (
87- {
88- id : isTrack ? 'track-num' : 'platform-num' ,
89- } ,
90- { platformCode } ,
64+ const platformLabel = getTrackOrPierOrPlatformWithNumText (
65+ intl ,
66+ leg . mode ,
67+ platformCode ,
9168 ) ;
69+
9270 return `${ platformChangeLabelText } ${ platformLabel } ` ;
9371 }
9472 return '' ;
9573}
9674
97- export { getBoardingInformationText , getPlatformChangeLabel } ;
75+ export { getBoardingInformationText } ;
9876export default BoardingInformation ;
0 commit comments