@@ -5,11 +5,31 @@ import { VelocityTransitionGroup } from 'velocity-react'
5
5
import moment from 'moment'
6
6
7
7
import { calculateFares , calculatePhysicalActivity , getTimeZoneOffset } from '../../util/itinerary'
8
+ import { mergeMessages } from '../../util/messages'
8
9
import { formatTime , getTimeFormat , getLongDateFormat } from '../../util/time'
9
10
10
11
class 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
+
11
30
render ( ) {
12
31
const { itinerary, timeFormat, longDateFormat } = this . props
32
+ const messages = mergeMessages ( TripDetails . defaultProps , this . props )
13
33
const date = moment ( itinerary . startTime )
14
34
15
35
// process the transit fare
@@ -25,15 +45,16 @@ class TripDetails extends Component {
25
45
fare = (
26
46
< span >
27
47
{ transitFare && (
28
- < span > Transit Fare : < b > { centsToString ( transitFare ) } </ b > </ span >
48
+ < span > { messages . transitFare } : < b > { centsToString ( transitFare ) } </ b > </ span >
29
49
) }
30
50
{ minTNCFare !== 0 && (
31
51
< span >
32
52
< br />
33
53
< span style = { { textTransform : 'capitalize' } } >
34
54
{ companies . toLowerCase ( ) }
35
55
</ span > { ' ' }
36
- Fare: < b > { dollarsToString ( minTNCFare ) } - { dollarsToString ( maxTNCFare ) } </ b >
56
+ { messages . fare } :{ ' ' }
57
+ < b > { dollarsToString ( minTNCFare ) } - { dollarsToString ( maxTNCFare ) } </ b >
37
58
</ span >
38
59
) }
39
60
</ span >
@@ -50,27 +71,36 @@ class TripDetails extends Component {
50
71
51
72
return (
52
73
< div className = 'trip-details' >
53
- < div className = 'trip-details-header' > Trip Details </ div >
74
+ < div className = 'trip-details-header' > { messages . title } </ div >
54
75
< div className = 'trip-details-body' >
55
76
< TripDetail
77
+ description = { messages . departDescription }
56
78
icon = { < i className = 'fa fa-calendar' /> }
57
79
summary = {
58
80
< 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
+ }
61
88
</ span >
62
89
}
63
90
/>
64
91
{ fare && (
65
92
< TripDetail
93
+ description = { messages . transitFareDescription }
66
94
icon = { < i className = 'fa fa-money' /> }
67
95
summary = { fare }
68
96
/>
69
97
) }
70
98
{ caloriesBurned > 0 && (
71
99
< TripDetail
72
100
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.
74
104
description = {
75
105
< span >
76
106
Calories burned is based on < b > { Math . round ( walkDuration / 60 ) } minute(s)</ b > { ' ' }
@@ -147,6 +177,7 @@ class TripDetail extends Component {
147
177
148
178
const mapStateToProps = ( state , ownProps ) => {
149
179
return {
180
+ messages : state . otp . config . language . tripDetails ,
150
181
routingType : state . otp . currentQuery . routingType ,
151
182
tnc : state . otp . tnc ,
152
183
timeFormat : getTimeFormat ( state . otp . config ) ,
0 commit comments