diff --git a/lib/alerts/actions/activeAlert.js b/lib/alerts/actions/activeAlert.js index f2fda37c3..5480bd376 100644 --- a/lib/alerts/actions/activeAlert.js +++ b/lib/alerts/actions/activeAlert.js @@ -28,7 +28,12 @@ export const setActivePublished = createAction( ) export const updateActiveEntity = createAction( 'UPDATE_ACTIVE_ALERT_ENTITY', - (payload: AlertEntity) => payload + (payload: { + agency?: any, + entity: AlertEntity, + field: string, + value: any + }) => payload ) export type ActiveAlertActions = ActionType | diff --git a/lib/alerts/components/AgencySelector.js b/lib/alerts/components/AgencySelector.js index 44fe91253..35c1aedb0 100644 --- a/lib/alerts/components/AgencySelector.js +++ b/lib/alerts/components/AgencySelector.js @@ -18,7 +18,7 @@ export default class AgencySelector extends Component { _onSelect = (evt: SyntheticInputEvent) => { const {entity, feeds, updateActiveEntity} = this.props const feed = getFeed(feeds, evt.target.value) - updateActiveEntity(entity, 'AGENCY', feed) + updateActiveEntity({entity, field: 'AGENCY', value: feed}) } render () { diff --git a/lib/alerts/components/ModeSelector.js b/lib/alerts/components/ModeSelector.js index 46f8f27c6..b7fb06e5f 100644 --- a/lib/alerts/components/ModeSelector.js +++ b/lib/alerts/components/ModeSelector.js @@ -14,8 +14,10 @@ type Props = { } export default class ModeSelector extends Component { - _onChange = (evt: SyntheticInputEvent) => - this.props.updateActiveEntity(this.props.entity, 'MODE', this.getMode(evt.target.value)) + _onChange = (evt: SyntheticInputEvent) => { + const {entity, updateActiveEntity} = this.props + updateActiveEntity({entity, field: 'MODE', value: this.getMode(evt.target.value)}) + } getMode = (routeType: string) => modes.find((mode) => mode.gtfsType === +routeType) diff --git a/lib/alerts/components/RouteSelector.js b/lib/alerts/components/RouteSelector.js index 178946791..f3b1e2b95 100644 --- a/lib/alerts/components/RouteSelector.js +++ b/lib/alerts/components/RouteSelector.js @@ -22,13 +22,14 @@ type Props = { export default class RouteSelector extends Component { _onChange = (value: GtfsOption) => { const {entity, filterByStop, updateActiveEntity} = this.props + const field = 'ROUTE' if (value) { - updateActiveEntity(entity, 'ROUTE', value.route, value.agency) + updateActiveEntity({entity, field, value: value.route, agency: value.agency}) } else if (value == null) { if (filterByStop) { - updateActiveEntity(entity, 'ROUTE', null, entity.agency) + updateActiveEntity({entity, field, value: null, agency: entity.agency}) } else { - updateActiveEntity(entity, 'ROUTE', null, null) + updateActiveEntity({entity, field, value: null, agency: null}) } } } diff --git a/lib/alerts/components/StopSelector.js b/lib/alerts/components/StopSelector.js index 906875a3c..059e91440 100644 --- a/lib/alerts/components/StopSelector.js +++ b/lib/alerts/components/StopSelector.js @@ -21,8 +21,9 @@ type Props = { export default class StopSelector extends Component { _onChange = (value: GtfsOption) => { const {entity, updateActiveEntity} = this.props - if (value) updateActiveEntity(entity, 'STOP', value.stop, value.agency) - else updateActiveEntity(entity, 'STOP', null, null) + const field = 'STOP' + if (value) updateActiveEntity({entity, field, value: value.stop, agency: value.agency}) + else updateActiveEntity({entity, field, value: null, agency: null}) } render () {