Skip to content

Commit 34679f4

Browse files
committed
fix(field-trip): refactor trip status icon
this does not resolve entirely ibi-group/trimet-mod-otp#302 (a backend change is also needed), but it does DRY things out a bit and make things a bit easier to follow re ibi-group/trimet-mod-otp#302
1 parent 240588a commit 34679f4

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

lib/components/admin/field-trip-list.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import Loading from '../narrative/loading'
1010
import {getVisibleRequests, TABS} from '../../util/call-taker'
1111
import {FETCH_STATUS} from '../../util/constants'
1212

13+
import FieldTripStatusIcon from './field-trip-status-icon'
1314
import {FieldTripRecordButton, WindowHeader} from './styled'
1415
import DraggableWindow from './draggable-window'
1516

@@ -186,10 +187,6 @@ class FieldTripRequestRecord extends Component {
186187
onClick(request)
187188
}
188189

189-
_getStatusIcon = (status) => status
190-
? <Icon className='text-success' type='check' />
191-
: <Icon className='text-warning' type='exclamation-circle' />
192-
193190
render () {
194191
const {active, request} = this.props
195192
const style = {
@@ -223,10 +220,10 @@ class FieldTripRequestRecord extends Component {
223220
</span>
224221
<span style={{display: 'inline-block', width: '50%'}}>
225222
<span style={{marginLeft: '10px'}}>
226-
{this._getStatusIcon(outboundTripStatus)} Outbound
223+
<FieldTripStatusIcon status={outboundTripStatus} /> Outbound
227224
</span>
228225
<span style={{marginLeft: '10px'}}>
229-
{this._getStatusIcon(inboundTripStatus)} Inbound
226+
<FieldTripStatusIcon status={inboundTripStatus} /> Inbound
230227
</span>
231228
</span>
232229
<span style={{display: 'block', fontSize: '.9em'}}>

lib/components/admin/trip-status.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import { connect } from 'react-redux'
55

66
import * as fieldTripActions from '../../actions/field-trip'
77
import * as formActions from '../../actions/form'
8-
import Icon from '../narrative/icon'
98
import { getTripFromRequest } from '../../util/call-taker'
109

10+
import FieldTripStatusIcon from './field-trip-status-icon'
1111
import {
1212
Bold,
1313
Button,
@@ -47,13 +47,11 @@ class TripStatus extends Component {
4747
viewRequestTripItineraries(request, outbound)
4848
}
4949

50-
_renderStatusIcon = () => this.props.status
51-
? <Icon className='text-success' type='check' />
52-
: <Icon className='text-warning' type='exclamation-circle' />
50+
_tripIsPlanned = () => this.props.status && this.props.trip
5351

5452
_renderTripStatus = () => {
55-
const { status, trip } = this.props
56-
if (!status || !trip) {
53+
const { trip } = this.props
54+
if (!this._tripIsPlanned()) {
5755
return (
5856
<Para>
5957
No itineraries planned! Click Plan to plan trip.
@@ -92,7 +90,7 @@ class TripStatus extends Component {
9290
return (
9391
<Full>
9492
<Header>
95-
{this._renderStatusIcon()}
93+
<FieldTripStatusIcon status={this._tripIsPlanned()} />
9694
{outbound ? 'Outbound' : 'Inbound'} trip
9795
<Button bsSize='xs' onClick={this._onPlanTrip}>Plan</Button>
9896
<Button

0 commit comments

Comments
 (0)