From 7502be1c5e445e9f75e231e136af93184210f006 Mon Sep 17 00:00:00 2001 From: ronreg-ribdev <56719257+ronreg-ribdev@users.noreply.github.com> Date: Wed, 3 Jun 2020 03:22:09 -0700 Subject: [PATCH] StationPicker sends json message --- src/js/components/root.js | 23 +++++++++++++++++++---- urbit/app/bartinfo.hoon | 10 ++++++++++ 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/js/components/root.js b/src/js/components/root.js index 47792e1..b626ab4 100644 --- a/src/js/components/root.js +++ b/src/js/components/root.js @@ -74,8 +74,19 @@ class RoutePlanner extends Component { }; } - stationSearch() { - console.log("Searching"); + static getDerivedStateFromProps(props, state) { + if (state.fromStation === null && props.stations && props.stations[0]) { + const abbr = props.stations[0].abbr; + return { fromStation: abbr, toStation: abbr}; + } + return null; + } + + stationSearch(evt) { + evt.preventDefault(); + api.action("bartinfo", "json", { + from: this.state.fromStation, + to: this.state.toStation}); } changeStation(evt) { @@ -98,14 +109,18 @@ class RoutePlanner extends Component { } renderStationForm() { + let initialState = null; + if (this.props.stations && this.props.stations[0]) { + initialState = this.props.stations[0].abbr; + } return (