Skip to content

Commit

Permalink
fix(call-taker): fix mode dropdown for uber + transit
Browse files Browse the repository at this point in the history
fix #421
  • Loading branch information
landonreed committed Jul 23, 2021
1 parent 518def8 commit 3208487
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions lib/components/form/call-taker/mode-dropdown.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { toSentenceCase } from '@opentripplanner/core-utils/lib/itinerary'
import coreUtils from '@opentripplanner/core-utils'
import React, { Component } from 'react'

const { hasTransit, toSentenceCase } = coreUtils.itinerary

/**
* Dropdown selector for the Call Taker form that allows quick selection of the
* full set of exclusive modes and access modes + transit. This will also
Expand Down Expand Up @@ -43,8 +45,9 @@ export default class ModeDropdown extends Component {
_onChange = evt => {
const {value: mode} = evt.target
const {updateTransitModes} = this.props
const selectedOption = this._getModeOptions().filter(o => o.value === mode)
const transitIsSelected = mode.indexOf('TRANSIT') !== -1
const selectedOption = this._getModeOptions().find(o => o.value === mode)
const transitIsSelected = hasTransit(mode)
const params = { mode }
if (transitIsSelected) {
// Collect transit modes and selected access mode.
const accessMode = mode === 'TRANSIT' ? 'WALK' : mode.replace('TRANSIT,', '')
Expand All @@ -54,17 +57,14 @@ export default class ModeDropdown extends Component {
? this.props.selectedTransitModes
: this.props.modes.transitModes.map(m => m.mode)
const newModes = [...transitModes, accessMode]
if (accessMode.indexOf('CAR') !== -1) newModes.push('WALK')
updateTransitModes(transitModes)
const params = { mode: newModes.join(',') }
params.mode = newModes.join(',')
// Update companies if provided by selected option.
if (selectedOption && selectedOption.company) {
params.companies = selectedOption.company
if (selectedOption?.company) {
params.companies = [selectedOption.company]
}
this.props.onChange(params)
} else {
this.props.onChange({ mode })
}
this.props.onChange(params)
}

render () {
Expand Down

0 comments on commit 3208487

Please sign in to comment.