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: +