1
- import {
2
- getDateFormat ,
3
- getLongDateFormat ,
4
- getTimeFormat
5
- } from '@opentripplanner/core-utils/lib/time'
6
- import AlertsBody from '@opentripplanner/itinerary-body/lib/TransitLegBody/alerts-body'
7
- import React from 'react'
1
+ /* eslint-disable react/prop-types */
8
2
import { Button , Glyphicon , Panel } from 'react-bootstrap'
9
- import { injectIntl , FormattedMessage } from 'react-intl'
10
3
import { connect } from 'react-redux'
4
+ import { FormattedMessage , injectIntl } from 'react-intl'
5
+ import AlertsBody from '@opentripplanner/itinerary-body/lib/TransitLegBody/alerts-body'
6
+ import React from 'react'
11
7
import styled from 'styled-components'
12
8
13
9
import {
@@ -23,25 +19,24 @@ const StyledFooterButton = styled(Button)`
23
19
margin-right: 10px;
24
20
`
25
21
26
- export function FooterButton ( { bsStyle, glyphIcon, onClick, text } ) {
22
+ export function FooterButton ( { bsStyle, glyphIcon, onClick, text } ) {
27
23
return (
28
24
< StyledFooterButton bsStyle = { bsStyle } onClick = { onClick } >
29
25
< Glyphicon glyph = { glyphIcon } /> { text }
30
26
</ StyledFooterButton >
31
27
)
32
28
}
33
29
34
- function MonitoredTripAlerts ( { alerts, longDateFormat , timeFormat } ) {
30
+ function MonitoredTripAlerts ( { alerts } ) {
35
31
return (
36
32
< Panel . Body >
37
33
< h4 >
38
- < FormattedMessage id = 'components.TripStatus.alerts' values = { { alerts : alerts . length } } />
34
+ < FormattedMessage
35
+ id = "components.TripStatus.alerts"
36
+ values = { { alerts : alerts . length } }
37
+ />
39
38
</ h4 >
40
- < AlertsBody
41
- alerts = { alerts }
42
- longDateFormat = { longDateFormat }
43
- timeFormat = { timeFormat }
44
- />
39
+ < AlertsBody alerts = { alerts } />
45
40
</ Panel . Body >
46
41
)
47
42
}
@@ -52,12 +47,10 @@ function MonitoredTripAlerts ({ alerts, longDateFormat, timeFormat }) {
52
47
* passed to this component with the necessary data for rendering each portion
53
48
* of this component.
54
49
*/
55
- function TripStatus ( {
50
+ function TripStatus ( {
56
51
confirmAndDeleteUserMonitoredTrip,
57
- longDateFormat,
58
52
planNewTripFromMonitoredTrip,
59
53
renderData,
60
- timeFormat,
61
54
togglePauseTrip,
62
55
toggleSnoozeTrip
63
56
} ) {
@@ -72,11 +65,7 @@ function TripStatus ({
72
65
< Panel . Body > { renderData . bodyText } </ Panel . Body >
73
66
{ /* Alerts */ }
74
67
{ renderData . shouldRenderAlerts && (
75
- < MonitoredTripAlerts
76
- alerts = { renderData . alerts }
77
- longDateFormat = { longDateFormat }
78
- timeFormat = { timeFormat }
79
- />
68
+ < MonitoredTripAlerts alerts = { renderData . alerts } />
80
69
) }
81
70
{ /* Footer buttons */ }
82
71
< Panel . Body >
@@ -96,17 +85,17 @@ function TripStatus ({
96
85
) }
97
86
{ renderData . shouldRenderDeleteTripButton && (
98
87
< FooterButton
99
- bsStyle = ' error'
100
- glyphIcon = ' trash'
88
+ bsStyle = " error"
89
+ glyphIcon = " trash"
101
90
onClick = { confirmAndDeleteUserMonitoredTrip }
102
- text = { < FormattedMessage id = ' components.TripStatus.deleteTrip' /> }
91
+ text = { < FormattedMessage id = " components.TripStatus.deleteTrip" /> }
103
92
/>
104
93
) }
105
94
{ renderData . shouldRenderPlanNewTripButton && (
106
95
< FooterButton
107
- glyphIcon = ' search'
96
+ glyphIcon = " search"
108
97
onClick = { planNewTripFromMonitoredTrip }
109
- text = { < FormattedMessage id = ' components.TripStatus.planNewTrip' /> }
98
+ text = { < FormattedMessage id = " components.TripStatus.planNewTrip" /> }
110
99
/>
111
100
) }
112
101
</ Panel . Body >
@@ -117,40 +106,29 @@ function TripStatus ({
117
106
// connect to the redux store
118
107
const mapStateToProps = ( state , ownProps ) => {
119
108
const { monitoredTrip } = ownProps
120
- const dateFormat = getDateFormat ( state . otp . config )
121
- const longDateFormat = getLongDateFormat ( state . otp . config )
122
- const timeFormat = getTimeFormat ( state . otp . config )
123
-
124
109
const renderData = getRenderData ( {
125
- dateFormat,
126
- longDateFormat,
127
110
monitoredTrip,
128
- onTimeThresholdSeconds : state . otp . config . onTimeThresholdSeconds ,
129
- timeFormat
111
+ onTimeThresholdSeconds : state . otp . config . onTimeThresholdSeconds
130
112
} )
131
113
132
114
return {
133
- dateFormat,
134
- longDateFormat,
135
- renderData,
136
- timeFormat
115
+ renderData
137
116
}
138
117
}
139
118
140
119
const mapDispatchToProps = ( dispatch , ownProps ) => {
141
120
const { intl, monitoredTrip } = ownProps
142
121
return {
143
- confirmAndDeleteUserMonitoredTrip : ( ) => dispatch (
144
- confirmAndDeleteUserMonitoredTrip ( monitoredTrip . id , intl )
145
- ) ,
146
- planNewTripFromMonitoredTrip : ( ) => dispatch (
147
- planNewTripFromMonitoredTrip ( monitoredTrip )
148
- ) ,
122
+ confirmAndDeleteUserMonitoredTrip : ( ) =>
123
+ dispatch ( confirmAndDeleteUserMonitoredTrip ( monitoredTrip . id , intl ) ) ,
124
+ planNewTripFromMonitoredTrip : ( ) =>
125
+ dispatch ( planNewTripFromMonitoredTrip ( monitoredTrip ) ) ,
149
126
togglePauseTrip : ( ) => dispatch ( togglePauseTrip ( monitoredTrip , intl ) ) ,
150
127
toggleSnoozeTrip : ( ) => dispatch ( toggleSnoozeTrip ( monitoredTrip , intl ) )
151
128
}
152
129
}
153
130
154
- export default connect ( mapStateToProps , mapDispatchToProps ) (
155
- injectIntl ( TripStatus )
156
- )
131
+ export default connect (
132
+ mapStateToProps ,
133
+ mapDispatchToProps
134
+ ) ( injectIntl ( TripStatus ) )
0 commit comments