@@ -5,11 +5,31 @@ import { VelocityTransitionGroup } from 'velocity-react'
55import moment from 'moment'
66
77import { calculateFares , calculatePhysicalActivity , getTimeZoneOffset } from '../../util/itinerary'
8+ import { mergeMessages } from '../../util/messages'
89import { formatTime , getTimeFormat , getLongDateFormat } from '../../util/time'
910
1011class TripDetails extends Component {
12+ static defaultProps = {
13+ // Note: messages with default null values included here for visibility.
14+ // Overriding with a truthy string value will cause the expandable help
15+ // message to appear in trip details.
16+ messages : {
17+ at : 'at' ,
18+ caloriesBurned : 'Calories Burned' ,
19+ // FIXME: Add templated string description.
20+ caloriesBurnedDescription : null ,
21+ depart : 'Depart' ,
22+ departDescription : null ,
23+ title : 'Trip Details' ,
24+ fare : 'Fare' ,
25+ transitFare : 'Transit Fare' ,
26+ transitFareDescription : null
27+ }
28+ }
29+
1130 render ( ) {
1231 const { itinerary, timeFormat, longDateFormat } = this . props
32+ const messages = mergeMessages ( TripDetails . defaultProps , this . props )
1333 const date = moment ( itinerary . startTime )
1434
1535 // process the transit fare
@@ -25,15 +45,16 @@ class TripDetails extends Component {
2545 fare = (
2646 < span >
2747 { transitFare && (
28- < span > Transit Fare : < b > { centsToString ( transitFare ) } </ b > </ span >
48+ < span > { messages . transitFare } : < b > { centsToString ( transitFare ) } </ b > </ span >
2949 ) }
3050 { minTNCFare !== 0 && (
3151 < span >
3252 < br />
3353 < span style = { { textTransform : 'capitalize' } } >
3454 { companies . toLowerCase ( ) }
3555 </ span > { ' ' }
36- Fare: < b > { dollarsToString ( minTNCFare ) } - { dollarsToString ( maxTNCFare ) } </ b >
56+ { messages . fare } :{ ' ' }
57+ < b > { dollarsToString ( minTNCFare ) } - { dollarsToString ( maxTNCFare ) } </ b >
3758 </ span >
3859 ) }
3960 </ span >
@@ -50,27 +71,36 @@ class TripDetails extends Component {
5071
5172 return (
5273 < div className = 'trip-details' >
53- < div className = 'trip-details-header' > Trip Details </ div >
74+ < div className = 'trip-details-header' > { messages . title } </ div >
5475 < div className = 'trip-details-body' >
5576 < TripDetail
77+ description = { messages . departDescription }
5678 icon = { < i className = 'fa fa-calendar' /> }
5779 summary = {
5880 < span >
59- < span > Depart < b > { date . format ( longDateFormat ) } </ b > </ span >
60- { this . props . routingType === 'ITINERARY' && < span > at < b > { formatTime ( itinerary . startTime , timeOptions ) } </ b > </ span > }
81+ < span > { messages . depart } < b > { date . format ( longDateFormat ) } </ b > </ span >
82+ { this . props . routingType === 'ITINERARY' &&
83+ < span >
84+ { ' ' } { messages . at } { ' ' }
85+ < b > { formatTime ( itinerary . startTime , timeOptions ) } </ b >
86+ </ span >
87+ }
6188 </ span >
6289 }
6390 />
6491 { fare && (
6592 < TripDetail
93+ description = { messages . transitFareDescription }
6694 icon = { < i className = 'fa fa-money' /> }
6795 summary = { fare }
6896 />
6997 ) }
7098 { caloriesBurned > 0 && (
7199 < TripDetail
72100 icon = { < i className = 'fa fa-heartbeat' /> }
73- summary = { < span > Calories Burned: < b > { Math . round ( caloriesBurned ) } </ b > </ span > }
101+ summary = { < span > { messages . caloriesBurned } : < b > { Math . round ( caloriesBurned ) } </ b > </ span > }
102+ // FIXME: Come up with a way to replace the caloriesBurnedDescription text with
103+ // templated strings.
74104 description = {
75105 < span >
76106 Calories burned is based on < b > { Math . round ( walkDuration / 60 ) } minute(s)</ b > { ' ' }
@@ -147,6 +177,7 @@ class TripDetail extends Component {
147177
148178const mapStateToProps = ( state , ownProps ) => {
149179 return {
180+ messages : state . otp . config . language . tripDetails ,
150181 routingType : state . otp . currentQuery . routingType ,
151182 tnc : state . otp . tnc ,
152183 timeFormat : getTimeFormat ( state . otp . config ) ,
0 commit comments