Skip to content

Commit

Permalink
Fix bug with selecting from stations. (#740)
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrickCleary committed Jul 12, 2023
1 parent 5d687fd commit a80fbe6
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions common/components/widgets/StationSelectorWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,27 @@ export const StationSelectorWidget: React.FC<StationSelectorWidgetProps> = ({ li
);
break;
case 'from': {
if (newStation?.branches?.some((branch) => toStation?.branches?.includes(branch))) {
if (
newStation &&
newStation.branches &&
!newStation?.branches?.some((branch) => toStation?.branches?.includes(branch))
) {
// If `from` station is on a separate branch, set the `to` station to gov center for GL and Park for RL.
const newToStation = getStationForInvalidFromSelection(line);
const stationIds = stopIdsForStations(newStation, newToStation);
updateQueryParams(
{
from: stopIdsForStations(newStation, toStation).fromStopIds?.[0],
from: stationIds?.fromStopIds?.[0],
to: stationIds?.toStopIds?.[0],
},
undefined,
false
);
break;
}
// If `from` station is on a separate branch, set the `to` station to gov center for GL and Park for RL.
const newToStation = getStationForInvalidFromSelection(line);
const stationIds = stopIdsForStations(newStation, newToStation);
updateQueryParams(
{
from: stationIds?.fromStopIds?.[0],
to: stationIds?.toStopIds?.[0],
from: stopIdsForStations(newStation, toStation).fromStopIds?.[0],
},
undefined,
false
Expand Down

0 comments on commit a80fbe6

Please sign in to comment.