diff --git a/common/components/inputs/StationSelector.tsx b/common/components/inputs/StationSelector.tsx index b5fc7a47..0167a172 100644 --- a/common/components/inputs/StationSelector.tsx +++ b/common/components/inputs/StationSelector.tsx @@ -5,7 +5,7 @@ import { faBicycle, faChevronDown, faWheelchair } from '@fortawesome/free-solid- import classNames from 'classnames'; import type { Station } from '../../types/stations'; import { useDelimitatedRoute } from '../../utils/router'; -import { optionsForField } from '../../utils/stations'; +import { optionsForField, stopIdsForStations } from '../../utils/stations'; import { buttonHighlightFocus, lineColorBackground, @@ -77,8 +77,10 @@ export const StationSelector: React.FC = ({ key={stationIndex} disabled={ type === 'from' - ? station.station === toStation.station - : station.station === fromStation.station + ? station.station === toStation.station || + stopIdsForStations(station, toStation).fromStopIds?.length === 0 + : station.station === fromStation.station || + stopIdsForStations(fromStation, station).toStopIds?.length === 0 } className={({ active, selected, disabled }) => classNames( diff --git a/common/components/widgets/StationSelectorWidget.tsx b/common/components/widgets/StationSelectorWidget.tsx index 87e7799c..6410b105 100644 --- a/common/components/widgets/StationSelectorWidget.tsx +++ b/common/components/widgets/StationSelectorWidget.tsx @@ -35,6 +35,7 @@ export const StationSelectorWidget: React.FC = ({ const stations = optionsStation(lineShort, busRoute, crRoute); const toStation = to ? getParentStationForStopId(to) : stations?.[stations.length - 2]; const fromStation = from ? getParentStationForStopId(from) : stations?.[1]; + React.useEffect(() => { const { fromStopIds, toStopIds } = stopIdsForStations(fromStation, toStation); updateQueryParams({ from: fromStopIds?.[0], to: toStopIds?.[0] }); diff --git a/common/constants/stations.ts b/common/constants/stations.ts index f6d19ae9..3b718a14 100644 --- a/common/constants/stations.ts +++ b/common/constants/stations.ts @@ -74,6 +74,7 @@ import cr_greenbush from './cr_constants/cr-greenbush.json'; import cr_fairmount from './cr_constants/cr-fairmount.json'; import cr_kingston from './cr_constants/cr-kingston.json'; import cr_middleborough from './cr_constants/cr-middleborough.json'; +import cr_newburyport from './cr_constants/cr-newburyport.json'; import cr_needham from './cr_constants/cr-needham.json'; import cr_providence from './cr_constants/cr-providence.json'; @@ -155,6 +156,7 @@ export const crStations: { [key: string]: LineMap } = { ...cr_fairmount, ...cr_kingston, ...cr_middleborough, + ...cr_newburyport, ...cr_needham, ...cr_providence, }; diff --git a/modules/tripexplorer/TripExplorer.tsx b/modules/tripexplorer/TripExplorer.tsx index e5c0071b..0463e128 100644 --- a/modules/tripexplorer/TripExplorer.tsx +++ b/modules/tripexplorer/TripExplorer.tsx @@ -36,6 +36,7 @@ export const TripExplorer = () => { if (!(fromStation && toStation)) { return null; } + return ( @@ -53,4 +54,5 @@ export const TripExplorer = () => { ); }; + TripExplorer.Layout = Layout.Dashboard;