Skip to content

Commit

Permalink
fix(alerts): fix updateActiveEntity func signature
Browse files Browse the repository at this point in the history
  • Loading branch information
landonreed committed Jan 8, 2019
1 parent ce6c180 commit c2fa055
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
7 changes: 6 additions & 1 deletion lib/alerts/actions/activeAlert.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof deleteActiveEntity> |
Expand Down
2 changes: 1 addition & 1 deletion lib/alerts/components/AgencySelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default class AgencySelector extends Component<Props> {
_onSelect = (evt: SyntheticInputEvent<HTMLInputElement>) => {
const {entity, feeds, updateActiveEntity} = this.props
const feed = getFeed(feeds, evt.target.value)
updateActiveEntity(entity, 'AGENCY', feed)
updateActiveEntity({entity, field: 'AGENCY', value: feed})
}

render () {
Expand Down
6 changes: 4 additions & 2 deletions lib/alerts/components/ModeSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ type Props = {
}

export default class ModeSelector extends Component<Props> {
_onChange = (evt: SyntheticInputEvent<HTMLInputElement>) =>
this.props.updateActiveEntity(this.props.entity, 'MODE', this.getMode(evt.target.value))
_onChange = (evt: SyntheticInputEvent<HTMLInputElement>) => {
const {entity, updateActiveEntity} = this.props
updateActiveEntity({entity, field: 'MODE', value: this.getMode(evt.target.value)})
}

getMode = (routeType: string) => modes.find((mode) => mode.gtfsType === +routeType)

Expand Down
7 changes: 4 additions & 3 deletions lib/alerts/components/RouteSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ type Props = {
export default class RouteSelector extends Component<Props> {
_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})
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions lib/alerts/components/StopSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ type Props = {
export default class StopSelector extends Component<Props> {
_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 () {
Expand Down

0 comments on commit c2fa055

Please sign in to comment.