From 656374a2fb21d50c6c053678a25a7a120c610f1b Mon Sep 17 00:00:00 2001 From: ronreg-ribdev <56719257+ronreg-ribdev@users.noreply.github.com> Date: Wed, 3 Jun 2020 03:43:46 -0700 Subject: [PATCH] Schedule picker widget --- src/js/components/root.js | 61 ++++++++++++++++++++++++++++++++------- 1 file changed, 50 insertions(+), 11 deletions(-) diff --git a/src/js/components/root.js b/src/js/components/root.js index 50505a5..e5803c2 100644 --- a/src/js/components/root.js +++ b/src/js/components/root.js @@ -12,6 +12,50 @@ function isSundaySchedule(curTime) { return isSunday; } +function getOptionsFromStations(stations) { + return _.map(stations, (station) => { + const abbr = station.abbr; + const name = station.name; + return ; + }); +} + +class ScheduleWidget extends Component { + constructor(props) { + super(props); + this.state = { station: "" }; + } + + static getDerivedStateFromProps(props, state) { + if (state.station === "" && props.stations && props.stations[0]) { + const abbr = props.stations[0].abbr; + return { station: abbr } + } + return null; + } + getSchedule(evt) { + console.log("Get schedule"); + evt.preventDefault(); + } + + changeStation(evt) { + const value = evt.target.value; + this.setState({station: value}); + } + + render() { + const stations = this.props.stations; + return (
+
+ + +
+
); + } +} + class ElevatorWidget extends Component { statuses() { @@ -99,26 +143,17 @@ class RoutePlanner extends Component { } } - renderStationOptions() { - const stations = this.props.stations; - return _.map(stations, (station) => { - const abbr = station.abbr; - const name = station.name; - return ; - }); - } - renderStationForm() { const receivedStations = this.props.stations; return (
From:
To:
); @@ -143,6 +178,10 @@ class RoutePlanner extends Component {
Search scheduled trains: { this.renderStationForm() } + +
+ or see the official bart scheduler for a given station, date and time: +