diff --git a/lib/components/form/settings-selector-panel.js b/lib/components/form/settings-selector-panel.js index f63c65a1a..e217045a2 100644 --- a/lib/components/form/settings-selector-panel.js +++ b/lib/components/form/settings-selector-panel.js @@ -41,15 +41,15 @@ class SettingsSelectorPanel extends Component { _setBikeOnly = () => { this._setSoloMode('BICYCLE') } - _setOwnBike = () => { - const nonBikeModes = this.props.queryModes.filter(m => !m.startsWith('BICYCLE')) - this.props.setQueryParam({ mode: 'BICYCLE,' + nonBikeModes.join(',') }) + _addBikeModeToQueryModes = (bikeMode) => { + const { queryModes, setQueryParam } = this.props + const nonBikeModes = queryModes.filter(m => !m.startsWith('BICYCLE')) + setQueryParam({ mode: [...nonBikeModes, bikeMode].join(',') }) } - _setRentedBike = () => { - const nonBikeModes = this.props.queryModes.filter(m => !m.startsWith('BICYCLE')) - this.props.setQueryParam({ mode: 'BICYCLE_RENT,' + nonBikeModes.join(',') }) - } + _setOwnBike = () => this._addBikeModeToQueryModes('BICYCLE') + + _setRentedBike = () => this._addBikeModeToQueryModes('BICYCLE_RENT') _toggleTransitMode (mode) { const modeStr = mode.mode || mode @@ -86,13 +86,17 @@ class SettingsSelectorPanel extends Component { } // If no transit modes selected, select all - if (!queryModes || queryModes.length === 0) queryModes = getTransitModes(this.props.config) + if (!queryModes || queryModes.length === 0) { + queryModes = getTransitModes(this.props.config) + } // Add the access mode queryModes.push(modeStr) // Do extra stuff if mode selected was a TNC - queryParamUpdate.companies = (modeStr === 'CAR_HAIL' || modeStr === 'CAR_RENT') ? mode.company.toUpperCase() : null + queryParamUpdate.companies = (modeStr === 'CAR_HAIL' || modeStr === 'CAR_RENT') + ? mode.company.toUpperCase() + : null queryParamUpdate.mode = queryModes.join(',') diff --git a/yarn.lock b/yarn.lock index 82ef55030..2e5791d10 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2306,6 +2306,11 @@ buffer@^5.0.2: base64-js "^1.0.2" ieee754 "^1.1.4" +builtin-modules@^1.0.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f" + integrity sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8= + builtin-status-codes@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz#85982878e21b98e1c66425e03d0174788f569ee8" @@ -6035,6 +6040,13 @@ is-buffer@^1.1.0, is-buffer@^1.1.4, is-buffer@^1.1.5, is-buffer@~1.1.1: resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be" integrity sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w== +is-builtin-module@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-builtin-module/-/is-builtin-module-1.0.0.tgz#540572d34f7ac3119f8f76c30cbc1b1e037affbe" + integrity sha1-VAVy0096wxGfj3bDDLwbHgN6/74= + dependencies: + builtin-modules "^1.0.0" + is-callable@^1.1.3, is-callable@^1.1.4: version "1.1.4" resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.4.tgz#1e1adf219e1eeb684d691f9d6a05ff0d30a24d75"