Skip to content

Commit f5abca1

Browse files
author
David Emory
committed
refactor(api): Move autoPlan to config
1 parent 8f44e46 commit f5abca1

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed
File renamed without changes.

lib/actions/form.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export function formChanged () {
4141
return function (dispatch, getState) {
4242
dispatch(changingForm())
4343
// TODO: make auto-plan trip a configurable
44-
if (queryIsValid(getState().otp) && getState().otp.ui.autoPlan) {
44+
if (queryIsValid(getState().otp) && getState().otp.config.autoPlan) {
4545
dispatch(planTrip())
4646
}
4747
}

lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import ItineraryCarousel from './components/narrative/itinerary-carousel'
1515
import NarrativeItineraries from './components/narrative/narrative-itineraries'
1616
import NarrativeItinerary from './components/narrative/narrative-itinerary'
1717

18-
import { setAutoPlan } from './actions/ui'
18+
import { setAutoPlan } from './actions/config'
1919

2020
import createOtpReducer from './reducers/create-otp-reducer'
2121

lib/reducers/create-otp-reducer.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import update from 'immutability-helper'
44
// import { getDefaultQuery } from '../util/state'
55
import { getCurrentDate, getCurrentTime } from '../util/time'
66

7+
const defaultConfig = {
8+
autoPlan: true
9+
}
10+
711
// TODO: parse query params
812
const defaultQuery = {
913
type: 'ITINERARY',
@@ -24,13 +28,10 @@ function createOtpReducer (config, initialQuery) {
2428
const currentQuery = Object.assign(defaultQuery, initialQuery)
2529
console.log(currentQuery)
2630
const initialState = {
27-
config,
31+
config: Object.assign(defaultConfig, config),
2832
currentQuery,
2933
searches: [],
30-
activeSearch: 0,
31-
ui: {
32-
autoPlan: true
33-
}
34+
activeSearch: 0
3435
}
3536

3637
return (state = initialState, action) => {
@@ -105,7 +106,7 @@ function createOtpReducer (config, initialQuery) {
105106
return update(state, { activeSearch: { $set: null } })
106107

107108
case 'SET_AUTOPLAN':
108-
return update(state, { ui: { autoPlan: { $set: action.payload.autoPlan } } })
109+
return update(state, { config: { autoPlan: { $set: action.payload.autoPlan } } })
109110

110111
default:
111112
return state

0 commit comments

Comments
 (0)