Skip to content

Commit c2fa055

Browse files
committed
fix(alerts): fix updateActiveEntity func signature
1 parent ce6c180 commit c2fa055

File tree

5 files changed

+18
-9
lines changed

5 files changed

+18
-9
lines changed

lib/alerts/actions/activeAlert.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@ export const setActivePublished = createAction(
2828
)
2929
export const updateActiveEntity = createAction(
3030
'UPDATE_ACTIVE_ALERT_ENTITY',
31-
(payload: AlertEntity) => payload
31+
(payload: {
32+
agency?: any,
33+
entity: AlertEntity,
34+
field: string,
35+
value: any
36+
}) => payload
3237
)
3338

3439
export type ActiveAlertActions = ActionType<typeof deleteActiveEntity> |

lib/alerts/components/AgencySelector.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default class AgencySelector extends Component<Props> {
1818
_onSelect = (evt: SyntheticInputEvent<HTMLInputElement>) => {
1919
const {entity, feeds, updateActiveEntity} = this.props
2020
const feed = getFeed(feeds, evt.target.value)
21-
updateActiveEntity(entity, 'AGENCY', feed)
21+
updateActiveEntity({entity, field: 'AGENCY', value: feed})
2222
}
2323

2424
render () {

lib/alerts/components/ModeSelector.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ type Props = {
1414
}
1515

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

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

lib/alerts/components/RouteSelector.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@ type Props = {
2222
export default class RouteSelector extends Component<Props> {
2323
_onChange = (value: GtfsOption) => {
2424
const {entity, filterByStop, updateActiveEntity} = this.props
25+
const field = 'ROUTE'
2526
if (value) {
26-
updateActiveEntity(entity, 'ROUTE', value.route, value.agency)
27+
updateActiveEntity({entity, field, value: value.route, agency: value.agency})
2728
} else if (value == null) {
2829
if (filterByStop) {
29-
updateActiveEntity(entity, 'ROUTE', null, entity.agency)
30+
updateActiveEntity({entity, field, value: null, agency: entity.agency})
3031
} else {
31-
updateActiveEntity(entity, 'ROUTE', null, null)
32+
updateActiveEntity({entity, field, value: null, agency: null})
3233
}
3334
}
3435
}

lib/alerts/components/StopSelector.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ type Props = {
2121
export default class StopSelector extends Component<Props> {
2222
_onChange = (value: GtfsOption) => {
2323
const {entity, updateActiveEntity} = this.props
24-
if (value) updateActiveEntity(entity, 'STOP', value.stop, value.agency)
25-
else updateActiveEntity(entity, 'STOP', null, null)
24+
const field = 'STOP'
25+
if (value) updateActiveEntity({entity, field, value: value.stop, agency: value.agency})
26+
else updateActiveEntity({entity, field, value: null, agency: null})
2627
}
2728

2829
render () {

0 commit comments

Comments
 (0)