diff --git a/src/index.js b/src/index.js index f988e26..275e443 100644 --- a/src/index.js +++ b/src/index.js @@ -37,7 +37,6 @@ const Departures = ({ stop, title }) => { const update = () => { monitor(stop).then((departures) => { setDepartures(departures) - console.log(departures) }) } update() @@ -83,7 +82,7 @@ const Departures = ({ stop, title }) => {
Typ
-
+
Linie
@@ -107,7 +106,7 @@ const Departures = ({ stop, title }) => { /> )}
-
+
{departure.line}
@@ -124,11 +123,11 @@ const Departures = ({ stop, title }) => { } const BoardLayout = ({ children }) => ( -
-
+
+
{children}
-
+
- +
@@ -158,74 +157,142 @@ const BoardLayout = ({ children }) => (
) -const Board = ({ stop, title }) => ( +const Board = ({ ...props }) => ( - + {props.stop1 && props.title1 ? ( + + ) : null} + {props.stop2 && props.title2 ? ( + + ) : null} + {props.stop3 && props.title3 ? ( + + ) : null} ) -const Home = () => { - const [stopItems, setStopItems] = useState([]) +const Default = () => ( +
+
+

+ Etwas ist schiefgelaufen. +
Bitte prüfen Sie ihre Konfiguration! +

+ + Jetzt einrichten + +
+
+) + +const Config = ({ ...props }) => { + const [searchItems, setSearchItems] = useState([]) + const [configItems, setConfigItems] = useState([]) + const [configUrl, setConfigUrl] = useState('') + + useEffect(() => { + let url = `${baseroute}/?` + configItems.map((item, index) => { + if (index > 0) { + url = + url + + '&title' + + (index + 1) + + '=' + + item.name + + '&stop' + + (index + 1) + + '=' + + item.id + } else { + url = + url + + 'title' + + (index + 1) + + '=' + + item.name + + '&stop' + + (index + 1) + + '=' + + item.id + } + }) + setConfigUrl(url) + }, [configItems]) const inputChanged = (e) => { findStop(e.target.value) - .then((stopItems) => { - setStopItems(stopItems) + .then((searchItems) => { + setSearchItems(searchItems) }) .catch(console.error) } + return ( -
-
-
-

VVO | Departure Board

-
-
-

- This departure board application is based on Preact and - the WebAPI of VVO / DVB. -

-

- Github:{' '} - - https://github.com/valentin-vogel/dvb-departure-board - -

+
+
+
+

DVB | Abfahrtsmonitor

-
- Departure Board: - - Example for 1 Stop:{' '} +
+
+
+ Suche eine Haltestelle +
+
+ +
+ z.B. Postplatz +
+
+
    + {searchItems.map((item) => ( +
  • + {item.id} - {item.name} - {item.city} + +
  • + ))} +
+
+
+
+ Konfiguration +
+
    + {configItems.map((item) => ( +
  • + {item.id} - {item.name} - {item.city} +
  • + ))} +
- /departures?title=Postplatz&stop=33000037 + Abfahrtsmonitor anschauen - -
-
- Stop search: - -
- {stopItems.map((item) => ( - - {item.id} - {item.name} - {item.city} - - ))}
@@ -233,11 +300,16 @@ const Home = () => { ) } +const Base = ({ ...props }) => { + if (props.stop1 && props.title1) return + if (props.c) return + return +} + export default function App() { return ( - - + ) }